summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/addresseditwidget.cpp55
-rw-r--r--kaddressbook/addresseditwidget.h18
-rw-r--r--kaddressbook/addresseeconfig.cpp6
-rw-r--r--kaddressbook/addresseeconfig.h6
-rw-r--r--kaddressbook/addresseeeditordialog.cpp9
-rw-r--r--kaddressbook/addresseeeditorwidget.cpp46
-rw-r--r--kaddressbook/addresseeeditorwidget.h12
-rw-r--r--kaddressbook/addresseeutil.cpp2
-rw-r--r--kaddressbook/addviewdialog.cpp16
-rw-r--r--kaddressbook/addviewdialog.h10
-rw-r--r--kaddressbook/details/detailsviewcontainer.cpp19
-rw-r--r--kaddressbook/details/detailsviewcontainer.h8
-rw-r--r--kaddressbook/details/look_basic.cpp6
-rw-r--r--kaddressbook/details/look_basic.h4
-rw-r--r--kaddressbook/details/look_details.cpp12
-rw-r--r--kaddressbook/details/look_details.h4
-rw-r--r--kaddressbook/details/look_html.cpp6
-rw-r--r--kaddressbook/emaileditwidget.cpp16
-rw-r--r--kaddressbook/emaileditwidget.h10
-rw-r--r--kaddressbook/extensionmanager.cpp14
-rw-r--r--kaddressbook/extensionmanager.h10
-rw-r--r--kaddressbook/extensionwidget.cpp5
-rw-r--r--kaddressbook/extensionwidget.h4
-rw-r--r--kaddressbook/features/distributionlistwidget.cpp39
-rw-r--r--kaddressbook/features/distributionlistwidget.h13
-rw-r--r--kaddressbook/features/mergewidget.cpp14
-rw-r--r--kaddressbook/features/mergewidget.h2
-rw-r--r--kaddressbook/filter.cpp2
-rw-r--r--kaddressbook/filter.h4
-rw-r--r--kaddressbook/filtereditdialog.cpp38
-rw-r--r--kaddressbook/filtereditdialog.h9
-rw-r--r--kaddressbook/geowidget.cpp35
-rw-r--r--kaddressbook/geowidget.h4
-rw-r--r--kaddressbook/imagewidget.cpp32
-rw-r--r--kaddressbook/imagewidget.h3
-rw-r--r--kaddressbook/incsearchwidget.cpp14
-rw-r--r--kaddressbook/jumpbuttonbar.cpp13
-rw-r--r--kaddressbook/jumpbuttonbar.h11
-rw-r--r--kaddressbook/kabcore.cpp146
-rw-r--r--kaddressbook/kabcore.h40
-rw-r--r--kaddressbook/kabprefs.cpp4
-rw-r--r--kaddressbook/kabprefs.h8
-rw-r--r--kaddressbook/kaddressbook.pro46
-rw-r--r--kaddressbook/kaddressbookE.pro6
-rw-r--r--kaddressbook/kaddressbookmain.cpp22
-rw-r--r--kaddressbook/kaddressbookmain.h14
-rw-r--r--kaddressbook/kaddressbookview.cpp8
-rw-r--r--kaddressbook/kaddressbookview.h12
-rw-r--r--kaddressbook/kcmconfigs/addresseewidget.cpp36
-rw-r--r--kaddressbook/kcmconfigs/addresseewidget.h8
-rw-r--r--kaddressbook/kcmconfigs/extensionconfigdialog.cpp11
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.cpp59
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.h6
-rw-r--r--kaddressbook/kcmconfigs/kcmkabconfig.cpp8
-rw-r--r--kaddressbook/keywidget.cpp28
-rw-r--r--kaddressbook/mainembedded.cpp5
-rw-r--r--kaddressbook/nameeditdialog.cpp12
-rw-r--r--kaddressbook/old_mainwindow.cpp12
-rw-r--r--kaddressbook/phoneeditwidget.cpp60
-rw-r--r--kaddressbook/phoneeditwidget.h24
-rw-r--r--kaddressbook/secrecywidget.cpp8
-rw-r--r--kaddressbook/undo.cpp4
-rw-r--r--kaddressbook/undo.h4
-rw-r--r--kaddressbook/undocmds.cpp2
-rw-r--r--kaddressbook/viewconfigurefieldspage.cpp54
-rw-r--r--kaddressbook/viewconfigurefieldspage.h8
-rw-r--r--kaddressbook/viewconfigurefilterpage.cpp15
-rw-r--r--kaddressbook/viewconfigurefilterpage.h4
-rw-r--r--kaddressbook/viewconfigurewidget.cpp19
-rw-r--r--kaddressbook/viewconfigurewidget.h4
-rw-r--r--kaddressbook/viewmanager.cpp30
-rw-r--r--kaddressbook/viewmanager.h12
-rw-r--r--kaddressbook/views/cardview.cpp114
-rw-r--r--kaddressbook/views/cardview.h14
-rw-r--r--kaddressbook/views/colorlistbox.cpp25
-rw-r--r--kaddressbook/views/colorlistbox.h15
-rw-r--r--kaddressbook/views/configurecardviewdialog.cpp57
-rw-r--r--kaddressbook/views/configurecardviewdialog.h6
-rw-r--r--kaddressbook/views/configuretableviewdialog.cpp35
-rw-r--r--kaddressbook/views/configuretableviewdialog.h6
-rw-r--r--kaddressbook/views/contactlistview.cpp32
-rw-r--r--kaddressbook/views/contactlistview.h6
-rw-r--r--kaddressbook/views/kaddressbookcardview.cpp19
-rw-r--r--kaddressbook/views/kaddressbookcardview.h3
-rw-r--r--kaddressbook/views/kaddressbookiconview.cpp60
-rw-r--r--kaddressbook/views/kaddressbookiconview.h29
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp56
-rw-r--r--kaddressbook/views/kaddressbooktableview.h18
-rw-r--r--kaddressbook/xxport/csv_xxport.cpp14
-rw-r--r--kaddressbook/xxport/csvimportdialog.cpp66
-rw-r--r--kaddressbook/xxport/csvimportdialog.h12
-rw-r--r--kaddressbook/xxport/kde2_xxport.cpp4
-rw-r--r--kaddressbook/xxport/vcard_xxport.cpp20
-rw-r--r--kaddressbook/xxportmanager.cpp17
-rw-r--r--kaddressbook/xxportmanager.h4
-rw-r--r--kaddressbook/xxportobject.cpp4
-rw-r--r--kaddressbook/xxportselectdialog.cpp59
-rw-r--r--kaddressbook/xxportselectdialog.h12
98 files changed, 1095 insertions, 882 deletions
diff --git a/kaddressbook/addresseditwidget.cpp b/kaddressbook/addresseditwidget.cpp
index 3dcd592..83908d0 100644
--- a/kaddressbook/addresseditwidget.cpp
+++ b/kaddressbook/addresseditwidget.cpp
@@ -1,622 +1,629 @@
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 2003 Tobias Koenig <tokoe@kde.org> 4 2003 Tobias Koenig <tokoe@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qbuttongroup.h> 25#include <q3buttongroup.h>
26#include <qcheckbox.h> 26#include <qcheckbox.h>
27#include <qhbox.h> 27#include <q3hbox.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qlistbox.h> 30#include <q3listbox.h>
31#include <qlistview.h> 31#include <q3listview.h>
32#include <qpushbutton.h> 32#include <qpushbutton.h>
33#include <qsignal.h> 33#include <q3signal.h>
34#include <qstring.h> 34#include <qstring.h>
35#include <qapplication.h> 35#include <qapplication.h>
36#include <QDesktopWidget>
37
38#include <Q3VBoxLayout>
39#include <Q3GridLayout>
36 40
37#ifndef KAB_EMBEDDED 41#ifndef KAB_EMBEDDED
38#include <qtextedit.h> 42#include <q3textedit.h>
43//Added by qt3to4:
44#include <Q3ValueList>
45#include <Q3VBoxLayout>
39#include <kaccelmanager.h> 46#include <kaccelmanager.h>
40#include <kbuttonbox.h> 47#include <kbuttonbox.h>
41#else //KAB_EMBEDDED 48#else //KAB_EMBEDDED
42#include <qmultilineedit.h> 49#include <q3multilineedit.h>
43#endif //KAB_EMBEDDED 50#endif //KAB_EMBEDDED
44 51
45#include <qtoolbutton.h> 52#include <qtoolbutton.h>
46#include <qtooltip.h> 53#include <qtooltip.h>
47 54
48#include <kapplication.h> 55#include <kapplication.h>
49#include <kcombobox.h> 56#include <kcombobox.h>
50#include <kconfig.h> 57#include <kconfig.h>
51#include <kdebug.h> 58#include <kdebug.h>
52#include <kdialog.h> 59#include <kdialog.h>
53#include <kiconloader.h> 60#include <kiconloader.h>
54#include <klineedit.h> 61#include <klineedit.h>
55#include <klistview.h> 62#include <klistview.h>
56#include <klocale.h> 63#include <klocale.h>
57#include <kglobal.h> 64#include <kglobal.h>
58#include <kmessagebox.h> 65#include <kmessagebox.h>
59#include <kseparator.h> 66#include <kseparator.h>
60 67
61#include "addresseditwidget.h" 68#include "addresseditwidget.h"
62 69
63 70
64 71
65AddressEditWidget::AddressEditWidget( QWidget *parent, const char *name ) 72AddressEditWidget::AddressEditWidget( QWidget *parent, const char *name )
66 : QWidget( parent, name ) 73 : QWidget( parent, name )
67{ 74{
68 75
69 mConfig = AddresseeConfig::instance(); 76 mConfig = AddresseeConfig::instance();
70 QVBoxLayout *layout = new QVBoxLayout( this ); 77 Q3VBoxLayout *layout = new Q3VBoxLayout( this );
71 layout->setSpacing( KDialog::spacingHintSmall() ); 78 layout->setSpacing( KDialog::spacingHintSmall() );
72 QHBox *b1 = new QHBox( this); 79 Q3HBox *b1 = new Q3HBox( this);
73 //QLabel * label = new QLabel( b1 ); 80 //QLabel * label = new QLabel( b1 );
74 //label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) ); 81 //label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) );
75 82
76 83
77 //label->setAlignment( AlignCenter); 84 //label->setAlignment( AlignCenter);
78 layout->addWidget( b1 ); 85 layout->addWidget( b1 );
79 mTypeCombo = new AddressTypeCombo( mAddressList, b1 ); 86 mTypeCombo = new AddressTypeCombo( mAddressList, b1 );
80 QPushButton *editButton = new QPushButton( i18n( "&Edit Addresses..." ), 87 QPushButton *editButton = new QPushButton( i18n( "&Edit Addresses..." ),
81 b1 ); 88 b1 );
82 connect( mTypeCombo, SIGNAL( activated( int ) ), 89 connect( mTypeCombo, SIGNAL( activated( int ) ),
83 SLOT( updateAddressEdit() ) ); 90 SLOT( updateAddressEdit() ) );
84 // layout->addWidget( mTypeCombo ); 91 // layout->addWidget( mTypeCombo );
85 92
86#ifndef KAB_EMBEDDED 93#ifndef KAB_EMBEDDED
87 mAddressTextEdit = new QTextEdit( this ); 94 mAddressTextEdit = new Q3TextEdit( this );
88 mAddressTextEdit->setReadOnly( true ); 95 mAddressTextEdit->setReadOnly( true );
89 mAddressTextEdit->setMinimumHeight( 20 ); 96 mAddressTextEdit->setMinimumHeight( 20 );
90#else //KAB_EMBEDDED 97#else //KAB_EMBEDDED
91 mAddressTextEdit = new QMultiLineEdit( this ); 98 mAddressTextEdit = new Q3MultiLineEdit( this );
92 mAddressTextEdit->setReadOnly( true ); 99 mAddressTextEdit->setReadOnly( true );
93 mAddressTextEdit->setMinimumHeight( 20 ); 100 mAddressTextEdit->setMinimumHeight( 20 );
94#endif //KAB_EMBEDDED 101#endif //KAB_EMBEDDED
95 102
96 layout->addWidget( mAddressTextEdit ); 103 layout->addWidget( mAddressTextEdit );
97 104
98 105
99 connect( editButton, SIGNAL( clicked() ), SLOT( edit() ) ); 106 connect( editButton, SIGNAL( clicked() ), SLOT( edit() ) );
100} 107}
101 108
102AddressEditWidget::~AddressEditWidget() 109AddressEditWidget::~AddressEditWidget()
103{ 110{
104 111
105} 112}
106 113
107KABC::Address::List AddressEditWidget::addresses() 114KABC::Address::List AddressEditWidget::addresses()
108{ 115{
109 KABC::Address::List retList; 116 KABC::Address::List retList;
110 117
111 KABC::Address::List::Iterator it; 118 KABC::Address::List::Iterator it;
112 for ( it = mAddressList.begin(); it != mAddressList.end(); ++it ) 119 for ( it = mAddressList.begin(); it != mAddressList.end(); ++it )
113 if ( !(*it).isEmpty() ) 120 if ( !(*it).isEmpty() )
114 retList.append( *it ); 121 retList.append( *it );
115 122
116 return retList; 123 return retList;
117} 124}
118 125
119void AddressEditWidget::setAddresses( const KABC::Addressee &addr, 126void AddressEditWidget::setAddresses( const KABC::Addressee &addr,
120 const KABC::Address::List &list ) 127 const KABC::Address::List &list )
121{ 128{
122 mAddressee = addr; 129 mAddressee = addr;
123 130
124 mAddressList.clear(); 131 mAddressList.clear();
125 132
126 // Insert types for existing numbers. 133 // Insert types for existing numbers.
127 mTypeCombo->insertTypeList( list ); 134 mTypeCombo->insertTypeList( list );
128 135
129 QValueList<int> defaultTypes; 136 Q3ValueList<int> defaultTypes;
130 defaultTypes << KABC::Address::Home; 137 defaultTypes << KABC::Address::Home;
131 defaultTypes << KABC::Address::Work; 138 defaultTypes << KABC::Address::Work;
132 139
133 mConfig->setUid( mAddressee.uid() ); 140 mConfig->setUid( mAddressee.uid() );
134 QValueList<int> configList = mConfig->noDefaultAddrTypes(); 141 Q3ValueList<int> configList = mConfig->noDefaultAddrTypes();
135 QValueList<int>::ConstIterator it; 142 Q3ValueList<int>::ConstIterator it;
136 for ( it = configList.begin(); it != configList.end(); ++it ) 143 for ( it = configList.begin(); it != configList.end(); ++it )
137 defaultTypes.remove( *it ); 144 defaultTypes.remove( *it );
138 145
139 // Insert default types. 146 // Insert default types.
140 // Doing this for mPrefCombo is enough because the list is shared by all 147 // Doing this for mPrefCombo is enough because the list is shared by all
141 // combos. 148 // combos.
142 for( it = defaultTypes.begin(); it != defaultTypes.end(); ++it ) { 149 for( it = defaultTypes.begin(); it != defaultTypes.end(); ++it ) {
143 if ( !mTypeCombo->hasType( *it ) ) 150 if ( !mTypeCombo->hasType( *it ) )
144 mTypeCombo->insertType( list, *it, Address( *it ) ); 151 mTypeCombo->insertType( list, *it, Address( *it ) );
145 } 152 }
146 153
147 mTypeCombo->updateTypes(); 154 mTypeCombo->updateTypes();
148 155
149 // find preferred address which will be shown 156 // find preferred address which will be shown
150 int preferred = KABC::Address::Home; // default if no preferred address set 157 int preferred = KABC::Address::Home; // default if no preferred address set
151 uint i; 158 uint i;
152 for (i = 0; i < list.count(); i++) 159 for (i = 0; i < list.count(); i++)
153 if ( list[i].type() & KABC::Address::Pref ) { 160 if ( list[i].type() & KABC::Address::Pref ) {
154 preferred = list[i].type(); 161 preferred = list[i].type();
155 break; 162 break;
156 } 163 }
157 164
158 mTypeCombo->selectType( preferred ); 165 mTypeCombo->selectType( preferred );
159 166
160 updateAddressEdit(); 167 updateAddressEdit();
161} 168}
162 169
163void AddressEditWidget::edit() 170void AddressEditWidget::edit()
164{ 171{
165 AddressEditDialog dialog( mAddressList, mTypeCombo->currentItem(), this ); 172 AddressEditDialog dialog( mAddressList, mTypeCombo->currentItem(), this );
166 if ( dialog.exec() ) { 173 if ( dialog.exec() ) {
167 if ( dialog.changed() ) { 174 if ( dialog.changed() ) {
168 mAddressList = dialog.addresses(); 175 mAddressList = dialog.addresses();
169 176
170 bool hasHome = false, hasWork = false; 177 bool hasHome = false, hasWork = false;
171 KABC::Address::List::Iterator it; 178 KABC::Address::List::Iterator it;
172 for ( it = mAddressList.begin(); it != mAddressList.end(); ++it ) { 179 for ( it = mAddressList.begin(); it != mAddressList.end(); ++it ) {
173 if ( (*it).type() == KABC::Address::Home ) { 180 if ( (*it).type() == KABC::Address::Home ) {
174 if ( !(*it).isEmpty() ) 181 if ( !(*it).isEmpty() )
175 hasHome = true; 182 hasHome = true;
176 } 183 }
177 if ( (*it).type() == KABC::Address::Work ) { 184 if ( (*it).type() == KABC::Address::Work ) {
178 if ( !(*it).isEmpty() ) 185 if ( !(*it).isEmpty() )
179 hasWork = true; 186 hasWork = true;
180 } 187 }
181 } 188 }
182 189
183 mConfig->setUid( mAddressee.uid() ); 190 mConfig->setUid( mAddressee.uid() );
184 QValueList<int> configList; 191 Q3ValueList<int> configList;
185 if ( !hasHome ) { 192 if ( !hasHome ) {
186 configList << KABC::Address::Home; 193 configList << KABC::Address::Home;
187 } 194 }
188 if ( !hasWork ) { 195 if ( !hasWork ) {
189 configList << KABC::Address::Work; 196 configList << KABC::Address::Work;
190 } 197 }
191 mConfig->setNoDefaultAddrTypes( configList ); 198 mConfig->setNoDefaultAddrTypes( configList );
192 199
193 mTypeCombo->updateTypes(); 200 mTypeCombo->updateTypes();
194 updateAddressEdit(); 201 updateAddressEdit();
195 emit modified(); 202 emit modified();
196 } 203 }
197 } 204 }
198} 205}
199 206
200void AddressEditWidget::updateAddressEdit() 207void AddressEditWidget::updateAddressEdit()
201{ 208{
202 KABC::Address::List::Iterator it = mTypeCombo->selectedElement(); 209 KABC::Address::List::Iterator it = mTypeCombo->selectedElement();
203 210
204 bool block = signalsBlocked(); 211 bool block = signalsBlocked();
205 blockSignals( true ); 212 blockSignals( true );
206 213
207 mAddressTextEdit->setText( "" ); 214 mAddressTextEdit->setText( "" );
208 215
209 if ( it != mAddressList.end() ) { 216 if ( it != mAddressList.end() ) {
210 KABC::Address a = *it; 217 KABC::Address a = *it;
211 if ( !a.isEmpty() ) { 218 if ( !a.isEmpty() ) {
212#if KDE_VERSION >= 319 219#if KDE_VERSION >= 319
213 if ( a.type() & KABC::Address::Work ) { 220 if ( a.type() & KABC::Address::Work ) {
214 mAddressTextEdit->setText( a.formattedAddress( mAddressee.realName(), 221 mAddressTextEdit->setText( a.formattedAddress( mAddressee.realName(),
215 mAddressee.organization() ) ); 222 mAddressee.organization() ) );
216 } else { 223 } else {
217 mAddressTextEdit->setText( a.formattedAddress( mAddressee.realName() ) ); 224 mAddressTextEdit->setText( a.formattedAddress( mAddressee.realName() ) );
218 } 225 }
219#else 226#else
220 QString text; 227 QString text;
221 if ( !a.street().isEmpty() ) 228 if ( !a.street().isEmpty() )
222 text += a.street() + "\n"; 229 text += a.street() + "\n";
223 230
224 if ( !a.postOfficeBox().isEmpty() ) 231 if ( !a.postOfficeBox().isEmpty() )
225 text += a.postOfficeBox() + "\n"; 232 text += a.postOfficeBox() + "\n";
226 233
227 text += a.locality() + QString(" ") + a.region(); 234 text += a.locality() + QString(" ") + a.region();
228 235
229 if ( !a.postalCode().isEmpty() ) 236 if ( !a.postalCode().isEmpty() )
230 text += QString(", ") + a.postalCode(); 237 text += QString(", ") + a.postalCode();
231 238
232 text += "\n"; 239 text += "\n";
233 240
234 if ( !a.country().isEmpty() ) 241 if ( !a.country().isEmpty() )
235 text += a.country() + "\n"; 242 text += a.country() + "\n";
236 243
237 text += a.extended(); 244 text += a.extended();
238 245
239 mAddressTextEdit->setText( text ); 246 mAddressTextEdit->setText( text );
240#endif 247#endif
241 } 248 }
242 } 249 }
243 250
244 blockSignals( block ); 251 blockSignals( block );
245} 252}
246 253
247AddressEditDialog::AddressEditDialog( const KABC::Address::List &list, 254AddressEditDialog::AddressEditDialog( const KABC::Address::List &list,
248 int selected, QWidget *parent, 255 int selected, QWidget *parent,
249 const char *name ) 256 const char *name )
250 : KDialogBase( Plain, i18n( "Edit Address" ), Ok | Cancel, Ok, 257 : KDialogBase( Plain, i18n( "Edit Address" ), Ok | Cancel, Ok,
251 parent, name, true, true ), 258 parent, name, true, true ),
252 mPreviousAddress( 0 ) 259 mPreviousAddress( 0 )
253{ 260{
254 mAddressList = list; 261 mAddressList = list;
255 262
256 QWidget *page = plainPage(); 263 QWidget *page = plainPage();
257 264
258 QGridLayout *topLayout = new QGridLayout( page, 8, 2 ); 265 Q3GridLayout *topLayout = new Q3GridLayout( page, 8, 2 );
259 topLayout->setSpacing( spacingHintSmall() ); 266 topLayout->setSpacing( spacingHintSmall() );
260 267
261 mTypeCombo = new AddressTypeCombo( mAddressList, page ); 268 mTypeCombo = new AddressTypeCombo( mAddressList, page );
262 topLayout->addMultiCellWidget( mTypeCombo, 0, 0, 0, 1 ); 269 topLayout->addMultiCellWidget( mTypeCombo, 0, 0, 0, 1 );
263 270
264 QLabel *label = new QLabel( i18n( "Street:" ), page ); 271 QLabel *label = new QLabel( i18n( "Street:" ), page );
265 label->setAlignment( Qt::AlignTop | Qt::AlignLeft ); 272 label->setAlignment( Qt::AlignTop | Qt::AlignLeft );
266 topLayout->addWidget( label, 1, 0 ); 273 topLayout->addWidget( label, 1, 0 );
267 274
268#ifndef KAB_EMBEDDED 275#ifndef KAB_EMBEDDED
269 mStreetTextEdit = new QTextEdit( page ); 276 mStreetTextEdit = new Q3TextEdit( page );
270#else //KAB_EMBEDDED 277#else //KAB_EMBEDDED
271 mStreetTextEdit = new QMultiLineEdit( page ); 278 mStreetTextEdit = new Q3MultiLineEdit( page );
272//US qDebug("AddressEditDialog::AddressEditDialog has to be changed"); 279//US qDebug("AddressEditDialog::AddressEditDialog has to be changed");
273#endif //KAB_EMBEDDED 280#endif //KAB_EMBEDDED
274 281
275 label->setBuddy( mStreetTextEdit ); 282 label->setBuddy( mStreetTextEdit );
276 topLayout->addWidget( mStreetTextEdit, 1, 1 ); 283 topLayout->addWidget( mStreetTextEdit, 1, 1 );
277 284
278 label = new QLabel( i18n( "Post office box:" ), page ); 285 label = new QLabel( i18n( "Post office box:" ), page );
279 topLayout->addWidget( label, 2 , 0 ); 286 topLayout->addWidget( label, 2 , 0 );
280 mPOBoxEdit = new KLineEdit( page ); 287 mPOBoxEdit = new KLineEdit( page );
281 label->setBuddy( mPOBoxEdit ); 288 label->setBuddy( mPOBoxEdit );
282 topLayout->addWidget( mPOBoxEdit, 2, 1 ); 289 topLayout->addWidget( mPOBoxEdit, 2, 1 );
283 int maxwid = QApplication::desktop()->width(); 290 int maxwid = QApplication::desktop()->width();
284 maxwid -= (spacingHintSmall()+label->sizeHint().width() ); 291 maxwid -= (spacingHintSmall()+label->sizeHint().width() );
285 label = new QLabel( i18n( "Locality:" ), page ); 292 label = new QLabel( i18n( "Locality:" ), page );
286 topLayout->addWidget( label, 3, 0 ); 293 topLayout->addWidget( label, 3, 0 );
287 mLocalityEdit = new KLineEdit( page ); 294 mLocalityEdit = new KLineEdit( page );
288 label->setBuddy( mLocalityEdit ); 295 label->setBuddy( mLocalityEdit );
289 topLayout->addWidget( mLocalityEdit, 3, 1 ); 296 topLayout->addWidget( mLocalityEdit, 3, 1 );
290 297
291 label = new QLabel( i18n( "Region:" ), page ); 298 label = new QLabel( i18n( "Region:" ), page );
292 topLayout->addWidget( label, 4, 0 ); 299 topLayout->addWidget( label, 4, 0 );
293 mRegionEdit = new KLineEdit( page ); 300 mRegionEdit = new KLineEdit( page );
294 label->setBuddy( mRegionEdit ); 301 label->setBuddy( mRegionEdit );
295 topLayout->addWidget( mRegionEdit, 4, 1 ); 302 topLayout->addWidget( mRegionEdit, 4, 1 );
296 303
297 label = new QLabel( i18n( "Postal code:" ), page ); 304 label = new QLabel( i18n( "Postal code:" ), page );
298 topLayout->addWidget( label, 5, 0 ); 305 topLayout->addWidget( label, 5, 0 );
299 mPostalCodeEdit = new KLineEdit( page ); 306 mPostalCodeEdit = new KLineEdit( page );
300 label->setBuddy( mPostalCodeEdit ); 307 label->setBuddy( mPostalCodeEdit );
301 topLayout->addWidget( mPostalCodeEdit, 5, 1 ); 308 topLayout->addWidget( mPostalCodeEdit, 5, 1 );
302 309
303 label = new QLabel( i18n( "Country:" ), page ); 310 label = new QLabel( i18n( "Country:" ), page );
304 topLayout->addWidget( label, 6, 0 ); 311 topLayout->addWidget( label, 6, 0 );
305 mCountryCombo = new KComboBox( page ); 312 mCountryCombo = new KComboBox( page );
306 313
307 mCountryCombo->setMaximumWidth( maxwid -10 ); 314 mCountryCombo->setMaximumWidth( maxwid -10 );
308 mCountryCombo->setEditable( true ); 315 mCountryCombo->setEditable( true );
309 mCountryCombo->setDuplicatesEnabled( false ); 316 mCountryCombo->setDuplicatesEnabled( false );
310 mCountryCombo->setAutoCompletion( true ); 317 mCountryCombo->setAutoCompletion( true );
311 fillCountryCombo(); 318 fillCountryCombo();
312 label->setBuddy( mCountryCombo ); 319 label->setBuddy( mCountryCombo );
313 topLayout->addWidget( mCountryCombo, 6, 1 ); 320 topLayout->addWidget( mCountryCombo, 6, 1 );
314 mCountryCombo->setSizeLimit( 8); 321 mCountryCombo->setMaxVisibleItems( 8);
315 mPreferredCheckBox = new QCheckBox( i18n( "This is the preferred address" ), page ); 322 mPreferredCheckBox = new QCheckBox( i18n( "This is the preferred address" ), page );
316 topLayout->addMultiCellWidget( mPreferredCheckBox, 7, 7, 0, 1 ); 323 topLayout->addMultiCellWidget( mPreferredCheckBox, 7, 7, 0, 1 );
317 /* 324 /*
318 KSeparator *sep = new KSeparator( KSeparator::HLine, page ); 325 KSeparator *sep = new KSeparator( KSeparator::HLine, page );
319 topLayout->addMultiCellWidget( sep, 8, 8, 0, 1 ); 326 topLayout->addMultiCellWidget( sep, 8, 8, 0, 1 );
320 */ 327 */
321 QHBox *buttonBox = new QHBox( page ); 328 Q3HBox *buttonBox = new Q3HBox( page );
322 buttonBox->setSpacing( spacingHint() ); 329 buttonBox->setSpacing( spacingHint() );
323 topLayout->addMultiCellWidget( buttonBox, 9, 9, 0, 1 ); 330 topLayout->addMultiCellWidget( buttonBox, 9, 9, 0, 1 );
324 331
325 QPushButton *addButton = new QPushButton( i18n( "New..." ), buttonBox ); 332 QPushButton *addButton = new QPushButton( i18n( "New..." ), buttonBox );
326 connect( addButton, SIGNAL( clicked() ), SLOT( addAddress() ) ); 333 connect( addButton, SIGNAL( clicked() ), SLOT( addAddress() ) );
327 334
328 mRemoveButton = new QPushButton( i18n( "Remove" ), buttonBox ); 335 mRemoveButton = new QPushButton( i18n( "Remove" ), buttonBox );
329 connect( mRemoveButton, SIGNAL( clicked() ), SLOT( removeAddress() ) ); 336 connect( mRemoveButton, SIGNAL( clicked() ), SLOT( removeAddress() ) );
330 337
331 mChangeTypeButton = new QPushButton( i18n( "Change Type" ), buttonBox ); 338 mChangeTypeButton = new QPushButton( i18n( "Change Type" ), buttonBox );
332 connect( mChangeTypeButton, SIGNAL( clicked() ), SLOT( changeType() ) ); 339 connect( mChangeTypeButton, SIGNAL( clicked() ), SLOT( changeType() ) );
333 340
334 mTypeCombo->updateTypes(); 341 mTypeCombo->updateTypes();
335 mTypeCombo->setCurrentItem( selected ); 342 mTypeCombo->setCurrentItem( selected );
336 343
337 updateAddressEdits(); 344 updateAddressEdits();
338 345
339 connect( mTypeCombo, SIGNAL( activated( int ) ), 346 connect( mTypeCombo, SIGNAL( activated( int ) ),
340 SLOT( updateAddressEdits() ) ); 347 SLOT( updateAddressEdits() ) );
341 connect( mStreetTextEdit, SIGNAL( textChanged() ), SLOT( modified() ) ); 348 connect( mStreetTextEdit, SIGNAL( textChanged() ), SLOT( modified() ) );
342 connect( mPOBoxEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 349 connect( mPOBoxEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
343 connect( mLocalityEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 350 connect( mLocalityEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
344 connect( mRegionEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 351 connect( mRegionEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
345 connect( mPostalCodeEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 352 connect( mPostalCodeEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
346 connect( mCountryCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 353 connect( mCountryCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
347 connect( mPreferredCheckBox, SIGNAL( toggled( bool ) ), SLOT( modified() ) ); 354 connect( mPreferredCheckBox, SIGNAL( toggled( bool ) ), SLOT( modified() ) );
348 355
349#ifndef KAB_EMBEDDED 356#ifndef KAB_EMBEDDED
350 KAcceleratorManager::manage( this ); 357 KAcceleratorManager::manage( this );
351#else //KAB_EMBEDDED 358#else //KAB_EMBEDDED
352//US qDebug("AddressEditDialog::AddressEditDialog has to be changed 2"); 359//US qDebug("AddressEditDialog::AddressEditDialog has to be changed 2");
353#endif //KAB_EMBEDDED 360#endif //KAB_EMBEDDED
354 361
355 mChanged = false; 362 mChanged = false;
356 363
357 bool state = (mAddressList.count() > 0); 364 bool state = (mAddressList.count() > 0);
358 mRemoveButton->setEnabled( state ); 365 mRemoveButton->setEnabled( state );
359 mChangeTypeButton->setEnabled( state ); 366 mChangeTypeButton->setEnabled( state );
360#ifndef DESKTOP_VERSION 367#ifndef DESKTOP_VERSION
361 showMaximized(); 368 showMaximized();
362#endif 369#endif
363} 370}
364 371
365AddressEditDialog::~AddressEditDialog() 372AddressEditDialog::~AddressEditDialog()
366{ 373{
367} 374}
368 375
369KABC::Address::List AddressEditDialog::addresses() 376KABC::Address::List AddressEditDialog::addresses()
370{ 377{
371 saveAddress( *(mTypeCombo->selectedElement()) ); 378 saveAddress( *(mTypeCombo->selectedElement()) );
372 379
373 return mAddressList; 380 return mAddressList;
374} 381}
375 382
376bool AddressEditDialog::changed() const 383bool AddressEditDialog::changed() const
377{ 384{
378 return mChanged; 385 return mChanged;
379} 386}
380 387
381void AddressEditDialog::addAddress() 388void AddressEditDialog::addAddress()
382{ 389{
383 AddressTypeDialog dlg( mTypeCombo->selectedType(), this ); 390 AddressTypeDialog dlg( mTypeCombo->selectedType(), this );
384 if ( dlg.exec() ) { 391 if ( dlg.exec() ) {
385 mAddressList.append( Address( dlg.type() ) ); 392 mAddressList.append( Address( dlg.type() ) );
386 393
387 mTypeCombo->updateTypes(); 394 mTypeCombo->updateTypes();
388 mTypeCombo->setCurrentItem( mTypeCombo->count() - 1 ); 395 mTypeCombo->setCurrentItem( mTypeCombo->count() - 1 );
389 updateAddressEdits(); 396 updateAddressEdits();
390 397
391 modified(); 398 modified();
392 399
393 mRemoveButton->setEnabled( true ); 400 mRemoveButton->setEnabled( true );
394 mChangeTypeButton->setEnabled( true ); 401 mChangeTypeButton->setEnabled( true );
395 } 402 }
396} 403}
397 404
398void AddressEditDialog::removeAddress() 405void AddressEditDialog::removeAddress()
399{ 406{
400 if ( mAddressList.count() > 0 ) { 407 if ( mAddressList.count() > 0 ) {
401 KABC::Address::List::Iterator it = mTypeCombo->selectedElement(); 408 KABC::Address::List::Iterator it = mTypeCombo->selectedElement();
402 if ( mPreviousAddress && mPreviousAddress->id() == (*it).id() ) 409 if ( mPreviousAddress && mPreviousAddress->id() == (*it).id() )
403 mPreviousAddress = 0; 410 mPreviousAddress = 0;
404 411
405 mAddressList.remove( it ); 412 mAddressList.remove( it );
406 mTypeCombo->updateTypes(); 413 mTypeCombo->updateTypes();
407 updateAddressEdits(); 414 updateAddressEdits();
408 415
409 modified(); 416 modified();
410 } 417 }
411 418
412 bool state = ( mAddressList.count() > 0 ); 419 bool state = ( mAddressList.count() > 0 );
413 mRemoveButton->setEnabled( state ); 420 mRemoveButton->setEnabled( state );
414 mChangeTypeButton->setEnabled( state ); 421 mChangeTypeButton->setEnabled( state );
415} 422}
416 423
417void AddressEditDialog::changeType() 424void AddressEditDialog::changeType()
418{ 425{
419 KABC::Address::List::Iterator a = mTypeCombo->selectedElement(); 426 KABC::Address::List::Iterator a = mTypeCombo->selectedElement();
420 427
421 AddressTypeDialog dlg( (*a).type(), this ); 428 AddressTypeDialog dlg( (*a).type(), this );
422 if ( dlg.exec() ) { 429 if ( dlg.exec() ) {
423 (*a).setType( dlg.type() ); 430 (*a).setType( dlg.type() );
424 431
425 mTypeCombo->updateTypes(); 432 mTypeCombo->updateTypes();
426 433
427 modified(); 434 modified();
428 } 435 }
429} 436}
430 437
431void AddressEditDialog::updateAddressEdits() 438void AddressEditDialog::updateAddressEdits()
432{ 439{
433 if ( mPreviousAddress ) 440 if ( mPreviousAddress )
434 saveAddress( *mPreviousAddress ); 441 saveAddress( *mPreviousAddress );
435 442
436 KABC::Address::List::Iterator it = mTypeCombo->selectedElement(); 443 KABC::Address::List::Iterator it = mTypeCombo->selectedElement();
437 KABC::Address a = *it; 444 KABC::Address a = *it;
438 mPreviousAddress = &(*it); 445 mPreviousAddress = &(*it);
439 446
440 bool tmp = mChanged; 447 bool tmp = mChanged;
441 448
442 mStreetTextEdit->setText( a.street() ); 449 mStreetTextEdit->setText( a.street() );
443 mRegionEdit->setText( a.region() ); 450 mRegionEdit->setText( a.region() );
444 mLocalityEdit->setText( a.locality() ); 451 mLocalityEdit->setText( a.locality() );
445 mPostalCodeEdit->setText( a.postalCode() ); 452 mPostalCodeEdit->setText( a.postalCode() );
446 mPOBoxEdit->setText( a.postOfficeBox() ); 453 mPOBoxEdit->setText( a.postOfficeBox() );
447 454
448#ifndef KAB_EMBEDDED 455#ifndef KAB_EMBEDDED
449 mCountryCombo->setCurrentText( a.country() ); 456 mCountryCombo->setCurrentText( a.country() );
450#else //KAB_EMBEDDED 457#else //KAB_EMBEDDED
451 mCountryCombo->setEditText( a.country() ); 458 mCountryCombo->setEditText( a.country() );
452//US qDebug("AddressEditDialog::updateAddressEdits has to be changed 1"); 459//US qDebug("AddressEditDialog::updateAddressEdits has to be changed 1");
453#endif //KAB_EMBEDDED 460#endif //KAB_EMBEDDED
454 461
455 mPreferredCheckBox->setChecked( a.type() & KABC::Address::Pref ); 462 mPreferredCheckBox->setChecked( a.type() & KABC::Address::Pref );
456 463
457 mStreetTextEdit->setFocus(); 464 mStreetTextEdit->setFocus();
458 465
459 mChanged = tmp; 466 mChanged = tmp;
460} 467}
461 468
462void AddressEditDialog::modified() 469void AddressEditDialog::modified()
463{ 470{
464 mChanged = true; 471 mChanged = true;
465} 472}
466 473
467void AddressEditDialog::saveAddress( KABC::Address &addr ) 474void AddressEditDialog::saveAddress( KABC::Address &addr )
468{ 475{
469 addr.setLocality( mLocalityEdit->text() ); 476 addr.setLocality( mLocalityEdit->text() );
470 addr.setRegion( mRegionEdit->text() ); 477 addr.setRegion( mRegionEdit->text() );
471 addr.setPostalCode( mPostalCodeEdit->text() ); 478 addr.setPostalCode( mPostalCodeEdit->text() );
472 addr.setCountry( mCountryCombo->currentText() ); 479 addr.setCountry( mCountryCombo->currentText() );
473 addr.setPostOfficeBox( mPOBoxEdit->text() ); 480 addr.setPostOfficeBox( mPOBoxEdit->text() );
474 addr.setStreet( mStreetTextEdit->text() ); 481 addr.setStreet( mStreetTextEdit->text() );
475 482
476 483
477 if ( mPreferredCheckBox->isChecked() ) { 484 if ( mPreferredCheckBox->isChecked() ) {
478 KABC::Address::List::Iterator it; 485 KABC::Address::List::Iterator it;
479 for ( it = mAddressList.begin(); it != mAddressList.end(); ++it ) 486 for ( it = mAddressList.begin(); it != mAddressList.end(); ++it )
480 (*it).setType( (*it).type() & ~( KABC::Address::Pref ) ); 487 (*it).setType( (*it).type() & ~( KABC::Address::Pref ) );
481 488
482 addr.setType( addr.type() | KABC::Address::Pref ); 489 addr.setType( addr.type() | KABC::Address::Pref );
483 } 490 }
484} 491}
485 492
486void AddressEditDialog::fillCountryCombo() 493void AddressEditDialog::fillCountryCombo()
487{ 494{
488 QString country[] = { 495 QString country[] = {
489 i18n( "Afghanistan" ), i18n( "Albania" ), i18n( "Algeria" ), 496 i18n( "Afghanistan" ), i18n( "Albania" ), i18n( "Algeria" ),
490 i18n( "American Samoa" ), i18n( "Andorra" ), i18n( "Angola" ), 497 i18n( "American Samoa" ), i18n( "Andorra" ), i18n( "Angola" ),
491 i18n( "Anguilla" ), i18n( "Antarctica" ), i18n( "Antigua and Barbuda" ), 498 i18n( "Anguilla" ), i18n( "Antarctica" ), i18n( "Antigua and Barbuda" ),
492 i18n( "Argentina" ), i18n( "Armenia" ), i18n( "Aruba" ), 499 i18n( "Argentina" ), i18n( "Armenia" ), i18n( "Aruba" ),
493 i18n( "Ashmore and Cartier Islands" ), i18n( "Australia" ), 500 i18n( "Ashmore and Cartier Islands" ), i18n( "Australia" ),
494 i18n( "Austria" ), i18n( "Azerbaijan" ), i18n( "Bahamas" ), 501 i18n( "Austria" ), i18n( "Azerbaijan" ), i18n( "Bahamas" ),
495 i18n( "Bahrain" ), i18n( "Bangladesh" ), i18n( "Barbados" ), 502 i18n( "Bahrain" ), i18n( "Bangladesh" ), i18n( "Barbados" ),
496 i18n( "Belarus" ), i18n( "Belgium" ), i18n( "Belize" ), 503 i18n( "Belarus" ), i18n( "Belgium" ), i18n( "Belize" ),
497 i18n( "Benin" ), i18n( "Bermuda" ), i18n( "Bhutan" ), 504 i18n( "Benin" ), i18n( "Bermuda" ), i18n( "Bhutan" ),
498 i18n( "Bolivia" ), i18n( "Bosnia and Herzegovina" ), i18n( "Botswana" ), 505 i18n( "Bolivia" ), i18n( "Bosnia and Herzegovina" ), i18n( "Botswana" ),
499 i18n( "Brazil" ), i18n( "Brunei" ), i18n( "Bulgaria" ), 506 i18n( "Brazil" ), i18n( "Brunei" ), i18n( "Bulgaria" ),
500 i18n( "Burkina Faso" ), i18n( "Burundi" ), i18n( "Cambodia" ), 507 i18n( "Burkina Faso" ), i18n( "Burundi" ), i18n( "Cambodia" ),
501 i18n( "Cameroon" ), i18n( "Canada" ), i18n( "Cape Verde" ), 508 i18n( "Cameroon" ), i18n( "Canada" ), i18n( "Cape Verde" ),
502 i18n( "Cayman Islands" ), i18n( "Central African Republic" ), 509 i18n( "Cayman Islands" ), i18n( "Central African Republic" ),
503 i18n( "Chad" ), i18n( "Chile" ), i18n( "China" ), i18n( "Colombia" ), 510 i18n( "Chad" ), i18n( "Chile" ), i18n( "China" ), i18n( "Colombia" ),
504 i18n( "Comoros" ), i18n( "Congo" ), i18n( "Congo, Dem. Rep." ), 511 i18n( "Comoros" ), i18n( "Congo" ), i18n( "Congo, Dem. Rep." ),
505 i18n( "Costa Rica" ), i18n( "Croatia" ), 512 i18n( "Costa Rica" ), i18n( "Croatia" ),
506 i18n( "Cuba" ), i18n( "Cyprus" ), i18n( "Czech Republic" ), 513 i18n( "Cuba" ), i18n( "Cyprus" ), i18n( "Czech Republic" ),
507 i18n( "Denmark" ), i18n( "Djibouti" ), 514 i18n( "Denmark" ), i18n( "Djibouti" ),
508 i18n( "Dominica" ), i18n( "Dominican Republic" ), i18n( "Ecuador" ), 515 i18n( "Dominica" ), i18n( "Dominican Republic" ), i18n( "Ecuador" ),
509 i18n( "Egypt" ), i18n( "El Salvador" ), i18n( "Equatorial Guinea" ), 516 i18n( "Egypt" ), i18n( "El Salvador" ), i18n( "Equatorial Guinea" ),
510 i18n( "Eritrea" ), i18n( "Estonia" ), i18n( "England" ), 517 i18n( "Eritrea" ), i18n( "Estonia" ), i18n( "England" ),
511 i18n( "Ethiopia" ), i18n( "European Union" ), i18n( "Faroe Islands" ), 518 i18n( "Ethiopia" ), i18n( "European Union" ), i18n( "Faroe Islands" ),
512 i18n( "Fiji" ), i18n( "Finland" ), i18n( "France" ), 519 i18n( "Fiji" ), i18n( "Finland" ), i18n( "France" ),
513 i18n( "French Polynesia" ), i18n( "Gabon" ), i18n( "Gambia" ), 520 i18n( "French Polynesia" ), i18n( "Gabon" ), i18n( "Gambia" ),
514 i18n( "Georgia" ), i18n( "Germany" ), i18n( "Ghana" ), 521 i18n( "Georgia" ), i18n( "Germany" ), i18n( "Ghana" ),
515 i18n( "Greece" ), i18n( "Greenland" ), i18n( "Grenada" ), 522 i18n( "Greece" ), i18n( "Greenland" ), i18n( "Grenada" ),
516 i18n( "Guam" ), i18n( "Guatemala" ), i18n( "Guinea" ), 523 i18n( "Guam" ), i18n( "Guatemala" ), i18n( "Guinea" ),
517 i18n( "Guinea-Bissau" ), i18n( "Guyana" ), i18n( "Haiti" ), 524 i18n( "Guinea-Bissau" ), i18n( "Guyana" ), i18n( "Haiti" ),
518 i18n( "Honduras" ), i18n( "Hong Kong" ), i18n( "Hungary" ), 525 i18n( "Honduras" ), i18n( "Hong Kong" ), i18n( "Hungary" ),
519 i18n( "Iceland" ), i18n( "India" ), i18n( "Indonesia" ), 526 i18n( "Iceland" ), i18n( "India" ), i18n( "Indonesia" ),
520 i18n( "Iran" ), i18n( "Iraq" ), i18n( "Ireland" ), 527 i18n( "Iran" ), i18n( "Iraq" ), i18n( "Ireland" ),
521 i18n( "Israel" ), i18n( "Italy" ), i18n( "Ivory Coast" ), 528 i18n( "Israel" ), i18n( "Italy" ), i18n( "Ivory Coast" ),
522 i18n( "Jamaica" ), i18n( "Japan" ), i18n( "Jordan" ), 529 i18n( "Jamaica" ), i18n( "Japan" ), i18n( "Jordan" ),
523 i18n( "Kazakhstan" ), i18n( "Kenya" ), i18n( "Kiribati" ), 530 i18n( "Kazakhstan" ), i18n( "Kenya" ), i18n( "Kiribati" ),
524 i18n( "Korea, North" ), i18n( "Korea, South" ), 531 i18n( "Korea, North" ), i18n( "Korea, South" ),
525 i18n( "Kuwait" ), i18n( "Kyrgyzstan" ), i18n( "Laos" ), 532 i18n( "Kuwait" ), i18n( "Kyrgyzstan" ), i18n( "Laos" ),
526 i18n( "Latvia" ), i18n( "Lebanon" ), i18n( "Lesotho" ), 533 i18n( "Latvia" ), i18n( "Lebanon" ), i18n( "Lesotho" ),
527 i18n( "Liberia" ), i18n( "Libya" ), i18n( "Liechtenstein" ), 534 i18n( "Liberia" ), i18n( "Libya" ), i18n( "Liechtenstein" ),
528 i18n( "Lithuania" ), i18n( "Luxembourg" ), i18n( "Macau" ), 535 i18n( "Lithuania" ), i18n( "Luxembourg" ), i18n( "Macau" ),
529 i18n( "Madagascar" ), i18n( "Malawi" ), i18n( "Malaysia" ), 536 i18n( "Madagascar" ), i18n( "Malawi" ), i18n( "Malaysia" ),
530 i18n( "Maldives" ), i18n( "Mali" ), i18n( "Malta" ), 537 i18n( "Maldives" ), i18n( "Mali" ), i18n( "Malta" ),
531 i18n( "Marshall Islands" ), i18n( "Martinique" ), i18n( "Mauritania" ), 538 i18n( "Marshall Islands" ), i18n( "Martinique" ), i18n( "Mauritania" ),
532 i18n( "Mauritius" ), i18n( "Mexico" ), 539 i18n( "Mauritius" ), i18n( "Mexico" ),
533 i18n( "Micronesia, Federated States Of" ), i18n( "Moldova" ), 540 i18n( "Micronesia, Federated States Of" ), i18n( "Moldova" ),
534 i18n( "Monaco" ), i18n( "Mongolia" ), i18n( "Montserrat" ), 541 i18n( "Monaco" ), i18n( "Mongolia" ), i18n( "Montserrat" ),
535 i18n( "Morocco" ), i18n( "Mozambique" ), i18n( "Myanmar" ), 542 i18n( "Morocco" ), i18n( "Mozambique" ), i18n( "Myanmar" ),
536 i18n( "Namibia" ), 543 i18n( "Namibia" ),
537 i18n( "Nauru" ), i18n( "Nepal" ), i18n( "Netherlands" ), 544 i18n( "Nauru" ), i18n( "Nepal" ), i18n( "Netherlands" ),
538 i18n( "Netherlands Antilles" ), i18n( "New Caledonia" ), 545 i18n( "Netherlands Antilles" ), i18n( "New Caledonia" ),
539 i18n( "New Zealand" ), i18n( "Nicaragua" ), i18n( "Niger" ), 546 i18n( "New Zealand" ), i18n( "Nicaragua" ), i18n( "Niger" ),
540 i18n( "Nigeria" ), i18n( "Niue" ), i18n( "North Korea" ), 547 i18n( "Nigeria" ), i18n( "Niue" ), i18n( "North Korea" ),
541 i18n( "Northern Ireland" ), i18n( "Northern Mariana Islands" ), 548 i18n( "Northern Ireland" ), i18n( "Northern Mariana Islands" ),
542 i18n( "Norway" ), i18n( "Oman" ), i18n( "Pakistan" ), i18n( "Palau" ), 549 i18n( "Norway" ), i18n( "Oman" ), i18n( "Pakistan" ), i18n( "Palau" ),
543 i18n( "Palestinian" ), i18n( "Panama" ), i18n( "Papua New Guinea" ), 550 i18n( "Palestinian" ), i18n( "Panama" ), i18n( "Papua New Guinea" ),
544 i18n( "Paraguay" ), i18n( "Peru" ), i18n( "Philippines" ), 551 i18n( "Paraguay" ), i18n( "Peru" ), i18n( "Philippines" ),
545 i18n( "Poland" ), i18n( "Portugal" ), i18n( "Puerto Rico" ), 552 i18n( "Poland" ), i18n( "Portugal" ), i18n( "Puerto Rico" ),
546 i18n( "Qatar" ), i18n( "Romania" ), i18n( "Russia" ), i18n( "Rwanda" ), 553 i18n( "Qatar" ), i18n( "Romania" ), i18n( "Russia" ), i18n( "Rwanda" ),
547 i18n( "St. Kitts and Nevis" ), i18n( "St. Lucia" ), 554 i18n( "St. Kitts and Nevis" ), i18n( "St. Lucia" ),
548 i18n( "St. Vincent and the Grenadines" ), i18n( "San Marino" ), 555 i18n( "St. Vincent and the Grenadines" ), i18n( "San Marino" ),
549 i18n( "Sao Tome and Principe" ), i18n( "Saudi Arabia" ), 556 i18n( "Sao Tome and Principe" ), i18n( "Saudi Arabia" ),
550 i18n( "Senegal" ), i18n( "Serbia & Montenegro" ), i18n( "Seychelles" ), 557 i18n( "Senegal" ), i18n( "Serbia & Montenegro" ), i18n( "Seychelles" ),
551 i18n( "Sierra Leone" ), i18n( "Singapore" ), i18n( "Slovakia" ), 558 i18n( "Sierra Leone" ), i18n( "Singapore" ), i18n( "Slovakia" ),
552 i18n( "Slovenia" ), i18n( "Solomon Islands" ), i18n( "Somalia" ), 559 i18n( "Slovenia" ), i18n( "Solomon Islands" ), i18n( "Somalia" ),
553 i18n( "South Africa" ), i18n( "South Korea" ), i18n( "Spain" ), 560 i18n( "South Africa" ), i18n( "South Korea" ), i18n( "Spain" ),
554 i18n( "Sri Lanka" ), i18n( "St. Kitts and Nevis" ), i18n( "Sudan" ), 561 i18n( "Sri Lanka" ), i18n( "St. Kitts and Nevis" ), i18n( "Sudan" ),
555 i18n( "Suriname" ), i18n( "Swaziland" ), i18n( "Sweden" ), 562 i18n( "Suriname" ), i18n( "Swaziland" ), i18n( "Sweden" ),
556 i18n( "Switzerland" ), i18n( "Syria" ), i18n( "Taiwan" ), 563 i18n( "Switzerland" ), i18n( "Syria" ), i18n( "Taiwan" ),
557 i18n( "Tajikistan" ), i18n( "Tanzania" ), i18n( "Thailand" ), 564 i18n( "Tajikistan" ), i18n( "Tanzania" ), i18n( "Thailand" ),
558 i18n( "Tibet" ), i18n( "Togo" ), i18n( "Tonga" ), 565 i18n( "Tibet" ), i18n( "Togo" ), i18n( "Tonga" ),
559 i18n( "Trinidad and Tobago" ), i18n( "Tunisia" ), i18n( "Turkey" ), 566 i18n( "Trinidad and Tobago" ), i18n( "Tunisia" ), i18n( "Turkey" ),
560 i18n( "Turkmenistan" ), i18n( "Turks and Caicos Islands" ), 567 i18n( "Turkmenistan" ), i18n( "Turks and Caicos Islands" ),
561 i18n( "Tuvalu" ), i18n( "Uganda " ), i18n( "Ukraine" ), 568 i18n( "Tuvalu" ), i18n( "Uganda " ), i18n( "Ukraine" ),
562 i18n( "United Arab Emirates" ), i18n( "United Kingdom" ), 569 i18n( "United Arab Emirates" ), i18n( "United Kingdom" ),
563 i18n( "United States" ), i18n( "Uruguay" ), i18n( "Uzbekistan" ), 570 i18n( "United States" ), i18n( "Uruguay" ), i18n( "Uzbekistan" ),
564 i18n( "Vanuatu" ), i18n( "Vatican City" ), i18n( "Venezuela" ), 571 i18n( "Vanuatu" ), i18n( "Vatican City" ), i18n( "Venezuela" ),
565 i18n( "Vietnam" ), i18n( "Western Samoa" ), i18n( "Yemen" ), 572 i18n( "Vietnam" ), i18n( "Western Samoa" ), i18n( "Yemen" ),
566 i18n( "Yugoslavia" ), i18n( "Zaire" ), i18n( "Zambia" ), 573 i18n( "Yugoslavia" ), i18n( "Zaire" ), i18n( "Zambia" ),
567 i18n( "Zimbabwe" ), 574 i18n( "Zimbabwe" ),
568 "" 575 ""
569 }; 576 };
570 577
571 QStringList countries; 578 QStringList countries;
572 for ( int i = 0; !country[ i ].isEmpty(); ++i ) 579 for ( int i = 0; !country[ i ].isEmpty(); ++i )
573 countries.append( country[ i ] ); 580 countries.append( country[ i ] );
574 581
575 countries.sort(); 582 countries.sort();
576 583
577 mCountryCombo->insertStringList( countries ); 584 mCountryCombo->insertStringList( countries );
578} 585}
579 586
580 587
581AddressTypeDialog::AddressTypeDialog( int type, QWidget *parent ) 588AddressTypeDialog::AddressTypeDialog( int type, QWidget *parent )
582 : KDialogBase( Plain, i18n( "Edit Address Type" ), Ok | Cancel, Ok, 589 : KDialogBase( Plain, i18n( "Edit Address Type" ), Ok | Cancel, Ok,
583 parent, "AddressTypeDialog" ) 590 parent, "AddressTypeDialog" )
584{ 591{
585 QWidget *page = plainPage(); 592 QWidget *page = plainPage();
586 QVBoxLayout *layout = new QVBoxLayout( page ); 593 Q3VBoxLayout *layout = new Q3VBoxLayout( page );
587 594
588 mGroup = new QButtonGroup( 2, Horizontal, i18n( "Address Types" ), page ); 595 mGroup = new Q3ButtonGroup( 2, Qt::Horizontal, i18n( "Address Types" ), page );
589 layout->addWidget( mGroup ); 596 layout->addWidget( mGroup );
590 597
591 mTypeList = KABC::Address::typeList(); 598 mTypeList = KABC::Address::typeList();
592 mTypeList.remove( KABC::Address::Pref ); 599 mTypeList.remove( KABC::Address::Pref );
593 600
594 KABC::Address::TypeList::Iterator it; 601 KABC::Address::TypeList::Iterator it;
595 for ( it = mTypeList.begin(); it != mTypeList.end(); ++it ) 602 for ( it = mTypeList.begin(); it != mTypeList.end(); ++it )
596 new QCheckBox( KABC::Address::typeLabel( *it ), mGroup ); 603 new QCheckBox( KABC::Address::typeLabel( *it ), mGroup );
597 604
598 for ( int i = 0; i < mGroup->count(); ++i ) { 605 for ( int i = 0; i < mGroup->count(); ++i ) {
599 QCheckBox *box = (QCheckBox*)mGroup->find( i ); 606 QCheckBox *box = (QCheckBox*)mGroup->find( i );
600 box->setChecked( type & mTypeList[ i ] ); 607 box->setChecked( type & mTypeList[ i ] );
601 } 608 }
602} 609}
603 610
604AddressTypeDialog::~AddressTypeDialog() 611AddressTypeDialog::~AddressTypeDialog()
605{ 612{
606} 613}
607 614
608int AddressTypeDialog::type() const 615int AddressTypeDialog::type() const
609{ 616{
610 int type = 0; 617 int type = 0;
611 for ( int i = 0; i < mGroup->count(); ++i ) { 618 for ( int i = 0; i < mGroup->count(); ++i ) {
612 QCheckBox *box = (QCheckBox*)mGroup->find( i ); 619 QCheckBox *box = (QCheckBox*)mGroup->find( i );
613 if ( box->isChecked() ) 620 if ( box->isChecked() )
614 type += mTypeList[ i ]; 621 type += mTypeList[ i ];
615 } 622 }
616 623
617 return type; 624 return type;
618} 625}
619 626
620#ifndef KAB_EMBEDDED 627#ifndef KAB_EMBEDDED_
621#include "addresseditwidget.moc" 628#include "moc_addresseditwidget.cpp"
622#endif //KAB_EMBEDDED 629#endif //KAB_EMBEDDED
diff --git a/kaddressbook/addresseditwidget.h b/kaddressbook/addresseditwidget.h
index bc96d74..1d4e138 100644
--- a/kaddressbook/addresseditwidget.h
+++ b/kaddressbook/addresseditwidget.h
@@ -1,159 +1,159 @@
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 ADDRESSEDITWIDGET_H 24#ifndef ADDRESSEDITWIDGET_H
25#define ADDRESSEDITWIDGET_H 25#define ADDRESSEDITWIDGET_H
26 26
27#include <qwidget.h> 27#include <qwidget.h>
28 28
29#include <kdialogbase.h> 29#include <kdialogbase.h>
30#include <kabc/address.h> 30#include <kabc/address.h>
31#include <kabc/addressee.h> 31#include <kabc/addressee.h>
32 32
33#include "addresseeconfig.h" 33#include "addresseeconfig.h"
34#include "typecombo.h" 34#include "typecombo.h"
35 35
36class QButtonGroup; 36class Q3ButtonGroup;
37class QCheckBox; 37class QCheckBox;
38class QListView; 38class Q3ListView;
39#ifndef KAB_EMBEDDED 39#ifndef KAB_EMBEDDED
40class QTextEdit; 40class Q3TextEdit;
41#else //KAB_EMBEDDED 41#else //KAB_EMBEDDED
42class QMultiLineEdit; 42class Q3MultiLineEdit;
43#endif //KAB_EMBEDDED 43#endif //KAB_EMBEDDED
44class QToolButton; 44class QToolButton;
45 45
46class KComboBox; 46class KComboBox;
47class KLineEdit; 47class KLineEdit;
48class KListView; 48class KListView;
49 49
50typedef TypeCombo<KABC::Address> AddressTypeCombo; 50typedef TypeCombo<KABC::Address> AddressTypeCombo;
51 51
52/** 52/**
53 Editor widget for addresses. 53 Editor widget for addresses.
54 */ 54 */
55class AddressEditWidget : public QWidget 55class AddressEditWidget : public QWidget
56{ 56{
57 Q_OBJECT 57 Q_OBJECT
58 58
59 public: 59 public:
60 AddressEditWidget( QWidget *parent, const char *name = 0 ); 60 AddressEditWidget( QWidget *parent, const char *name = 0 );
61 ~AddressEditWidget(); 61 ~AddressEditWidget();
62 62
63 KABC::Address::List addresses(); 63 KABC::Address::List addresses();
64 void setAddresses( const KABC::Addressee &addr, 64 void setAddresses( const KABC::Addressee &addr,
65 const KABC::Address::List &list ); 65 const KABC::Address::List &list );
66 66
67 void updateTypeCombo( const KABC::Address::List&, KComboBox* ); 67 void updateTypeCombo( const KABC::Address::List&, KComboBox* );
68 KABC::Address currentAddress( KComboBox*, int ); 68 KABC::Address currentAddress( KComboBox*, int );
69 69
70 signals: 70 signals:
71 void modified(); 71 void modified();
72 72
73 protected slots: 73 protected slots:
74 void updateAddressEdit(); 74 void updateAddressEdit();
75 75
76 void edit(); 76 void edit();
77 77
78 private: 78 private:
79 AddresseeConfig * mConfig; 79 AddresseeConfig * mConfig;
80 AddressTypeCombo *mTypeCombo; 80 AddressTypeCombo *mTypeCombo;
81 81
82 QPushButton *mEditButton; 82 QPushButton *mEditButton;
83#ifndef KAB_EMBEDDED 83#ifndef KAB_EMBEDDED
84 QTextEdit *mAddressTextEdit; 84 Q3TextEdit *mAddressTextEdit;
85#else //KAB_EMBEDDED 85#else //KAB_EMBEDDED
86 QMultiLineEdit *mAddressTextEdit; 86 Q3MultiLineEdit *mAddressTextEdit;
87#endif //KAB_EMBEDDED 87#endif //KAB_EMBEDDED
88 88
89 KABC::Address::List mAddressList; 89 KABC::Address::List mAddressList;
90 KABC::Addressee mAddressee; 90 KABC::Addressee mAddressee;
91 int mIndex; 91 int mIndex;
92}; 92};
93 93
94/** 94/**
95 Dialog for editing address details. 95 Dialog for editing address details.
96 */ 96 */
97class AddressEditDialog : public KDialogBase 97class AddressEditDialog : public KDialogBase
98{ 98{
99 Q_OBJECT 99 Q_OBJECT
100 100
101 public: 101 public:
102 AddressEditDialog( const KABC::Address::List &list, int selected, 102 AddressEditDialog( const KABC::Address::List &list, int selected,
103 QWidget *parent, const char *name = 0 ); 103 QWidget *parent, const char *name = 0 );
104 ~AddressEditDialog(); 104 ~AddressEditDialog();
105 105
106 KABC::Address::List addresses(); 106 KABC::Address::List addresses();
107 bool changed() const; 107 bool changed() const;
108 108
109 protected slots: 109 protected slots:
110 void addAddress(); 110 void addAddress();
111 void removeAddress(); 111 void removeAddress();
112 void changeType(); 112 void changeType();
113 113
114 void updateAddressEdits(); 114 void updateAddressEdits();
115 void modified(); 115 void modified();
116 116
117 private: 117 private:
118 void saveAddress( KABC::Address &addr ); 118 void saveAddress( KABC::Address &addr );
119 void fillCountryCombo(); 119 void fillCountryCombo();
120 120
121 AddressTypeCombo *mTypeCombo; 121 AddressTypeCombo *mTypeCombo;
122#ifndef KAB_EMBEDDED 122#ifndef KAB_EMBEDDED
123 QTextEdit *mStreetTextEdit; 123 Q3TextEdit *mStreetTextEdit;
124#else //KAB_EMBEDDED 124#else //KAB_EMBEDDED
125 QMultiLineEdit *mStreetTextEdit; 125 Q3MultiLineEdit *mStreetTextEdit;
126#endif //KAB_EMBEDDED 126#endif //KAB_EMBEDDED
127 KComboBox *mCountryCombo; 127 KComboBox *mCountryCombo;
128 KLineEdit *mRegionEdit; 128 KLineEdit *mRegionEdit;
129 KLineEdit *mLocalityEdit; 129 KLineEdit *mLocalityEdit;
130 KLineEdit *mPostalCodeEdit; 130 KLineEdit *mPostalCodeEdit;
131 KLineEdit *mPOBoxEdit; 131 KLineEdit *mPOBoxEdit;
132 QCheckBox *mPreferredCheckBox; 132 QCheckBox *mPreferredCheckBox;
133 133
134 QPushButton *mRemoveButton; 134 QPushButton *mRemoveButton;
135 QPushButton *mChangeTypeButton; 135 QPushButton *mChangeTypeButton;
136 136
137 KABC::Address::List mAddressList; 137 KABC::Address::List mAddressList;
138 KABC::Address *mPreviousAddress; 138 KABC::Address *mPreviousAddress;
139 bool mChanged; 139 bool mChanged;
140}; 140};
141 141
142/** 142/**
143 Dialog for selecting an address type. 143 Dialog for selecting an address type.
144 */ 144 */
145class AddressTypeDialog : public KDialogBase 145class AddressTypeDialog : public KDialogBase
146{ 146{
147 public: 147 public:
148 AddressTypeDialog( int type, QWidget *parent ); 148 AddressTypeDialog( int type, QWidget *parent );
149 ~AddressTypeDialog(); 149 ~AddressTypeDialog();
150 150
151 int type() const; 151 int type() const;
152 152
153 private: 153 private:
154 QButtonGroup *mGroup; 154 Q3ButtonGroup *mGroup;
155 155
156 KABC::Address::TypeList mTypeList; 156 KABC::Address::TypeList mTypeList;
157}; 157};
158 158
159#endif 159#endif
diff --git a/kaddressbook/addresseeconfig.cpp b/kaddressbook/addresseeconfig.cpp
index ea0436f..81b1bf4 100644
--- a/kaddressbook/addresseeconfig.cpp
+++ b/kaddressbook/addresseeconfig.cpp
@@ -1,94 +1,96 @@
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 "addresseeconfig.h" 24#include "addresseeconfig.h"
25#include "kabprefs.h" 25#include "kabprefs.h"
26//US 26//US
27#include <kstandarddirs.h> 27#include <kstandarddirs.h>
28#include <qfileinfo.h> 28#include <qfileinfo.h>
29//Added by qt3to4:
30#include <Q3ValueList>
29 31
30using namespace KABC; 32using namespace KABC;
31 33
32static AddresseeConfig* extern_AddresseeConfig = 0; 34static AddresseeConfig* extern_AddresseeConfig = 0;
33static KConfig * extern_Config = 0; 35static KConfig * extern_Config = 0;
34 36
35AddresseeConfig::AddresseeConfig() 37AddresseeConfig::AddresseeConfig()
36{ 38{
37 39
38 40
39} 41}
40AddresseeConfig::~AddresseeConfig() 42AddresseeConfig::~AddresseeConfig()
41{ 43{
42 delete AddresseeConfig::config(); 44 delete AddresseeConfig::config();
43} 45}
44 46
45 47
46AddresseeConfig* AddresseeConfig::instance() 48AddresseeConfig* AddresseeConfig::instance()
47{ 49{
48 if ( ! extern_AddresseeConfig ) 50 if ( ! extern_AddresseeConfig )
49 extern_AddresseeConfig = new AddresseeConfig(); 51 extern_AddresseeConfig = new AddresseeConfig();
50 return extern_AddresseeConfig; 52 return extern_AddresseeConfig;
51} 53}
52KConfig* AddresseeConfig::config() 54KConfig* AddresseeConfig::config()
53{ 55{
54 if ( ! extern_Config ) { 56 if ( ! extern_Config ) {
55 QString conf = locateLocal("config", "kaddressrc"); 57 QString conf = locateLocal("config", "kaddressrc");
56 extern_Config= new KConfig( conf ); 58 extern_Config= new KConfig( conf );
57 } 59 }
58 return extern_Config; 60 return extern_Config;
59} 61}
60 62
61 63
62void AddresseeConfig::setUid( const QString & uid ) 64void AddresseeConfig::setUid( const QString & uid )
63{ 65{
64 AddresseeConfig::config()->setGroup( uid ); 66 AddresseeConfig::config()->setGroup( uid );
65 mUid = uid; 67 mUid = uid;
66} 68}
67 69
68void AddresseeConfig::setAutomaticNameParsing( bool value ) 70void AddresseeConfig::setAutomaticNameParsing( bool value )
69{ 71{
70 AddresseeConfig::config()->writeEntry( "AutomaticNameParsing", value ); 72 AddresseeConfig::config()->writeEntry( "AutomaticNameParsing", value );
71} 73}
72 74
73 bool AddresseeConfig::automaticNameParsing() 75 bool AddresseeConfig::automaticNameParsing()
74{ 76{
75 77
76 return AddresseeConfig::config()->readBoolEntry( "AutomaticNameParsing", 78 return AddresseeConfig::config()->readBoolEntry( "AutomaticNameParsing",
77 KABPrefs::instance()->mAutomaticNameParsing ); 79 KABPrefs::instance()->mAutomaticNameParsing );
78} 80}
79 81
80void AddresseeConfig::setNoDefaultAddrTypes( const QValueList<int> &types ) 82void AddresseeConfig::setNoDefaultAddrTypes( const Q3ValueList<int> &types )
81{ 83{
82 AddresseeConfig::config()->writeEntry( "NoDefaultAddrTypes", types ); 84 AddresseeConfig::config()->writeEntry( "NoDefaultAddrTypes", types );
83 AddresseeConfig::config()->sync(); 85 AddresseeConfig::config()->sync();
84} 86}
85 87
86 QValueList<int> AddresseeConfig::noDefaultAddrTypes() const 88 Q3ValueList<int> AddresseeConfig::noDefaultAddrTypes() const
87{ 89{
88 return AddresseeConfig::config()->readIntListEntry( "NoDefaultAddrTypes" ); 90 return AddresseeConfig::config()->readIntListEntry( "NoDefaultAddrTypes" );
89} 91}
90 92
91void AddresseeConfig::remove( const QString & uid ) 93void AddresseeConfig::remove( const QString & uid )
92{ 94{
93 AddresseeConfig::config()->deleteGroup( uid ); 95 AddresseeConfig::config()->deleteGroup( uid );
94} 96}
diff --git a/kaddressbook/addresseeconfig.h b/kaddressbook/addresseeconfig.h
index 47fbdd6..f6bb3e9 100644
--- a/kaddressbook/addresseeconfig.h
+++ b/kaddressbook/addresseeconfig.h
@@ -1,55 +1,57 @@
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#ifndef ADDRESSEECONFIG_H 24#ifndef ADDRESSEECONFIG_H
25#define ADDRESSEECONFIG_H 25#define ADDRESSEECONFIG_H
26 26
27#include <kabc/addressee.h> 27#include <kabc/addressee.h>
28#include <kconfig.h> 28#include <kconfig.h>
29//Added by qt3to4:
30#include <Q3ValueList>
29 31
30using namespace KABC; 32using namespace KABC;
31 33
32class AddresseeConfig 34class AddresseeConfig
33{ 35{
34 public: 36 public:
35 AddresseeConfig(); 37 AddresseeConfig();
36 ~AddresseeConfig(); 38 ~AddresseeConfig();
37 static AddresseeConfig* instance(); 39 static AddresseeConfig* instance();
38 static KConfig* config(); 40 static KConfig* config();
39 41
40 Addressee addressee(); 42 Addressee addressee();
41 43
42 void setUid( const QString & uid ); 44 void setUid( const QString & uid );
43 void setAutomaticNameParsing( bool value ); 45 void setAutomaticNameParsing( bool value );
44 bool automaticNameParsing(); 46 bool automaticNameParsing();
45 47
46 void setNoDefaultAddrTypes( const QValueList<int> &types ); 48 void setNoDefaultAddrTypes( const Q3ValueList<int> &types );
47 QValueList<int> noDefaultAddrTypes() const; 49 Q3ValueList<int> noDefaultAddrTypes() const;
48 50
49 void remove( const QString & uid); 51 void remove( const QString & uid);
50 52
51 private: 53 private:
52 QString mUid; 54 QString mUid;
53}; 55};
54 56
55#endif 57#endif
diff --git a/kaddressbook/addresseeeditordialog.cpp b/kaddressbook/addresseeeditordialog.cpp
index b5a60f2..b925a07 100644
--- a/kaddressbook/addresseeeditordialog.cpp
+++ b/kaddressbook/addresseeeditordialog.cpp
@@ -1,123 +1,126 @@
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#include <qlayout.h> 24#include <qlayout.h>
25#include <qapplication.h> 25#include <qapplication.h>
26#include <QDesktopWidget>
27//Added by qt3to4:
28#include <Q3VBoxLayout>
26 29
27#include <kdebug.h> 30#include <kdebug.h>
28#include <klocale.h> 31#include <klocale.h>
29#include <kglobal.h> 32#include <kglobal.h>
30 33
31#include "addresseeeditorwidget.h" 34#include "addresseeeditorwidget.h"
32#include "kabcore.h" 35#include "kabcore.h"
33 36
34#include "addresseeeditordialog.h" 37#include "addresseeeditordialog.h"
35 38
36AddresseeEditorDialog::AddresseeEditorDialog( KABCore *core, QWidget *parent, 39AddresseeEditorDialog::AddresseeEditorDialog( KABCore *core, QWidget *parent,
37 const char *name ) 40 const char *name )
38 : KDialogBase( KDialogBase::Plain, i18n( "Edit Contact" ), 41 : KDialogBase( KDialogBase::Plain, i18n( "Edit Contact" ),
39 KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply, 42 KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply,
40 KDialogBase::Ok, parent, name, true ) 43 KDialogBase::Ok, parent, name, true )
41{ 44{
42 45
43 46
44 QWidget *page = plainPage(); 47 QWidget *page = plainPage();
45 48
46 QVBoxLayout *layout = new QVBoxLayout( page ); 49 Q3VBoxLayout *layout = new Q3VBoxLayout( page );
47 50
48 mEditorWidget = new AddresseeEditorWidget( core, false, page ); 51 mEditorWidget = new AddresseeEditorWidget( core, false, page );
49 connect( mEditorWidget, SIGNAL( modified( const KABC::Addressee::List& ) ), 52 connect( mEditorWidget, SIGNAL( modified( const KABC::Addressee::List& ) ),
50 SLOT( widgetModified() ) ); 53 SLOT( widgetModified() ) );
51 layout->addWidget( mEditorWidget ); 54 layout->addWidget( mEditorWidget );
52 55
53 enableButton( KDialogBase::Apply, false ); 56 enableButton( KDialogBase::Apply, false );
54 if ( QApplication::desktop()->width() < 480 ) { 57 if ( QApplication::desktop()->width() < 480 ) {
55 hideButtons(); 58 hideButtons();
56 } 59 }
57} 60}
58 61
59AddresseeEditorDialog::~AddresseeEditorDialog() 62AddresseeEditorDialog::~AddresseeEditorDialog()
60{ 63{
61 //emit editorDestroyed( mEditorWidget->addressee().uid() ); 64 //emit editorDestroyed( mEditorWidget->addressee().uid() );
62} 65}
63 66
64void AddresseeEditorDialog::setAddressee( const KABC::Addressee &addr ) 67void AddresseeEditorDialog::setAddressee( const KABC::Addressee &addr )
65{ 68{
66 enableButton( KDialogBase::Apply, false ); 69 enableButton( KDialogBase::Apply, false );
67 70
68 mEditorWidget->setAddressee( addr ); 71 mEditorWidget->setAddressee( addr );
69 72
70 this->setCaption(i18n ("Edit ") + addr.formattedName()); 73 this->setCaption(i18n ("Edit ") + addr.formattedName());
71} 74}
72 75
73KABC::Addressee AddresseeEditorDialog::addressee() 76KABC::Addressee AddresseeEditorDialog::addressee()
74{ 77{
75 return mEditorWidget->addressee(); 78 return mEditorWidget->addressee();
76} 79}
77 80
78bool AddresseeEditorDialog::dirty() 81bool AddresseeEditorDialog::dirty()
79{ 82{
80 return mEditorWidget->dirty(); 83 return mEditorWidget->dirty();
81} 84}
82 85
83void AddresseeEditorDialog::slotApply() 86void AddresseeEditorDialog::slotApply()
84{ 87{
85 if ( mEditorWidget->dirty() ) { 88 if ( mEditorWidget->dirty() ) {
86 mEditorWidget->save(); 89 mEditorWidget->save();
87 emit contactModified( mEditorWidget->addressee() ); 90 emit contactModified( mEditorWidget->addressee() );
88 } 91 }
89 92
90 enableButton( KDialogBase::Apply, false ); 93 enableButton( KDialogBase::Apply, false );
91 94
92 KDialogBase::slotApply(); 95 KDialogBase::slotApply();
93} 96}
94 97
95void AddresseeEditorDialog:: accept () 98void AddresseeEditorDialog:: accept ()
96{ 99{
97 slotOk(); 100 slotOk();
98 101
99} 102}
100void AddresseeEditorDialog::slotOk() 103void AddresseeEditorDialog::slotOk()
101{ 104{
102 slotApply(); 105 slotApply();
103 106
104 //KDialogBase::slotOk(); 107 //KDialogBase::slotOk();
105 emit okClicked(); 108 emit okClicked();
106 QDialog::accept(); 109 QDialog::accept();
107} 110}
108 111
109void AddresseeEditorDialog::widgetModified() 112void AddresseeEditorDialog::widgetModified()
110{ 113{
111 enableButton( KDialogBase::Apply, true ); 114 enableButton( KDialogBase::Apply, true );
112} 115}
113 116
114void AddresseeEditorDialog::slotCancel() 117void AddresseeEditorDialog::slotCancel()
115{ 118{
116 KDialogBase::slotCancel(); 119 KDialogBase::slotCancel();
117 120
118 121
119} 122}
120 123
121#ifndef KAB_EMBEDDED 124#ifndef KAB_EMBEDDED_
122#include "addresseeeditordialog.moc" 125#include "moc_addresseeeditordialog.cpp"
123#endif //KAB_EMBEDDED 126#endif //KAB_EMBEDDED
diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp
index 4313998..a95db03 100644
--- a/kaddressbook/addresseeeditorwidget.cpp
+++ b/kaddressbook/addresseeeditorwidget.cpp
@@ -1,1435 +1,1439 @@
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#include <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qhbox.h> 25#include <q3hbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qlistbox.h> 28#include <q3listbox.h>
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30#include <qtabwidget.h> 30#include <qtabwidget.h>
31#include <qapplication.h> 31#include <qapplication.h>
32 32
33#ifndef KAB_EMBEDDED 33#ifndef KAB_EMBEDDED
34#include <qtextedit.h> 34#include <q3textedit.h>
35//Added by qt3to4:
36#include <Q3GridLayout>
37#include <Q3PopupMenu>
38#include <Q3VBoxLayout>
35 39
36#include <kaccelmanager.h> 40#include <kaccelmanager.h>
37#include "keywidget.h" 41#include "keywidget.h"
38#include "soundwidget.h" 42#include "soundwidget.h"
39 43
40#else //KAB_EMBEDDED 44#else //KAB_EMBEDDED
41#include <qmultilineedit.h> 45#include <q3multilineedit.h>
42#endif //KAB_EMBEDDED 46#endif //KAB_EMBEDDED
43 47
44 48
45#include "keywidget.h" 49#include "keywidget.h"
46#include "geowidget.h" 50#include "geowidget.h"
47#include "imagewidget.h" 51#include "imagewidget.h"
48#include "nameeditdialog.h" 52#include "nameeditdialog.h"
49#include "phoneeditwidget.h" 53#include "phoneeditwidget.h"
50#include "secrecywidget.h" 54#include "secrecywidget.h"
51 55
52 56
53#include <qtoolbutton.h> 57#include <qtoolbutton.h>
54#include <qtooltip.h> 58#include <qtooltip.h>
55 59
56#include <kapplication.h> 60#include <kapplication.h>
57#include <kconfig.h> 61#include <kconfig.h>
58#include <kcombobox.h> 62#include <kcombobox.h>
59#include <kdebug.h> 63#include <kdebug.h>
60#include <kdialogbase.h> 64#include <kdialogbase.h>
61#include <kglobal.h> 65#include <kglobal.h>
62#include <kiconloader.h> 66#include <kiconloader.h>
63#include <klineedit.h> 67#include <klineedit.h>
64#include <klocale.h> 68#include <klocale.h>
65#include <kmessagebox.h> 69#include <kmessagebox.h>
66#include <kseparator.h> 70#include <kseparator.h>
67#include <ksqueezedtextlabel.h> 71#include <ksqueezedtextlabel.h>
68 72
69#include <libkdepim/categoryeditdialog.h> 73#include <libkdepim/categoryeditdialog.h>
70#include <libkdepim/categoryselectdialog.h> 74#include <libkdepim/categoryselectdialog.h>
71 75
72#include <libkdepim/kdateedit.h> 76#include <libkdepim/kdateedit.h>
73 77
74#include "addresseditwidget.h" 78#include "addresseditwidget.h"
75#include "emaileditwidget.h" 79#include "emaileditwidget.h"
76#include "kabcore.h" 80#include "kabcore.h"
77#include "kabprefs.h" 81#include "kabprefs.h"
78 82
79#include "addresseeeditorwidget.h" 83#include "addresseeeditorwidget.h"
80 84
81 85
82 86
83AddresseeEditorWidget::AddresseeEditorWidget( KABCore *core, bool isExtension, 87AddresseeEditorWidget::AddresseeEditorWidget( KABCore *core, bool isExtension,
84 QWidget *parent, const char *name ) 88 QWidget *parent, const char *name )
85 : ExtensionWidget( core, parent, name ), mIsExtension( isExtension ), 89 : ExtensionWidget( core, parent, name ), mIsExtension( isExtension ),
86 mBlockSignals( false ) 90 mBlockSignals( false )
87{ 91{
88 92
89 mAConfig = AddresseeConfig::instance(); 93 mAConfig = AddresseeConfig::instance();
90 94
91 mFormattedNameType = NameEditDialog::CustomName; 95 mFormattedNameType = NameEditDialog::CustomName;
92 initGUI(); 96 initGUI();
93 mCategoryDialog = 0; 97 mCategoryDialog = 0;
94 mCategoryEditDialog = 0; 98 mCategoryEditDialog = 0;
95 99
96 // Load the empty addressee as defaults 100 // Load the empty addressee as defaults
97 load(); 101 load();
98 102
99 mDirty = false; 103 mDirty = false;
100} 104}
101 105
102AddresseeEditorWidget::~AddresseeEditorWidget() 106AddresseeEditorWidget::~AddresseeEditorWidget()
103{ 107{
104 kdDebug(5720) << "~AddresseeEditorWidget()" << endl; 108 kdDebug(5720) << "~AddresseeEditorWidget()" << endl;
105} 109}
106 110
107void AddresseeEditorWidget::contactsSelectionChanged() 111void AddresseeEditorWidget::contactsSelectionChanged()
108{ 112{
109 KABC::Addressee::List list = selectedContacts(); 113 KABC::Addressee::List list = selectedContacts();
110 114
111 mAddressee = list[ 0 ]; 115 mAddressee = list[ 0 ];
112 load(); 116 load();
113} 117}
114 118
115void AddresseeEditorWidget::setAddressee( const KABC::Addressee &addr ) 119void AddresseeEditorWidget::setAddressee( const KABC::Addressee &addr )
116{ 120{
117 mAddressee = addr; 121 mAddressee = addr;
118 load(); 122 load();
119} 123}
120 124
121const KABC::Addressee &AddresseeEditorWidget::addressee() 125const KABC::Addressee &AddresseeEditorWidget::addressee()
122{ 126{
123 return mAddressee; 127 return mAddressee;
124} 128}
125 129
126void AddresseeEditorWidget::textChanged( const QString& ) 130void AddresseeEditorWidget::textChanged( const QString& )
127{ 131{
128 emitModified(); 132 emitModified();
129} 133}
130 134
131void AddresseeEditorWidget::initGUI() 135void AddresseeEditorWidget::initGUI()
132{ 136{
133 QVBoxLayout *layout = new QVBoxLayout( this ); 137 Q3VBoxLayout *layout = new Q3VBoxLayout( this );
134 138
135 mTabWidget = new QTabWidget( this ); 139 mTabWidget = new QTabWidget( this );
136 layout->addWidget( mTabWidget ); 140 layout->addWidget( mTabWidget );
137 141
138 setupTab1(); 142 setupTab1();
139 setupTab1_1(); 143 setupTab1_1();
140 setupTab2(); 144 setupTab2();
141 setupTab2_1(); 145 setupTab2_1();
142 setupTab3(); 146 setupTab3();
143 setupTab3_1(); 147 setupTab3_1();
144 148
145 mNameEdit->setFocus(); 149 mNameEdit->setFocus();
146 150
147 connect( mTabWidget, SIGNAL( currentChanged(QWidget*) ), 151 connect( mTabWidget, SIGNAL( currentChanged(QWidget*) ),
148 SLOT( pageChanged(QWidget*) ) ); 152 SLOT( pageChanged(QWidget*) ) );
149} 153}
150 154
151void AddresseeEditorWidget::setupTab1() 155void AddresseeEditorWidget::setupTab1()
152{ 156{
153 // This is the General tab 157 // This is the General tab
154 QWidget *tab1 = new QWidget( mTabWidget ); 158 QWidget *tab1 = new QWidget( mTabWidget );
155 159
156//US QGridLayout *layout = new QGridLayout( tab1, 11, 7 ); 160//US QGridLayout *layout = new QGridLayout( tab1, 11, 7 );
157 bool horLayout = false; 161 bool horLayout = false;
158 int maxCol = 1; 162 int maxCol = 1;
159 if ( QApplication::desktop()->width() == 640 || QApplication::desktop()->width() == 320 ) { 163 if ( QApplication::desktop()->width() == 640 || QApplication::desktop()->width() == 320 ) {
160 horLayout = true; 164 horLayout = true;
161 maxCol = 3; 165 maxCol = 3;
162 } 166 }
163 QGridLayout *layout = new QGridLayout( tab1, 7-maxCol, maxCol ); 167 Q3GridLayout *layout = new Q3GridLayout( tab1, 7-maxCol, maxCol );
164 168
165 layout->setMargin( KDialogBase::marginHintSmall() ); 169 layout->setMargin( KDialogBase::marginHintSmall() );
166 layout->setSpacing( KDialogBase::spacingHintSmall() ); 170 layout->setSpacing( KDialogBase::spacingHintSmall() );
167 171
168 QLabel *label; 172 QLabel *label;
169 KSeparator* bar; 173 KSeparator* bar;
170 QPushButton *button; 174 QPushButton *button;
171 175
172 ////////////////////////////////// 176 //////////////////////////////////
173 // Upper left group (person info) 177 // Upper left group (person info)
174 178
175 // Person icon 179 // Person icon
176 /* LR 180 /* LR
177 label = new QLabel( tab1 ); 181 label = new QLabel( tab1 );
178//US ambiguous call. Add one more parameter 182//US ambiguous call. Add one more parameter
179//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); 183//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) );
180 label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); 184 label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) );
181 layout->addMultiCellWidget( label, 0, 1, 0, 0 ); 185 layout->addMultiCellWidget( label, 0, 1, 0, 0 );
182 */ 186 */
183 // First name 187 // First name
184 button = new QPushButton( i18n( "Name..." ), tab1 ); 188 button = new QPushButton( i18n( "Name..." ), tab1 );
185//US QToolTip::add( button, i18n( "Edit the contact's name" ) ); 189//US QToolTip::add( button, i18n( "Edit the contact's name" ) );
186 mNameEdit = new KLineEdit( tab1, "mNameEdit" ); 190 mNameEdit = new KLineEdit( tab1, "mNameEdit" );
187 connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), 191 connect( mNameEdit, SIGNAL( textChanged( const QString& ) ),
188 SLOT( nameTextChanged( const QString& ) ) ); 192 SLOT( nameTextChanged( const QString& ) ) );
189 connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) ); 193 connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) );
190 194
191 mNameLabel = new KSqueezedTextLabel( tab1 ); 195 mNameLabel = new KSqueezedTextLabel( tab1 );
192 mNameLabel->hide(); 196 mNameLabel->hide();
193 197
194 layout->addWidget( button, 0, 0 ); 198 layout->addWidget( button, 0, 0 );
195 layout->addWidget( mNameEdit, 0, 1 ); 199 layout->addWidget( mNameEdit, 0, 1 );
196 layout->addWidget( mNameLabel, 0, 1 ); 200 layout->addWidget( mNameLabel, 0, 1 );
197 201
198 button = new QPushButton( i18n( "Role:" ), tab1 ); 202 button = new QPushButton( i18n( "Role:" ), tab1 );
199 connect( button, SIGNAL( clicked() ), SLOT( setRole2FN() ) ); 203 connect( button, SIGNAL( clicked() ), SLOT( setRole2FN() ) );
200 //label = new QLabel( i18n( "Role:" ), tab1 ); 204 //label = new QLabel( i18n( "Role:" ), tab1 );
201 mRoleEdit = new KLineEdit( tab1 ); 205 mRoleEdit = new KLineEdit( tab1 );
202 connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ), 206 connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ),
203 SLOT( textChanged( const QString& ) ) ); 207 SLOT( textChanged( const QString& ) ) );
204 //label->setBuddy( mRoleEdit ); 208 //label->setBuddy( mRoleEdit );
205 if ( horLayout ) { 209 if ( horLayout ) {
206 layout->addWidget( button, 0, 2 ); 210 layout->addWidget( button, 0, 2 );
207 layout->addWidget( mRoleEdit, 0, 3 ); 211 layout->addWidget( mRoleEdit, 0, 3 );
208 212
209 } else { 213 } else {
210 layout->addWidget( button, 1, 0 ); 214 layout->addWidget( button, 1, 0 );
211 layout->addWidget( mRoleEdit, 1, 1 ); 215 layout->addWidget( mRoleEdit, 1, 1 );
212 } 216 }
213 // Organization 217 // Organization
214 button = new QPushButton( i18n( "Organization:" ), tab1 ); 218 button = new QPushButton( i18n( "Organization:" ), tab1 );
215 connect( button, SIGNAL( clicked() ), SLOT( setCompany2FN() ) ); 219 connect( button, SIGNAL( clicked() ), SLOT( setCompany2FN() ) );
216 //label = new QLabel( i18n( "Organization:" ), tab1 ); 220 //label = new QLabel( i18n( "Organization:" ), tab1 );
217 mOrgEdit = new KLineEdit( tab1 ); 221 mOrgEdit = new KLineEdit( tab1 );
218 //label->setBuddy( mOrgEdit ); 222 //label->setBuddy( mOrgEdit );
219 connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ), 223 connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ),
220 SLOT( textChanged( const QString& ) ) ); 224 SLOT( textChanged( const QString& ) ) );
221 if ( horLayout ) { 225 if ( horLayout ) {
222 layout->addWidget( button, 1, 2 ); 226 layout->addWidget( button, 1, 2 );
223 layout->addWidget( mOrgEdit, 1, 3 ); 227 layout->addWidget( mOrgEdit, 1, 3 );
224 228
225 } else { 229 } else {
226 layout->addWidget( button, 2, 0 ); 230 layout->addWidget( button, 2, 0 );
227 layout->addWidget( mOrgEdit, 2, 1 ); 231 layout->addWidget( mOrgEdit, 2, 1 );
228 } 232 }
229 233
230 // File as (formatted name) 234 // File as (formatted name)
231 label = new QLabel( i18n( "Format.n.:" ), tab1 ); 235 label = new QLabel( i18n( "Format.n.:" ), tab1 );
232 mFormattedNameLabel = new KSqueezedTextLabel( tab1 ); 236 mFormattedNameLabel = new KSqueezedTextLabel( tab1 );
233 if ( horLayout ) { 237 if ( horLayout ) {
234 layout->addWidget( label, 1,0 ); 238 layout->addWidget( label, 1,0 );
235 layout->addWidget( mFormattedNameLabel, 1, 1 ); 239 layout->addWidget( mFormattedNameLabel, 1, 1 );
236 } else { 240 } else {
237 layout->addWidget( label, 3, 0 ); 241 layout->addWidget( label, 3, 0 );
238 layout->addWidget( mFormattedNameLabel, 3, 1 ); 242 layout->addWidget( mFormattedNameLabel, 3, 1 );
239 } 243 }
240 /* LR 244 /* LR
241 // Left hand separator. This separator doesn't go all the way 245 // Left hand separator. This separator doesn't go all the way
242 // across so the dialog still flows from top to bottom 246 // across so the dialog still flows from top to bottom
243 bar = new KSeparator( KSeparator::HLine, tab1 ); 247 bar = new KSeparator( KSeparator::HLine, tab1 );
244 layout->addMultiCellWidget( bar, 4, 4, 0, 2 ); 248 layout->addMultiCellWidget( bar, 4, 4, 0, 2 );
245 */ 249 */
246 ////////////////////////////////////// 250 //////////////////////////////////////
247 251
248 /* LR 252 /* LR
249 // Phone numbers (upper right) 253 // Phone numbers (upper right)
250 label = new QLabel( tab1 ); 254 label = new QLabel( tab1 );
251//US loadIcon call is ambiguous. Add one more parameter 255//US loadIcon call is ambiguous. Add one more parameter
252//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); 256//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) );
253 label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); 257 label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) );
254//US layout->addMultiCellWidget( label, 0, 1, 3, 3 ); 258//US layout->addMultiCellWidget( label, 0, 1, 3, 3 );
255 layout->addMultiCellWidget( label, 5, 6, 0, 0 ); 259 layout->addMultiCellWidget( label, 5, 6, 0, 0 );
256 */ 260 */
257 mPhoneEditWidget = new PhoneEditWidget( tab1 ); 261 mPhoneEditWidget = new PhoneEditWidget( tab1 );
258 connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); 262 connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
259//US layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 ); 263//US layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 );
260 int iii; 264 int iii;
261#ifndef DESKTOP_VERSION 265#ifndef DESKTOP_VERSION
262 iii = 7; 266 iii = 7;
263#else 267#else
264 iii = 8; 268 iii = 8;
265#endif 269#endif
266 layout->addMultiCellWidget( mPhoneEditWidget, 5-maxCol, 5-maxCol+4, 0, maxCol ); 270 layout->addMultiCellWidget( mPhoneEditWidget, 5-maxCol, 5-maxCol+4, 0, maxCol );
267 iii = 6-maxCol+4; 271 iii = 6-maxCol+4;
268 /* LR 272 /* LR
269 bar = new KSeparator( KSeparator::HLine, tab1 ); 273 bar = new KSeparator( KSeparator::HLine, tab1 );
270//US layout->addMultiCellWidget( bar, 4, 4, 3, 6 ); 274//US layout->addMultiCellWidget( bar, 4, 4, 3, 6 );
271 layout->addMultiCellWidget( bar, 9, 9, 0, 2 ); 275 layout->addMultiCellWidget( bar, 9, 9, 0, 2 );
272 */ 276 */
273/*US 277/*US
274 ////////////////////////////////////// 278 //////////////////////////////////////
275 // Addresses (lower left) 279 // Addresses (lower left)
276 label = new QLabel( tab1 ); 280 label = new QLabel( tab1 );
277//US loadIcon call is ambiguous. Add one more parameter 281//US loadIcon call is ambiguous. Add one more parameter
278//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop ) ); 282//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop ) );
279 label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) ); 283 label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) );
280 layout->addMultiCellWidget( label, 5, 6, 0, 0 ); 284 layout->addMultiCellWidget( label, 5, 6, 0, 0 );
281 285
282 mAddressEditWidget = new AddressEditWidget( tab1 ); 286 mAddressEditWidget = new AddressEditWidget( tab1 );
283 connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); 287 connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
284 layout->addMultiCellWidget( mAddressEditWidget, 5, 9, 1, 2 ); 288 layout->addMultiCellWidget( mAddressEditWidget, 5, 9, 1, 2 );
285 289
286 ////////////////////////////////////// 290 //////////////////////////////////////
287 // Email / Web (lower right) 291 // Email / Web (lower right)
288 label = new QLabel( tab1 ); 292 label = new QLabel( tab1 );
289//US loadIcon call is ambiguous. Add one more parameter 293//US loadIcon call is ambiguous. Add one more parameter
290//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop) ); 294//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop) );
291 label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop, 0) ); 295 label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop, 0) );
292 layout->addMultiCellWidget( label, 5, 6, 3, 3 ); 296 layout->addMultiCellWidget( label, 5, 6, 3, 3 );
293 297
294 mEmailWidget = new EmailEditWidget( tab1 ); 298 mEmailWidget = new EmailEditWidget( tab1 );
295 connect( mEmailWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); 299 connect( mEmailWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
296 layout->addMultiCellWidget( mEmailWidget, 5, 6, 4, 6 ); 300 layout->addMultiCellWidget( mEmailWidget, 5, 6, 4, 6 );
297 301
298 // add the separator 302 // add the separator
299 bar = new KSeparator( KSeparator::HLine, tab1 ); 303 bar = new KSeparator( KSeparator::HLine, tab1 );
300 layout->addMultiCellWidget( bar, 7, 7, 3, 6 ); 304 layout->addMultiCellWidget( bar, 7, 7, 3, 6 );
301 305
302 label = new QLabel( tab1 ); 306 label = new QLabel( tab1 );
303//US loadIcon call is ambiguous. Add one more parameter 307//US loadIcon call is ambiguous. Add one more parameter
304//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop) ); 308//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop) );
305 label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop, 0) ); 309 label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop, 0) );
306 layout->addMultiCellWidget( label, 8, 9, 3, 3 ); 310 layout->addMultiCellWidget( label, 8, 9, 3, 3 );
307 311
308 label = new QLabel( i18n( "URL:" ), tab1 ); 312 label = new QLabel( i18n( "URL:" ), tab1 );
309 mURLEdit = new KLineEdit( tab1 ); 313 mURLEdit = new KLineEdit( tab1 );
310 connect( mURLEdit, SIGNAL( textChanged( const QString& ) ), 314 connect( mURLEdit, SIGNAL( textChanged( const QString& ) ),
311 SLOT( textChanged( const QString& ) ) ); 315 SLOT( textChanged( const QString& ) ) );
312 label->setBuddy( mURLEdit ); 316 label->setBuddy( mURLEdit );
313 layout->addWidget( label, 8, 4 ); 317 layout->addWidget( label, 8, 4 );
314 layout->addMultiCellWidget( mURLEdit, 8, 8, 5, 6 ); 318 layout->addMultiCellWidget( mURLEdit, 8, 8, 5, 6 );
315 319
316 label = new QLabel( i18n( "&IM address:" ), tab1 ); 320 label = new QLabel( i18n( "&IM address:" ), tab1 );
317 mIMAddressEdit = new KLineEdit( tab1 ); 321 mIMAddressEdit = new KLineEdit( tab1 );
318 connect( mIMAddressEdit, SIGNAL( textChanged( const QString& ) ), 322 connect( mIMAddressEdit, SIGNAL( textChanged( const QString& ) ),
319 SLOT( textChanged( const QString& ) ) ); 323 SLOT( textChanged( const QString& ) ) );
320 label->setBuddy( mIMAddressEdit ); 324 label->setBuddy( mIMAddressEdit );
321 layout->addWidget( label, 9, 4 ); 325 layout->addWidget( label, 9, 4 );
322 layout->addMultiCellWidget( mIMAddressEdit, 9, 9, 5, 6 ); 326 layout->addMultiCellWidget( mIMAddressEdit, 9, 9, 5, 6 );
323 327
324 layout->addColSpacing( 6, 50 ); 328 layout->addColSpacing( 6, 50 );
325 329
326 bar = new KSeparator( KSeparator::HLine, tab1 ); 330 bar = new KSeparator( KSeparator::HLine, tab1 );
327 layout->addMultiCellWidget( bar, 10, 10, 0, 6 ); 331 layout->addMultiCellWidget( bar, 10, 10, 0, 6 );
328*/ 332*/
329 /////////////////////////////////////// 333 ///////////////////////////////////////
330 QHBox *categoryBox = new QHBox( tab1 ,"cato"); 334 Q3HBox *categoryBox = new Q3HBox( tab1 ,"cato");
331 categoryBox->setSpacing( KDialogBase::spacingHint() ); 335 categoryBox->setSpacing( KDialogBase::spacingHint() );
332 categoryBox->setMargin( KDialogBase::marginHintSmall() ); 336 categoryBox->setMargin( KDialogBase::marginHintSmall() );
333 337
334 // Categories 338 // Categories
335 button = new QPushButton( i18n( "Categories" )+":", categoryBox ); 339 button = new QPushButton( i18n( "Categories" )+":", categoryBox );
336 connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) ); 340 connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) );
337 341
338 mCategoryEdit = new QPushButton ( categoryBox ); 342 mCategoryEdit = new QPushButton ( categoryBox );
339 mCategoryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); 343 mCategoryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) );
340 mCatPopup = new QPopupMenu ( categoryBox ); 344 mCatPopup = new Q3PopupMenu ( categoryBox );
341 mCategoryEdit->setPopup( mCatPopup ); 345 mCategoryEdit->setPopup( mCatPopup );
342 connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup())); 346 connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup()));
343 connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int ))); 347 connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int )));
344 //connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ), 348 //connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ),
345 // SLOT( textChanged( const QString& ) ) ); 349 // SLOT( textChanged( const QString& ) ) );
346 350
347 mSecrecyWidget = new SecrecyWidget( categoryBox ); 351 mSecrecyWidget = new SecrecyWidget( categoryBox );
348 connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 352 connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
349 353
350//US layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 ); 354//US layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 );
351 layout->addMultiCellWidget( categoryBox, iii, iii, 0, maxCol ); 355 layout->addMultiCellWidget( categoryBox, iii, iii, 0, maxCol );
352 356
353 // Build the layout and add to the tab widget 357 // Build the layout and add to the tab widget
354 layout->activate(); // required 358 layout->activate(); // required
355 359
356 mTabWidget->addTab( tab1, i18n( "&General" ) ); 360 mTabWidget->addTab( tab1, i18n( "&General" ) );
357} 361}
358 362
359void AddresseeEditorWidget::showCatPopup() 363void AddresseeEditorWidget::showCatPopup()
360{ 364{
361 mCatPopup->clear(); 365 mCatPopup->clear();
362 QStringList checkedCategories = QStringList::split (",", mCategoryEdit->text()); 366 QStringList checkedCategories = QStringList::split (",", mCategoryEdit->text());
363 int index = 0; 367 int index = 0;
364 for (QStringList::Iterator it = KABPrefs::instance()->mCustomCategories.begin (); 368 for (QStringList::Iterator it = KABPrefs::instance()->mCustomCategories.begin ();
365 it != KABPrefs::instance()->mCustomCategories.end (); 369 it != KABPrefs::instance()->mCustomCategories.end ();
366 ++it) { 370 ++it) {
367 mCatPopup->insertItem (*it, index ); 371 mCatPopup->insertItem (*it, index );
368 //mCategory[index] = *it; 372 //mCategory[index] = *it;
369 if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true); 373 if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true);
370 ++index; 374 ++index;
371 } 375 }
372} 376}
373void AddresseeEditorWidget::selectedCatPopup( int index ) 377void AddresseeEditorWidget::selectedCatPopup( int index )
374{ 378{
375 QStringList categories = QStringList::split (",", mCategoryEdit->text()); 379 QStringList categories = QStringList::split (",", mCategoryEdit->text());
376 QString colcat = categories.first(); 380 QString colcat = categories.first();
377 if (categories.find ( KABPrefs::instance()->mCustomCategories[index]) != categories.end ()) 381 if (categories.find ( KABPrefs::instance()->mCustomCategories[index]) != categories.end ())
378 categories.remove (KABPrefs::instance()->mCustomCategories[index]); 382 categories.remove (KABPrefs::instance()->mCustomCategories[index]);
379 else 383 else
380 categories.insert (categories.end(), KABPrefs::instance()->mCustomCategories[index]); 384 categories.insert (categories.end(), KABPrefs::instance()->mCustomCategories[index]);
381 categories.sort (); 385 categories.sort ();
382 if ( !colcat.isEmpty() ) { 386 if ( !colcat.isEmpty() ) {
383 if ( categories.find ( colcat ) != categories.end () ) { 387 if ( categories.find ( colcat ) != categories.end () ) {
384 categories.remove( colcat ); 388 categories.remove( colcat );
385 categories.prepend( colcat ); 389 categories.prepend( colcat );
386 } 390 }
387 } 391 }
388 mCategoryEdit->setText( categories.join(",") ); 392 mCategoryEdit->setText( categories.join(",") );
389 emitModified(); 393 emitModified();
390} 394}
391void AddresseeEditorWidget::setRole2FN() 395void AddresseeEditorWidget::setRole2FN()
392{ 396{
393 if ( mRoleEdit->text().isEmpty() ) return; 397 if ( mRoleEdit->text().isEmpty() ) return;
394 mFormattedNameType = NameEditDialog::CustomName; 398 mFormattedNameType = NameEditDialog::CustomName;
395 mAddressee.setFormattedName( mRoleEdit->text() ); 399 mAddressee.setFormattedName( mRoleEdit->text() );
396 mFormattedNameLabel->setText( mRoleEdit->text() ); 400 mFormattedNameLabel->setText( mRoleEdit->text() );
397 emitModified(); 401 emitModified();
398} 402}
399void AddresseeEditorWidget::setCompany2FN() 403void AddresseeEditorWidget::setCompany2FN()
400{ 404{
401 if ( mOrgEdit->text().isEmpty() ) return; 405 if ( mOrgEdit->text().isEmpty() ) return;
402 mFormattedNameType = NameEditDialog::CustomName; 406 mFormattedNameType = NameEditDialog::CustomName;
403 mAddressee.setFormattedName( mOrgEdit->text() ); 407 mAddressee.setFormattedName( mOrgEdit->text() );
404 mFormattedNameLabel->setText( mOrgEdit->text() ); 408 mFormattedNameLabel->setText( mOrgEdit->text() );
405 emitModified(); 409 emitModified();
406} 410}
407 411
408void AddresseeEditorWidget::setupTab1_1() 412void AddresseeEditorWidget::setupTab1_1()
409{ 413{
410 // This is the Address tab 414 // This is the Address tab
411 QWidget *tab1_1 = new QWidget( mTabWidget ); 415 QWidget *tab1_1 = new QWidget( mTabWidget );
412 416
413//US QGridLayout *layout = new QGridLayout( tab1_1, 11, 7 ); 417//US QGridLayout *layout = new QGridLayout( tab1_1, 11, 7 );
414 QGridLayout *layout = new QGridLayout( tab1_1, 7, 2 ); 418 Q3GridLayout *layout = new Q3GridLayout( tab1_1, 7, 2 );
415 layout->setMargin( KDialogBase::marginHintSmall() ); 419 layout->setMargin( KDialogBase::marginHintSmall() );
416 layout->setSpacing( KDialogBase::spacingHintSmall() ); 420 layout->setSpacing( KDialogBase::spacingHintSmall() );
417 421
418 QLabel *label; 422 QLabel *label;
419 KSeparator* bar; 423 KSeparator* bar;
420 QPushButton *button; 424 QPushButton *button;
421 425
422/*US 426/*US
423 ////////////////////////////////// 427 //////////////////////////////////
424 // Upper left group (person info) 428 // Upper left group (person info)
425 429
426 // Person icon 430 // Person icon
427 label = new QLabel( tab1 ); 431 label = new QLabel( tab1 );
428//US ambiguous call. Add one more parameter 432//US ambiguous call. Add one more parameter
429//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); 433//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) );
430 label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); 434 label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) );
431 layout->addMultiCellWidget( label, 0, 1, 0, 0 ); 435 layout->addMultiCellWidget( label, 0, 1, 0, 0 );
432 436
433 // First name 437 // First name
434 button = new QPushButton( i18n( "Name..." ), tab1 ); 438 button = new QPushButton( i18n( "Name..." ), tab1 );
435 QToolTip::add( button, i18n( "Edit the contact's name" ) ); 439 QToolTip::add( button, i18n( "Edit the contact's name" ) );
436 mNameEdit = new KLineEdit( tab1, "mNameEdit" ); 440 mNameEdit = new KLineEdit( tab1, "mNameEdit" );
437 connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), 441 connect( mNameEdit, SIGNAL( textChanged( const QString& ) ),
438 SLOT( nameTextChanged( const QString& ) ) ); 442 SLOT( nameTextChanged( const QString& ) ) );
439 connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) ); 443 connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) );
440 444
441#ifndef KAB_EMBEDDED 445#ifndef KAB_EMBEDDED
442 mNameLabel = new KSqueezedTextLabel( tab1 ); 446 mNameLabel = new KSqueezedTextLabel( tab1 );
443 mNameLabel->hide(); 447 mNameLabel->hide();
444#else //KAB_EMBEDDED 448#else //KAB_EMBEDDED
445qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); 449qDebug("AddresseeEditorWidget::setupTab1 has to be changed");
446#endif //KAB_EMBEDDED 450#endif //KAB_EMBEDDED
447 451
448 layout->addWidget( button, 0, 1 ); 452 layout->addWidget( button, 0, 1 );
449 layout->addWidget( mNameEdit, 0, 2 ); 453 layout->addWidget( mNameEdit, 0, 2 );
450 454
451#ifndef KAB_EMBEDDED 455#ifndef KAB_EMBEDDED
452 layout->addWidget( mNameLabel, 0, 2 ); 456 layout->addWidget( mNameLabel, 0, 2 );
453#else //KAB_EMBEDDED 457#else //KAB_EMBEDDED
454qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); 458qDebug("AddresseeEditorWidget::setupTab1 has to be changed");
455#endif //KAB_EMBEDDED 459#endif //KAB_EMBEDDED
456 460
457 label = new QLabel( i18n( "Role:" ), tab1 ); 461 label = new QLabel( i18n( "Role:" ), tab1 );
458 mRoleEdit = new KLineEdit( tab1 ); 462 mRoleEdit = new KLineEdit( tab1 );
459 connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ), 463 connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ),
460 SLOT( textChanged( const QString& ) ) ); 464 SLOT( textChanged( const QString& ) ) );
461 label->setBuddy( mRoleEdit ); 465 label->setBuddy( mRoleEdit );
462 layout->addWidget( label, 1, 1 ); 466 layout->addWidget( label, 1, 1 );
463 layout->addWidget( mRoleEdit, 1, 2 ); 467 layout->addWidget( mRoleEdit, 1, 2 );
464 468
465 // Organization 469 // Organization
466 label = new QLabel( i18n( "Organization:" ), tab1 ); 470 label = new QLabel( i18n( "Organization:" ), tab1 );
467 mOrgEdit = new KLineEdit( tab1 ); 471 mOrgEdit = new KLineEdit( tab1 );
468 label->setBuddy( mOrgEdit ); 472 label->setBuddy( mOrgEdit );
469 connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ), 473 connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ),
470 SLOT( textChanged( const QString& ) ) ); 474 SLOT( textChanged( const QString& ) ) );
471 layout->addWidget( label, 2, 1 ); 475 layout->addWidget( label, 2, 1 );
472 layout->addWidget( mOrgEdit, 2, 2 ); 476 layout->addWidget( mOrgEdit, 2, 2 );
473 477
474 // File as (formatted name) 478 // File as (formatted name)
475 label = new QLabel( i18n( "Formatted name:" ), tab1 ); 479 label = new QLabel( i18n( "Formatted name:" ), tab1 );
476#ifndef KAB_EMBEDDED 480#ifndef KAB_EMBEDDED
477 mFormattedNameLabel = new KSqueezedTextLabel( tab1 ); 481 mFormattedNameLabel = new KSqueezedTextLabel( tab1 );
478#else //KAB_EMBEDDED 482#else //KAB_EMBEDDED
479qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); 483qDebug("AddresseeEditorWidget::setupTab1 has to be changed");
480#endif //KAB_EMBEDDED 484#endif //KAB_EMBEDDED
481 layout->addWidget( label, 3, 1 ); 485 layout->addWidget( label, 3, 1 );
482#ifndef KAB_EMBEDDED 486#ifndef KAB_EMBEDDED
483 layout->addWidget( mFormattedNameLabel, 3, 2 ); 487 layout->addWidget( mFormattedNameLabel, 3, 2 );
484#else //KAB_EMBEDDED 488#else //KAB_EMBEDDED
485qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); 489qDebug("AddresseeEditorWidget::setupTab1 has to be changed");
486#endif //KAB_EMBEDDED 490#endif //KAB_EMBEDDED
487 491
488 // Left hand separator. This separator doesn't go all the way 492 // Left hand separator. This separator doesn't go all the way
489 // across so the dialog still flows from top to bottom 493 // across so the dialog still flows from top to bottom
490 bar = new KSeparator( KSeparator::HLine, tab1 ); 494 bar = new KSeparator( KSeparator::HLine, tab1 );
491 layout->addMultiCellWidget( bar, 4, 4, 0, 2 ); 495 layout->addMultiCellWidget( bar, 4, 4, 0, 2 );
492 496
493 ////////////////////////////////////// 497 //////////////////////////////////////
494 // Phone numbers (upper right) 498 // Phone numbers (upper right)
495 label = new QLabel( tab1 ); 499 label = new QLabel( tab1 );
496//US loadIcon call is ambiguous. Add one more parameter 500//US loadIcon call is ambiguous. Add one more parameter
497//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); 501//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) );
498 label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); 502 label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) );
499 layout->addMultiCellWidget( label, 0, 1, 3, 3 ); 503 layout->addMultiCellWidget( label, 0, 1, 3, 3 );
500 504
501 mPhoneEditWidget = new PhoneEditWidget( tab1 ); 505 mPhoneEditWidget = new PhoneEditWidget( tab1 );
502 connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); 506 connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
503 layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 ); 507 layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 );
504 508
505 bar = new KSeparator( KSeparator::HLine, tab1 ); 509 bar = new KSeparator( KSeparator::HLine, tab1 );
506 layout->addMultiCellWidget( bar, 4, 4, 3, 6 ); 510 layout->addMultiCellWidget( bar, 4, 4, 3, 6 );
507*/ 511*/
508 ////////////////////////////////////// 512 //////////////////////////////////////
509 // Addresses (lower left) 513 // Addresses (lower left)
510 /* LR 514 /* LR
511 label = new QLabel( tab1_1 ); 515 label = new QLabel( tab1_1 );
512//US loadIcon call is ambiguous. Add one more parameter 516//US loadIcon call is ambiguous. Add one more parameter
513//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop ) ); 517//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop ) );
514 label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) ); 518 label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) );
515//US layout->addMultiCellWidget( label, 5, 6, 0, 0 ); 519//US layout->addMultiCellWidget( label, 5, 6, 0, 0 );
516 layout->addMultiCellWidget( label, 0, 1, 0, 0 ); 520 layout->addMultiCellWidget( label, 0, 1, 0, 0 );
517 */ 521 */
518 522
519 mAddressEditWidget = new AddressEditWidget( tab1_1 ); 523 mAddressEditWidget = new AddressEditWidget( tab1_1 );
520 connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); 524 connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
521//US layout->addMultiCellWidget( mAddressEditWidget, 5, 9, 1, 2 ); 525//US layout->addMultiCellWidget( mAddressEditWidget, 5, 9, 1, 2 );
522 layout->addMultiCellWidget( mAddressEditWidget, 0, 4, 0, 1 ); 526 layout->addMultiCellWidget( mAddressEditWidget, 0, 4, 0, 1 );
523 527
524//US 528//US
525/* LR 529/* LR
526 bar = new KSeparator( KSeparator::HLine, tab1_1 ); 530 bar = new KSeparator( KSeparator::HLine, tab1_1 );
527 layout->addMultiCellWidget( bar, 5, 5, 0, 3 ); 531 layout->addMultiCellWidget( bar, 5, 5, 0, 3 );
528*/ 532*/
529 533
530 ////////////////////////////////////// 534 //////////////////////////////////////
531 // Email / Web (lower right) 535 // Email / Web (lower right)
532 /* LR 536 /* LR
533 label = new QLabel( tab1_1 ); 537 label = new QLabel( tab1_1 );
534//US loadIcon call is ambiguous. Add one more parameter 538//US loadIcon call is ambiguous. Add one more parameter
535//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop) ); 539//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop) );
536 label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop, 0) ); 540 label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop, 0) );
537//US layout->addMultiCellWidget( label, 5, 6, 3, 3 ); 541//US layout->addMultiCellWidget( label, 5, 6, 3, 3 );
538 layout->addMultiCellWidget( label, 6, 7, 0, 0 ); 542 layout->addMultiCellWidget( label, 6, 7, 0, 0 );
539 */ 543 */
540 mEmailWidget = new EmailEditWidget( tab1_1 ); 544 mEmailWidget = new EmailEditWidget( tab1_1 );
541 connect( mEmailWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); 545 connect( mEmailWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
542//US layout->addMultiCellWidget( mEmailWidget, 5, 6, 4, 6 ); 546//US layout->addMultiCellWidget( mEmailWidget, 5, 6, 4, 6 );
543 layout->addMultiCellWidget( mEmailWidget, 5, 6, 0, 1 ); 547 layout->addMultiCellWidget( mEmailWidget, 5, 6, 0, 1 );
544 548
545 /* LR 549 /* LR
546 // add the separator 550 // add the separator
547 bar = new KSeparator( KSeparator::HLine, tab1_1 ); 551 bar = new KSeparator( KSeparator::HLine, tab1_1 );
548//US layout->addMultiCellWidget( bar, 7, 7, 3, 6 ); 552//US layout->addMultiCellWidget( bar, 7, 7, 3, 6 );
549 layout->addMultiCellWidget( bar, 8, 8, 0, 3 ); 553 layout->addMultiCellWidget( bar, 8, 8, 0, 3 );
550 554
551 label = new QLabel( tab1_1 ); 555 label = new QLabel( tab1_1 );
552//US loadIcon call is ambiguous. Add one more parameter 556//US loadIcon call is ambiguous. Add one more parameter
553//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop) ); 557//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop) );
554 label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop, 0) ); 558 label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop, 0) );
555//US layout->addMultiCellWidget( label, 8, 9, 3, 3 ); 559//US layout->addMultiCellWidget( label, 8, 9, 3, 3 );
556 layout->addMultiCellWidget( label, 9, 10, 0, 0 ); 560 layout->addMultiCellWidget( label, 9, 10, 0, 0 );
557 */ 561 */
558 label = new QLabel( i18n( "URL:" ), tab1_1 ); 562 label = new QLabel( i18n( "URL:" ), tab1_1 );
559 mURLEdit = new KLineEdit( tab1_1 ); 563 mURLEdit = new KLineEdit( tab1_1 );
560 connect( mURLEdit, SIGNAL( textChanged( const QString& ) ), 564 connect( mURLEdit, SIGNAL( textChanged( const QString& ) ),
561 SLOT( textChanged( const QString& ) ) ); 565 SLOT( textChanged( const QString& ) ) );
562 label->setBuddy( mURLEdit ); 566 label->setBuddy( mURLEdit );
563//US layout->addWidget( label, 8, 4 ); 567//US layout->addWidget( label, 8, 4 );
564 layout->addWidget( label, 7,0 ); 568 layout->addWidget( label, 7,0 );
565//US layout->addMultiCellWidget( mURLEdit, 8, 8, 5, 6 ); 569//US layout->addMultiCellWidget( mURLEdit, 8, 8, 5, 6 );
566 layout->addWidget( mURLEdit, 7, 1); 570 layout->addWidget( mURLEdit, 7, 1);
567 571
568 label = new QLabel( i18n( "&IM address:" ), tab1_1 ); 572 label = new QLabel( i18n( "&IM address:" ), tab1_1 );
569 mIMAddressEdit = new KLineEdit( tab1_1 ); 573 mIMAddressEdit = new KLineEdit( tab1_1 );
570 connect( mIMAddressEdit, SIGNAL( textChanged( const QString& ) ), 574 connect( mIMAddressEdit, SIGNAL( textChanged( const QString& ) ),
571 SLOT( textChanged( const QString& ) ) ); 575 SLOT( textChanged( const QString& ) ) );
572 label->setBuddy( mIMAddressEdit ); 576 label->setBuddy( mIMAddressEdit );
573//US layout->addWidget( label, 9, 4 ); 577//US layout->addWidget( label, 9, 4 );
574 layout->addWidget( label, 8, 0 ); 578 layout->addWidget( label, 8, 0 );
575//US layout->addMultiCellWidget( mIMAddressEdit, 9, 9, 5, 6 ); 579//US layout->addMultiCellWidget( mIMAddressEdit, 9, 9, 5, 6 );
576 layout->addWidget( mIMAddressEdit, 8,1 ); 580 layout->addWidget( mIMAddressEdit, 8,1 );
577 581
578//US layout->addColSpacing( 6, 50 ); 582//US layout->addColSpacing( 6, 50 );
579 583
580//US bar = new KSeparator( KSeparator::HLine, tab1_1 ); 584//US bar = new KSeparator( KSeparator::HLine, tab1_1 );
581//US layout->addMultiCellWidget( bar, 10, 10, 0, 6 ); 585//US layout->addMultiCellWidget( bar, 10, 10, 0, 6 );
582 586
583/*US 587/*US
584 /////////////////////////////////////// 588 ///////////////////////////////////////
585 QHBox *categoryBox = new QHBox( tab1 ); 589 QHBox *categoryBox = new QHBox( tab1 );
586 categoryBox->setSpacing( KDialogBase::spacingHintSmall() ); 590 categoryBox->setSpacing( KDialogBase::spacingHintSmall() );
587 591
588 // Categories 592 // Categories
589 button = new QPushButton( i18n( "Categories" ), categoryBox ); 593 button = new QPushButton( i18n( "Categories" ), categoryBox );
590 connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) ); 594 connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) );
591 595
592 mCategoryEdit = new KLineEdit( categoryBox ); 596 mCategoryEdit = new KLineEdit( categoryBox );
593 mCategoryEdit->setReadOnly( true ); 597 mCategoryEdit->setReadOnly( true );
594 connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ), 598 connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ),
595 SLOT( textChanged( const QString& ) ) ); 599 SLOT( textChanged( const QString& ) ) );
596 600
597 mSecrecyWidget = new SecrecyWidget( categoryBox ); 601 mSecrecyWidget = new SecrecyWidget( categoryBox );
598 connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 602 connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
599 603
600 layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 ); 604 layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 );
601*/ 605*/
602 // Build the layout and add to the tab widget 606 // Build the layout and add to the tab widget
603 layout->activate(); // required 607 layout->activate(); // required
604 608
605 mTabWidget->addTab( tab1_1, i18n( "&Address" ) ); 609 mTabWidget->addTab( tab1_1, i18n( "&Address" ) );
606} 610}
607 611
608 612
609 613
610void AddresseeEditorWidget::setupTab2() 614void AddresseeEditorWidget::setupTab2()
611{ 615{
612 // This is the Details tab 616 // This is the Details tab
613 QWidget *tab2 = new QWidget( mTabWidget ); 617 QWidget *tab2 = new QWidget( mTabWidget );
614 618
615 QGridLayout *layout = new QGridLayout( tab2, 8, 3 ); 619 Q3GridLayout *layout = new Q3GridLayout( tab2, 8, 3 );
616 layout->setMargin( KDialogBase::marginHintSmall() ); 620 layout->setMargin( KDialogBase::marginHintSmall() );
617 layout->setSpacing( KDialogBase::spacingHintSmall() ); 621 layout->setSpacing( KDialogBase::spacingHintSmall() );
618 622
619 QLabel *label; 623 QLabel *label;
620 KSeparator* bar; 624 KSeparator* bar;
621 625
622 /////////////////////// 626 ///////////////////////
623 // Office info 627 // Office info
624 628
625 // Department 629 // Department
626 label = new QLabel( tab2 ); 630 label = new QLabel( tab2 );
627//US loadIcon call is ambiguous. Add one more parameter 631//US loadIcon call is ambiguous. Add one more parameter
628//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) ); 632//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) );
629 label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) ); 633 label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) );
630 layout->addMultiCellWidget( label, 0, 1, 0, 0 ); 634 layout->addMultiCellWidget( label, 0, 1, 0, 0 );
631 635
632 label = new QLabel( i18n( "Department:" ), tab2 ); 636 label = new QLabel( i18n( "Department:" ), tab2 );
633 layout->addWidget( label, 0, 1 ); 637 layout->addWidget( label, 0, 1 );
634 mDepartmentEdit = new KLineEdit( tab2 ); 638 mDepartmentEdit = new KLineEdit( tab2 );
635 connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ), 639 connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ),
636 SLOT( textChanged( const QString& ) ) ); 640 SLOT( textChanged( const QString& ) ) );
637 label->setBuddy( mDepartmentEdit ); 641 label->setBuddy( mDepartmentEdit );
638 layout->addWidget( mDepartmentEdit, 0, 2 ); 642 layout->addWidget( mDepartmentEdit, 0, 2 );
639 643
640 label = new QLabel( i18n( "Office:" ), tab2 ); 644 label = new QLabel( i18n( "Office:" ), tab2 );
641 layout->addWidget( label, 1, 1 ); 645 layout->addWidget( label, 1, 1 );
642 mOfficeEdit = new KLineEdit( tab2 ); 646 mOfficeEdit = new KLineEdit( tab2 );
643 connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ), 647 connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ),
644 SLOT( textChanged( const QString& ) ) ); 648 SLOT( textChanged( const QString& ) ) );
645 label->setBuddy( mOfficeEdit ); 649 label->setBuddy( mOfficeEdit );
646 layout->addWidget( mOfficeEdit, 1, 2 ); 650 layout->addWidget( mOfficeEdit, 1, 2 );
647 651
648 label = new QLabel( i18n( "Profession:" ), tab2 ); 652 label = new QLabel( i18n( "Profession:" ), tab2 );
649 layout->addWidget( label, 2, 1 ); 653 layout->addWidget( label, 2, 1 );
650 mProfessionEdit = new KLineEdit( tab2 ); 654 mProfessionEdit = new KLineEdit( tab2 );
651 connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ), 655 connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ),
652 SLOT( textChanged( const QString& ) ) ); 656 SLOT( textChanged( const QString& ) ) );
653 label->setBuddy( mProfessionEdit ); 657 label->setBuddy( mProfessionEdit );
654 layout->addWidget( mProfessionEdit, 2, 2 ); 658 layout->addWidget( mProfessionEdit, 2, 2 );
655 659
656 label = new QLabel( i18n( "Manager\'s name:" ), tab2 ); 660 label = new QLabel( i18n( "Manager\'s name:" ), tab2 );
657//US layout->addWidget( label, 0, 3 ); 661//US layout->addWidget( label, 0, 3 );
658 layout->addWidget( label, 3, 1 ); 662 layout->addWidget( label, 3, 1 );
659 mManagerEdit = new KLineEdit( tab2 ); 663 mManagerEdit = new KLineEdit( tab2 );
660 connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ), 664 connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ),
661 SLOT( textChanged( const QString& ) ) ); 665 SLOT( textChanged( const QString& ) ) );
662 label->setBuddy( mManagerEdit ); 666 label->setBuddy( mManagerEdit );
663//US layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 ); 667//US layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 );
664 layout->addWidget( mManagerEdit, 3, 2 ); 668 layout->addWidget( mManagerEdit, 3, 2 );
665 669
666 label = new QLabel( i18n( "Assistant's name:" ), tab2 ); 670 label = new QLabel( i18n( "Assistant's name:" ), tab2 );
667//US layout->addWidget( label, 1, 3 ); 671//US layout->addWidget( label, 1, 3 );
668 layout->addWidget( label, 4, 1 ); 672 layout->addWidget( label, 4, 1 );
669 mAssistantEdit = new KLineEdit( tab2 ); 673 mAssistantEdit = new KLineEdit( tab2 );
670 connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ), 674 connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ),
671 SLOT( textChanged( const QString& ) ) ); 675 SLOT( textChanged( const QString& ) ) );
672 label->setBuddy( mAssistantEdit ); 676 label->setBuddy( mAssistantEdit );
673//US layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 ); 677//US layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 );
674 layout->addWidget( mAssistantEdit, 4, 2 ); 678 layout->addWidget( mAssistantEdit, 4, 2 );
675 679
676 bar = new KSeparator( KSeparator::HLine, tab2 ); 680 bar = new KSeparator( KSeparator::HLine, tab2 );
677//US layout->addMultiCellWidget( bar, 3, 3, 0, 5 ); 681//US layout->addMultiCellWidget( bar, 3, 3, 0, 5 );
678 layout->addMultiCellWidget( bar, 5, 5, 0, 2 ); 682 layout->addMultiCellWidget( bar, 5, 5, 0, 2 );
679 683
680 ///////////////////////////////////////////////// 684 /////////////////////////////////////////////////
681 // Personal info 685 // Personal info
682 686
683 //label = new QLabel( tab2 ); 687 //label = new QLabel( tab2 );
684//US loadIcon call is ambiguous. Add one more parameter 688//US loadIcon call is ambiguous. Add one more parameter
685//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); 689//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) );
686 //label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); 690 //label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) );
687//US layout->addMultiCellWidget( label, 4, 5, 0, 0 ); 691//US layout->addMultiCellWidget( label, 4, 5, 0, 0 );
688 //layout->addMultiCellWidget( label, 6, 7, 0, 0 ); 692 //layout->addMultiCellWidget( label, 6, 7, 0, 0 );
689 693
690 694
691 int iii = 6; 695 int iii = 6;
692 696
693 if ( QApplication::desktop()->width() == 640 ) { 697 if ( QApplication::desktop()->width() == 640 ) {
694 QHBox * nbox = new QHBox ( tab2 ); 698 Q3HBox * nbox = new Q3HBox ( tab2 );
695 label = new QLabel( i18n( "Nick name:" )+" ", nbox ); 699 label = new QLabel( i18n( "Nick name:" )+" ", nbox );
696 mNicknameEdit = new KLineEdit( nbox ); 700 mNicknameEdit = new KLineEdit( nbox );
697 connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ), 701 connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ),
698 SLOT( textChanged( const QString& ) ) ); 702 SLOT( textChanged( const QString& ) ) );
699 label->setBuddy( mNicknameEdit ); 703 label->setBuddy( mNicknameEdit );
700 704
701 label = new QLabel( " "+i18n( "Spouse's name:" )+" ", nbox ); 705 label = new QLabel( " "+i18n( "Spouse's name:" )+" ", nbox );
702 mSpouseEdit = new KLineEdit( nbox ); 706 mSpouseEdit = new KLineEdit( nbox );
703 connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ), 707 connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ),
704 SLOT( textChanged( const QString& ) ) ); 708 SLOT( textChanged( const QString& ) ) );
705 label->setBuddy( mSpouseEdit ); 709 label->setBuddy( mSpouseEdit );
706 layout->addMultiCellWidget( nbox, iii, iii, 1, 2 ); 710 layout->addMultiCellWidget( nbox, iii, iii, 1, 2 );
707 ++iii; 711 ++iii;
708 712
709 } else { 713 } else {
710 label = new QLabel( i18n( "Nick name:" ), tab2 ); 714 label = new QLabel( i18n( "Nick name:" ), tab2 );
711 layout->addWidget( label, iii, 1 ); 715 layout->addWidget( label, iii, 1 );
712 mNicknameEdit = new KLineEdit( tab2 ); 716 mNicknameEdit = new KLineEdit( tab2 );
713 connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ), 717 connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ),
714 SLOT( textChanged( const QString& ) ) ); 718 SLOT( textChanged( const QString& ) ) );
715 label->setBuddy( mNicknameEdit ); 719 label->setBuddy( mNicknameEdit );
716 layout->addWidget( mNicknameEdit, iii, 2 ); 720 layout->addWidget( mNicknameEdit, iii, 2 );
717 ++iii; 721 ++iii;
718 722
719 label = new QLabel( i18n( "Spouse's name:" ), tab2 ); 723 label = new QLabel( i18n( "Spouse's name:" ), tab2 );
720 layout->addWidget( label, iii, 1 ); 724 layout->addWidget( label, iii, 1 );
721 mSpouseEdit = new KLineEdit( tab2 ); 725 mSpouseEdit = new KLineEdit( tab2 );
722 connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ), 726 connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ),
723 SLOT( textChanged( const QString& ) ) ); 727 SLOT( textChanged( const QString& ) ) );
724 label->setBuddy( mSpouseEdit ); 728 label->setBuddy( mSpouseEdit );
725 layout->addWidget( mSpouseEdit, iii, 2 ); 729 layout->addWidget( mSpouseEdit, iii, 2 );
726 ++iii; 730 ++iii;
727 } 731 }
728 732
729 label = new QLabel( i18n( "Children's names:" ), tab2 ); 733 label = new QLabel( i18n( "Children's names:" ), tab2 );
730 layout->addWidget( label, iii, 1 ); 734 layout->addWidget( label, iii, 1 );
731 mChildEdit = new KLineEdit( tab2 ); 735 mChildEdit = new KLineEdit( tab2 );
732 connect( mChildEdit, SIGNAL( textChanged( const QString& ) ), 736 connect( mChildEdit, SIGNAL( textChanged( const QString& ) ),
733 SLOT( textChanged( const QString& ) ) ); 737 SLOT( textChanged( const QString& ) ) );
734 label->setBuddy( mChildEdit ); 738 label->setBuddy( mChildEdit );
735 layout->addWidget( mChildEdit, iii, 2 ); 739 layout->addWidget( mChildEdit, iii, 2 );
736 ++iii; 740 ++iii;
737 if ( QApplication::desktop()->width() == 640 ) { 741 if ( QApplication::desktop()->width() == 640 ) {
738 QHBox * nbox = new QHBox ( tab2 ); 742 Q3HBox * nbox = new Q3HBox ( tab2 );
739 label = new QLabel( i18n( "Birthday:" )+" ", nbox ); 743 label = new QLabel( i18n( "Birthday:" )+" ", nbox );
740 mBirthdayPicker = new KDateEdit( nbox ); 744 mBirthdayPicker = new KDateEdit( nbox );
741 //mBirthdayPicker->toggleDateFormat(); 745 //mBirthdayPicker->toggleDateFormat();
742 mBirthdayPicker->setHandleInvalid( true ); 746 mBirthdayPicker->setHandleInvalid( true );
743 connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ), 747 connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ),
744 SLOT( dateChanged( QDate ) ) ); 748 SLOT( dateChanged( QDate ) ) );
745 749
746 label->setBuddy( mBirthdayPicker ); 750 label->setBuddy( mBirthdayPicker );
747 751
748 label = new QLabel( " "+i18n( "Anniversary:" )+" ", nbox ); 752 label = new QLabel( " "+i18n( "Anniversary:" )+" ", nbox );
749 mAnniversaryPicker = new KDateEdit( nbox ); 753 mAnniversaryPicker = new KDateEdit( nbox );
750 mAnniversaryPicker->setHandleInvalid( true ); 754 mAnniversaryPicker->setHandleInvalid( true );
751 connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ), 755 connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ),
752 SLOT( dateChanged( QDate ) ) ); 756 SLOT( dateChanged( QDate ) ) );
753 757
754 label->setBuddy( mAnniversaryPicker ); 758 label->setBuddy( mAnniversaryPicker );
755 layout->addMultiCellWidget( nbox, iii, iii, 1, 2 ); 759 layout->addMultiCellWidget( nbox, iii, iii, 1, 2 );
756 ++iii; 760 ++iii;
757 761
758 } else { 762 } else {
759 763
760 label = new QLabel( i18n( "Birthday:" ), tab2 ); 764 label = new QLabel( i18n( "Birthday:" ), tab2 );
761 layout->addWidget( label, iii, 1 ); 765 layout->addWidget( label, iii, 1 );
762 mBirthdayPicker = new KDateEdit( tab2 ); 766 mBirthdayPicker = new KDateEdit( tab2 );
763 //mBirthdayPicker->toggleDateFormat(); 767 //mBirthdayPicker->toggleDateFormat();
764 mBirthdayPicker->setHandleInvalid( true ); 768 mBirthdayPicker->setHandleInvalid( true );
765 connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ), 769 connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ),
766 SLOT( dateChanged( QDate ) ) ); 770 SLOT( dateChanged( QDate ) ) );
767 771
768 label->setBuddy( mBirthdayPicker ); 772 label->setBuddy( mBirthdayPicker );
769 layout->addWidget( mBirthdayPicker, iii, 2 ); 773 layout->addWidget( mBirthdayPicker, iii, 2 );
770 ++iii; 774 ++iii;
771 775
772 label = new QLabel( i18n( "Anniversary:" ), tab2 ); 776 label = new QLabel( i18n( "Anniversary:" ), tab2 );
773 layout->addWidget( label, iii, 1 ); 777 layout->addWidget( label, iii, 1 );
774 mAnniversaryPicker = new KDateEdit( tab2 ); 778 mAnniversaryPicker = new KDateEdit( tab2 );
775 mAnniversaryPicker->setHandleInvalid( true ); 779 mAnniversaryPicker->setHandleInvalid( true );
776 connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ), 780 connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ),
777 SLOT( dateChanged( QDate ) ) ); 781 SLOT( dateChanged( QDate ) ) );
778 782
779 label->setBuddy( mAnniversaryPicker ); 783 label->setBuddy( mAnniversaryPicker );
780 layout->addWidget( mAnniversaryPicker, iii, 2 ); 784 layout->addWidget( mAnniversaryPicker, iii, 2 );
781 ++iii; 785 ++iii;
782 786
783 } 787 }
784 788
785 label = new QLabel( i18n( "Gender:" ), tab2 ); 789 label = new QLabel( i18n( "Gender:" ), tab2 );
786 layout->addWidget( label, iii, 1 ); 790 layout->addWidget( label, iii, 1 );
787 mGenderBox = new QComboBox ( tab2 ); 791 mGenderBox = new QComboBox ( tab2 );
788 mGenderBox->insertItem ( i18n( "ALIEN (undefined)" )); 792 mGenderBox->insertItem ( i18n( "ALIEN (undefined)" ));
789 mGenderBox->insertItem ( i18n( "female" )); 793 mGenderBox->insertItem ( i18n( "female" ));
790 mGenderBox->insertItem ( i18n( "male" )); 794 mGenderBox->insertItem ( i18n( "male" ));
791 connect( mGenderBox, SIGNAL( activated ( const QString & ) ), 795 connect( mGenderBox, SIGNAL( activated ( const QString & ) ),
792 SLOT( textChanged( const QString& ) ) ); 796 SLOT( textChanged( const QString& ) ) );
793 label->setBuddy( mGenderBox ); 797 label->setBuddy( mGenderBox );
794 layout->addWidget( mGenderBox, iii, 2 ); 798 layout->addWidget( mGenderBox, iii, 2 );
795 ++iii; 799 ++iii;
796 // Build the layout and add to the tab widget 800 // Build the layout and add to the tab widget
797 layout->activate(); // required 801 layout->activate(); // required
798 802
799 mTabWidget->addTab( tab2, i18n( "&Details" ) ); 803 mTabWidget->addTab( tab2, i18n( "&Details" ) );
800} 804}
801 805
802void AddresseeEditorWidget::setupTab2_1() 806void AddresseeEditorWidget::setupTab2_1()
803{ 807{
804 // This is the Details tab 808 // This is the Details tab
805 QWidget *tab2_2 = new QWidget( mTabWidget ); 809 QWidget *tab2_2 = new QWidget( mTabWidget );
806 810
807 QGridLayout *layout = new QGridLayout( tab2_2, 1, 2 ); 811 Q3GridLayout *layout = new Q3GridLayout( tab2_2, 1, 2 );
808 layout->setMargin( KDialogBase::marginHintSmall() ); 812 layout->setMargin( KDialogBase::marginHintSmall() );
809 layout->setSpacing( KDialogBase::spacingHintSmall() ); 813 layout->setSpacing( KDialogBase::spacingHintSmall() );
810 814
811 QLabel *label; 815 QLabel *label;
812 KSeparator* bar; 816 KSeparator* bar;
813 817
814/*US 818/*US
815 /////////////////////// 819 ///////////////////////
816 // Office info 820 // Office info
817 821
818 // Department 822 // Department
819 label = new QLabel( tab2 ); 823 label = new QLabel( tab2 );
820//US loadIcon call is ambiguous. Add one more parameter 824//US loadIcon call is ambiguous. Add one more parameter
821//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) ); 825//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) );
822 label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) ); 826 label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) );
823 layout->addMultiCellWidget( label, 0, 1, 0, 0 ); 827 layout->addMultiCellWidget( label, 0, 1, 0, 0 );
824 828
825 label = new QLabel( i18n( "Department:" ), tab2 ); 829 label = new QLabel( i18n( "Department:" ), tab2 );
826 layout->addWidget( label, 0, 1 ); 830 layout->addWidget( label, 0, 1 );
827 mDepartmentEdit = new KLineEdit( tab2 ); 831 mDepartmentEdit = new KLineEdit( tab2 );
828 connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ), 832 connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ),
829 SLOT( textChanged( const QString& ) ) ); 833 SLOT( textChanged( const QString& ) ) );
830 label->setBuddy( mDepartmentEdit ); 834 label->setBuddy( mDepartmentEdit );
831 layout->addWidget( mDepartmentEdit, 0, 2 ); 835 layout->addWidget( mDepartmentEdit, 0, 2 );
832 836
833 label = new QLabel( i18n( "Office:" ), tab2 ); 837 label = new QLabel( i18n( "Office:" ), tab2 );
834 layout->addWidget( label, 1, 1 ); 838 layout->addWidget( label, 1, 1 );
835 mOfficeEdit = new KLineEdit( tab2 ); 839 mOfficeEdit = new KLineEdit( tab2 );
836 connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ), 840 connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ),
837 SLOT( textChanged( const QString& ) ) ); 841 SLOT( textChanged( const QString& ) ) );
838 label->setBuddy( mOfficeEdit ); 842 label->setBuddy( mOfficeEdit );
839 layout->addWidget( mOfficeEdit, 1, 2 ); 843 layout->addWidget( mOfficeEdit, 1, 2 );
840 844
841 label = new QLabel( i18n( "Profession:" ), tab2 ); 845 label = new QLabel( i18n( "Profession:" ), tab2 );
842 layout->addWidget( label, 2, 1 ); 846 layout->addWidget( label, 2, 1 );
843 mProfessionEdit = new KLineEdit( tab2 ); 847 mProfessionEdit = new KLineEdit( tab2 );
844 connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ), 848 connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ),
845 SLOT( textChanged( const QString& ) ) ); 849 SLOT( textChanged( const QString& ) ) );
846 label->setBuddy( mProfessionEdit ); 850 label->setBuddy( mProfessionEdit );
847 layout->addWidget( mProfessionEdit, 2, 2 ); 851 layout->addWidget( mProfessionEdit, 2, 2 );
848 852
849 label = new QLabel( i18n( "Manager\'s name:" ), tab2 ); 853 label = new QLabel( i18n( "Manager\'s name:" ), tab2 );
850 layout->addWidget( label, 0, 3 ); 854 layout->addWidget( label, 0, 3 );
851 mManagerEdit = new KLineEdit( tab2 ); 855 mManagerEdit = new KLineEdit( tab2 );
852 connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ), 856 connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ),
853 SLOT( textChanged( const QString& ) ) ); 857 SLOT( textChanged( const QString& ) ) );
854 label->setBuddy( mManagerEdit ); 858 label->setBuddy( mManagerEdit );
855 layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 ); 859 layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 );
856 860
857 label = new QLabel( i18n( "Assistant's name:" ), tab2 ); 861 label = new QLabel( i18n( "Assistant's name:" ), tab2 );
858 layout->addWidget( label, 1, 3 ); 862 layout->addWidget( label, 1, 3 );
859 mAssistantEdit = new KLineEdit( tab2 ); 863 mAssistantEdit = new KLineEdit( tab2 );
860 connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ), 864 connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ),
861 SLOT( textChanged( const QString& ) ) ); 865 SLOT( textChanged( const QString& ) ) );
862 label->setBuddy( mAssistantEdit ); 866 label->setBuddy( mAssistantEdit );
863 layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 ); 867 layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 );
864 868
865 bar = new KSeparator( KSeparator::HLine, tab2 ); 869 bar = new KSeparator( KSeparator::HLine, tab2 );
866 layout->addMultiCellWidget( bar, 3, 3, 0, 5 ); 870 layout->addMultiCellWidget( bar, 3, 3, 0, 5 );
867 871
868 ///////////////////////////////////////////////// 872 /////////////////////////////////////////////////
869 // Personal info 873 // Personal info
870 874
871 label = new QLabel( tab2 ); 875 label = new QLabel( tab2 );
872//US loadIcon call is ambiguous. Add one more parameter 876//US loadIcon call is ambiguous. Add one more parameter
873//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); 877//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) );
874 label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); 878 label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) );
875 layout->addMultiCellWidget( label, 4, 5, 0, 0 ); 879 layout->addMultiCellWidget( label, 4, 5, 0, 0 );
876 880
877 label = new QLabel( i18n( "Nick name:" ), tab2 ); 881 label = new QLabel( i18n( "Nick name:" ), tab2 );
878 layout->addWidget( label, 4, 1 ); 882 layout->addWidget( label, 4, 1 );
879 mNicknameEdit = new KLineEdit( tab2 ); 883 mNicknameEdit = new KLineEdit( tab2 );
880 connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ), 884 connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ),
881 SLOT( textChanged( const QString& ) ) ); 885 SLOT( textChanged( const QString& ) ) );
882 label->setBuddy( mNicknameEdit ); 886 label->setBuddy( mNicknameEdit );
883 layout->addWidget( mNicknameEdit, 4, 2 ); 887 layout->addWidget( mNicknameEdit, 4, 2 );
884 888
885 label = new QLabel( i18n( "Spouse's name:" ), tab2 ); 889 label = new QLabel( i18n( "Spouse's name:" ), tab2 );
886 layout->addWidget( label, 5, 1 ); 890 layout->addWidget( label, 5, 1 );
887 mSpouseEdit = new KLineEdit( tab2 ); 891 mSpouseEdit = new KLineEdit( tab2 );
888 connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ), 892 connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ),
889 SLOT( textChanged( const QString& ) ) ); 893 SLOT( textChanged( const QString& ) ) );
890 label->setBuddy( mSpouseEdit ); 894 label->setBuddy( mSpouseEdit );
891 layout->addWidget( mSpouseEdit, 5, 2 ); 895 layout->addWidget( mSpouseEdit, 5, 2 );
892 896
893 label = new QLabel( i18n( "Birthday:" ), tab2 ); 897 label = new QLabel( i18n( "Birthday:" ), tab2 );
894 layout->addWidget( label, 4, 3 ); 898 layout->addWidget( label, 4, 3 );
895 mBirthdayPicker = new KDateEdit( tab2 ); 899 mBirthdayPicker = new KDateEdit( tab2 );
896 mBirthdayPicker->setHandleInvalid( true ); 900 mBirthdayPicker->setHandleInvalid( true );
897 connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ), 901 connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ),
898 SLOT( dateChanged( QDate ) ) ); 902 SLOT( dateChanged( QDate ) ) );
899 connect( mBirthdayPicker, SIGNAL( invalidDateEntered() ), 903 connect( mBirthdayPicker, SIGNAL( invalidDateEntered() ),
900 SLOT( invalidDate() ) ); 904 SLOT( invalidDate() ) );
901 connect( mBirthdayPicker, SIGNAL( textChanged( const QString& ) ), 905 connect( mBirthdayPicker, SIGNAL( textChanged( const QString& ) ),
902 SLOT( emitModified() ) ); 906 SLOT( emitModified() ) );
903 label->setBuddy( mBirthdayPicker ); 907 label->setBuddy( mBirthdayPicker );
904 layout->addWidget( mBirthdayPicker, 4, 4 ); 908 layout->addWidget( mBirthdayPicker, 4, 4 );
905 909
906 label = new QLabel( i18n( "Anniversary:" ), tab2 ); 910 label = new QLabel( i18n( "Anniversary:" ), tab2 );
907 layout->addWidget( label, 5, 3 ); 911 layout->addWidget( label, 5, 3 );
908 mAnniversaryPicker = new KDateEdit( tab2 ); 912 mAnniversaryPicker = new KDateEdit( tab2 );
909 mAnniversaryPicker->setHandleInvalid( true ); 913 mAnniversaryPicker->setHandleInvalid( true );
910 connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ), 914 connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ),
911 SLOT( dateChanged( QDate ) ) ); 915 SLOT( dateChanged( QDate ) ) );
912 connect( mAnniversaryPicker, SIGNAL( invalidDateEntered() ), 916 connect( mAnniversaryPicker, SIGNAL( invalidDateEntered() ),
913 SLOT( invalidDate() ) ); 917 SLOT( invalidDate() ) );
914 connect( mAnniversaryPicker, SIGNAL( textChanged( const QString& ) ), 918 connect( mAnniversaryPicker, SIGNAL( textChanged( const QString& ) ),
915 SLOT( emitModified() ) ); 919 SLOT( emitModified() ) );
916 label->setBuddy( mAnniversaryPicker ); 920 label->setBuddy( mAnniversaryPicker );
917 layout->addWidget( mAnniversaryPicker, 5, 4 ); 921 layout->addWidget( mAnniversaryPicker, 5, 4 );
918 922
919 bar = new KSeparator( KSeparator::HLine, tab2 ); 923 bar = new KSeparator( KSeparator::HLine, tab2 );
920 layout->addMultiCellWidget( bar, 6, 6, 0, 5 ); 924 layout->addMultiCellWidget( bar, 6, 6, 0, 5 );
921*/ 925*/
922 ////////////////////////////////////// 926 //////////////////////////////////////
923 // Notes 927 // Notes
924 label = new QLabel( i18n( "Note:" ), tab2_2 ); 928 label = new QLabel( i18n( "Note:" ), tab2_2 );
925 label->setAlignment( Qt::AlignTop | Qt::AlignLeft ); 929 label->setAlignment( Qt::AlignTop | Qt::AlignLeft );
926//US layout->addWidget( label, 7, 0 ); 930//US layout->addWidget( label, 7, 0 );
927 layout->addWidget( label, 0, 0 ); 931 layout->addWidget( label, 0, 0 );
928#ifndef KAB_EMBEDDED 932#ifndef KAB_EMBEDDED
929 mNoteEdit = new QTextEdit( tab2_2 ); 933 mNoteEdit = new Q3TextEdit( tab2_2 );
930 mNoteEdit->setWordWrap( QTextEdit::WidgetWidth ); 934 mNoteEdit->setWordWrap( Q3TextEdit::WidgetWidth );
931 mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); 935 mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() );
932#else //KAB_EMBEDDED 936#else //KAB_EMBEDDED
933 mNoteEdit = new QMultiLineEdit( tab2_2 ); 937 mNoteEdit = new Q3MultiLineEdit( tab2_2 );
934 mNoteEdit->setWordWrap( QMultiLineEdit::WidgetWidth ); 938 mNoteEdit->setWordWrap( Q3MultiLineEdit::WidgetWidth );
935 mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); 939 mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() );
936#endif //KAB_EMBEDDED 940#endif //KAB_EMBEDDED
937 941
938 connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) ); 942 connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) );
939 label->setBuddy( mNoteEdit ); 943 label->setBuddy( mNoteEdit );
940//US layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 ); 944//US layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 );
941 layout->addWidget( mNoteEdit, 1, 0); 945 layout->addWidget( mNoteEdit, 1, 0);
942 946
943 // Build the layout and add to the tab widget 947 // Build the layout and add to the tab widget
944 layout->activate(); // required 948 layout->activate(); // required
945 949
946 mTabWidget->addTab( tab2_2, i18n( "&Notes" ) ); 950 mTabWidget->addTab( tab2_2, i18n( "&Notes" ) );
947} 951}
948 952
949 953
950 954
951void AddresseeEditorWidget::setupTab3() 955void AddresseeEditorWidget::setupTab3()
952{ 956{
953 // This is the Misc tab 957 // This is the Misc tab
954 QWidget *tab3 = new QWidget( mTabWidget ); 958 QWidget *tab3 = new QWidget( mTabWidget );
955 959
956 QGridLayout *layout = new QGridLayout( tab3, 1, 1 ); 960 Q3GridLayout *layout = new Q3GridLayout( tab3, 1, 1 );
957 layout->setMargin( KDialogBase::marginHintSmall() ); 961 layout->setMargin( KDialogBase::marginHintSmall() );
958 layout->setSpacing( KDialogBase::spacingHintSmall() ); 962 layout->setSpacing( KDialogBase::spacingHintSmall() );
959//US layout->setColStretch( 2, 1 ); 963//US layout->setColStretch( 2, 1 );
960 964
961 ////////////////////////////////////// 965 //////////////////////////////////////
962 // Geo 966 // Geo
963 mGeoWidget = new GeoWidget( tab3 ); 967 mGeoWidget = new GeoWidget( tab3 );
964 // mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() ); 968 // mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() );
965 connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 969 connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
966 layout->addWidget( mGeoWidget, 0, 0 ); 970 layout->addWidget( mGeoWidget, 0, 0 );
967/*US 971/*US
968 ////////////////////////////////////// 972 //////////////////////////////////////
969 // Sound 973 // Sound
970#ifndef KAB_EMBEDDED 974#ifndef KAB_EMBEDDED
971 mSoundWidget = new SoundWidget( tab3 ); 975 mSoundWidget = new SoundWidget( tab3 );
972 mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() ); 976 mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() );
973 connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 977 connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
974 layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop ); 978 layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop );
975#else //KAB_EMBEDDED 979#else //KAB_EMBEDDED
976qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); 980qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed");
977#endif //KAB_EMBEDDED 981#endif //KAB_EMBEDDED
978 982
979 ////////////////////////////////////// 983 //////////////////////////////////////
980 // Images 984 // Images
981 mImageWidget = new ImageWidget( tab3 ); 985 mImageWidget = new ImageWidget( tab3 );
982 mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); 986 mImageWidget->setMinimumSize( mImageWidget->sizeHint() );
983 connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 987 connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
984 layout->addWidget( mImageWidget, 1, 0, Qt::AlignTop ); 988 layout->addWidget( mImageWidget, 1, 0, Qt::AlignTop );
985*/ 989*/
986//US 990//US
987/* 991/*
988 KSeparator* bar = new KSeparator( KSeparator::HLine, tab3 ); 992 KSeparator* bar = new KSeparator( KSeparator::HLine, tab3 );
989 layout->addMultiCellWidget( bar, 1, 1, 0, 0 ); 993 layout->addMultiCellWidget( bar, 1, 1, 0, 0 );
990*/ 994*/
991 ////////////////////////////////////// 995 //////////////////////////////////////
992 // Keys 996 // Keys
993 mKeyWidget = new KeyWidget( tab3 ); 997 mKeyWidget = new KeyWidget( tab3 );
994 //mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); 998 //mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() );
995 connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 999 connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
996//US layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); 1000//US layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop );
997 layout->addWidget( mKeyWidget, 1, 0 ); 1001 layout->addWidget( mKeyWidget, 1, 0 );
998 1002
999 mTabWidget->addTab( tab3, i18n( "&Misc" ) ); 1003 mTabWidget->addTab( tab3, i18n( "&Misc" ) );
1000} 1004}
1001 1005
1002void AddresseeEditorWidget::setupTab3_1() 1006void AddresseeEditorWidget::setupTab3_1()
1003{ 1007{
1004 // This is the Misc tab 1008 // This is the Misc tab
1005 QWidget *tab3 = new QWidget( mTabWidget ); 1009 QWidget *tab3 = new QWidget( mTabWidget );
1006 1010
1007//US QGridLayout *layout = new QGridLayout( tab3, 2, 3 ); 1011//US QGridLayout *layout = new QGridLayout( tab3, 2, 3 );
1008 QGridLayout *layout = new QGridLayout( tab3, 1, 1 ); 1012 Q3GridLayout *layout = new Q3GridLayout( tab3, 1, 1 );
1009 layout->setMargin( KDialogBase::marginHint() ); 1013 layout->setMargin( KDialogBase::marginHint() );
1010 layout->setSpacing( KDialogBase::spacingHint() ); 1014 layout->setSpacing( KDialogBase::spacingHint() );
1011//US layout->setColStretch( 2, 1 ); 1015//US layout->setColStretch( 2, 1 );
1012 1016
1013/*US 1017/*US
1014 ////////////////////////////////////// 1018 //////////////////////////////////////
1015 // Geo 1019 // Geo
1016 mGeoWidget = new GeoWidget( tab3 ); 1020 mGeoWidget = new GeoWidget( tab3 );
1017 mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() ); 1021 mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() );
1018 connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 1022 connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
1019 layout->addWidget( mGeoWidget, 0, 0, Qt::AlignTop ); 1023 layout->addWidget( mGeoWidget, 0, 0, Qt::AlignTop );
1020*/ 1024*/
1021 ////////////////////////////////////// 1025 //////////////////////////////////////
1022 // Sound 1026 // Sound
1023#ifndef KAB_EMBEDDED 1027#ifndef KAB_EMBEDDED
1024 mSoundWidget = new SoundWidget( tab3 ); 1028 mSoundWidget = new SoundWidget( tab3 );
1025 mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() ); 1029 mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() );
1026 connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 1030 connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
1027 layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop ); 1031 layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop );
1028#else //KAB_EMBEDDED 1032#else //KAB_EMBEDDED
1029//US qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); 1033//US qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed");
1030#endif //KAB_EMBEDDED 1034#endif //KAB_EMBEDDED
1031 1035
1032 ////////////////////////////////////// 1036 //////////////////////////////////////
1033 // Images 1037 // Images
1034 mImageWidget = new ImageWidget( tab3 ); 1038 mImageWidget = new ImageWidget( tab3 );
1035 mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); 1039 mImageWidget->setMinimumSize( mImageWidget->sizeHint() );
1036 connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 1040 connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
1037 layout->addWidget( mImageWidget, 0, 0, Qt::AlignTop ); 1041 layout->addWidget( mImageWidget, 0, 0, Qt::AlignTop );
1038/*US 1042/*US
1039 ////////////////////////////////////// 1043 //////////////////////////////////////
1040 // Keys 1044 // Keys
1041 mKeyWidget = new KeyWidget( tab3 ); 1045 mKeyWidget = new KeyWidget( tab3 );
1042 mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); 1046 mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() );
1043 connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 1047 connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
1044 layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); 1048 layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop );
1045*/ 1049*/
1046 mTabWidget->addTab( tab3, i18n( "&Images" ) ); 1050 mTabWidget->addTab( tab3, i18n( "&Images" ) );
1047} 1051}
1048 1052
1049 1053
1050void AddresseeEditorWidget::load() 1054void AddresseeEditorWidget::load()
1051{ 1055{
1052 1056
1053 // Block signals in case anything tries to emit modified 1057 // Block signals in case anything tries to emit modified
1054 // CS: This doesn't seem to work. 1058 // CS: This doesn't seem to work.
1055 bool block = signalsBlocked(); 1059 bool block = signalsBlocked();
1056 blockSignals( true ); 1060 blockSignals( true );
1057 mBlockSignals = true; // used for internal signal blocking 1061 mBlockSignals = true; // used for internal signal blocking
1058 1062
1059 mNameEdit->setText( mAddressee.assembledName() ); 1063 mNameEdit->setText( mAddressee.assembledName() );
1060 1064
1061 if ( mAddressee.formattedName().isEmpty() ) { 1065 if ( mAddressee.formattedName().isEmpty() ) {
1062//US KConfig config( "kaddressbookrc" ); 1066//US KConfig config( "kaddressbookrc" );
1063 KConfig config( locateLocal("config", "kabcrc") ); 1067 KConfig config( locateLocal("config", "kabcrc") );
1064 config.setGroup( "General" ); 1068 config.setGroup( "General" );
1065 mFormattedNameType = config.readNumEntry( "FormattedNameType", 1 ); 1069 mFormattedNameType = config.readNumEntry( "FormattedNameType", 1 );
1066 mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); 1070 mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) );
1067 } else {; 1071 } else {;
1068 if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::SimpleName ) ) 1072 if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::SimpleName ) )
1069 mFormattedNameType = NameEditDialog::SimpleName; 1073 mFormattedNameType = NameEditDialog::SimpleName;
1070 else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::FullName ) ) 1074 else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::FullName ) )
1071 mFormattedNameType = NameEditDialog::FullName; 1075 mFormattedNameType = NameEditDialog::FullName;
1072 else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseName ) ) 1076 else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseName ) )
1073 mFormattedNameType = NameEditDialog::ReverseName; 1077 mFormattedNameType = NameEditDialog::ReverseName;
1074 else 1078 else
1075 mFormattedNameType = NameEditDialog::CustomName; 1079 mFormattedNameType = NameEditDialog::CustomName;
1076 } 1080 }
1077 1081
1078 mFormattedNameLabel->setText( mAddressee.formattedName() ); 1082 mFormattedNameLabel->setText( mAddressee.formattedName() );
1079 1083
1080 mAConfig->setUid( mAddressee.uid() ); 1084 mAConfig->setUid( mAddressee.uid() );
1081 if ( mAConfig->automaticNameParsing() ) { 1085 if ( mAConfig->automaticNameParsing() ) {
1082 mNameLabel->hide(); 1086 mNameLabel->hide();
1083 mNameEdit->show(); 1087 mNameEdit->show();
1084 } else { 1088 } else {
1085 mNameEdit->hide(); 1089 mNameEdit->hide();
1086 mNameLabel->setText( mNameEdit->text() ); 1090 mNameLabel->setText( mNameEdit->text() );
1087 mNameLabel->show(); 1091 mNameLabel->show();
1088 } 1092 }
1089 1093
1090 mRoleEdit->setText( mAddressee.role() ); 1094 mRoleEdit->setText( mAddressee.role() );
1091 mOrgEdit->setText( mAddressee.organization() ); 1095 mOrgEdit->setText( mAddressee.organization() );
1092 1096
1093//US mURLEdit->setURL( mAddressee.url().url() ); 1097//US mURLEdit->setURL( mAddressee.url().url() );
1094 mURLEdit->setText( mAddressee.url().prettyURL() ); 1098 mURLEdit->setText( mAddressee.url().prettyURL() );
1095//US?? mURLEdit->home( false ); 1099//US?? mURLEdit->home( false );
1096 1100
1097 // mNoteEdit->setText( mAddressee.note() ); 1101 // mNoteEdit->setText( mAddressee.note() );
1098 mNoteEdit->setText( mAddressee.note() ); 1102 mNoteEdit->setText( mAddressee.note() );
1099 mEmailWidget->setEmails( mAddressee.emails() ); 1103 mEmailWidget->setEmails( mAddressee.emails() );
1100 mPhoneEditWidget->setPhoneNumbers( mAddressee.phoneNumbers() ); 1104 mPhoneEditWidget->setPhoneNumbers( mAddressee.phoneNumbers() );
1101 mAddressEditWidget->setAddresses( mAddressee, mAddressee.addresses() ); 1105 mAddressEditWidget->setAddresses( mAddressee, mAddressee.addresses() );
1102 mBirthdayPicker->setDate( mAddressee.birthday().date() ); 1106 mBirthdayPicker->setDate( mAddressee.birthday().date() );
1103 1107
1104//US mAnniversaryPicker->setDate( QDate::fromString( mAddressee.custom( 1108//US mAnniversaryPicker->setDate( QDate::fromString( mAddressee.custom(
1105//US "KADDRESSBOOK", "X-Anniversary" ), Qt::ISODate) ); 1109//US "KADDRESSBOOK", "X-Anniversary" ), Qt::ISODate) );
1106 QDate dt = KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ), 1110 QDate dt = KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ),
1107 "%Y-%m-%d"); // = Qt::ISODate 1111 "%Y-%m-%d"); // = Qt::ISODate
1108 mAnniversaryPicker->setDate( dt ); 1112 mAnniversaryPicker->setDate( dt );
1109 1113
1110 1114
1111 mNicknameEdit->setText( mAddressee.nickName() ); 1115 mNicknameEdit->setText( mAddressee.nickName() );
1112 mCategoryEdit->setText( mAddressee.categories().join( "," ) ); 1116 mCategoryEdit->setText( mAddressee.categories().join( "," ) );
1113 1117
1114 mGeoWidget->setGeo( mAddressee.geo() ); 1118 mGeoWidget->setGeo( mAddressee.geo() );
1115 mImageWidget->setPhoto( mAddressee.photo() ); 1119 mImageWidget->setPhoto( mAddressee.photo() );
1116 mImageWidget->setLogo( mAddressee.logo() ); 1120 mImageWidget->setLogo( mAddressee.logo() );
1117 mKeyWidget->setKeys( mAddressee.keys() ); 1121 mKeyWidget->setKeys( mAddressee.keys() );
1118 mSecrecyWidget->setSecrecy( mAddressee.secrecy() ); 1122 mSecrecyWidget->setSecrecy( mAddressee.secrecy() );
1119#ifndef KAB_EMBEDDED 1123#ifndef KAB_EMBEDDED
1120 mSoundWidget->setSound( mAddressee.sound() ); 1124 mSoundWidget->setSound( mAddressee.sound() );
1121#else //KAB_EMBEDDED 1125#else //KAB_EMBEDDED
1122//US qDebug("AddresseeEditorWidget::load has to be changed 2"); 1126//US qDebug("AddresseeEditorWidget::load has to be changed 2");
1123#endif //KAB_EMBEDDED 1127#endif //KAB_EMBEDDED
1124 1128
1125 // Load customs 1129 // Load customs
1126 mIMAddressEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ) ); 1130 mIMAddressEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ) );
1127 mSpouseEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ) ); 1131 mSpouseEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ) );
1128 mChildEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Children" ) ); 1132 mChildEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Children" ) );
1129 mManagerEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ) ); 1133 mManagerEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ) );
1130 mAssistantEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ) ); 1134 mAssistantEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ) );
1131 mDepartmentEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Department" ) ); 1135 mDepartmentEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Department" ) );
1132 mOfficeEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Office" ) ); 1136 mOfficeEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Office" ) );
1133 mProfessionEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Profession" ) ); 1137 mProfessionEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Profession" ) );
1134 QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" ); 1138 QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" );
1135 if ( gen == "female" ) 1139 if ( gen == "female" )
1136 mGenderBox->setCurrentItem ( 1 ); 1140 mGenderBox->setCurrentItem ( 1 );
1137 else if ( gen == "male" ) 1141 else if ( gen == "male" )
1138 mGenderBox->setCurrentItem ( 2 ); 1142 mGenderBox->setCurrentItem ( 2 );
1139 else 1143 else
1140 mGenderBox->setCurrentItem ( 0 ); 1144 mGenderBox->setCurrentItem ( 0 );
1141 blockSignals( block ); 1145 blockSignals( block );
1142 mBlockSignals = false; 1146 mBlockSignals = false;
1143 1147
1144 mDirty = false; 1148 mDirty = false;
1145} 1149}
1146 1150
1147void AddresseeEditorWidget::save() 1151void AddresseeEditorWidget::save()
1148{ 1152{
1149 if ( !dirty() ) { 1153 if ( !dirty() ) {
1150 return; 1154 return;
1151 } 1155 }
1152 1156
1153 mAddressee.setRevision( QDateTime::currentDateTime() ); 1157 mAddressee.setRevision( QDateTime::currentDateTime() );
1154 1158
1155 mAddressee.setRole( mRoleEdit->text() ); 1159 mAddressee.setRole( mRoleEdit->text() );
1156 mAddressee.setOrganization( mOrgEdit->text() ); 1160 mAddressee.setOrganization( mOrgEdit->text() );
1157 mAddressee.setUrl( KURL( mURLEdit->text() ) ); 1161 mAddressee.setUrl( KURL( mURLEdit->text() ) );
1158 mAddressee.setNote( mNoteEdit->text() ); 1162 mAddressee.setNote( mNoteEdit->text() );
1159 if ( mBirthdayPicker->inputIsValid() ) { 1163 if ( mBirthdayPicker->inputIsValid() ) {
1160 QDate da = mBirthdayPicker->date(); 1164 QDate da = mBirthdayPicker->date();
1161 mAddressee.setBirthday( QDateTime( da ) ); 1165 mAddressee.setBirthday( QDateTime( da ) );
1162 //qDebug("bday %s ",da.toString().latin1()); 1166 //qDebug("bday %s ",da.toString().latin1());
1163 } 1167 }
1164 else { 1168 else {
1165 mAddressee.setBirthday( QDateTime() ); 1169 mAddressee.setBirthday( QDateTime() );
1166 mBirthdayPicker->clear(); 1170 mBirthdayPicker->clear();
1167 } 1171 }
1168 mAddressee.setNickName( mNicknameEdit->text() ); 1172 mAddressee.setNickName( mNicknameEdit->text() );
1169 mAddressee.setCategories( QStringList::split( ",", mCategoryEdit->text() ) ); 1173 mAddressee.setCategories( QStringList::split( ",", mCategoryEdit->text() ) );
1170 1174
1171 mAddressee.setGeo( mGeoWidget->geo() ); 1175 mAddressee.setGeo( mGeoWidget->geo() );
1172 mAddressee.setPhoto( mImageWidget->photo() ); 1176 mAddressee.setPhoto( mImageWidget->photo() );
1173 mAddressee.setLogo( mImageWidget->logo() ); 1177 mAddressee.setLogo( mImageWidget->logo() );
1174 mAddressee.setKeys( mKeyWidget->keys() ); 1178 mAddressee.setKeys( mKeyWidget->keys() );
1175#ifndef KAB_EMBEDDED 1179#ifndef KAB_EMBEDDED
1176 mAddressee.setSound( mSoundWidget->sound() ); 1180 mAddressee.setSound( mSoundWidget->sound() );
1177#else //KAB_EMBEDDED 1181#else //KAB_EMBEDDED
1178//US qDebug("AddresseeEditorWidget::save sound not supported"); 1182//US qDebug("AddresseeEditorWidget::save sound not supported");
1179#endif //KAB_EMBEDDED 1183#endif //KAB_EMBEDDED
1180 mAddressee.setSecrecy( mSecrecyWidget->secrecy() ); 1184 mAddressee.setSecrecy( mSecrecyWidget->secrecy() );
1181 1185
1182 // save custom fields 1186 // save custom fields
1183 mAddressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMAddressEdit->text() ); 1187 mAddressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMAddressEdit->text() );
1184 mAddressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", mSpouseEdit->text() ); 1188 mAddressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", mSpouseEdit->text() );
1185 mAddressee.insertCustom( "KADDRESSBOOK", "X-Children", mChildEdit->text() ); 1189 mAddressee.insertCustom( "KADDRESSBOOK", "X-Children", mChildEdit->text() );
1186 mAddressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", mManagerEdit->text() ); 1190 mAddressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", mManagerEdit->text() );
1187 mAddressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", mAssistantEdit->text() ); 1191 mAddressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", mAssistantEdit->text() );
1188 mAddressee.insertCustom( "KADDRESSBOOK", "X-Department", mDepartmentEdit->text() ); 1192 mAddressee.insertCustom( "KADDRESSBOOK", "X-Department", mDepartmentEdit->text() );
1189 mAddressee.insertCustom( "KADDRESSBOOK", "X-Office", mOfficeEdit->text() ); 1193 mAddressee.insertCustom( "KADDRESSBOOK", "X-Office", mOfficeEdit->text() );
1190 mAddressee.insertCustom( "KADDRESSBOOK", "X-Profession", mProfessionEdit->text() ); 1194 mAddressee.insertCustom( "KADDRESSBOOK", "X-Profession", mProfessionEdit->text() );
1191 if ( mAnniversaryPicker->inputIsValid() ) { 1195 if ( mAnniversaryPicker->inputIsValid() ) {
1192 QString dt = KGlobal::locale()->formatDate(mAnniversaryPicker->date(), true, KLocale::ISODate); 1196 QString dt = KGlobal::locale()->formatDate(mAnniversaryPicker->date(), true, KLocale::ISODate);
1193 mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); 1197 mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
1194 } 1198 }
1195 else { 1199 else {
1196 mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" ); 1200 mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" );
1197 mAnniversaryPicker->clear(); 1201 mAnniversaryPicker->clear();
1198 } 1202 }
1199 int gen = mGenderBox->currentItem (); 1203 int gen = mGenderBox->currentItem ();
1200 if ( gen == 1 ) 1204 if ( gen == 1 )
1201 mAddressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); 1205 mAddressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female");
1202 else if ( gen == 2 ) 1206 else if ( gen == 2 )
1203 mAddressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); 1207 mAddressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male");
1204 else 1208 else
1205 mAddressee.removeCustom( "KADDRESSBOOK", "X-Gender" ); 1209 mAddressee.removeCustom( "KADDRESSBOOK", "X-Gender" );
1206 1210
1207 // Save the email addresses 1211 // Save the email addresses
1208 QStringList emails = mAddressee.emails(); 1212 QStringList emails = mAddressee.emails();
1209 QStringList::Iterator iter; 1213 QStringList::Iterator iter;
1210 for ( iter = emails.begin(); iter != emails.end(); ++iter ) 1214 for ( iter = emails.begin(); iter != emails.end(); ++iter )
1211 mAddressee.removeEmail( *iter ); 1215 mAddressee.removeEmail( *iter );
1212 1216
1213 emails = mEmailWidget->emails(); 1217 emails = mEmailWidget->emails();
1214 bool first = true; 1218 bool first = true;
1215 for ( iter = emails.begin(); iter != emails.end(); ++iter ) { 1219 for ( iter = emails.begin(); iter != emails.end(); ++iter ) {
1216 mAddressee.insertEmail( *iter, first ); 1220 mAddressee.insertEmail( *iter, first );
1217 first = false; 1221 first = false;
1218 } 1222 }
1219 1223
1220 // Save the phone numbers 1224 // Save the phone numbers
1221 KABC::PhoneNumber::List phoneNumbers; 1225 KABC::PhoneNumber::List phoneNumbers;
1222 KABC::PhoneNumber::List::Iterator phoneIter; 1226 KABC::PhoneNumber::List::Iterator phoneIter;
1223 phoneNumbers = mAddressee.phoneNumbers(); 1227 phoneNumbers = mAddressee.phoneNumbers();
1224 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); 1228 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end();
1225 ++phoneIter ) 1229 ++phoneIter )
1226 mAddressee.removePhoneNumber( *phoneIter ); 1230 mAddressee.removePhoneNumber( *phoneIter );
1227 1231
1228 phoneNumbers = mPhoneEditWidget->phoneNumbers(); 1232 phoneNumbers = mPhoneEditWidget->phoneNumbers();
1229 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); 1233 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end();
1230 ++phoneIter ) 1234 ++phoneIter )
1231 mAddressee.insertPhoneNumber( *phoneIter ); 1235 mAddressee.insertPhoneNumber( *phoneIter );
1232 mAddressee.makePhoneNumbersOLcompatible(); 1236 mAddressee.makePhoneNumbersOLcompatible();
1233 // Save the addresses 1237 // Save the addresses
1234 KABC::Address::List addresses; 1238 KABC::Address::List addresses;
1235 KABC::Address::List::Iterator addressIter; 1239 KABC::Address::List::Iterator addressIter;
1236 addresses = mAddressee.addresses(); 1240 addresses = mAddressee.addresses();
1237 for ( addressIter = addresses.begin(); addressIter != addresses.end(); 1241 for ( addressIter = addresses.begin(); addressIter != addresses.end();
1238 ++addressIter ) 1242 ++addressIter )
1239 mAddressee.removeAddress( *addressIter ); 1243 mAddressee.removeAddress( *addressIter );
1240 1244
1241 addresses = mAddressEditWidget->addresses(); 1245 addresses = mAddressEditWidget->addresses();
1242 for ( addressIter = addresses.begin(); addressIter != addresses.end(); 1246 for ( addressIter = addresses.begin(); addressIter != addresses.end();
1243 ++addressIter ) 1247 ++addressIter )
1244 mAddressee.insertAddress( *addressIter ); 1248 mAddressee.insertAddress( *addressIter );
1245 mDirty = false; 1249 mDirty = false;
1246} 1250}
1247 1251
1248bool AddresseeEditorWidget::dirty() 1252bool AddresseeEditorWidget::dirty()
1249{ 1253{
1250 1254
1251 if ( ! mDirty ) { 1255 if ( ! mDirty ) {
1252 if ( mBirthdayPicker->inputIsValid() ) { 1256 if ( mBirthdayPicker->inputIsValid() ) {
1253 QDate da = mBirthdayPicker->date(); 1257 QDate da = mBirthdayPicker->date();
1254 if ( !(da == mAddressee.birthday().date())) 1258 if ( !(da == mAddressee.birthday().date()))
1255 mDirty = true; 1259 mDirty = true;
1256 } 1260 }
1257 else { 1261 else {
1258 mBirthdayPicker->clear(); 1262 mBirthdayPicker->clear();
1259 } 1263 }
1260 if ( mAnniversaryPicker->inputIsValid() ) { 1264 if ( mAnniversaryPicker->inputIsValid() ) {
1261 QDate da = mAnniversaryPicker->date(); 1265 QDate da = mAnniversaryPicker->date();
1262 if ( da != KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ), 1266 if ( da != KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ),
1263 "%Y-%m-%d")) 1267 "%Y-%m-%d"))
1264 mDirty = true; 1268 mDirty = true;
1265 } 1269 }
1266 else { 1270 else {
1267 mAnniversaryPicker->clear(); 1271 mAnniversaryPicker->clear();
1268 } 1272 }
1269 } 1273 }
1270 return mDirty; 1274 return mDirty;
1271} 1275}
1272 1276
1273void AddresseeEditorWidget::nameTextChanged( const QString &text ) 1277void AddresseeEditorWidget::nameTextChanged( const QString &text )
1274{ 1278{
1275 if ( mBlockSignals ) 1279 if ( mBlockSignals )
1276 return; 1280 return;
1277 // use the addressee class to parse the name for us 1281 // use the addressee class to parse the name for us
1278 mAConfig->setUid( mAddressee.uid() ); 1282 mAConfig->setUid( mAddressee.uid() );
1279 if ( mAConfig->automaticNameParsing() ) { 1283 if ( mAConfig->automaticNameParsing() ) {
1280 if ( !mAddressee.formattedName().isEmpty() ) { 1284 if ( !mAddressee.formattedName().isEmpty() ) {
1281 QString fn = mAddressee.formattedName(); 1285 QString fn = mAddressee.formattedName();
1282 mAddressee.setNameFromString( text ); 1286 mAddressee.setNameFromString( text );
1283 mAddressee.setFormattedName( fn ); 1287 mAddressee.setFormattedName( fn );
1284 } else { 1288 } else {
1285 // use extra addressee to avoid a formatted name assignment 1289 // use extra addressee to avoid a formatted name assignment
1286 Addressee addr; 1290 Addressee addr;
1287 addr.setNameFromString( text ); 1291 addr.setNameFromString( text );
1288 mAddressee.setPrefix( addr.prefix() ); 1292 mAddressee.setPrefix( addr.prefix() );
1289 mAddressee.setGivenName( addr.givenName() ); 1293 mAddressee.setGivenName( addr.givenName() );
1290 mAddressee.setAdditionalName( addr.additionalName() ); 1294 mAddressee.setAdditionalName( addr.additionalName() );
1291 mAddressee.setFamilyName( addr.familyName() ); 1295 mAddressee.setFamilyName( addr.familyName() );
1292 mAddressee.setSuffix( addr.suffix() ); 1296 mAddressee.setSuffix( addr.suffix() );
1293 } 1297 }
1294 } 1298 }
1295 nameBoxChanged(); 1299 nameBoxChanged();
1296 1300
1297 1301
1298 emitModified(); 1302 emitModified();
1299} 1303}
1300 1304
1301void AddresseeEditorWidget::nameBoxChanged() 1305void AddresseeEditorWidget::nameBoxChanged()
1302{ 1306{
1303 KABC::Addressee addr; 1307 KABC::Addressee addr;
1304 mAConfig->setUid( mAddressee.uid() ); 1308 mAConfig->setUid( mAddressee.uid() );
1305 if ( mAConfig->automaticNameParsing() ) { 1309 if ( mAConfig->automaticNameParsing() ) {
1306 addr.setNameFromString( mNameEdit->text() ); 1310 addr.setNameFromString( mNameEdit->text() );
1307 mNameLabel->hide(); 1311 mNameLabel->hide();
1308 mNameEdit->show(); 1312 mNameEdit->show();
1309 } else { 1313 } else {
1310 addr = mAddressee; 1314 addr = mAddressee;
1311 mNameEdit->hide(); 1315 mNameEdit->hide();
1312 mNameLabel->setText( mNameEdit->text() ); 1316 mNameLabel->setText( mNameEdit->text() );
1313 mNameLabel->show(); 1317 mNameLabel->show();
1314 } 1318 }
1315 1319
1316 if ( mFormattedNameType != NameEditDialog::CustomName ) { 1320 if ( mFormattedNameType != NameEditDialog::CustomName ) {
1317 mFormattedNameLabel->setText( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); 1321 mFormattedNameLabel->setText( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) );
1318 mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); 1322 mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) );
1319 } 1323 }
1320} 1324}
1321 1325
1322void AddresseeEditorWidget::nameButtonClicked() 1326void AddresseeEditorWidget::nameButtonClicked()
1323{ 1327{
1324 // show the name dialog. 1328 // show the name dialog.
1325 NameEditDialog dialog( mAddressee, mFormattedNameType, this ); 1329 NameEditDialog dialog( mAddressee, mFormattedNameType, this );
1326 1330
1327 if ( KApplication::execDialog( &dialog) ) { 1331 if ( KApplication::execDialog( &dialog) ) {
1328 if ( dialog.changed() ) { 1332 if ( dialog.changed() ) {
1329 mAddressee.setFamilyName( dialog.familyName() ); 1333 mAddressee.setFamilyName( dialog.familyName() );
1330 mAddressee.setGivenName( dialog.givenName() ); 1334 mAddressee.setGivenName( dialog.givenName() );
1331 mAddressee.setPrefix( dialog.prefix() ); 1335 mAddressee.setPrefix( dialog.prefix() );
1332 mAddressee.setSuffix( dialog.suffix() ); 1336 mAddressee.setSuffix( dialog.suffix() );
1333 mAddressee.setAdditionalName( dialog.additionalName() ); 1337 mAddressee.setAdditionalName( dialog.additionalName() );
1334 mFormattedNameType = dialog.formattedNameType(); 1338 mFormattedNameType = dialog.formattedNameType();
1335 if ( mFormattedNameType == NameEditDialog::CustomName ) { 1339 if ( mFormattedNameType == NameEditDialog::CustomName ) {
1336 mFormattedNameLabel->setText( dialog.customFormattedName() ); 1340 mFormattedNameLabel->setText( dialog.customFormattedName() );
1337 mAddressee.setFormattedName( dialog.customFormattedName() ); 1341 mAddressee.setFormattedName( dialog.customFormattedName() );
1338 } 1342 }
1339 // Update the name edit. 1343 // Update the name edit.
1340 bool block = mNameEdit->signalsBlocked(); 1344 bool block = mNameEdit->signalsBlocked();
1341 mNameEdit->blockSignals( true ); 1345 mNameEdit->blockSignals( true );
1342 mNameEdit->setText( mAddressee.assembledName() ); 1346 mNameEdit->setText( mAddressee.assembledName() );
1343 mNameEdit->blockSignals( block ); 1347 mNameEdit->blockSignals( block );
1344 1348
1345 // Update the combo box. 1349 // Update the combo box.
1346 nameBoxChanged(); 1350 nameBoxChanged();
1347 1351
1348 emitModified(); 1352 emitModified();
1349 } 1353 }
1350 } 1354 }
1351} 1355}
1352 1356
1353void AddresseeEditorWidget::categoryButtonClicked() 1357void AddresseeEditorWidget::categoryButtonClicked()
1354{ 1358{
1355 // Show the category dialog 1359 // Show the category dialog
1356 if ( mCategoryDialog == 0 ) { 1360 if ( mCategoryDialog == 0 ) {
1357 mCategoryDialog = new KPIM::CategorySelectDialog( KABPrefs::instance(), this ); 1361 mCategoryDialog = new KPIM::CategorySelectDialog( KABPrefs::instance(), this );
1358 connect( mCategoryDialog, SIGNAL( categoriesSelected( const QStringList& ) ), 1362 connect( mCategoryDialog, SIGNAL( categoriesSelected( const QStringList& ) ),
1359 SLOT(categoriesSelected( const QStringList& ) ) ); 1363 SLOT(categoriesSelected( const QStringList& ) ) );
1360 connect( mCategoryDialog, SIGNAL( editCategories() ), SLOT( editCategories() ) ); 1364 connect( mCategoryDialog, SIGNAL( editCategories() ), SLOT( editCategories() ) );
1361 } 1365 }
1362 1366
1363 mCategoryDialog->setCategories(); 1367 mCategoryDialog->setCategories();
1364 mCategoryDialog->setSelected( QStringList::split( ",", mCategoryEdit->text() ) ); 1368 mCategoryDialog->setSelected( QStringList::split( ",", mCategoryEdit->text() ) );
1365 mCategoryDialog->show(); 1369 mCategoryDialog->show();
1366 mCategoryDialog->raise(); 1370 mCategoryDialog->raise();
1367} 1371}
1368 1372
1369void AddresseeEditorWidget::categoriesSelected( const QStringList &list ) 1373void AddresseeEditorWidget::categoriesSelected( const QStringList &list )
1370{ 1374{
1371 mCategoryEdit->setText( list.join( "," ) ); 1375 mCategoryEdit->setText( list.join( "," ) );
1372} 1376}
1373 1377
1374void AddresseeEditorWidget::editCategories() 1378void AddresseeEditorWidget::editCategories()
1375{ 1379{
1376 if ( mCategoryEditDialog == 0 ) { 1380 if ( mCategoryEditDialog == 0 ) {
1377 mCategoryEditDialog = new KPIM::CategoryEditDialog( KABPrefs::instance(), this ); 1381 mCategoryEditDialog = new KPIM::CategoryEditDialog( KABPrefs::instance(), this );
1378 connect( mCategoryEditDialog, SIGNAL( categoryConfigChanged() ), 1382 connect( mCategoryEditDialog, SIGNAL( categoryConfigChanged() ),
1379 SLOT( categoryButtonClicked() ) ); 1383 SLOT( categoryButtonClicked() ) );
1380 } 1384 }
1381 1385
1382 mCategoryEditDialog->show(); 1386 mCategoryEditDialog->show();
1383 mCategoryEditDialog->raise(); 1387 mCategoryEditDialog->raise();
1384} 1388}
1385 1389
1386void AddresseeEditorWidget::emitModified() 1390void AddresseeEditorWidget::emitModified()
1387{ 1391{
1388 mDirty = true; 1392 mDirty = true;
1389 1393
1390 KABC::Addressee::List list; 1394 KABC::Addressee::List list;
1391 1395
1392 if ( mIsExtension && !mBlockSignals ) { 1396 if ( mIsExtension && !mBlockSignals ) {
1393 save(); 1397 save();
1394 list.append( mAddressee ); 1398 list.append( mAddressee );
1395 } 1399 }
1396 1400
1397 emit modified( list ); 1401 emit modified( list );
1398} 1402}
1399 1403
1400void AddresseeEditorWidget::dateChanged( QDate ) 1404void AddresseeEditorWidget::dateChanged( QDate )
1401{ 1405{
1402 emitModified(); 1406 emitModified();
1403} 1407}
1404 1408
1405//US invalid dates are handdled by the KDateEdit widget itself 1409//US invalid dates are handdled by the KDateEdit widget itself
1406void AddresseeEditorWidget::invalidDate() 1410void AddresseeEditorWidget::invalidDate()
1407{ 1411{
1408 KMessageBox::sorry( this, i18n( "You must specify a valid date" ) ); 1412 KMessageBox::sorry( this, i18n( "You must specify a valid date" ) );
1409} 1413}
1410 1414
1411 1415
1412void AddresseeEditorWidget::pageChanged( QWidget *wdg ) 1416void AddresseeEditorWidget::pageChanged( QWidget *wdg )
1413{ 1417{
1414#ifndef KAB_EMBEDDED 1418#ifndef KAB_EMBEDDED
1415 if ( wdg ) 1419 if ( wdg )
1416 KAcceleratorManager::manage( wdg ); 1420 KAcceleratorManager::manage( wdg );
1417#else //KAB_EMBEDDED 1421#else //KAB_EMBEDDED
1418//US 1422//US
1419#endif //KAB_EMBEDDED 1423#endif //KAB_EMBEDDED
1420 1424
1421} 1425}
1422 1426
1423QString AddresseeEditorWidget::title() const 1427QString AddresseeEditorWidget::title() const
1424{ 1428{
1425 return i18n( "Contact Editor" ); 1429 return i18n( "Contact Editor" );
1426} 1430}
1427 1431
1428QString AddresseeEditorWidget::identifier() const 1432QString AddresseeEditorWidget::identifier() const
1429{ 1433{
1430 return i18n( "contact_editor" ); 1434 return i18n( "contact_editor" );
1431} 1435}
1432 1436
1433#ifndef KAB_EMBEDDED 1437#ifndef KAB_EMBEDDED_
1434#include "addresseeeditorwidget.moc" 1438#include "moc_addresseeeditorwidget.cpp"
1435#endif //KAB_EMBEDDED 1439#endif //KAB_EMBEDDED
diff --git a/kaddressbook/addresseeeditorwidget.h b/kaddressbook/addresseeeditorwidget.h
index 816bbb5..aa1207e 100644
--- a/kaddressbook/addresseeeditorwidget.h
+++ b/kaddressbook/addresseeeditorwidget.h
@@ -1,193 +1,193 @@
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 ADDRESSEEEDITORWIDGET_H 24#ifndef ADDRESSEEEDITORWIDGET_H
25#define ADDRESSEEEDITORWIDGET_H 25#define ADDRESSEEEDITORWIDGET_H
26 26
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qpopupmenu.h> 28#include <q3popupmenu.h>
29#include <qcombobox.h> 29#include <qcombobox.h>
30 30
31#include <kabc/addressee.h> 31#include <kabc/addressee.h>
32#include <kdialogbase.h> 32#include <kdialogbase.h>
33#include <kjanuswidget.h> 33#include <kjanuswidget.h>
34 34
35#include "extensionwidget.h" 35#include "extensionwidget.h"
36 36
37class AddresseeConfig; 37class AddresseeConfig;
38class QCheckBox; 38class QCheckBox;
39class QSpinBox; 39class QSpinBox;
40class QTabWidget; 40class QTabWidget;
41 41
42#ifndef KAB_EMBEDDED 42#ifndef KAB_EMBEDDED
43class QTextEdit; 43class Q3TextEdit;
44#else //KAB_EMBEDDED 44#else //KAB_EMBEDDED
45class QMultiLineEdit; 45class Q3MultiLineEdit;
46#endif //KAB_EMBEDDED 46#endif //KAB_EMBEDDED
47 47
48class KComboBox; 48class KComboBox;
49class KDateEdit; 49class KDateEdit;
50class KLineEdit; 50class KLineEdit;
51class KSqueezedTextLabel; 51class KSqueezedTextLabel;
52 52
53class AddressEditWidget; 53class AddressEditWidget;
54class EmailEditWidget; 54class EmailEditWidget;
55class GeoWidget; 55class GeoWidget;
56class ImageWidget; 56class ImageWidget;
57class KABCore; 57class KABCore;
58class KeyWidget; 58class KeyWidget;
59class PhoneEditWidget; 59class PhoneEditWidget;
60class SecrecyWidget; 60class SecrecyWidget;
61class SoundWidget; 61class SoundWidget;
62 62
63namespace KPIM 63namespace KPIM
64{ 64{
65 class CategorySelectDialog; 65 class CategorySelectDialog;
66 class CategoryEditDialog; 66 class CategoryEditDialog;
67} 67}
68 68
69namespace KABC { class AddressBook; } 69namespace KABC { class AddressBook; }
70 70
71class AddresseeEditorWidget : public ExtensionWidget 71class AddresseeEditorWidget : public ExtensionWidget
72{ 72{
73 Q_OBJECT 73 Q_OBJECT
74 74
75 public: 75 public:
76 AddresseeEditorWidget( KABCore *core, bool isExtension, 76 AddresseeEditorWidget( KABCore *core, bool isExtension,
77 QWidget *parent, const char *name = 0 ); 77 QWidget *parent, const char *name = 0 );
78 ~AddresseeEditorWidget(); 78 ~AddresseeEditorWidget();
79 79
80 void setAddressee( const KABC::Addressee& ); 80 void setAddressee( const KABC::Addressee& );
81 const KABC::Addressee &addressee(); 81 const KABC::Addressee &addressee();
82 82
83 void contactsSelectionChanged(); 83 void contactsSelectionChanged();
84 84
85 void load(); 85 void load();
86 void save(); 86 void save();
87 87
88 bool dirty(); 88 bool dirty();
89 89
90 QString title() const; 90 QString title() const;
91 QString identifier() const; 91 QString identifier() const;
92 92
93 protected slots: 93 protected slots:
94 void showCatPopup(); 94 void showCatPopup();
95 void selectedCatPopup( int ); 95 void selectedCatPopup( int );
96 void setRole2FN(); 96 void setRole2FN();
97 void setCompany2FN(); 97 void setCompany2FN();
98 void textChanged( const QString& ); 98 void textChanged( const QString& );
99 void pageChanged( QWidget *wdg ); 99 void pageChanged( QWidget *wdg );
100 100
101 /** 101 /**
102 Emits the modified signal and sets the dirty flag. Any slot 102 Emits the modified signal and sets the dirty flag. Any slot
103 that modifies data should use this method instead of calling emit 103 that modifies data should use this method instead of calling emit
104 modified() directly. 104 modified() directly.
105 */ 105 */
106 void emitModified(); 106 void emitModified();
107 107
108 void dateChanged( QDate ); 108 void dateChanged( QDate );
109 void invalidDate(); 109 void invalidDate();
110 void nameTextChanged( const QString& ); 110 void nameTextChanged( const QString& );
111 void nameBoxChanged(); 111 void nameBoxChanged();
112 void nameButtonClicked(); 112 void nameButtonClicked();
113 void categoryButtonClicked(); 113 void categoryButtonClicked();
114 114
115 /** 115 /**
116 Called whenever the categories change in the categories dialog. 116 Called whenever the categories change in the categories dialog.
117 */ 117 */
118 void categoriesSelected( const QStringList& ); 118 void categoriesSelected( const QStringList& );
119 119
120 /** 120 /**
121 Edits which categories are available in the CategorySelectDialog. 121 Edits which categories are available in the CategorySelectDialog.
122 */ 122 */
123 void editCategories(); 123 void editCategories();
124 124
125 private: 125 private:
126 AddresseeConfig * mAConfig; 126 AddresseeConfig * mAConfig;
127 void initGUI(); 127 void initGUI();
128 void setupTab1(); 128 void setupTab1();
129 void setupTab1_1(); 129 void setupTab1_1();
130 void setupTab2(); 130 void setupTab2();
131 void setupTab2_1(); 131 void setupTab2_1();
132 void setupTab3(); 132 void setupTab3();
133 void setupTab3_1(); 133 void setupTab3_1();
134 134
135 KABC::Addressee mAddressee; 135 KABC::Addressee mAddressee;
136 int mFormattedNameType; 136 int mFormattedNameType;
137 bool mDirty; 137 bool mDirty;
138 bool mIsExtension; 138 bool mIsExtension;
139 bool mBlockSignals; 139 bool mBlockSignals;
140 140
141 // GUI 141 // GUI
142 KPIM::CategorySelectDialog *mCategoryDialog; 142 KPIM::CategorySelectDialog *mCategoryDialog;
143 KPIM::CategoryEditDialog *mCategoryEditDialog; 143 KPIM::CategoryEditDialog *mCategoryEditDialog;
144 QTabWidget *mTabWidget; 144 QTabWidget *mTabWidget;
145 145
146 // Tab1 and Tab1_1 146 // Tab1 and Tab1_1
147 KLineEdit *mNameEdit; 147 KLineEdit *mNameEdit;
148 KLineEdit *mRoleEdit; 148 KLineEdit *mRoleEdit;
149 KLineEdit *mOrgEdit; 149 KLineEdit *mOrgEdit;
150 150
151 KSqueezedTextLabel *mFormattedNameLabel; 151 KSqueezedTextLabel *mFormattedNameLabel;
152 AddressEditWidget *mAddressEditWidget; 152 AddressEditWidget *mAddressEditWidget;
153 EmailEditWidget *mEmailWidget; 153 EmailEditWidget *mEmailWidget;
154 PhoneEditWidget *mPhoneEditWidget; 154 PhoneEditWidget *mPhoneEditWidget;
155 KLineEdit *mURLEdit; 155 KLineEdit *mURLEdit;
156 KLineEdit *mIMAddressEdit; 156 KLineEdit *mIMAddressEdit;
157 QPushButton *mCategoryEdit; 157 QPushButton *mCategoryEdit;
158 QPopupMenu *mCatPopup; 158 Q3PopupMenu *mCatPopup;
159 SecrecyWidget *mSecrecyWidget; 159 SecrecyWidget *mSecrecyWidget;
160 KSqueezedTextLabel *mNameLabel; 160 KSqueezedTextLabel *mNameLabel;
161 161
162 // Tab2 and Tab2_2 162 // Tab2 and Tab2_2
163 KLineEdit *mDepartmentEdit; 163 KLineEdit *mDepartmentEdit;
164 KLineEdit *mOfficeEdit; 164 KLineEdit *mOfficeEdit;
165 KLineEdit *mProfessionEdit; 165 KLineEdit *mProfessionEdit;
166 KLineEdit *mManagerEdit; 166 KLineEdit *mManagerEdit;
167 KLineEdit *mAssistantEdit; 167 KLineEdit *mAssistantEdit;
168 KLineEdit *mNicknameEdit; 168 KLineEdit *mNicknameEdit;
169 KLineEdit *mSpouseEdit; 169 KLineEdit *mSpouseEdit;
170 KLineEdit *mChildEdit; 170 KLineEdit *mChildEdit;
171 QComboBox *mGenderBox; 171 QComboBox *mGenderBox;
172 KDateEdit *mBirthdayPicker; 172 KDateEdit *mBirthdayPicker;
173 KDateEdit *mAnniversaryPicker; 173 KDateEdit *mAnniversaryPicker;
174#ifndef KAB_EMBEDDED 174#ifndef KAB_EMBEDDED
175 QTextEdit *mNoteEdit; 175 Q3TextEdit *mNoteEdit;
176#else //KAB_EMBEDDED 176#else //KAB_EMBEDDED
177 QMultiLineEdit *mNoteEdit; 177 Q3MultiLineEdit *mNoteEdit;
178#endif //KAB_EMBEDDED 178#endif //KAB_EMBEDDED
179 179
180 QSpinBox *mTimeZoneSpin; 180 QSpinBox *mTimeZoneSpin;
181 QSpinBox *mGeoLat; 181 QSpinBox *mGeoLat;
182 QSpinBox *mGeoLon; 182 QSpinBox *mGeoLon;
183 183
184 // Tab3 184 // Tab3
185 GeoWidget *mGeoWidget; 185 GeoWidget *mGeoWidget;
186 ImageWidget *mImageWidget; 186 ImageWidget *mImageWidget;
187#ifndef KAB_EMBEDDED 187#ifndef KAB_EMBEDDED
188 SoundWidget *mSoundWidget; 188 SoundWidget *mSoundWidget;
189#endif //KAB_EMBEDDED 189#endif //KAB_EMBEDDED
190 KeyWidget *mKeyWidget; 190 KeyWidget *mKeyWidget;
191}; 191};
192 192
193#endif 193#endif
diff --git a/kaddressbook/addresseeutil.cpp b/kaddressbook/addresseeutil.cpp
index 366384a..a860f6d 100644
--- a/kaddressbook/addresseeutil.cpp
+++ b/kaddressbook/addresseeutil.cpp
@@ -1,66 +1,66 @@
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#include <kabc/stdaddressbook.h> 24#include <kabc/stdaddressbook.h>
25#include <kabc/vcardconverter.h> 25#include <kabc/vcardconverter.h>
26#include <kdebug.h> 26#include <kdebug.h>
27#include <klocale.h> 27#include <klocale.h>
28#include <kmessagebox.h> 28#include <kmessagebox.h>
29 29
30#include "addresseeutil.h" 30#include "addresseeutil.h"
31 31
32QString AddresseeUtil::addresseesToClipboard( const KABC::Addressee::List &list ) 32QString AddresseeUtil::addresseesToClipboard( const KABC::Addressee::List &list )
33{ 33{
34 KABC::VCardConverter converter; 34 KABC::VCardConverter converter;
35 QString vcard; 35 QString vcard;
36 36
37 KABC::Addressee::List::ConstIterator it; 37 KABC::Addressee::List::ConstIterator it;
38 for ( it = list.begin(); it != list.end(); ++it ) { 38 for ( it = list.begin(); it != list.end(); ++it ) {
39 QString tmp; 39 QString tmp;
40 if ( converter.addresseeToVCard( *it, tmp ) ) 40 if ( converter.addresseeToVCard( *it, tmp ) )
41 vcard += tmp + "\r\n"; 41 vcard += tmp + "\r\n";
42 } 42 }
43 43
44 return vcard; 44 return vcard;
45} 45}
46 46
47KABC::Addressee::List AddresseeUtil::clipboardToAddressees( const QString &data ) 47KABC::Addressee::List AddresseeUtil::clipboardToAddressees( const QString &data )
48{ 48{
49 uint numVCards = data.contains( "BEGIN:VCARD", false ); 49 uint numVCards = data.count( "BEGIN:VCARD", Qt::CaseInsensitive );
50 QStringList dataList = QStringList::split( "\r\n\r\n", data ); 50 QStringList dataList = QStringList::split( "\r\n\r\n", data );
51 51
52 KABC::Addressee::List addrList; 52 KABC::Addressee::List addrList;
53 for ( uint i = 0; i < numVCards && i < dataList.count(); ++i ) { 53 for ( uint i = 0; i < numVCards && i < dataList.count(); ++i ) {
54 KABC::VCardConverter converter; 54 KABC::VCardConverter converter;
55 KABC::Addressee addr; 55 KABC::Addressee addr;
56 56
57 if ( !converter.vCardToAddressee( dataList[ i ].stripWhiteSpace(), addr ) ) { 57 if ( !converter.vCardToAddressee( dataList[ i ].stripWhiteSpace(), addr ) ) {
58 KMessageBox::error( 0, i18n( "Invalid vCard format in clipboard" ) ); 58 KMessageBox::error( 0, i18n( "Invalid vCard format in clipboard" ) );
59 continue; 59 continue;
60 } 60 }
61 61
62 addrList.append( addr ); 62 addrList.append( addr );
63 } 63 }
64 64
65 return addrList; 65 return addrList;
66} 66}
diff --git a/kaddressbook/addviewdialog.cpp b/kaddressbook/addviewdialog.cpp
index 6def26b..b52a83c 100644
--- a/kaddressbook/addviewdialog.cpp
+++ b/kaddressbook/addviewdialog.cpp
@@ -1,118 +1,120 @@
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 KAB_EMBEDDED 24#ifndef KAB_EMBEDDED
25#endif //KAB_EMBEDDED 25#endif //KAB_EMBEDDED
26 26
27#include <qradiobutton.h> 27#include <qradiobutton.h>
28#include <qbuttongroup.h> 28#include <q3buttongroup.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qlineedit.h> 30#include <qlineedit.h>
31#include <qlayout.h> 31#include <qlayout.h>
32//Added by qt3to4:
33#include <Q3GridLayout>
32 34
33#include <klocale.h> 35#include <klocale.h>
34#include <kglobal.h> 36#include <kglobal.h>
35#include "kaddressbookview.h" 37#include "kaddressbookview.h"
36#include "addviewdialog.h" 38#include "addviewdialog.h"
37 39
38AddViewDialog::AddViewDialog( QDict<ViewFactory> *viewFactoryDict, 40AddViewDialog::AddViewDialog( Q3Dict<ViewFactory> *viewFactoryDict,
39 QWidget *parent, const char *name ) 41 QWidget *parent, const char *name )
40 : KDialogBase( KDialogBase::Plain, i18n( "Add View" ), 42 : KDialogBase( KDialogBase::Plain, i18n( "Add View" ),
41 KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, 43 KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok,
42 parent, name ), 44 parent, name ),
43 mViewFactoryDict( viewFactoryDict ) 45 mViewFactoryDict( viewFactoryDict )
44{ 46{
45//US setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 300), KMIN(KGlobal::getDesktopHeight(), 300)); 47//US setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 300), KMIN(KGlobal::getDesktopHeight(), 300));
46 48
47 mTypeId = 0; 49 mTypeId = 0;
48 50
49 QWidget *page = plainPage(); 51 QWidget *page = plainPage();
50 52
51 QGridLayout *layout = new QGridLayout( page, 2, 2 ); 53 Q3GridLayout *layout = new Q3GridLayout( page, 2, 2 );
52 layout->setSpacing( spacingHint() ); 54 layout->setSpacing( spacingHint() );
53 layout->setRowStretch( 1, 1 ); 55 layout->setRowStretch( 1, 1 );
54 layout->setColStretch( 1, 1 ); 56 layout->setColStretch( 1, 1 );
55 57
56 QLabel *label = new QLabel( i18n( "View name:" ), page ); 58 QLabel *label = new QLabel( i18n( "View name:" ), page );
57 layout->addWidget( label, 0, 0 ); 59 layout->addWidget( label, 0, 0 );
58 60
59 mViewNameEdit = new QLineEdit( page ); 61 mViewNameEdit = new QLineEdit( page );
60 connect( mViewNameEdit, SIGNAL( textChanged( const QString& ) ), 62 connect( mViewNameEdit, SIGNAL( textChanged( const QString& ) ),
61 SLOT( textChanged( const QString& ) ) ); 63 SLOT( textChanged( const QString& ) ) );
62 layout->addWidget( mViewNameEdit, 0, 1 ); 64 layout->addWidget( mViewNameEdit, 0, 1 );
63 65
64 mTypeGroup = new QButtonGroup( 2, Qt::Horizontal, i18n( "View Type" ), page ); 66 mTypeGroup = new Q3ButtonGroup( 2, Qt::Horizontal, i18n( "View Type" ), page );
65 connect( mTypeGroup, SIGNAL( clicked( int ) ), this, SLOT( clicked( int ) ) ); 67 connect( mTypeGroup, SIGNAL( clicked( int ) ), this, SLOT( clicked( int ) ) );
66 layout->addMultiCellWidget( mTypeGroup, 1, 1, 0, 1 ); 68 layout->addMultiCellWidget( mTypeGroup, 1, 1, 0, 1 );
67 69
68 // Now create the radio buttons. This needs some layout work. 70 // Now create the radio buttons. This needs some layout work.
69 QDictIterator<ViewFactory> iter( *mViewFactoryDict ); 71 Q3DictIterator<ViewFactory> iter( *mViewFactoryDict );
70 for ( iter.toFirst(); iter.current(); ++iter ) { 72 for ( iter.toFirst(); iter.current(); ++iter ) {
71//US i am not quit sure, why I can nopt use (*iter)-> here 73//US i am not quit sure, why I can nopt use (*iter)-> here
72//US new QRadioButton( (*iter)->type(), mTypeGroup ); 74//US new QRadioButton( (*iter)->type(), mTypeGroup );
73//US label = new QLabel( (*iter)->description(), mTypeGroup ); 75//US label = new QLabel( (*iter)->description(), mTypeGroup );
74#ifdef DESKTOP_VERSION 76#ifdef DESKTOP_VERSION
75 new QRadioButton( (*iter)->type(), mTypeGroup ); 77 new QRadioButton( (*iter)->type(), mTypeGroup );
76 label = new QLabel( (*iter)->description(), mTypeGroup ); 78 label = new QLabel( (*iter)->description(), mTypeGroup );
77#else 79#else
78 new QRadioButton( (*iter).type(), mTypeGroup ); 80 new QRadioButton( (*iter).type(), mTypeGroup );
79 label = new QLabel( (*iter).description(), mTypeGroup ); 81 label = new QLabel( (*iter).description(), mTypeGroup );
80 82
81#endif 83#endif
82 label->setAlignment( Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak ); 84 label->setAlignment( Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak );
83 } 85 }
84 86
85 mTypeGroup->setButton( 0 ); 87 mTypeGroup->setButton( 0 );
86 mViewNameEdit->setFocus(); 88 mViewNameEdit->setFocus();
87 enableButton( KDialogBase::Ok, false ); 89 enableButton( KDialogBase::Ok, false );
88 90
89 91
90} 92}
91 93
92AddViewDialog::~AddViewDialog() 94AddViewDialog::~AddViewDialog()
93{ 95{
94} 96}
95 97
96QString AddViewDialog::viewName()const 98QString AddViewDialog::viewName()const
97{ 99{
98 return mViewNameEdit->text(); 100 return mViewNameEdit->text();
99} 101}
100 102
101QString AddViewDialog::viewType()const 103QString AddViewDialog::viewType()const
102{ 104{
103 return mTypeGroup->find( mTypeId )->text(); 105 return mTypeGroup->find( mTypeId )->text();
104} 106}
105 107
106void AddViewDialog::clicked( int id ) 108void AddViewDialog::clicked( int id )
107{ 109{
108 mTypeId = id; 110 mTypeId = id;
109} 111}
110 112
111void AddViewDialog::textChanged( const QString &text ) 113void AddViewDialog::textChanged( const QString &text )
112{ 114{
113 enableButton( KDialogBase::Ok, !text.isEmpty() ); 115 enableButton( KDialogBase::Ok, !text.isEmpty() );
114} 116}
115 117
116#ifndef KAB_EMBEDDED 118#ifndef KAB_EMBEDDED_
117#include "addviewdialog.moc" 119#include "moc_addviewdialog.cpp"
118#endif //KAB_EMBEDDED 120#endif //KAB_EMBEDDED
diff --git a/kaddressbook/addviewdialog.h b/kaddressbook/addviewdialog.h
index 8cc12f5..c3e8efd 100644
--- a/kaddressbook/addviewdialog.h
+++ b/kaddressbook/addviewdialog.h
@@ -1,73 +1,73 @@
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 ADDVIEWDIALOG_H 24#ifndef ADDVIEWDIALOG_H
25#define ADDVIEWDIALOG_H 25#define ADDVIEWDIALOG_H
26 26
27#include <kdialogbase.h> 27#include <kdialogbase.h>
28#include <qdict.h> 28#include <q3dict.h>
29#include <qstring.h> 29#include <qstring.h>
30 30
31class ViewFactory; 31class ViewFactory;
32class QButtonGroup; 32class Q3ButtonGroup;
33class QLineEdit; 33class QLineEdit;
34 34
35 35
36/** 36/**
37 Modal dialog used for adding a new view. The dialog asks for the name of 37 Modal dialog used for adding a new view. The dialog asks for the name of
38 the view as well as the type. Someday it would be nice for this to be a 38 the view as well as the type. Someday it would be nice for this to be a
39 wizard. 39 wizard.
40 */ 40 */
41class AddViewDialog : public KDialogBase 41class AddViewDialog : public KDialogBase
42{ 42{
43 Q_OBJECT 43 Q_OBJECT
44 44
45 public: 45 public:
46 AddViewDialog( QDict<ViewFactory> *viewFactoryDict, QWidget *parent, 46 AddViewDialog( Q3Dict<ViewFactory> *viewFactoryDict, QWidget *parent,
47 const char *name = 0 ); 47 const char *name = 0 );
48 ~AddViewDialog(); 48 ~AddViewDialog();
49 49
50 QString viewName()const; 50 QString viewName()const;
51 51
52 QString viewType()const ; 52 QString viewType()const ;
53 53
54 protected slots: 54 protected slots:
55 /** 55 /**
56 Called when the user selects a type radio button. 56 Called when the user selects a type radio button.
57 */ 57 */
58 void clicked( int id ); 58 void clicked( int id );
59 59
60 /** 60 /**
61 Called when the user changes the text in the name of the view. 61 Called when the user changes the text in the name of the view.
62 */ 62 */
63 void textChanged( const QString &text ); 63 void textChanged( const QString &text );
64 64
65 private: 65 private:
66 QDict<ViewFactory> *mViewFactoryDict; 66 Q3Dict<ViewFactory> *mViewFactoryDict;
67 QLineEdit *mViewNameEdit; 67 QLineEdit *mViewNameEdit;
68 QButtonGroup *mTypeGroup; 68 Q3ButtonGroup *mTypeGroup;
69 69
70 int mTypeId; 70 int mTypeId;
71}; 71};
72 72
73#endif 73#endif
diff --git a/kaddressbook/details/detailsviewcontainer.cpp b/kaddressbook/details/detailsviewcontainer.cpp
index cee5886..4a86aca 100644
--- a/kaddressbook/details/detailsviewcontainer.cpp
+++ b/kaddressbook/details/detailsviewcontainer.cpp
@@ -1,164 +1,167 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 1996-2002 Mirko Boehm <mirko@kde.org> 3 Copyright (c) 1996-2002 Mirko Boehm <mirko@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 <qcombobox.h> 24#include <qcombobox.h>
25#include <qframe.h> 25#include <q3frame.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qwidgetstack.h> 28#include <q3widgetstack.h>
29//Added by qt3to4:
30#include <Q3HBoxLayout>
31#include <Q3VBoxLayout>
29 32
30#include <kapplication.h> 33#include <kapplication.h>
31#include <kdebug.h> 34#include <kdebug.h>
32#include <kdialog.h> 35#include <kdialog.h>
33 36
34#include "look_basic.h" 37#include "look_basic.h"
35//#include "look_details.h" 38//#include "look_details.h"
36#include "look_html.h" 39#include "look_html.h"
37 40
38#ifdef KAB_EMBEDDED 41#ifdef KAB_EMBEDDED
39#include "kabprefs.h" 42#include "kabprefs.h"
40#endif //KAB_EMBEDDED 43#endif //KAB_EMBEDDED
41 44
42 45
43#include "detailsviewcontainer.h" 46#include "detailsviewcontainer.h"
44 47
45ViewContainer::ViewContainer( QWidget *parent, const char* name ) 48ViewContainer::ViewContainer( QWidget *parent, const char* name )
46 : QWidget( parent, name ), mCurrentLook( 0 ) 49 : QWidget( parent, name ), mCurrentLook( 0 )
47{ 50{
48 QBoxLayout *topLayout = new QVBoxLayout( this ); 51 Q3BoxLayout *topLayout = new Q3VBoxLayout( this );
49 //topLayout->setMargin( KDialog::marginHint() ); 52 //topLayout->setMargin( KDialog::marginHint() );
50 //topLayout->setSpacing( KDialog::spacingHint() ); 53 //topLayout->setSpacing( KDialog::spacingHint() );
51 topLayout->setMargin( 0 ); 54 topLayout->setMargin( 0 );
52 topLayout->setSpacing( 0 ); 55 topLayout->setSpacing( 0 );
53 56
54 QBoxLayout *styleLayout = new QHBoxLayout( topLayout ); 57 Q3BoxLayout *styleLayout = new Q3HBoxLayout( topLayout );
55 58
56 QLabel *label = new QLabel( i18n("Style:"), this ); 59 QLabel *label = new QLabel( i18n("Style:"), this );
57 styleLayout->addWidget( label ); 60 styleLayout->addWidget( label );
58 61
59 mStyleCombo = new QComboBox( this ); 62 mStyleCombo = new QComboBox( this );
60 styleLayout->addWidget( mStyleCombo ); 63 styleLayout->addWidget( mStyleCombo );
61 64
62 QFrame *frameRuler = new QFrame( this ); 65 Q3Frame *frameRuler = new Q3Frame( this );
63//US frameRuler->setFrameShape( QFrame::HLine ); 66//US frameRuler->setFrameShape( QFrame::HLine );
64//US frameRuler->setFrameShadow( QFrame::Sunken ); 67//US frameRuler->setFrameShadow( QFrame::Sunken );
65//US topLayout->addWidget( frameRuler ); 68//US topLayout->addWidget( frameRuler );
66 69
67 mDetailsStack = new QWidgetStack( this ); 70 mDetailsStack = new Q3WidgetStack( this );
68 topLayout->addWidget( mDetailsStack, 1 ); 71 topLayout->addWidget( mDetailsStack, 1 );
69 72
70 registerLooks(); 73 registerLooks();
71 74
72#if 1 75#if 1
73 // Hide detailed view selection combo box, because we currently have 76 // Hide detailed view selection combo box, because we currently have
74 // only one. Reenable it when there are more detailed views. 77 // only one. Reenable it when there are more detailed views.
75 label->hide(); 78 label->hide();
76 mStyleCombo->hide(); 79 mStyleCombo->hide();
77 frameRuler->hide(); 80 frameRuler->hide();
78#endif 81#endif
79} 82}
80 83
81void ViewContainer::printView() 84void ViewContainer::printView()
82{ 85{
83 mCurrentLook->printView(); 86 mCurrentLook->printView();
84} 87}
85KABBasicLook *ViewContainer::currentLook() 88KABBasicLook *ViewContainer::currentLook()
86{ 89{
87 return mCurrentLook; 90 return mCurrentLook;
88} 91}
89 92
90void ViewContainer::registerLooks() 93void ViewContainer::registerLooks()
91{ 94{
92 mLookFactories.append( new KABHtmlViewFactory( mDetailsStack ) ); 95 mLookFactories.append( new KABHtmlViewFactory( mDetailsStack ) );
93// mLookFactories.append( new KABDetailedViewFactory( mDetailsStack ) ); 96// mLookFactories.append( new KABDetailedViewFactory( mDetailsStack ) );
94 mStyleCombo->clear(); 97 mStyleCombo->clear();
95 98
96 for ( uint i = 0; i < mLookFactories.count(); ++i ) 99 for ( uint i = 0; i < mLookFactories.count(); ++i )
97 mStyleCombo->insertItem( mLookFactories.at( i )->description() ); 100 mStyleCombo->insertItem( mLookFactories.at( i )->description() );
98 101
99 if ( !mLookFactories.isEmpty() ) 102 if ( !mLookFactories.isEmpty() )
100 slotStyleSelected( 0 ); 103 slotStyleSelected( 0 );
101} 104}
102 105
103void ViewContainer::slotStyleSelected( int index ) 106void ViewContainer::slotStyleSelected( int index )
104{ 107{
105#ifndef KAB_EMBEDDED 108#ifndef KAB_EMBEDDED
106 KConfig *config = kapp->config(); 109 KConfig *config = kapp->config();
107#else //KAB_EMBEDDED 110#else //KAB_EMBEDDED
108 //US I hope I got the same config object as above expected. 111 //US I hope I got the same config object as above expected.
109 KConfig *config = KABPrefs::instance()->getConfig(); 112 KConfig *config = KABPrefs::instance()->getConfig();
110#endif //KAB_EMBEDDED 113#endif //KAB_EMBEDDED
111 KABC::Addressee addr; 114 KABC::Addressee addr;
112 115
113 if ( index >= 0 && index < mStyleCombo->count() ) { 116 if ( index >= 0 && index < mStyleCombo->count() ) {
114 if ( mCurrentLook != 0 ) { 117 if ( mCurrentLook != 0 ) {
115 mCurrentLook->saveSettings( config ); 118 mCurrentLook->saveSettings( config );
116 addr = mCurrentLook->addressee(); 119 addr = mCurrentLook->addressee();
117 120
118 delete mCurrentLook; 121 delete mCurrentLook;
119 mCurrentLook = 0; 122 mCurrentLook = 0;
120 } 123 }
121 124
122 KABLookFactory *factory = mLookFactories.at( index ); 125 KABLookFactory *factory = mLookFactories.at( index );
123 126
124 mCurrentLook = factory->create(); 127 mCurrentLook = factory->create();
125 mDetailsStack->raiseWidget( mCurrentLook ); 128 mDetailsStack->raiseWidget( mCurrentLook );
126 129
127 connect( mCurrentLook, SIGNAL( sendEmail( const QString& ) ), this, 130 connect( mCurrentLook, SIGNAL( sendEmail( const QString& ) ), this,
128 SIGNAL( sendEmail( const QString& ) ) ); 131 SIGNAL( sendEmail( const QString& ) ) );
129 connect( mCurrentLook, SIGNAL( browse( const QString& ) ), this, 132 connect( mCurrentLook, SIGNAL( browse( const QString& ) ), this,
130 SIGNAL( browse( const QString& ) ) ); 133 SIGNAL( browse( const QString& ) ) );
131 } 134 }
132 135
133 mCurrentLook->restoreSettings( config ); 136 mCurrentLook->restoreSettings( config );
134 mCurrentLook->setAddressee( addr ); 137 mCurrentLook->setAddressee( addr );
135} 138}
136 139
137void ViewContainer::setAddressee( const KABC::Addressee& addressee ) 140void ViewContainer::setAddressee( const KABC::Addressee& addressee )
138{ 141{
139 if ( mCurrentLook != 0 ) { 142 if ( mCurrentLook != 0 ) {
140 mCurrentAddressee = addressee; 143 mCurrentAddressee = addressee;
141 mCurrentLook->setAddressee( mCurrentAddressee ); 144 mCurrentLook->setAddressee( mCurrentAddressee );
142 145
143 } 146 }
144} 147}
145 148
146KABC::Addressee ViewContainer::addressee() 149KABC::Addressee ViewContainer::addressee()
147{ 150{
148 static KABC::Addressee empty; // do not use! 151 static KABC::Addressee empty; // do not use!
149 152
150 if ( !mCurrentLook ) 153 if ( !mCurrentLook )
151 return empty; 154 return empty;
152 else 155 else
153 return mCurrentLook->addressee(); 156 return mCurrentLook->addressee();
154} 157}
155 158
156void ViewContainer::setReadOnly( bool state ) 159void ViewContainer::setReadOnly( bool state )
157{ 160{
158 if ( mCurrentLook ) 161 if ( mCurrentLook )
159 mCurrentLook->setReadOnly( state ); 162 mCurrentLook->setReadOnly( state );
160} 163}
161 164
162#ifndef KAB_EMBEDDED 165#ifndef KAB_EMBEDDED_
163#include "detailsviewcontainer.moc" 166#include "moc_detailsviewcontainer.cpp"
164#endif //KAB_EMBEDDED 167#endif //KAB_EMBEDDED
diff --git a/kaddressbook/details/detailsviewcontainer.h b/kaddressbook/details/detailsviewcontainer.h
index 9684736..f310a30 100644
--- a/kaddressbook/details/detailsviewcontainer.h
+++ b/kaddressbook/details/detailsviewcontainer.h
@@ -1,103 +1,103 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 1996-2002 Mirko Boehm <mirko@kde.org> 3 Copyright (c) 1996-2002 Mirko Boehm <mirko@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#ifndef DETAILSVIEWCONTAINER_H 24#ifndef DETAILSVIEWCONTAINER_H
25#define DETAILSVIEWCONTAINER_H 25#define DETAILSVIEWCONTAINER_H
26 26
27#include <qptrlist.h> 27#include <q3ptrlist.h>
28 28
29#include "look_basic.h" 29#include "look_basic.h"
30 30
31class QComboBox; 31class QComboBox;
32class QWidgetStack; 32class Q3WidgetStack;
33 33
34class ViewContainer : public QWidget 34class ViewContainer : public QWidget
35{ 35{
36 Q_OBJECT 36 Q_OBJECT
37 37
38 public: 38 public:
39 ViewContainer( QWidget *parent = 0, const char* name = 0 ); 39 ViewContainer( QWidget *parent = 0, const char* name = 0 );
40 40
41 /** 41 /**
42 Return the look currently selected. If there is none, it 42 Return the look currently selected. If there is none, it
43 returns zero. Do not use this pointer to store a reference 43 returns zero. Do not use this pointer to store a reference
44 to a look, the user might select another one (e.g., create 44 to a look, the user might select another one (e.g., create
45 a new object) at any time. 45 a new object) at any time.
46 */ 46 */
47 KABBasicLook *currentLook(); 47 KABBasicLook *currentLook();
48 /** 48 /**
49 Return the contact currently displayed. 49 Return the contact currently displayed.
50 */ 50 */
51 KABC::Addressee addressee(); 51 KABC::Addressee addressee();
52 52
53 public slots: 53 public slots:
54 void printView(); 54 void printView();
55 /** 55 /**
56 Set the contact currently displayed. 56 Set the contact currently displayed.
57 */ 57 */
58 void setAddressee( const KABC::Addressee& addressee ); 58 void setAddressee( const KABC::Addressee& addressee );
59 59
60 /** 60 /**
61 Set read-write state. 61 Set read-write state.
62 */ 62 */
63 void setReadOnly( bool state ); 63 void setReadOnly( bool state );
64 64
65 signals: 65 signals:
66 /** 66 /**
67 The contact has been changed. 67 The contact has been changed.
68 */ 68 */
69 void addresseeChanged(); 69 void addresseeChanged();
70 70
71 /** 71 /**
72 The user acticated the email address displayed. This may happen 72 The user acticated the email address displayed. This may happen
73 by, for example, clicking on the displayed mailto-URL. 73 by, for example, clicking on the displayed mailto-URL.
74 */ 74 */
75 void sendEmail( const QString& ); 75 void sendEmail( const QString& );
76 76
77 /** 77 /**
78 The user activated one of the displayed HTTP URLs. For example 78 The user activated one of the displayed HTTP URLs. For example
79 by clicking on the displayed homepage address. 79 by clicking on the displayed homepage address.
80 */ 80 */
81 void browse( const QString& ); 81 void browse( const QString& );
82 82
83 protected: 83 protected:
84 /** 84 /**
85 A style has been selected. Overloaded from base class. 85 A style has been selected. Overloaded from base class.
86 */ 86 */
87 void slotStyleSelected( int ); 87 void slotStyleSelected( int );
88 88
89 /** 89 /**
90 Register the available looks. 90 Register the available looks.
91 */ 91 */
92 void registerLooks(); 92 void registerLooks();
93 93
94 private: 94 private:
95 KABC::Addressee mCurrentAddressee; 95 KABC::Addressee mCurrentAddressee;
96 KABBasicLook *mCurrentLook; 96 KABBasicLook *mCurrentLook;
97 QPtrList<KABLookFactory> mLookFactories; 97 Q3PtrList<KABLookFactory> mLookFactories;
98 98
99 QComboBox *mStyleCombo; 99 QComboBox *mStyleCombo;
100 QWidgetStack *mDetailsStack; 100 Q3WidgetStack *mDetailsStack;
101}; 101};
102 102
103#endif 103#endif
diff --git a/kaddressbook/details/look_basic.cpp b/kaddressbook/details/look_basic.cpp
index 0245686..48cc42a 100644
--- a/kaddressbook/details/look_basic.cpp
+++ b/kaddressbook/details/look_basic.cpp
@@ -1,75 +1,75 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 1996-2002 Mirko Boehm <mirko@kde.org> 3 Copyright (c) 1996-2002 Mirko Boehm <mirko@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 <kdebug.h> 24#include <kdebug.h>
25 25
26#include "look_basic.h" 26#include "look_basic.h"
27 27
28KABBasicLook::KABBasicLook( QWidget *parent, const char *name ) 28KABBasicLook::KABBasicLook( QWidget *parent, const char *name )
29 : QVBox( parent, name ), mReadOnly( false ) 29 : Q3VBox( parent, name ), mReadOnly( false )
30{ 30{
31} 31}
32 32
33void KABBasicLook::setReadOnly( bool state ) 33void KABBasicLook::setReadOnly( bool state )
34{ 34{
35 mReadOnly = state; 35 mReadOnly = state;
36} 36}
37 37
38bool KABBasicLook::isReadOnly() const 38bool KABBasicLook::isReadOnly() const
39{ 39{
40 return mReadOnly; 40 return mReadOnly;
41} 41}
42 42
43void KABBasicLook::setAddressee( const KABC::Addressee &addr ) 43void KABBasicLook::setAddressee( const KABC::Addressee &addr )
44{ 44{
45 if ( mAddressee == addr ) 45 if ( mAddressee == addr )
46 return; 46 return;
47 47
48 mAddressee = addr; 48 mAddressee = addr;
49 repaint( false ); 49 repaint( false );
50} 50}
51 51
52KABC::Addressee KABBasicLook::addressee() 52KABC::Addressee KABBasicLook::addressee()
53{ 53{
54 return mAddressee; 54 return mAddressee;
55} 55}
56 56
57void KABBasicLook::restoreSettings( KConfig* ) 57void KABBasicLook::restoreSettings( KConfig* )
58{ 58{
59} 59}
60 60
61void KABBasicLook::saveSettings( KConfig* ) 61void KABBasicLook::saveSettings( KConfig* )
62{ 62{
63} 63}
64 64
65KABLookFactory::KABLookFactory( QWidget *parent, const char *name ) 65KABLookFactory::KABLookFactory( QWidget *parent, const char *name )
66 : mParent( parent ), mName( name ) 66 : mParent( parent ), mName( name )
67{ 67{
68} 68}
69 69
70KABLookFactory::~KABLookFactory() 70KABLookFactory::~KABLookFactory()
71{ 71{
72} 72}
73#ifndef KAB_EMBEDDED 73#ifndef KAB_EMBEDDED_
74#include "look_basic.moc" 74#include "moc_look_basic.cpp"
75#endif //KAB_EMBEDDED 75#endif //KAB_EMBEDDED
diff --git a/kaddressbook/details/look_basic.h b/kaddressbook/details/look_basic.h
index a65c99c..a70e7f7 100644
--- a/kaddressbook/details/look_basic.h
+++ b/kaddressbook/details/look_basic.h
@@ -1,136 +1,136 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 1996-2002 Mirko Boehm <mirko@kde.org> 3 Copyright (c) 1996-2002 Mirko Boehm <mirko@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#ifndef LOOK_KABBASIC_H 24#ifndef LOOK_KABBASIC_H
25#define LOOK_KABBASIC_H 25#define LOOK_KABBASIC_H
26 26
27#include <kabc/addressbook.h> 27#include <kabc/addressbook.h>
28#include <qvbox.h> 28#include <q3vbox.h>
29 29
30class KConfig; 30class KConfig;
31 31
32/** 32/**
33 This is a pure virtual base class that defines the 33 This is a pure virtual base class that defines the
34 interface for how to display and change entries of 34 interface for how to display and change entries of
35 the KDE addressbook. 35 the KDE addressbook.
36 36
37 This basic widget does not show anything in its client space. 37 This basic widget does not show anything in its client space.
38 Derive it and implement its look and how the user may edit the 38 Derive it and implement its look and how the user may edit the
39 entry. 39 entry.
40 40
41 The paintEvent() has to paint the whole widget, since repaint() 41 The paintEvent() has to paint the whole widget, since repaint()
42 calls will not delete the widgets background. 42 calls will not delete the widgets background.
43 */ 43 */
44class KABBasicLook : public QVBox 44class KABBasicLook : public Q3VBox
45{ 45{
46 Q_OBJECT 46 Q_OBJECT
47 47
48 public: 48 public:
49 /** 49 /**
50 The constructor. 50 The constructor.
51 */ 51 */
52 KABBasicLook( QWidget *parent = 0, const char *name = 0 ); 52 KABBasicLook( QWidget *parent = 0, const char *name = 0 );
53 53
54 /** 54 /**
55 Set the entry. It will be displayed automatically. 55 Set the entry. It will be displayed automatically.
56 */ 56 */
57 virtual void setAddressee( const KABC::Addressee& addressee ); 57 virtual void setAddressee( const KABC::Addressee& addressee );
58 58
59 /** 59 /**
60 Get the current entry. 60 Get the current entry.
61 */ 61 */
62 virtual KABC::Addressee addressee(); 62 virtual KABC::Addressee addressee();
63 63
64 /** 64 /**
65 Configure the view from the configuration file. 65 Configure the view from the configuration file.
66 */ 66 */
67 virtual void restoreSettings( KConfig* ); 67 virtual void restoreSettings( KConfig* );
68 68
69 /** 69 /**
70 Save the view settings to the configuration file. 70 Save the view settings to the configuration file.
71 */ 71 */
72 virtual void saveSettings( KConfig* ); 72 virtual void saveSettings( KConfig* );
73 73
74 /** 74 /**
75 Retrieve read-write state. 75 Retrieve read-write state.
76 */ 76 */
77 bool isReadOnly() const; 77 bool isReadOnly() const;
78 void printView(){ emit printMyView();} 78 void printView(){ emit printMyView();}
79 79
80 signals: 80 signals:
81 void printMyView(); 81 void printMyView();
82 /** 82 /**
83 This signal is emitted when the user changed the entry. 83 This signal is emitted when the user changed the entry.
84 */ 84 */
85 void entryChanged(); 85 void entryChanged();
86 86
87 /** 87 /**
88 This signal indicates that the entry needs to be changed 88 This signal indicates that the entry needs to be changed
89 immidiately in the database. This might be due to changes in 89 immidiately in the database. This might be due to changes in
90 values that are available in menus. 90 values that are available in menus.
91 */ 91 */
92 void saveMe(); 92 void saveMe();
93 93
94 /** 94 /**
95 The user acticated the email address displayed. This may happen 95 The user acticated the email address displayed. This may happen
96 by, for example, clicking on the displayed mailto-URL. 96 by, for example, clicking on the displayed mailto-URL.
97 */ 97 */
98 void sendEmail( const QString &email ); 98 void sendEmail( const QString &email );
99 99
100 /** 100 /**
101 The user activated one of the displayed HTTP URLs. For example 101 The user activated one of the displayed HTTP URLs. For example
102 by clicking on the displayed homepage address. 102 by clicking on the displayed homepage address.
103 */ 103 */
104 void browse( const QString &url ); 104 void browse( const QString &url );
105 105
106 public slots: 106 public slots:
107 /** 107 /**
108 Set read-write state. 108 Set read-write state.
109 */ 109 */
110 virtual void setReadOnly( bool state ); 110 virtual void setReadOnly( bool state );
111 111
112 private: 112 private:
113 KABC::Addressee mAddressee; 113 KABC::Addressee mAddressee;
114 bool mReadOnly; 114 bool mReadOnly;
115}; 115};
116 116
117class KABLookFactory 117class KABLookFactory
118{ 118{
119 public: 119 public:
120 KABLookFactory( QWidget *parent = 0, const char *name = 0 ); 120 KABLookFactory( QWidget *parent = 0, const char *name = 0 );
121 virtual ~KABLookFactory(); 121 virtual ~KABLookFactory();
122 122
123 virtual KABBasicLook *create() = 0; 123 virtual KABBasicLook *create() = 0;
124 124
125 /** 125 /**
126 Overload this method to provide a one-liner description 126 Overload this method to provide a one-liner description
127 for your look. 127 for your look.
128 */ 128 */
129 virtual QString description() = 0; 129 virtual QString description() = 0;
130 130
131 protected: 131 protected:
132 QWidget *mParent; 132 QWidget *mParent;
133 const char* mName; 133 const char* mName;
134}; 134};
135 135
136#endif 136#endif
diff --git a/kaddressbook/details/look_details.cpp b/kaddressbook/details/look_details.cpp
index 11d06e9..2c3a79d 100644
--- a/kaddressbook/details/look_details.cpp
+++ b/kaddressbook/details/look_details.cpp
@@ -1,419 +1,419 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 1996-2002 Mirko Boehm <mirko@kde.org> 3 Copyright (c) 1996-2002 Mirko Boehm <mirko@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 <kconfig.h> 24#include <kconfig.h>
25#include <kdebug.h> 25#include <kdebug.h>
26#include <kglobalsettings.h> 26#include <kglobalsettings.h>
27#include <kinstance.h> 27#include <kinstance.h>
28#include <klocale.h> 28#include <klocale.h>
29#include <kstandarddirs.h> 29#include <kstandarddirs.h>
30 30
31#include <qcursor.h> 31#include <qcursor.h>
32#include <qdir.h> 32#include <qdir.h>
33#include <qpainter.h> 33#include <qpainter.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35 35
36#include "global.h" 36#include "global.h"
37#include "kabentrypainter.h" 37#include "kabentrypainter.h"
38 38
39#include "look_details.h" 39#include "look_details.h"
40 40
41#define GRID 5 41#define GRID 5
42 42
43const QString KABDetailedView::mBorderedBGDir = "kab3part/backgrounds/bordered/"; 43const QString KABDetailedView::mBorderedBGDir = "kab3part/backgrounds/bordered/";
44const QString KABDetailedView::mTiledBGDir = "kab3part/backgrounds/tiled/"; 44const QString KABDetailedView::mTiledBGDir = "kab3part/backgrounds/tiled/";
45 45
46KABDetailedView::KABDetailedView( QWidget *parent, const char *name ) 46KABDetailedView::KABDetailedView( QWidget *parent, const char *name )
47 : KABBasicLook( parent, name ), mPainter( 0 ), mBackgroundStyle( None ), 47 : KABBasicLook( parent, name ), mPainter( 0 ), mBackgroundStyle( None ),
48 mDefaultBGColor( white ), mHeadLineBGColor( darkBlue ), 48 mDefaultBGColor( white ), mHeadLineBGColor( darkBlue ),
49 mHeadLineTextColor( yellow ), mGrid( 3 ), mMenuBorderedBG( 0 ), 49 mHeadLineTextColor( yellow ), mGrid( 3 ), mMenuBorderedBG( 0 ),
50 mMenuTiledBG( 0 ) 50 mMenuTiledBG( 0 )
51{ 51{
52 KToggleAction** actions[] = { 52 KToggleAction** actions[] = {
53 &mActionShowAddresses, 53 &mActionShowAddresses,
54 &mActionShowEmails, 54 &mActionShowEmails,
55 &mActionShowPhones, 55 &mActionShowPhones,
56 &mActionShowURLs 56 &mActionShowURLs
57 }; 57 };
58 58
59 QString actionTexts[] = { 59 QString actionTexts[] = {
60 i18n( "Show Postal Addresses" ), 60 i18n( "Show Postal Addresses" ),
61 i18n( "Show Email Addresses" ), 61 i18n( "Show Email Addresses" ),
62 i18n( "Show Telephone Numbers" ), 62 i18n( "Show Telephone Numbers" ),
63 i18n( "Show Web Pages (URLs)" ) 63 i18n( "Show Web Pages (URLs)" )
64 }; 64 };
65 65
66 QFont general = KGlobalSettings::generalMaxFont(); 66 QFont general = KGlobalSettings::generalMaxFont();
67 QFont fixed = KGlobalSettings::fixedFont(); 67 QFont fixed = KGlobalSettings::fixedFont();
68 QString gfont = general.family(); 68 QString gfont = general.family();
69 QString ffont = fixed.family(); 69 QString ffont = fixed.family();
70 70
71 int gpointsize = general.pixelSize(); 71 int gpointsize = general.pixelSize();
72 if ( gpointsize == -1 ) 72 if ( gpointsize == -1 )
73 gpointsize = general.pointSize(); 73 gpointsize = general.pointSize();
74 74
75 int fpointsize = fixed.pixelSize(); 75 int fpointsize = fixed.pixelSize();
76 if ( fpointsize == -1 ) 76 if ( fpointsize == -1 )
77 fpointsize = fixed.pointSize(); 77 fpointsize = fixed.pointSize();
78 78
79 mPainter = new KABEntryPainter; 79 mPainter = new KABEntryPainter;
80 80
81 mPainter->setForegroundColor( black ); 81 mPainter->setForegroundColor( black );
82 mPainter->setHeaderColor( mHeadLineTextColor ); 82 mPainter->setHeaderColor( mHeadLineTextColor );
83 mPainter->setUseHeaderColor( mUseHeadLineBGColor ); 83 mPainter->setUseHeaderColor( mUseHeadLineBGColor );
84 mPainter->setBackgroundColor( mHeadLineBGColor ); 84 mPainter->setBackgroundColor( mHeadLineBGColor );
85 85
86 mPainter->setHeaderFont( QFont( gfont, gpointsize + 4, QFont::Bold, true ) ); 86 mPainter->setHeaderFont( QFont( gfont, gpointsize + 4, QFont::Bold, true ) );
87 mPainter->setHeadLineFont( QFont( gfont, gpointsize + 2, QFont::Bold, true ) ); 87 mPainter->setHeadLineFont( QFont( gfont, gpointsize + 2, QFont::Bold, true ) );
88 mPainter->setBodyFont( QFont( gfont, gpointsize, QFont::Normal, false ) ); 88 mPainter->setBodyFont( QFont( gfont, gpointsize, QFont::Normal, false ) );
89 mPainter->setFixedFont( QFont( ffont, fpointsize, QFont::Normal, false ) ); 89 mPainter->setFixedFont( QFont( ffont, fpointsize, QFont::Normal, false ) );
90 mPainter->setCommentFont( QFont( gfont, gpointsize, QFont::Normal, false ) ); 90 mPainter->setCommentFont( QFont( gfont, gpointsize, QFont::Normal, false ) );
91 91
92 const int numActions = sizeof( actions ) / sizeof( actions[ 0 ] ); 92 const int numActions = sizeof( actions ) / sizeof( actions[ 0 ] );
93 93
94 for ( int count = 0; count < numActions; ++count ) { 94 for ( int count = 0; count < numActions; ++count ) {
95 *actions[ count ] = new KToggleAction( actionTexts[ count ] ); 95 *actions[ count ] = new KToggleAction( actionTexts[ count ] );
96 (*actions[ count ])->setChecked( true ); 96 (*actions[ count ])->setChecked( true );
97 } 97 }
98 98
99 setMouseTracking( true ); 99 setMouseTracking( true );
100 100
101 setBackgroundMode( NoBackground ); 101 setBackgroundMode( NoBackground );
102} 102}
103 103
104KABDetailedView::~KABDetailedView() 104KABDetailedView::~KABDetailedView()
105{ 105{
106 delete mPainter; 106 delete mPainter;
107 mPainter = 0; 107 mPainter = 0;
108} 108}
109 109
110bool KABDetailedView::getBackground( QString path, QPixmap& image ) 110bool KABDetailedView::getBackground( QString path, QPixmap& image )
111{ 111{
112 QMap<QString, QPixmap>::iterator pos; 112 QMap<QString, QPixmap>::iterator pos;
113 113
114 pos = mBackgroundMap.find( path ); 114 pos = mBackgroundMap.find( path );
115 if ( pos == mBackgroundMap.end() ) { // the image has not been loaded previously 115 if ( pos == mBackgroundMap.end() ) { // the image has not been loaded previously
116 if ( image.load( path ) ) { 116 if ( image.load( path ) ) {
117 mBackgroundMap[ path ] = image; 117 mBackgroundMap[ path ] = image;
118 return true; 118 return true;
119 } else 119 } else
120 return false; 120 return false;
121 } else { // image found in cache 121 } else { // image found in cache
122 image = pos.data(); 122 image = pos.data();
123 return true; 123 return true;
124 } 124 }
125} 125}
126 126
127void KABDetailedView::paintEvent( QPaintEvent* ) 127void KABDetailedView::paintEvent( QPaintEvent* )
128{ 128{
129 const int BorderSpace = mGrid; 129 const int BorderSpace = mGrid;
130 QPixmap pm( width(), height() ); 130 QPixmap pm( width(), height() );
131 QPainter p; 131 QPainter p;
132 132
133 QRect entryArea = QRect( BorderSpace, mGrid, width() - mGrid - BorderSpace, 133 QRect entryArea = QRect( BorderSpace, mGrid, width() - mGrid - BorderSpace,
134 height() - 2 * mGrid ); 134 height() - 2 * mGrid );
135 p.begin( &pm ); 135 p.begin( &pm );
136 136
137 p.setPen( darkBlue ); 137 p.setPen( darkBlue );
138 p.setBrush( mDefaultBGColor ); 138 p.setBrush( mDefaultBGColor );
139 p.drawRect( 0, 0, width(), height() ); 139 p.drawRect( 0, 0, width(), height() );
140 switch ( mBackgroundStyle ) { 140 switch ( mBackgroundStyle ) {
141 case Tiled: 141 case Tiled:
142 p.drawTiledPixmap( 1, 1, width() - 2, height() - 2, mCurrentBackground ); 142 p.drawTiledPixmap( 1, 1, width() - 2, height() - 2, mCurrentBackground );
143 break; 143 break;
144 case Bordered: 144 case Bordered:
145 p.drawTiledPixmap( 1, 1, QMIN( width() - 2, mCurrentBackground.width() ), 145 p.drawTiledPixmap( 1, 1, QMIN( width() - 2, mCurrentBackground.width() ),
146 height() - 2, mCurrentBackground ); 146 height() - 2, mCurrentBackground );
147 break; 147 break;
148 case None: // no BG image defined for this entry: 148 case None: // no BG image defined for this entry:
149 default: 149 default:
150 if ( mUseDefaultBGImage ) 150 if ( mUseDefaultBGImage )
151 p.drawTiledPixmap( 1, 1, width() - 2, height() - 2, mDefaultBGImage ); 151 p.drawTiledPixmap( 1, 1, width() - 2, height() - 2, mDefaultBGImage );
152 break; 152 break;
153 }; 153 };
154 154
155 p.setViewport( entryArea ); 155 p.setViewport( entryArea );
156 156
157 mPainter->setShowAddresses( mActionShowAddresses->isChecked() ); 157 mPainter->setShowAddresses( mActionShowAddresses->isChecked() );
158 mPainter->setShowEmails( mActionShowEmails->isChecked() ); 158 mPainter->setShowEmails( mActionShowEmails->isChecked() );
159 mPainter->setShowPhones( mActionShowPhones->isChecked() ); 159 mPainter->setShowPhones( mActionShowPhones->isChecked() );
160 mPainter->setShowURLs( mActionShowURLs->isChecked() ); 160 mPainter->setShowURLs( mActionShowURLs->isChecked() );
161 mPainter->printAddressee( addressee(), QRect( 0, 0, entryArea.width(), 161 mPainter->printAddressee( addressee(), QRect( 0, 0, entryArea.width(),
162 entryArea.height() ), &p ); 162 entryArea.height() ), &p );
163 p.end(); 163 p.end();
164 bitBlt( this, 0, 0, &pm ); 164 bitBlt( this, 0, 0, &pm );
165} 165}
166 166
167void KABDetailedView::mouseMoveEvent( QMouseEvent *e ) 167void KABDetailedView::mouseMoveEvent( QMouseEvent *e )
168{ 168{
169 QPoint bias( mGrid, mGrid ); 169 QPoint bias( mGrid, mGrid );
170 int rc; 170 int rc;
171 bool hit = false; 171 bool hit = false;
172 172
173 if ( ( rc = mPainter->hitsEmail( e->pos() - bias ) ) != -1 ) 173 if ( ( rc = mPainter->hitsEmail( e->pos() - bias ) ) != -1 )
174 hit = true; 174 hit = true;
175 else if ( ( rc = mPainter->hitsURL( e->pos() - bias ) ) != -1 ) 175 else if ( ( rc = mPainter->hitsURL( e->pos() - bias ) ) != -1 )
176 hit = true; 176 hit = true;
177 else if ( ( rc = mPainter->hitsPhone( e->pos() - bias ) ) != -1 ) 177 else if ( ( rc = mPainter->hitsPhone( e->pos() - bias ) ) != -1 )
178 hit = true; 178 hit = true;
179 else if ( ( rc = mPainter->hitsTalk( e->pos() - bias ) ) != -1 ) 179 else if ( ( rc = mPainter->hitsTalk( e->pos() - bias ) ) != -1 )
180 hit = true; 180 hit = true;
181 181
182 if ( hit ) { 182 if ( hit ) {
183 if ( cursor().shape() != PointingHandCursor ) 183 if ( cursor().shape() != PointingHandCursor )
184 setCursor( PointingHandCursor ); 184 setCursor( PointingHandCursor );
185 else if( cursor().shape() != ArrowCursor ) 185 else if( cursor().shape() != ArrowCursor )
186 setCursor(ArrowCursor); 186 setCursor(ArrowCursor);
187 } 187 }
188} 188}
189 189
190void KABDetailedView::mousePressEvent( QMouseEvent *e ) 190void KABDetailedView::mousePressEvent( QMouseEvent *e )
191{ 191{
192 QPopupMenu menu( this ); 192 Q3PopupMenu menu( this );
193 QPopupMenu *menuBG = new QPopupMenu( &menu ); 193 Q3PopupMenu *menuBG = new Q3PopupMenu( &menu );
194 mMenuBorderedBG = new QPopupMenu( &menu ); 194 mMenuBorderedBG = new Q3PopupMenu( &menu );
195 mMenuTiledBG = new QPopupMenu( &menu ); 195 mMenuTiledBG = new Q3PopupMenu( &menu );
196 196
197 menu.insertItem( i18n( "Select Background" ), menuBG ); 197 menu.insertItem( i18n( "Select Background" ), menuBG );
198 menuBG->insertItem( i18n( "Bordered Backgrounds" ), mMenuBorderedBG ); 198 menuBG->insertItem( i18n( "Bordered Backgrounds" ), mMenuBorderedBG );
199 menuBG->insertItem( i18n( "Tiled Backgrounds" ), mMenuTiledBG ); 199 menuBG->insertItem( i18n( "Tiled Backgrounds" ), mMenuTiledBG );
200 menu.insertSeparator(); 200 menu.insertSeparator();
201 201
202 QPoint point = e->pos() - QPoint( mGrid, mGrid ); 202 QPoint point = e->pos() - QPoint( mGrid, mGrid );
203 int rc; 203 int rc;
204 QStringList dirsBorderedBG, dirsTiledBG; 204 QStringList dirsBorderedBG, dirsTiledBG;
205 QDir dir; 205 QDir dir;
206 206
207 switch( e->button() ) { 207 switch( e->button() ) {
208 case QMouseEvent::RightButton: 208 case QMouseEvent::RightButton:
209 if ( isReadOnly() ) 209 if ( isReadOnly() )
210 menu.setItemEnabled( menu.idAt( 0 ), false ); 210 menu.setItemEnabled( menu.idAt( 0 ), false );
211 else { 211 else {
212 // TODO: settings need to be saved in view options 212 // TODO: settings need to be saved in view options
213 dirsBorderedBG = KGlobal::instance()->dirs()->findDirs( "data", mBorderedBGDir ); 213 dirsBorderedBG = KGlobal::instance()->dirs()->findDirs( "data", mBorderedBGDir );
214 if ( dirsBorderedBG.count() > 0 ) { 214 if ( dirsBorderedBG.count() > 0 ) {
215 dir.setPath( dirsBorderedBG[ 0 ] ); 215 dir.setPath( dirsBorderedBG[ 0 ] );
216 mBorders = dir.entryList( QDir::Files ); 216 mBorders = dir.entryList( QDir::Files );
217 for ( uint count = 0; count < mBorders.count(); ++count ) 217 for ( uint count = 0; count < mBorders.count(); ++count )
218 mMenuBorderedBG->insertItem( mBorders[ count ], count ); 218 mMenuBorderedBG->insertItem( mBorders[ count ], count );
219 219
220 connect( mMenuBorderedBG, SIGNAL( activated( int ) ), 220 connect( mMenuBorderedBG, SIGNAL( activated( int ) ),
221 SLOT( slotBorderedBGSelected( int ) ) ); 221 SLOT( slotBorderedBGSelected( int ) ) );
222 } else 222 } else
223 menuBG->setItemEnabled( menuBG->idAt( 0 ), false ); 223 menuBG->setItemEnabled( menuBG->idAt( 0 ), false );
224 224
225 dirsTiledBG = KGlobal::instance()->dirs()->findDirs( "data", mTiledBGDir ); 225 dirsTiledBG = KGlobal::instance()->dirs()->findDirs( "data", mTiledBGDir );
226 if ( dirsTiledBG.count() > 0 ) { 226 if ( dirsTiledBG.count() > 0 ) {
227 dir.setPath( dirsTiledBG[ 0 ] ); 227 dir.setPath( dirsTiledBG[ 0 ] );
228 mTiles = dir.entryList( QDir::Files ); 228 mTiles = dir.entryList( QDir::Files );
229 for ( uint count = 0; count < mTiles.count(); ++count ) 229 for ( uint count = 0; count < mTiles.count(); ++count )
230 mMenuTiledBG->insertItem( mTiles[ count ], count ); 230 mMenuTiledBG->insertItem( mTiles[ count ], count );
231 231
232 connect( mMenuTiledBG, SIGNAL( activated( int ) ), 232 connect( mMenuTiledBG, SIGNAL( activated( int ) ),
233 SLOT( slotTiledBGSelected( int ) ) ); 233 SLOT( slotTiledBGSelected( int ) ) );
234 } else 234 } else
235 menuBG->setItemEnabled( menuBG->idAt( 1 ), false ); 235 menuBG->setItemEnabled( menuBG->idAt( 1 ), false );
236 } 236 }
237 237
238 mActionShowAddresses->plug( &menu ); 238 mActionShowAddresses->plug( &menu );
239 mActionShowEmails->plug( &menu ); 239 mActionShowEmails->plug( &menu );
240 mActionShowPhones->plug( &menu ); 240 mActionShowPhones->plug( &menu );
241 mActionShowURLs->plug( &menu ); 241 mActionShowURLs->plug( &menu );
242 242
243 menu.exec( e->globalPos() ); 243 menu.exec( e->globalPos() );
244 break; 244 break;
245 245
246 case QMouseEvent::LeftButton: 246 case QMouseEvent::LeftButton:
247 // find whether the pointer touches an email address, URL, 247 // find whether the pointer touches an email address, URL,
248 // talk address or telephone number: 248 // talk address or telephone number:
249 if ( ( rc = mPainter->hitsEmail( point ) ) != -1 ) { 249 if ( ( rc = mPainter->hitsEmail( point ) ) != -1 ) {
250 emit sendEmail( addressee().emails()[ rc ] ); 250 emit sendEmail( addressee().emails()[ rc ] );
251 break; 251 break;
252 } 252 }
253 if ( ( rc = mPainter->hitsURL( point ) ) != -1 ) { 253 if ( ( rc = mPainter->hitsURL( point ) ) != -1 ) {
254 emit browse( addressee().url().prettyURL() ); 254 emit browse( addressee().url().prettyURL() );
255 break; 255 break;
256 } 256 }
257 if ( ( rc = mPainter->hitsPhone( point ) ) != -1 ) { 257 if ( ( rc = mPainter->hitsPhone( point ) ) != -1 ) {
258 // not implemented yet 258 // not implemented yet
259 break; 259 break;
260 } 260 }
261 if ( ( rc = mPainter->hitsTalk( point ) ) != -1 ) { 261 if ( ( rc = mPainter->hitsTalk( point ) ) != -1 ) {
262 // not implemented yet 262 // not implemented yet
263 break; 263 break;
264 } 264 }
265 break; 265 break;
266 default: 266 default:
267 break; 267 break;
268 } 268 }
269 269
270 mMenuBorderedBG = 0; 270 mMenuBorderedBG = 0;
271 mMenuTiledBG = 0; 271 mMenuTiledBG = 0;
272} 272}
273 273
274void KABDetailedView::setAddressee( const KABC::Addressee &addr ) 274void KABDetailedView::setAddressee( const KABC::Addressee &addr )
275{ 275{
276 BackgroundStyle style = None; 276 BackgroundStyle style = None;
277 QString dir, file, styleSetting; 277 QString dir, file, styleSetting;
278 KABBasicLook::setAddressee( addr ); 278 KABBasicLook::setAddressee( addr );
279 279
280 // TODO: preload path and styleSetting with possible preference values 280 // TODO: preload path and styleSetting with possible preference values
281 styleSetting = addressee().custom( "kab", "BackgroundStyle" ); 281 styleSetting = addressee().custom( "kab", "BackgroundStyle" );
282 style = (BackgroundStyle)styleSetting.toInt(); 282 style = (BackgroundStyle)styleSetting.toInt();
283 file = addressee().custom( "kab", "BackgroundImage" ); 283 file = addressee().custom( "kab", "BackgroundImage" );
284 if ( !file.isEmpty() ) { 284 if ( !file.isEmpty() ) {
285 switch ( style ) { 285 switch ( style ) {
286 case Tiled: 286 case Tiled:
287 dir = mTiledBGDir; 287 dir = mTiledBGDir;
288 break; 288 break;
289 case Bordered: 289 case Bordered:
290 dir = mBorderedBGDir; 290 dir = mBorderedBGDir;
291 break; 291 break;
292 case None: 292 case None:
293 default: 293 default:
294 break; 294 break;
295 } 295 }
296 296
297 QStringList dirs = KGlobal::instance()->dirs()->findDirs( "data", dir ); 297 QStringList dirs = KGlobal::instance()->dirs()->findDirs( "data", dir );
298 mBackgroundStyle = None; 298 mBackgroundStyle = None;
299 if ( !dirs.isEmpty() ) { 299 if ( !dirs.isEmpty() ) {
300 uint count = 0; 300 uint count = 0;
301 for ( ; count < dirs.count(); ++count ) { 301 for ( ; count < dirs.count(); ++count ) {
302 QDir folder; 302 QDir folder;
303 folder.setPath( dirs[ count ] ); 303 folder.setPath( dirs[ count ] );
304 file = folder.absPath() + "/" + file; 304 file = folder.absPath() + "/" + file;
305 if ( getBackground( file, mCurrentBackground ) ) { 305 if ( getBackground( file, mCurrentBackground ) ) {
306 mBackgroundStyle = style; 306 mBackgroundStyle = style;
307 break; 307 break;
308 } 308 }
309 } 309 }
310 310
311 if ( count == dirs.count() ) { 311 if ( count == dirs.count() ) {
312 kdDebug(5720) << "KABDetailedView::setEntry: " << file 312 kdDebug(5720) << "KABDetailedView::setEntry: " << file
313 << " not locatable." << endl; 313 << " not locatable." << endl;
314 } 314 }
315 } 315 }
316 } else { // no background here 316 } else { // no background here
317 mBackgroundStyle = None; 317 mBackgroundStyle = None;
318 mCurrentBackground.resize( 0, 0 ); 318 mCurrentBackground.resize( 0, 0 );
319 } 319 }
320 320
321 repaint( false ); 321 repaint( false );
322} 322}
323 323
324void KABDetailedView::slotBorderedBGSelected( int index ) 324void KABDetailedView::slotBorderedBGSelected( int index )
325{ 325{
326 if ( index >= 0 && (uint)index < mBorders.count() && !isReadOnly() ) { 326 if ( index >= 0 && (uint)index < mBorders.count() && !isReadOnly() ) {
327 // get the selection and make it a full path 327 // get the selection and make it a full path
328 QString path = mBorders[ index ]; 328 QString path = mBorders[ index ];
329 mBackgroundStyle = Bordered; 329 mBackgroundStyle = Bordered;
330 addressee().insertCustom( "kab", "BackgroundStyle", 330 addressee().insertCustom( "kab", "BackgroundStyle",
331 QString().setNum( mBackgroundStyle ) ); 331 QString().setNum( mBackgroundStyle ) );
332 addressee().insertCustom( "kab", "BackgroundImage", path ); 332 addressee().insertCustom( "kab", "BackgroundImage", path );
333 setAddressee( addressee() ); 333 setAddressee( addressee() );
334 } 334 }
335} 335}
336 336
337void KABDetailedView::slotTiledBGSelected( int index ) 337void KABDetailedView::slotTiledBGSelected( int index )
338{ 338{
339 if ( index >= 0 && (uint)index < mTiles.count() && !isReadOnly() ) { 339 if ( index >= 0 && (uint)index < mTiles.count() && !isReadOnly() ) {
340 QString path = mTiles[ index ]; 340 QString path = mTiles[ index ];
341 mBackgroundStyle = Tiled; 341 mBackgroundStyle = Tiled;
342 addressee().insertCustom( "kab", "BackgroundStyle", 342 addressee().insertCustom( "kab", "BackgroundStyle",
343 QString().setNum( mBackgroundStyle ) ); 343 QString().setNum( mBackgroundStyle ) );
344 addressee().insertCustom( "kab", "BackgroundImage", path ); 344 addressee().insertCustom( "kab", "BackgroundImage", path );
345 setAddressee( addressee() ); 345 setAddressee( addressee() );
346 } 346 }
347} 347}
348 348
349void KABDetailedView::setReadOnly( bool state ) 349void KABDetailedView::setReadOnly( bool state )
350{ 350{
351 KABBasicLook::setReadOnly( state ); 351 KABBasicLook::setReadOnly( state );
352 repaint( false ); 352 repaint( false );
353} 353}
354 354
355void KABDetailedView::restoreSettings( KConfig *config ) 355void KABDetailedView::restoreSettings( KConfig *config )
356{ 356{
357 QFont general = KGlobalSettings::generalFont(); 357 QFont general = KGlobalSettings::generalFont();
358 QFont fixed = KGlobalSettings::fixedFont(); 358 QFont fixed = KGlobalSettings::fixedFont();
359 QString gfont = general.family(); 359 QString gfont = general.family();
360 QString ffont = fixed.family(); 360 QString ffont = fixed.family();
361 361
362 int gpointsize = general.pixelSize(); 362 int gpointsize = general.pixelSize();
363 if ( gpointsize == -1 ) 363 if ( gpointsize == -1 )
364 gpointsize = general.pointSize(); 364 gpointsize = general.pointSize();
365 365
366 int fpointsize = fixed.pixelSize(); 366 int fpointsize = fixed.pixelSize();
367 if ( fpointsize == -1 ) 367 if ( fpointsize == -1 )
368 fpointsize = fixed.pointSize(); 368 fpointsize = fixed.pointSize();
369 369
370 config->setGroup( ConfigView ); 370 config->setGroup( ConfigView );
371 371
372 // load the default background image: 372 // load the default background image:
373 QString bgImage; 373 QString bgImage;
374 mUseDefaultBGImage = config->readBoolEntry( ConfigView_UseDefaultBackground, true ); 374 mUseDefaultBGImage = config->readBoolEntry( ConfigView_UseDefaultBackground, true );
375 mDefaultBGColor = config->readColorEntry( ConfigView_DefaultBackgroundColor, &white ); 375 mDefaultBGColor = config->readColorEntry( ConfigView_DefaultBackgroundColor, &white );
376 bgImage = config->readEntry( ConfigView_DefaultBackgroundImage, "konqueror/tiles/kenwimer.png" ); 376 bgImage = config->readEntry( ConfigView_DefaultBackgroundImage, "konqueror/tiles/kenwimer.png" );
377 377
378 if ( mUseDefaultBGImage ) { 378 if ( mUseDefaultBGImage ) {
379 uint count = 0; 379 uint count = 0;
380 QStringList dirs = KGlobal::instance()->dirs()->findDirs( "data", "/" ); 380 QStringList dirs = KGlobal::instance()->dirs()->findDirs( "data", "/" );
381 if ( !dirs.isEmpty() ) { 381 if ( !dirs.isEmpty() ) {
382 for ( count = 0; count < dirs.count(); ++count ) { 382 for ( count = 0; count < dirs.count(); ++count ) {
383 if ( getBackground( dirs[ count ] + "/" + bgImage, mDefaultBGImage ) ) 383 if ( getBackground( dirs[ count ] + "/" + bgImage, mDefaultBGImage ) )
384 break; 384 break;
385 } 385 }
386 } 386 }
387 387
388 if ( count == dirs.count() ) { 388 if ( count == dirs.count() ) {
389 mUseDefaultBGImage = getBackground( bgImage, mDefaultBGImage ); 389 mUseDefaultBGImage = getBackground( bgImage, mDefaultBGImage );
390 if ( !mUseDefaultBGImage ) 390 if ( !mUseDefaultBGImage )
391 kdDebug(5720) << "KABDetailedView::configure: " 391 kdDebug(5720) << "KABDetailedView::configure: "
392 << "default BG image selected, but could not be loaded." 392 << "default BG image selected, but could not be loaded."
393 << endl; 393 << endl;
394 } 394 }
395 } 395 }
396 396
397 mDefaultBGColor = config->readColorEntry( ConfigView_DefaultBackgroundColor, &white ); 397 mDefaultBGColor = config->readColorEntry( ConfigView_DefaultBackgroundColor, &white );
398 mHeadLineBGColor = config->readColorEntry( ConfigView_HeadlineBGColor, &darkBlue ); 398 mHeadLineBGColor = config->readColorEntry( ConfigView_HeadlineBGColor, &darkBlue );
399 mHeadLineTextColor = config->readColorEntry( ConfigView_HeadlineTextColor, &yellow ); 399 mHeadLineTextColor = config->readColorEntry( ConfigView_HeadlineTextColor, &yellow );
400 mUseHeadLineBGColor = config->readBoolEntry( ConfigView_UseHeadlineBGColor, true ); 400 mUseHeadLineBGColor = config->readBoolEntry( ConfigView_UseHeadlineBGColor, true );
401 401
402 if ( !mPainter ) 402 if ( !mPainter )
403 mPainter = new KABEntryPainter; 403 mPainter = new KABEntryPainter;
404 404
405 mPainter->setForegroundColor( black ); 405 mPainter->setForegroundColor( black );
406 mPainter->setHeaderColor( mHeadLineTextColor ); 406 mPainter->setHeaderColor( mHeadLineTextColor );
407 mPainter->setUseHeaderColor( mUseHeadLineBGColor ); 407 mPainter->setUseHeaderColor( mUseHeadLineBGColor );
408 mPainter->setBackgroundColor( mHeadLineBGColor ); 408 mPainter->setBackgroundColor( mHeadLineBGColor );
409 409
410 mPainter->setHeaderFont( QFont( gfont, gpointsize + 4, QFont::Bold, true ) ); 410 mPainter->setHeaderFont( QFont( gfont, gpointsize + 4, QFont::Bold, true ) );
411 mPainter->setHeadLineFont( QFont( gfont, gpointsize + 2, QFont::Bold, true ) ); 411 mPainter->setHeadLineFont( QFont( gfont, gpointsize + 2, QFont::Bold, true ) );
412 mPainter->setBodyFont( QFont( gfont, gpointsize, QFont::Normal, false ) ); 412 mPainter->setBodyFont( QFont( gfont, gpointsize, QFont::Normal, false ) );
413 mPainter->setFixedFont( QFont( ffont, fpointsize, QFont::Normal, false ) ); 413 mPainter->setFixedFont( QFont( ffont, fpointsize, QFont::Normal, false ) );
414 mPainter->setCommentFont( QFont( gfont, gpointsize, QFont::Normal, false ) ); 414 mPainter->setCommentFont( QFont( gfont, gpointsize, QFont::Normal, false ) );
415} 415}
416 416
417#ifndef KAB_EMBEDDED 417#ifndef KAB_EMBEDDED_
418#include "look_details.moc" 418#include "moc_look_details.cpp"
419#endif //KAB_EMBEDDED 419#endif //KAB_EMBEDDED
diff --git a/kaddressbook/details/look_details.h b/kaddressbook/details/look_details.h
index e8d50a9..b59d3a7 100644
--- a/kaddressbook/details/look_details.h
+++ b/kaddressbook/details/look_details.h
@@ -1,157 +1,157 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 1996-2002 Mirko Boehm <mirko@kde.org> 3 Copyright (c) 1996-2002 Mirko Boehm <mirko@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#ifndef LOOK_DETAILS_H 24#ifndef LOOK_DETAILS_H
25#define LOOK_DETAILS_H 25#define LOOK_DETAILS_H
26 26
27#include <kabc/addressbook.h> 27#include <kabc/addressbook.h>
28#include <kaction.h> 28#include <kaction.h>
29#include <klocale.h> 29#include <klocale.h>
30 30
31#include <qmap.h> 31#include <qmap.h>
32#include <qpixmap.h> 32#include <qpixmap.h>
33#include <qptrlist.h> 33#include <qptrlist.h>
34#include <qrect.h> 34#include <qrect.h>
35 35
36#include "look_basic.h" 36#include "look_basic.h"
37 37
38class KABEntryPainter; 38class KABEntryPainter;
39class QComboBox; 39class QComboBox;
40 40
41/** 41/**
42 This class implements the detailed view. 42 This class implements the detailed view.
43 Currently, there is no possibility to change the entry in this 43 Currently, there is no possibility to change the entry in this
44 view. 44 view.
45 */ 45 */
46 46
47class KABDetailedView : public KABBasicLook 47class KABDetailedView : public KABBasicLook
48{ 48{
49 Q_OBJECT 49 Q_OBJECT
50 50
51 public: 51 public:
52 /** 52 /**
53 Enum to select how the background is drawn. 53 Enum to select how the background is drawn.
54 */ 54 */
55 enum BackgroundStyle 55 enum BackgroundStyle
56 { 56 {
57 None, 57 None,
58 Tiled, 58 Tiled,
59 Bordered 59 Bordered
60 }; 60 };
61 61
62 /** 62 /**
63 The constructor. 63 The constructor.
64 */ 64 */
65 KABDetailedView( QWidget *parent = 0, const char* name = 0 ); 65 KABDetailedView( QWidget *parent = 0, const char* name = 0 );
66 66
67 /** 67 /**
68 The virtual destructor. 68 The virtual destructor.
69 */ 69 */
70 virtual ~KABDetailedView(); 70 virtual ~KABDetailedView();
71 71
72 /** 72 /**
73 Set the addressee. 73 Set the addressee.
74 */ 74 */
75 void setAddressee( const KABC::Addressee& ); 75 void setAddressee( const KABC::Addressee& );
76 76
77 /** 77 /**
78 Overloaded from KABBasicLook. 78 Overloaded from KABBasicLook.
79 */ 79 */
80 void setReadOnly( bool ); 80 void setReadOnly( bool );
81 81
82 /** 82 /**
83 Overloaded from KABBasicLook. 83 Overloaded from KABBasicLook.
84 */ 84 */
85 void restoreSettings( KConfig* ); 85 void restoreSettings( KConfig* );
86 86
87 public slots: 87 public slots:
88 void slotBorderedBGSelected( int index ); 88 void slotBorderedBGSelected( int index );
89 void slotTiledBGSelected( int index ); 89 void slotTiledBGSelected( int index );
90 90
91 protected: 91 protected:
92 void paintEvent( QPaintEvent* ); 92 void paintEvent( QPaintEvent* );
93 void mousePressEvent( QMouseEvent* ); 93 void mousePressEvent( QMouseEvent* );
94 void mouseMoveEvent( QMouseEvent* ); 94 void mouseMoveEvent( QMouseEvent* );
95 95
96 /** 96 /**
97 A method to retrieve a background image according to the path 97 A method to retrieve a background image according to the path
98 stored in the entry. It is either loaded 98 stored in the entry. It is either loaded
99 from backgrounds, that acts as a cache, or from the file 99 from backgrounds, that acts as a cache, or from the file
100 and added to @see backgrounds. 100 and added to @see backgrounds.
101 */ 101 */
102 bool getBackground( QString path, QPixmap& image ); 102 bool getBackground( QString path, QPixmap& image );
103 103
104 private: 104 private:
105 QPtrList<QRect> mURLRects; 105 QPtrList<QRect> mURLRects;
106 QPtrList<QRect> mEmailRects; 106 QPtrList<QRect> mEmailRects;
107 QPtrList<QRect> mPhoneRects; 107 QPtrList<QRect> mPhoneRects;
108 KABEntryPainter *mPainter; 108 KABEntryPainter *mPainter;
109 109
110 QMap<QString, QPixmap> mBackgroundMap; 110 QMap<QString, QPixmap> mBackgroundMap;
111 QPixmap mCurrentBackground; 111 QPixmap mCurrentBackground;
112 112
113 BackgroundStyle mBackgroundStyle; 113 BackgroundStyle mBackgroundStyle;
114 114
115 bool mUseDefaultBGImage; 115 bool mUseDefaultBGImage;
116 bool mUseHeadLineBGColor; 116 bool mUseHeadLineBGColor;
117 117
118 QColor mDefaultBGColor; 118 QColor mDefaultBGColor;
119 QColor mHeadLineBGColor; 119 QColor mHeadLineBGColor;
120 QColor mHeadLineTextColor; 120 QColor mHeadLineTextColor;
121 121
122 QPixmap mDefaultBGImage; 122 QPixmap mDefaultBGImage;
123 123
124 KToggleAction *mActionShowAddresses; 124 KToggleAction *mActionShowAddresses;
125 KToggleAction *mActionShowEmails; 125 KToggleAction *mActionShowEmails;
126 KToggleAction *mActionShowPhones; 126 KToggleAction *mActionShowPhones;
127 KToggleAction *mActionShowURLs; 127 KToggleAction *mActionShowURLs;
128 128
129 const int mGrid; 129 const int mGrid;
130 QStringList mBorders; 130 QStringList mBorders;
131 QStringList mTiles; 131 QStringList mTiles;
132 132
133 QPopupMenu *mMenuBorderedBG; 133 Q3PopupMenu *mMenuBorderedBG;
134 QPopupMenu *mMenuTiledBG; 134 Q3PopupMenu *mMenuTiledBG;
135 135
136 static const QString mBorderedBGDir; 136 static const QString mBorderedBGDir;
137 static const QString mTiledBGDir; 137 static const QString mTiledBGDir;
138}; 138};
139 139
140class KABDetailedViewFactory : public KABLookFactory 140class KABDetailedViewFactory : public KABLookFactory
141{ 141{
142 public: 142 public:
143 KABDetailedViewFactory( QWidget *parent = 0, const char *name = 0 ) 143 KABDetailedViewFactory( QWidget *parent = 0, const char *name = 0 )
144 : KABLookFactory( parent, name ) {} 144 : KABLookFactory( parent, name ) {}
145 145
146 KABBasicLook *create() 146 KABBasicLook *create()
147 { 147 {
148 return new KABDetailedView( mParent, mName ); 148 return new KABDetailedView( mParent, mName );
149 } 149 }
150 150
151 QString description() 151 QString description()
152 { 152 {
153 return i18n( "Detailed Style: Display all details, no modifications." ); 153 return i18n( "Detailed Style: Display all details, no modifications." );
154 } 154 }
155}; 155};
156 156
157#endif 157#endif
diff --git a/kaddressbook/details/look_html.cpp b/kaddressbook/details/look_html.cpp
index bb30650..4ec1c7d 100644
--- a/kaddressbook/details/look_html.cpp
+++ b/kaddressbook/details/look_html.cpp
@@ -1,56 +1,56 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 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 <addresseeview.h> 24#include <addresseeview.h>
25 25
26#include "look_html.h" 26#include "look_html.h"
27#include <qscrollview.h> 27#include <q3scrollview.h>
28#include "kabprefs.h" 28#include "kabprefs.h"
29#include <kabc/addresseeview.h> 29#include <kabc/addresseeview.h>
30KABHtmlView::KABHtmlView( QWidget *parent, const char *name ) 30KABHtmlView::KABHtmlView( QWidget *parent, const char *name )
31 : KABBasicLook( parent, name ) 31 : KABBasicLook( parent, name )
32{ 32{
33 mView = new KABC::AddresseeView( this ); 33 mView = new KABC::AddresseeView( this );
34 mView->setFont( KABPrefs::instance()->mDetailsFont ); 34 mView->setFont( KABPrefs::instance()->mDetailsFont );
35 connect(this, SIGNAL(printMyView()), 35 connect(this, SIGNAL(printMyView()),
36 this , SLOT(printMe())); 36 this , SLOT(printMe()));
37} 37}
38 38
39KABHtmlView::~KABHtmlView() 39KABHtmlView::~KABHtmlView()
40{ 40{
41} 41}
42void KABHtmlView::printMe() 42void KABHtmlView::printMe()
43{ 43{
44 mView->printMe(); 44 mView->printMe();
45 45
46} 46}
47 47
48void KABHtmlView::setAddressee( const KABC::Addressee &addr ) 48void KABHtmlView::setAddressee( const KABC::Addressee &addr )
49{ 49{
50 mView->setFont( KABPrefs::instance()->mDetailsFont ); 50 mView->setFont( KABPrefs::instance()->mDetailsFont );
51 mView->setAddressee( addr ); 51 mView->setAddressee( addr );
52} 52}
53 53
54#ifndef KAB_EMBEDDED 54#ifndef KAB_EMBEDDED_
55#include "look_html.moc" 55#include "moc_look_html.cpp"
56#endif //KAB_EMBEDDED 56#endif //KAB_EMBEDDED
diff --git a/kaddressbook/emaileditwidget.cpp b/kaddressbook/emaileditwidget.cpp
index e72face..09df47f 100644
--- a/kaddressbook/emaileditwidget.cpp
+++ b/kaddressbook/emaileditwidget.cpp
@@ -1,277 +1,279 @@
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#include <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qstring.h> 28#include <qstring.h>
29#include <qtoolbutton.h> 29#include <qtoolbutton.h>
30#include <qtooltip.h> 30#include <qtooltip.h>
31#include <qlistbox.h> 31#include <q3listbox.h>
32//Added by qt3to4:
33#include <Q3GridLayout>
32 34
33#ifndef KAB_EMBEDDED 35#ifndef KAB_EMBEDDED
34#include <kaccelmanager.h> 36#include <kaccelmanager.h>
35#endif //KAB_EMBEDDED 37#endif //KAB_EMBEDDED
36#include <kconfig.h> 38#include <kconfig.h>
37#include <kcombobox.h> 39#include <kcombobox.h>
38#include <kdebug.h> 40#include <kdebug.h>
39#include <kglobal.h> 41#include <kglobal.h>
40#include <kdialog.h> 42#include <kdialog.h>
41#include <kiconloader.h> 43#include <kiconloader.h>
42#include <klineedit.h> 44#include <klineedit.h>
43#include <klocale.h> 45#include <klocale.h>
44#include <kmessagebox.h> 46#include <kmessagebox.h>
45 47
46#include "emaileditwidget.h" 48#include "emaileditwidget.h"
47 49
48EmailEditWidget::EmailEditWidget( QWidget *parent, const char *name ) 50EmailEditWidget::EmailEditWidget( QWidget *parent, const char *name )
49 : QWidget( parent, name ) 51 : QWidget( parent, name )
50{ 52{
51 QGridLayout *topLayout = new QGridLayout( this, 2, 2 ); 53 Q3GridLayout *topLayout = new Q3GridLayout( this, 2, 2 );
52 topLayout->setSpacing( KDialog::spacingHint() ); 54 topLayout->setSpacing( KDialog::spacingHint() );
53 QLabel* label = new QLabel( this ); 55 QLabel* label = new QLabel( this );
54 56
55 label->setPixmap( KGlobal::iconLoader()->loadIcon( "mail_send", KIcon::Desktop, 0) ); 57 label->setPixmap( KGlobal::iconLoader()->loadIcon( "mail_send", KIcon::Desktop, 0) );
56 58
57 topLayout->addWidget( label, 0, 0 ); 59 topLayout->addWidget( label, 0, 0 );
58 label->setAlignment( AlignCenter ); 60 label->setAlignment( Qt::AlignCenter );
59 QPushButton *editButton = new QPushButton( i18n( "Edit Email Addresses..." ), this); 61 QPushButton *editButton = new QPushButton( i18n( "Edit Email Addresses..." ), this);
60 topLayout->addWidget( editButton, 0, 1 ); 62 topLayout->addWidget( editButton, 0, 1 );
61 label = new QLabel( i18n( "Email:" ), this ); 63 label = new QLabel( i18n( "Email:" ), this );
62 topLayout->addWidget( label, 1, 0 ); 64 topLayout->addWidget( label, 1, 0 );
63 65
64 mEmailEdit = new KLineEdit( this ); 66 mEmailEdit = new KLineEdit( this );
65 connect( mEmailEdit, SIGNAL( textChanged( const QString& ) ), 67 connect( mEmailEdit, SIGNAL( textChanged( const QString& ) ),
66 SLOT( textChanged( const QString& ) ) ); 68 SLOT( textChanged( const QString& ) ) );
67 connect( mEmailEdit, SIGNAL( textChanged( const QString& ) ), 69 connect( mEmailEdit, SIGNAL( textChanged( const QString& ) ),
68 SIGNAL( modified() ) ); 70 SIGNAL( modified() ) );
69 label->setBuddy( mEmailEdit ); 71 label->setBuddy( mEmailEdit );
70 topLayout->addWidget( mEmailEdit, 1, 1 ); 72 topLayout->addWidget( mEmailEdit, 1, 1 );
71 73
72 74
73 connect( editButton, SIGNAL( clicked() ), SLOT( edit() ) ); 75 connect( editButton, SIGNAL( clicked() ), SLOT( edit() ) );
74 76
75 topLayout->activate(); 77 topLayout->activate();
76} 78}
77 79
78EmailEditWidget::~EmailEditWidget() 80EmailEditWidget::~EmailEditWidget()
79{ 81{
80} 82}
81 83
82void EmailEditWidget::setEmails( const QStringList &list ) 84void EmailEditWidget::setEmails( const QStringList &list )
83{ 85{
84 mEmailList = list; 86 mEmailList = list;
85 87
86 bool blocked = mEmailEdit->signalsBlocked(); 88 bool blocked = mEmailEdit->signalsBlocked();
87 mEmailEdit->blockSignals( true ); 89 mEmailEdit->blockSignals( true );
88 if ( list.count() > 0 ) 90 if ( list.count() > 0 )
89 mEmailEdit->setText( list[ 0 ] ); 91 mEmailEdit->setText( list[ 0 ] );
90 else 92 else
91 mEmailEdit->setText( "" ); 93 mEmailEdit->setText( "" );
92 mEmailEdit->blockSignals( blocked ); 94 mEmailEdit->blockSignals( blocked );
93} 95}
94 96
95QStringList EmailEditWidget::emails() 97QStringList EmailEditWidget::emails()
96{ 98{
97 if ( mEmailEdit->text().isEmpty() ) { 99 if ( mEmailEdit->text().isEmpty() ) {
98 if ( mEmailList.count() > 0 ) 100 if ( mEmailList.count() > 0 )
99 mEmailList.remove( mEmailList.begin() ); 101 mEmailList.remove( mEmailList.begin() );
100 } else { 102 } else {
101 if ( mEmailList.count() > 0 ) 103 if ( mEmailList.count() > 0 )
102 mEmailList.remove( mEmailList.begin() ); 104 mEmailList.remove( mEmailList.begin() );
103 105
104 mEmailList.prepend( mEmailEdit->text() ); 106 mEmailList.prepend( mEmailEdit->text() );
105 } 107 }
106 108
107 return mEmailList; 109 return mEmailList;
108} 110}
109 111
110void EmailEditWidget::edit() 112void EmailEditWidget::edit()
111{ 113{
112 EmailEditDialog dlg( mEmailList, this ); 114 EmailEditDialog dlg( mEmailList, this );
113 115
114 if ( dlg.exec() ) { 116 if ( dlg.exec() ) {
115 if ( dlg.changed() ) { 117 if ( dlg.changed() ) {
116 mEmailList = dlg.emails(); 118 mEmailList = dlg.emails();
117 mEmailEdit->setText( mEmailList[ 0 ] ); 119 mEmailEdit->setText( mEmailList[ 0 ] );
118 emit modified(); 120 emit modified();
119 } 121 }
120 } 122 }
121} 123}
122 124
123void EmailEditWidget::textChanged( const QString &text ) 125void EmailEditWidget::textChanged( const QString &text )
124{ 126{
125 if ( mEmailList.count() > 0 ) 127 if ( mEmailList.count() > 0 )
126 mEmailList.remove( mEmailList.begin() ); 128 mEmailList.remove( mEmailList.begin() );
127 129
128 mEmailList.prepend( text ); 130 mEmailList.prepend( text );
129} 131}
130 132
131 133
132EmailEditDialog::EmailEditDialog( const QStringList &list, QWidget *parent, 134EmailEditDialog::EmailEditDialog( const QStringList &list, QWidget *parent,
133 const char *name ) 135 const char *name )
134 : KDialogBase( KDialogBase::Plain, i18n( "Edit Email Addresses" ), 136 : KDialogBase( KDialogBase::Plain, i18n( "Edit Email Addresses" ),
135 KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, 137 KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok,
136 parent, name, true ) 138 parent, name, true )
137{ 139{
138 QWidget *page = plainPage(); 140 QWidget *page = plainPage();
139 141
140 QGridLayout *topLayout = new QGridLayout( page, 4, 3 ); 142 Q3GridLayout *topLayout = new Q3GridLayout( page, 4, 3 );
141 143
142 QLabel *label = new QLabel( i18n( "Email address:" ), page ); 144 QLabel *label = new QLabel( i18n( "Email address:" ), page );
143 topLayout->addWidget( label, 0, 0 ); 145 topLayout->addWidget( label, 0, 0 );
144 146
145 mEmailEdit = new KLineEdit( page ); 147 mEmailEdit = new KLineEdit( page );
146 label->setBuddy( mEmailEdit ); 148 label->setBuddy( mEmailEdit );
147 topLayout->addWidget( mEmailEdit, 0, 1 ); 149 topLayout->addWidget( mEmailEdit, 0, 1 );
148 connect( mEmailEdit, SIGNAL( returnPressed() ), SLOT( add() ) ); 150 connect( mEmailEdit, SIGNAL( returnPressed() ), SLOT( add() ) );
149 connect( mEmailEdit, SIGNAL( textChanged( const QString& ) ), 151 connect( mEmailEdit, SIGNAL( textChanged( const QString& ) ),
150 SLOT( emailChanged() ) ); 152 SLOT( emailChanged() ) );
151 153
152 mAddButton = new QPushButton( i18n( "Add" ), page ); 154 mAddButton = new QPushButton( i18n( "Add" ), page );
153 mAddButton->setEnabled( false ); 155 mAddButton->setEnabled( false );
154 connect( mAddButton, SIGNAL( clicked() ), SLOT( add() ) ); 156 connect( mAddButton, SIGNAL( clicked() ), SLOT( add() ) );
155 topLayout->addWidget( mAddButton, 0, 2 ); 157 topLayout->addWidget( mAddButton, 0, 2 );
156 158
157 mEmailListBox = new QListBox( page ); 159 mEmailListBox = new Q3ListBox( page );
158 160
159 // Make sure there is room for the scrollbar 161 // Make sure there is room for the scrollbar
160 mEmailListBox->setMinimumHeight( mEmailListBox->sizeHint().height() + 30 ); 162 mEmailListBox->setMinimumHeight( mEmailListBox->sizeHint().height() + 30 );
161 connect( mEmailListBox, SIGNAL( highlighted( int ) ), 163 connect( mEmailListBox, SIGNAL( highlighted( int ) ),
162 SLOT( selectionChanged( int ) ) ); 164 SLOT( selectionChanged( int ) ) );
163 topLayout->addMultiCellWidget( mEmailListBox, 1, 3, 0, 1 ); 165 topLayout->addMultiCellWidget( mEmailListBox, 1, 3, 0, 1 );
164 166
165 mEditButton = new QPushButton( i18n( "Change" ), page ); 167 mEditButton = new QPushButton( i18n( "Change" ), page );
166 connect( mEditButton, SIGNAL( clicked() ), SLOT( edit() ) ); 168 connect( mEditButton, SIGNAL( clicked() ), SLOT( edit() ) );
167 topLayout->addWidget( mEditButton, 1, 2 ); 169 topLayout->addWidget( mEditButton, 1, 2 );
168 170
169 mRemoveButton = new QPushButton( i18n( "Remove" ), page ); 171 mRemoveButton = new QPushButton( i18n( "Remove" ), page );
170 connect( mRemoveButton, SIGNAL( clicked() ), SLOT( remove() ) ); 172 connect( mRemoveButton, SIGNAL( clicked() ), SLOT( remove() ) );
171 topLayout->addWidget( mRemoveButton, 2, 2 ); 173 topLayout->addWidget( mRemoveButton, 2, 2 );
172 174
173 mStandardButton = new QPushButton( i18n( "Set Standard" ), page ); 175 mStandardButton = new QPushButton( i18n( "Set Standard" ), page );
174 connect( mStandardButton, SIGNAL( clicked() ), SLOT( standard() ) ); 176 connect( mStandardButton, SIGNAL( clicked() ), SLOT( standard() ) );
175 topLayout->addWidget( mStandardButton, 3, 2 ); 177 topLayout->addWidget( mStandardButton, 3, 2 );
176 178
177 topLayout->activate(); 179 topLayout->activate();
178 QStringList items = list; 180 QStringList items = list;
179 181
180qDebug("EmailEditDialog::EmailEditDialog has to be changed (lowPrio)"); 182qDebug("EmailEditDialog::EmailEditDialog has to be changed (lowPrio)");
181//US must be fixed !!! 183//US must be fixed !!!
182/* 184/*
183 if ( items.remove( "" ) > 0 ) 185 if ( items.remove( "" ) > 0 )
184 mChanged = true; 186 mChanged = true;
185 else 187 else
186 mChanged = false; 188 mChanged = false;
187*/ 189*/
188 190
189 mEmailListBox->insertStringList( items ); 191 mEmailListBox->insertStringList( items );
190 // set default state 192 // set default state
191 selectionChanged( -1 ); 193 selectionChanged( -1 );
192 mEmailEdit->setFocus(); 194 mEmailEdit->setFocus();
193 195
194#ifndef KAB_EMBEDDED 196#ifndef KAB_EMBEDDED
195 KAcceleratorManager::manage( this ); 197 KAcceleratorManager::manage( this );
196#else //KAB_EMBEDDED 198#else //KAB_EMBEDDED
197//US qDebug("EmailEditDialog::EmailEditDialog has to be changed"); 199//US qDebug("EmailEditDialog::EmailEditDialog has to be changed");
198#endif //KAB_EMBEDDED 200#endif //KAB_EMBEDDED
199 201
200} 202}
201 203
202EmailEditDialog::~EmailEditDialog() 204EmailEditDialog::~EmailEditDialog()
203{ 205{
204} 206}
205 207
206QStringList EmailEditDialog::emails() const 208QStringList EmailEditDialog::emails() const
207{ 209{
208 QStringList emails; 210 QStringList emails;
209 211
210 for ( uint i = 0; i < mEmailListBox->count(); ++i ) 212 for ( uint i = 0; i < mEmailListBox->count(); ++i )
211 emails << mEmailListBox->text( i ); 213 emails << mEmailListBox->text( i );
212 214
213 return emails; 215 return emails;
214} 216}
215 217
216void EmailEditDialog::add() 218void EmailEditDialog::add()
217{ 219{
218 mEmailListBox->insertItem( mEmailEdit->text() ); 220 mEmailListBox->insertItem( mEmailEdit->text() );
219 221
220 mEmailEdit->clear(); 222 mEmailEdit->clear();
221 mEmailEdit->setFocus(); 223 mEmailEdit->setFocus();
222 224
223 mChanged = true; 225 mChanged = true;
224} 226}
225 227
226void EmailEditDialog::edit() 228void EmailEditDialog::edit()
227{ 229{
228 mEmailEdit->setText( mEmailListBox->currentText() ); 230 mEmailEdit->setText( mEmailListBox->currentText() );
229 mEmailListBox->removeItem( mEmailListBox->currentItem() ); 231 mEmailListBox->removeItem( mEmailListBox->currentItem() );
230 mEmailEdit->setFocus(); 232 mEmailEdit->setFocus();
231} 233}
232 234
233void EmailEditDialog::remove() 235void EmailEditDialog::remove()
234{ 236{
235 QString address = mEmailListBox->currentText(); 237 QString address = mEmailListBox->currentText();
236 238
237 QString text = i18n( "<qt>Are you sure that you want to remove the email address <b>%1</b>?</qt>" ).arg( address ); 239 QString text = i18n( "<qt>Are you sure that you want to remove the email address <b>%1</b>?</qt>" ).arg( address );
238 QString caption = i18n( "Confirm Remove" ); 240 QString caption = i18n( "Confirm Remove" );
239 241
240 if ( KMessageBox::questionYesNo( this, text, caption ) == KMessageBox::Yes ) { 242 if ( KMessageBox::questionYesNo( this, text, caption ) == KMessageBox::Yes ) {
241 mEmailListBox->removeItem( mEmailListBox->currentItem() ); 243 mEmailListBox->removeItem( mEmailListBox->currentItem() );
242 mChanged = true; 244 mChanged = true;
243 } 245 }
244} 246}
245 247
246bool EmailEditDialog::changed() const 248bool EmailEditDialog::changed() const
247{ 249{
248 return mChanged; 250 return mChanged;
249} 251}
250 252
251void EmailEditDialog::standard() 253void EmailEditDialog::standard()
252{ 254{
253 QString text = mEmailListBox->currentText(); 255 QString text = mEmailListBox->currentText();
254 mEmailListBox->removeItem( mEmailListBox->currentItem() ); 256 mEmailListBox->removeItem( mEmailListBox->currentItem() );
255 mEmailListBox->insertItem( text, 0 ); 257 mEmailListBox->insertItem( text, 0 );
256 mEmailListBox->setSelected( 0, true ); 258 mEmailListBox->setSelected( 0, true );
257 259
258 mChanged = true; 260 mChanged = true;
259} 261}
260 262
261void EmailEditDialog::selectionChanged( int index ) 263void EmailEditDialog::selectionChanged( int index )
262{ 264{
263 bool value = ( index >= 0 ); // An item is selected 265 bool value = ( index >= 0 ); // An item is selected
264 266
265 mRemoveButton->setEnabled( value ); 267 mRemoveButton->setEnabled( value );
266 mEditButton->setEnabled( value ); 268 mEditButton->setEnabled( value );
267 mStandardButton->setEnabled( value ); 269 mStandardButton->setEnabled( value );
268} 270}
269 271
270void EmailEditDialog::emailChanged() 272void EmailEditDialog::emailChanged()
271{ 273{
272 mAddButton->setEnabled( !mEmailEdit->text().isEmpty() ); 274 mAddButton->setEnabled( !mEmailEdit->text().isEmpty() );
273} 275}
274 276
275#ifndef KAB_EMBEDDED 277#ifndef KAB_EMBEDDED_
276#include "emaileditwidget.moc" 278#include "moc_emaileditwidget.cpp"
277#endif //KAB_EMBEDDED 279#endif //KAB_EMBEDDED
diff --git a/kaddressbook/emaileditwidget.h b/kaddressbook/emaileditwidget.h
index acdecaf..618acee 100644
--- a/kaddressbook/emaileditwidget.h
+++ b/kaddressbook/emaileditwidget.h
@@ -1,101 +1,101 @@
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 EMAILEDITWIDGET_H 24#ifndef EMAILEDITWIDGET_H
25#define EMAILEDITWIDGET_H 25#define EMAILEDITWIDGET_H
26 26
27#include <kabc/addressee.h> 27#include <kabc/addressee.h>
28#include <kdialogbase.h> 28#include <kdialogbase.h>
29 29
30#include "addresseeconfig.h" 30#include "addresseeconfig.h"
31 31
32class QButtonGroup; 32class Q3ButtonGroup;
33class QCheckBox; 33class QCheckBox;
34class QListView; 34class Q3ListView;
35class QListBox; 35class Q3ListBox;
36class QTextEdit; 36class Q3TextEdit;
37class QToolButton; 37class QToolButton;
38 38
39class KComboBox; 39class KComboBox;
40class KLineEdit; 40class KLineEdit;
41class KListView; 41class KListView;
42 42
43/** 43/**
44 This widget displays a list box of the email addresses as well as buttons 44 This widget displays a list box of the email addresses as well as buttons
45 to manipulate them (up, down, add, remove). 45 to manipulate them (up, down, add, remove).
46*/ 46*/
47class EmailEditWidget : public QWidget 47class EmailEditWidget : public QWidget
48{ 48{
49 Q_OBJECT 49 Q_OBJECT
50 50
51 public: 51 public:
52 EmailEditWidget( QWidget *parent, const char *name = 0 ); 52 EmailEditWidget( QWidget *parent, const char *name = 0 );
53 ~EmailEditWidget(); 53 ~EmailEditWidget();
54 54
55 void setEmails( const QStringList &list ); 55 void setEmails( const QStringList &list );
56 QStringList emails(); 56 QStringList emails();
57 57
58 signals: 58 signals:
59 void modified(); 59 void modified();
60 60
61 private slots: 61 private slots:
62 void edit(); 62 void edit();
63 void textChanged( const QString& ); 63 void textChanged( const QString& );
64 64
65 private: 65 private:
66 KLineEdit *mEmailEdit; 66 KLineEdit *mEmailEdit;
67 QStringList mEmailList; 67 QStringList mEmailList;
68}; 68};
69 69
70class EmailEditDialog : public KDialogBase 70class EmailEditDialog : public KDialogBase
71{ 71{
72 Q_OBJECT 72 Q_OBJECT
73 73
74 public: 74 public:
75 EmailEditDialog( const QStringList &list, QWidget *parent, 75 EmailEditDialog( const QStringList &list, QWidget *parent,
76 const char *name = 0 ); 76 const char *name = 0 );
77 ~EmailEditDialog(); 77 ~EmailEditDialog();
78 78
79 QStringList emails() const; 79 QStringList emails() const;
80 bool changed() const; 80 bool changed() const;
81 81
82 protected slots: 82 protected slots:
83 void add(); 83 void add();
84 void remove(); 84 void remove();
85 void edit(); 85 void edit();
86 void standard(); 86 void standard();
87 void selectionChanged( int ); 87 void selectionChanged( int );
88 void emailChanged(); 88 void emailChanged();
89 89
90 private: 90 private:
91 KLineEdit *mEmailEdit; 91 KLineEdit *mEmailEdit;
92 QListBox *mEmailListBox; 92 Q3ListBox *mEmailListBox;
93 QPushButton *mAddButton; 93 QPushButton *mAddButton;
94 QPushButton *mRemoveButton; 94 QPushButton *mRemoveButton;
95 QPushButton *mEditButton; 95 QPushButton *mEditButton;
96 QPushButton *mStandardButton; 96 QPushButton *mStandardButton;
97 97
98 bool mChanged; 98 bool mChanged;
99}; 99};
100 100
101#endif 101#endif
diff --git a/kaddressbook/extensionmanager.cpp b/kaddressbook/extensionmanager.cpp
index 46defa1..5356224 100644
--- a/kaddressbook/extensionmanager.cpp
+++ b/kaddressbook/extensionmanager.cpp
@@ -1,249 +1,251 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 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#include <qlayout.h> 23#include <qlayout.h>
24#include <qapplication.h> 24#include <qapplication.h>
25//Added by qt3to4:
26#include <Q3HBoxLayout>
25#include <kactionclasses.h> 27#include <kactionclasses.h>
26#include <kconfig.h> 28#include <kconfig.h>
27#include <kdebug.h> 29#include <kdebug.h>
28#include <klocale.h> 30#include <klocale.h>
29 31
30#ifndef KAB_EMBEDDED 32#ifndef KAB_EMBEDDED
31#include <ktrader.h> 33#include <ktrader.h>
32#else //KAB_EMBEDDED 34#else //KAB_EMBEDDED
33#include <features/mergewidget.h> 35#include <features/mergewidget.h>
34#include <features/distributionlistwidget.h> 36#include <features/distributionlistwidget.h>
35#endif //KAB_EMBEDDED 37#endif //KAB_EMBEDDED
36 38
37#include "addresseeeditorwidget.h" 39#include "addresseeeditorwidget.h"
38#include "kabcore.h" 40#include "kabcore.h"
39#include "kabprefs.h" 41#include "kabprefs.h"
40 42
41#include "extensionmanager.h" 43#include "extensionmanager.h"
42 44
43ExtensionManager::ExtensionManager( KABCore *core, QWidget *parent, 45ExtensionManager::ExtensionManager( KABCore *core, QWidget *parent,
44 const char *name ) 46 const char *name )
45 : QScrollView( parent, name ), mCore( core ), mCurrentExtensionWidget( 0 ) 47 : Q3ScrollView( parent, name ), mCore( core ), mCurrentExtensionWidget( 0 )
46{ 48{
47#ifdef KAB_EMBEDDED 49#ifdef KAB_EMBEDDED
48//US QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); 50//US QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu();
49 QWidget *settingsmenu = (QWidget*)mCore->getViewMenu(); 51 QWidget *settingsmenu = (QWidget*)mCore->getViewMenu();
50#endif //KAB_EMBEDDED 52#endif //KAB_EMBEDDED
51 53
52 mActionExtensions = new KSelectAction( i18n( "Show Extension Bar" ), 0, 54 mActionExtensions = new KSelectAction( i18n( "Show Extension Bar" ), 0,
53 mCore->actionCollection(), 55 mCore->actionCollection(),
54 "options_show_extensions" ); 56 "options_show_extensions" );
55 57
56 mActionExtensions->plug( settingsmenu ,0); 58 mActionExtensions->plug( settingsmenu ,0);
57 59
58 connect( mActionExtensions, SIGNAL( activated( int ) ), 60 connect( mActionExtensions, SIGNAL( activated( int ) ),
59 SLOT( setActiveExtension( int ) ) ); 61 SLOT( setActiveExtension( int ) ) );
60 mWidgetBox = new QWidget( viewport() ); 62 mWidgetBox = new QWidget( viewport() );
61 new QHBoxLayout (mWidgetBox ); 63 new Q3HBoxLayout (mWidgetBox );
62 addChild( mWidgetBox ); 64 addChild( mWidgetBox );
63 setResizePolicy(AutoOneFit); 65 setResizePolicy(AutoOneFit);
64 createExtensionWidgets(); 66 createExtensionWidgets();
65 hide(); 67 hide();
66} 68}
67 69
68ExtensionManager::~ExtensionManager() 70ExtensionManager::~ExtensionManager()
69{ 71{
70} 72}
71 73
72void ExtensionManager::restoreSettings() 74void ExtensionManager::restoreSettings()
73{ 75{
74 mActionExtensions->setCurrentItem( KABPrefs::instance()->mCurrentExtension ); 76 mActionExtensions->setCurrentItem( KABPrefs::instance()->mCurrentExtension );
75 int i = 1; 77 int i = 1;
76 mCurrentExtensionWidget = mExtensionWidgetList.at( i-1 ); 78 mCurrentExtensionWidget = mExtensionWidgetList.at( i-1 );
77 while ( mCurrentExtensionWidget ) { 79 while ( mCurrentExtensionWidget ) {
78 if( i != KABPrefs::instance()->mCurrentExtension ) 80 if( i != KABPrefs::instance()->mCurrentExtension )
79 mCurrentExtensionWidget->hide(); 81 mCurrentExtensionWidget->hide();
80 mCurrentExtensionWidget = mExtensionWidgetList.at( ++i-1 ); 82 mCurrentExtensionWidget = mExtensionWidgetList.at( ++i-1 );
81 83
82 } 84 }
83 setActiveExtension( mActionExtensions->currentItem() ); 85 setActiveExtension( mActionExtensions->currentItem() );
84} 86}
85 87
86void ExtensionManager::saveSettings() 88void ExtensionManager::saveSettings()
87{ 89{
88 KABPrefs::instance()->mCurrentExtension = mActionExtensions->currentItem(); 90 KABPrefs::instance()->mCurrentExtension = mActionExtensions->currentItem();
89} 91}
90 92
91void ExtensionManager::reconfigure() 93void ExtensionManager::reconfigure()
92{ 94{
93 saveSettings(); 95 saveSettings();
94 createExtensionWidgets(); 96 createExtensionWidgets();
95 restoreSettings(); 97 restoreSettings();
96} 98}
97 99
98bool ExtensionManager::isQuickEditVisible() const 100bool ExtensionManager::isQuickEditVisible() const
99{ 101{
100 return ( mCurrentExtensionWidget && 102 return ( mCurrentExtensionWidget &&
101 mCurrentExtensionWidget->identifier() == "contact_editor" ); 103 mCurrentExtensionWidget->identifier() == "contact_editor" );
102} 104}
103 105
104void ExtensionManager::setSelectionChanged() 106void ExtensionManager::setSelectionChanged()
105{ 107{
106 if ( mCurrentExtensionWidget ) 108 if ( mCurrentExtensionWidget )
107 mCurrentExtensionWidget->contactsSelectionChanged(); 109 mCurrentExtensionWidget->contactsSelectionChanged();
108} 110}
109 111
110void ExtensionManager::setActiveExtension( int id ) 112void ExtensionManager::setActiveExtension( int id )
111{ 113{
112 //qDebug("+++++++++++++++++++ExtensionManager::setActiveExtension %d ", id); 114 //qDebug("+++++++++++++++++++ExtensionManager::setActiveExtension %d ", id);
113 if ( id == 0 ) { 115 if ( id == 0 ) {
114 hide(); 116 hide();
115 mCurrentExtensionWidget = 0; 117 mCurrentExtensionWidget = 0;
116#ifndef DESKTOP_VERSION 118#ifndef DESKTOP_VERSION
117//US our screen is so small, that we better hide the detailscreen, just in case. 119//US our screen is so small, that we better hide the detailscreen, just in case.
118//US mCore->setDetailsToState( ); 120//US mCore->setDetailsToState( );
119#endif //KAB_EMBEDDED 121#endif //KAB_EMBEDDED
120 } else if ( id > 0 ) { 122 } else if ( id > 0 ) {
121 if ( mCurrentExtensionWidget ) 123 if ( mCurrentExtensionWidget )
122 mCurrentExtensionWidget->hide(); 124 mCurrentExtensionWidget->hide();
123 125
124 mCurrentExtensionWidget = mExtensionWidgetList.at( id - 1 ); 126 mCurrentExtensionWidget = mExtensionWidgetList.at( id - 1 );
125 127
126 if ( mCurrentExtensionWidget ) { 128 if ( mCurrentExtensionWidget ) {
127#ifndef DESKTOP_VERSION 129#ifndef DESKTOP_VERSION
128//US our screen is so small, that we better hide the detailscreen, just in case. 130//US our screen is so small, that we better hide the detailscreen, just in case.
129//US mCore->setDetailsVisible( false ); 131//US mCore->setDetailsVisible( false );
130#endif //KAB_EMBEDDED 132#endif //KAB_EMBEDDED
131 show(); 133 show();
132 mWidgetBox->show(); 134 mWidgetBox->show();
133 mCurrentExtensionWidget->show(); 135 mCurrentExtensionWidget->show();
134 } else { 136 } else {
135 hide(); 137 hide();
136 mCurrentExtensionWidget = 0; 138 mCurrentExtensionWidget = 0;
137#ifndef DESKTOP_VERSION 139#ifndef DESKTOP_VERSION
138//US our screen is so small, that we better hide the detailscreen, just in case. 140//US our screen is so small, that we better hide the detailscreen, just in case.
139//US mCore->setDetailsToState( ); 141//US mCore->setDetailsToState( );
140#endif //KAB_EMBEDDED 142#endif //KAB_EMBEDDED
141 } 143 }
142 } 144 }
143 145
144 emit changedActiveExtension( id ); 146 emit changedActiveExtension( id );
145} 147}
146 148
147void ExtensionManager::createExtensionWidgets() 149void ExtensionManager::createExtensionWidgets()
148{ 150{
149 // clear extension widget list 151 // clear extension widget list
150 mExtensionWidgetList.setAutoDelete( true ); 152 mExtensionWidgetList.setAutoDelete( true );
151 QPtrListIterator<ExtensionWidget> wdgIt( mExtensionWidgetList ); 153 Q3PtrListIterator<ExtensionWidget> wdgIt( mExtensionWidgetList );
152 ExtensionWidget *wdg = 0; 154 ExtensionWidget *wdg = 0;
153 while ( ( wdg = wdgIt.current() ) != 0 ) 155 while ( ( wdg = wdgIt.current() ) != 0 )
154 mExtensionWidgetList.remove( wdg ); 156 mExtensionWidgetList.remove( wdg );
155 157
156 mExtensionWidgetList.setAutoDelete( false ); 158 mExtensionWidgetList.setAutoDelete( false );
157 159
158 QStringList extensionNames( i18n( "None" ) ); 160 QStringList extensionNames( i18n( "None" ) );
159 161
160 // add addressee editor as default 162 // add addressee editor as default
161 163
162 QHBoxLayout *hbl = (QHBoxLayout *) mWidgetBox->layout();; 164 Q3HBoxLayout *hbl = (Q3HBoxLayout *) mWidgetBox->layout();;
163 165
164 wdg = new AddresseeEditorWidget( mCore, true, mWidgetBox ); 166 wdg = new AddresseeEditorWidget( mCore, true, mWidgetBox );
165 hbl->addWidget( wdg ); 167 hbl->addWidget( wdg );
166 //wdg->hide(); 168 //wdg->hide();
167 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ), 169 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ),
168 SIGNAL( modified( const KABC::Addressee::List& ) ) ); 170 SIGNAL( modified( const KABC::Addressee::List& ) ) );
169 mExtensionWidgetList.append( wdg ); 171 mExtensionWidgetList.append( wdg );
170 extensionNames.append( wdg->title() ); 172 extensionNames.append( wdg->title() );
171 173
172 // load the other extensions 174 // load the other extensions
173 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; 175 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions;
174 176
175#ifndef KAB_EMBEDDED 177#ifndef KAB_EMBEDDED
176 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); 178 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" );
177 KTrader::OfferList::ConstIterator it; 179 KTrader::OfferList::ConstIterator it;
178 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 180 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
179 if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) 181 if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) )
180 continue; 182 continue;
181 183
182 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); 184 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() );
183 if ( !factory ) { 185 if ( !factory ) {
184 //kdDebug(5720) << "ExtensionManager::loadExtensions(): Factory creation failed" << endl; 186 //kdDebug(5720) << "ExtensionManager::loadExtensions(): Factory creation failed" << endl;
185 continue; 187 continue;
186 } 188 }
187 189
188 ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory ); 190 ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory );
189 191
190 if ( !extensionFactory ) { 192 if ( !extensionFactory ) {
191 //kdDebug(5720) << "ExtensionManager::loadExtensions(): Cast failed" << endl; 193 //kdDebug(5720) << "ExtensionManager::loadExtensions(): Cast failed" << endl;
192 continue; 194 continue;
193 } 195 }
194 196
195 if ( !activeExtensions.contains( extensionFactory->identifier() ) ) 197 if ( !activeExtensions.contains( extensionFactory->identifier() ) )
196 continue; 198 continue;
197 199
198 wdg = extensionFactory->extension( mCore, this ); 200 wdg = extensionFactory->extension( mCore, this );
199 if ( wdg ) { 201 if ( wdg ) {
200 //wdg->hide(); 202 //wdg->hide();
201 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ), 203 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ),
202 SIGNAL( modified( const KABC::Addressee::List& ) ) ); 204 SIGNAL( modified( const KABC::Addressee::List& ) ) );
203 mExtensionWidgetList.append( wdg ); 205 mExtensionWidgetList.append( wdg );
204 extensionNames.append( wdg->title() ); 206 extensionNames.append( wdg->title() );
205 } 207 }
206 } 208 }
207#else //KAB_EMBEDDED 209#else //KAB_EMBEDDED
208 //load Mergefactory/extension 210 //load Mergefactory/extension
209 ExtensionFactory *extensionFactory = new MergeFactory(); 211 ExtensionFactory *extensionFactory = new MergeFactory();
210 if ( activeExtensions.contains( extensionFactory->identifier() ) ) 212 if ( activeExtensions.contains( extensionFactory->identifier() ) )
211 { 213 {
212 wdg = extensionFactory->extension( mCore, mWidgetBox ); 214 wdg = extensionFactory->extension( mCore, mWidgetBox );
213 if ( wdg ) { 215 if ( wdg ) {
214 hbl->addWidget( wdg ); 216 hbl->addWidget( wdg );
215 //wdg->hide(); 217 //wdg->hide();
216 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ), 218 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ),
217 SIGNAL( modified( const KABC::Addressee::List& ) ) ); 219 SIGNAL( modified( const KABC::Addressee::List& ) ) );
218 mExtensionWidgetList.append( wdg ); 220 mExtensionWidgetList.append( wdg );
219 extensionNames.append( wdg->title() ); 221 extensionNames.append( wdg->title() );
220 } 222 }
221 } 223 }
222 224
223 //load DistributionListfactory/extension 225 //load DistributionListfactory/extension
224 extensionFactory = new DistributionListFactory(); 226 extensionFactory = new DistributionListFactory();
225 if (activeExtensions.contains( extensionFactory->identifier() ) ) 227 if (activeExtensions.contains( extensionFactory->identifier() ) )
226 { 228 {
227 wdg = extensionFactory->extension( mCore, mWidgetBox ); 229 wdg = extensionFactory->extension( mCore, mWidgetBox );
228 if ( wdg ) { 230 if ( wdg ) {
229 hbl->addWidget( wdg ); 231 hbl->addWidget( wdg );
230 //wdg->hide(); 232 //wdg->hide();
231 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ), 233 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ),
232 SIGNAL( modified( const KABC::Addressee::List& ) ) ); 234 SIGNAL( modified( const KABC::Addressee::List& ) ) );
233 mExtensionWidgetList.append( wdg ); 235 mExtensionWidgetList.append( wdg );
234 extensionNames.append( wdg->title() ); 236 extensionNames.append( wdg->title() );
235 } 237 }
236 } 238 }
237 239
238 hbl->addStretch(); 240 hbl->addStretch();
239 241
240#endif //KAB_EMBEDDED 242#endif //KAB_EMBEDDED
241 243
242 244
243 mActionExtensions->setItems( extensionNames ); 245 mActionExtensions->setItems( extensionNames );
244 mCurrentExtensionWidget = 0; 246 mCurrentExtensionWidget = 0;
245} 247}
246 248
247#ifndef KAB_EMBEDDED 249#ifndef KAB_EMBEDDED_
248#include "extensionmanager.moc" 250#include "moc_extensionmanager.cpp"
249#endif //KAB_EMBEDDED 251#endif //KAB_EMBEDDED
diff --git a/kaddressbook/extensionmanager.h b/kaddressbook/extensionmanager.h
index 611a037..84c948b 100644
--- a/kaddressbook/extensionmanager.h
+++ b/kaddressbook/extensionmanager.h
@@ -1,89 +1,89 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 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#ifndef EXTENSIONMANAGER_H 24#ifndef EXTENSIONMANAGER_H
25#define EXTENSIONMANAGER_H 25#define EXTENSIONMANAGER_H
26 26
27#include <qhbox.h> 27#include <q3hbox.h>
28#include <qscrollview.h> 28#include <q3scrollview.h>
29#include <qptrlist.h> 29#include <q3ptrlist.h>
30 30
31#include <extensionwidget.h> 31#include <extensionwidget.h>
32 32
33class KABCore; 33class KABCore;
34class KSelectAction; 34class KSelectAction;
35 35
36 36
37class ExtensionManager : public QScrollView 37class ExtensionManager : public Q3ScrollView
38{ 38{
39 Q_OBJECT 39 Q_OBJECT
40 40
41 public: 41 public:
42 ExtensionManager( KABCore *core, QWidget *parent, const char *name = 0 ); 42 ExtensionManager( KABCore *core, QWidget *parent, const char *name = 0 );
43 ~ExtensionManager(); 43 ~ExtensionManager();
44 44
45 /** 45 /**
46 Restores the extension manager specific settings. 46 Restores the extension manager specific settings.
47 */ 47 */
48 void restoreSettings(); 48 void restoreSettings();
49 49
50 /** 50 /**
51 Saves the extension manager specific settings. 51 Saves the extension manager specific settings.
52 */ 52 */
53 void saveSettings(); 53 void saveSettings();
54 54
55 /** 55 /**
56 Rereads the extension manager specific settings with some 56 Rereads the extension manager specific settings with some
57 additional initialization stuff. 57 additional initialization stuff.
58 */ 58 */
59 void reconfigure(); 59 void reconfigure();
60 60
61 /** 61 /**
62 Returns whether the quickedit extension is currently visible. 62 Returns whether the quickedit extension is currently visible.
63 */ 63 */
64 bool isQuickEditVisible() const; 64 bool isQuickEditVisible() const;
65 65
66 public slots: 66 public slots:
67 void setSelectionChanged(); 67 void setSelectionChanged();
68 68
69 signals: 69 signals:
70 void modified( const KABC::Addressee::List& ); 70 void modified( const KABC::Addressee::List& );
71 void changedActiveExtension( int id ); 71 void changedActiveExtension( int id );
72 72
73 private slots: 73 private slots:
74 void setActiveExtension( int id ); 74 void setActiveExtension( int id );
75 75
76 private: 76 private:
77 void createExtensionWidgets(); 77 void createExtensionWidgets();
78 78
79 KABCore *mCore; 79 KABCore *mCore;
80 QWidget *mWidgetBox; 80 QWidget *mWidgetBox;
81 81
82 ExtensionWidget *mCurrentExtensionWidget; 82 ExtensionWidget *mCurrentExtensionWidget;
83 QPtrList<ExtensionWidget> mExtensionWidgetList; 83 Q3PtrList<ExtensionWidget> mExtensionWidgetList;
84 84
85 KSelectAction *mActionExtensions; 85 KSelectAction *mActionExtensions;
86 86
87}; 87};
88 88
89#endif 89#endif
diff --git a/kaddressbook/extensionwidget.cpp b/kaddressbook/extensionwidget.cpp
index 69f4aa8..7c3b415 100644
--- a/kaddressbook/extensionwidget.cpp
+++ b/kaddressbook/extensionwidget.cpp
@@ -1,84 +1,83 @@
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 "configurewidget.h" 24#include "configurewidget.h"
25#include "kabcore.h" 25#include "kabcore.h"
26 26
27#include "extensionwidget.h" 27#include "extensionwidget.h"
28 28
29ExtensionWidget::ExtensionWidget( KABCore *core, QWidget *parent, 29ExtensionWidget::ExtensionWidget( KABCore *core, QWidget *parent,
30 const char *name ) 30 const char *name )
31 : QWidget( parent, name ), mCore( core ) 31 : QWidget( parent, name ), mCore( core )
32{ 32{
33} 33}
34 34
35ExtensionWidget::~ExtensionWidget() 35ExtensionWidget::~ExtensionWidget()
36{ 36{
37} 37}
38 38
39KABCore *ExtensionWidget::core() const 39KABCore *ExtensionWidget::core() const
40{ 40{
41 return mCore; 41 return mCore;
42} 42}
43 43
44bool ExtensionWidget::contactsSelected() const 44bool ExtensionWidget::contactsSelected() const
45{ 45{
46 return mCore->selectedUIDs().count() != 0; 46 return mCore->selectedUIDs().count() != 0;
47} 47}
48 48
49KABC::Addressee::List ExtensionWidget::selectedContacts() 49KABC::Addressee::List ExtensionWidget::selectedContacts()
50{ 50{
51 KABC::Addressee::List list; 51 KABC::Addressee::List list;
52 52
53 QStringList uids = mCore->selectedUIDs(); 53 QStringList uids = mCore->selectedUIDs();
54 QStringList::Iterator it; 54 QStringList::Iterator it;
55 for ( it = uids.begin(); it != uids.end(); ++it ) 55 for ( it = uids.begin(); it != uids.end(); ++it )
56 list.append( mCore->addressBook()->findByUid( *it ) ); 56 list.append( mCore->addressBook()->findByUid( *it ) );
57 57
58 return list; 58 return list;
59} 59}
60 60
61void ExtensionWidget::contactsSelectionChanged() 61void ExtensionWidget::contactsSelectionChanged()
62{ 62{
63 // do nothing 63 // do nothing
64} 64}
65 65
66QString ExtensionWidget::title() const 66QString ExtensionWidget::title() const
67{ 67{
68 return "<bug!!!>"; 68 return "<bug!!!>";
69} 69}
70 70
71QString ExtensionWidget::identifier() const 71QString ExtensionWidget::identifier() const
72{ 72{
73 return "<bug!!!>"; 73 return "<bug!!!>";
74} 74}
75 75
76ConfigureWidget *ExtensionFactory::configureWidget( QWidget*, const char* ) 76ConfigureWidget *ExtensionFactory::configureWidget( QWidget*, const char* )
77{ 77{
78 return 0; 78 return 0;
79} 79}
80 80
81#ifndef KAB_EMBEDDED 81#ifndef KAB_EMBEDDED_
82#include "extensionwidget.moc" 82#include "moc_extensionwidget.cpp"
83#endif //KAB_EMBEDDED 83#endif //KAB_EMBEDDED
84
diff --git a/kaddressbook/extensionwidget.h b/kaddressbook/extensionwidget.h
index fc91f21..9fcfba9 100644
--- a/kaddressbook/extensionwidget.h
+++ b/kaddressbook/extensionwidget.h
@@ -1,119 +1,119 @@
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#ifndef EXTENSIONWIDGET_H 24#ifndef EXTENSIONWIDGET_H
25#define EXTENSIONWIDGET_H 25#define EXTENSIONWIDGET_H
26 26
27#include <qwidget.h> 27#include <qwidget.h>
28 28
29#include <kabc/addressbook.h> 29#include <kabc/addressbook.h>
30#ifndef KAB_EMBEDDED 30#ifndef KAB_EMBEDDED
31#include <klibloader.h> 31#include <klibloader.h>
32#endif //KAB_EMBEDDED 32#endif //KAB_EMBEDDED
33 33
34class ConfigureWidget; 34class ConfigureWidget;
35class KABCore; 35class KABCore;
36 36
37class ExtensionWidget : public QWidget 37class ExtensionWidget : public QWidget
38{ 38{
39 Q_OBJECT 39 Q_OBJECT
40 40
41 public: 41 public:
42 ExtensionWidget( KABCore *core, QWidget *parent, const char *name = 0 ); 42 ExtensionWidget( KABCore *core, QWidget *parent, const char *name = 0 );
43 ~ExtensionWidget(); 43 ~ExtensionWidget();
44 44
45 /** 45 /**
46 @return A pointer to the core object 46 @return A pointer to the core object
47 */ 47 */
48 KABCore *core() const; 48 KABCore *core() const;
49 49
50 /** 50 /**
51 Returns whether there are selected contacts in the view. 51 Returns whether there are selected contacts in the view.
52 */ 52 */
53 bool contactsSelected() const; 53 bool contactsSelected() const;
54 54
55 /** 55 /**
56 Returns a list of contacts that are selected in the view. 56 Returns a list of contacts that are selected in the view.
57 Use @ref addresseesSelected() to test if there exists selected 57 Use @ref addresseesSelected() to test if there exists selected
58 contacts. 58 contacts.
59 */ 59 */
60 KABC::Addressee::List selectedContacts(); 60 KABC::Addressee::List selectedContacts();
61 61
62 /** 62 /**
63 This method is called whenever the selection in the view changed. 63 This method is called whenever the selection in the view changed.
64 */ 64 */
65 virtual void contactsSelectionChanged(); 65 virtual void contactsSelectionChanged();
66 66
67 /** 67 /**
68 This method should be reimplemented and return the i18ned title of this 68 This method should be reimplemented and return the i18ned title of this
69 widget. 69 widget.
70 */ 70 */
71 virtual QString title() const; 71 virtual QString title() const;
72 72
73 /** 73 /**
74 This method should be reimplemented and return a unique identifier. 74 This method should be reimplemented and return a unique identifier.
75 */ 75 */
76 virtual QString identifier() const; 76 virtual QString identifier() const;
77 77
78 signals: 78 signals:
79 void modified( const KABC::Addressee::List &list ); 79 void modified( const KABC::Addressee::List &list );
80 80
81 private: 81 private:
82 KABCore *mCore; 82 KABCore *mCore;
83 83
84 class ExtensionWidgetPrivate; 84 class ExtensionWidgetPrivate;
85 ExtensionWidgetPrivate *d; 85 ExtensionWidgetPrivate *d;
86}; 86};
87 87
88#ifndef KAB_EMBEDDED 88#ifndef KAB_EMBEDDED
89//MOC_SKIP_BEGIN 89#ifndef Q_MOC_RUN
90class ExtensionFactory : public KLibFactory 90class ExtensionFactory : public KLibFactory
91//MOC_SKIP_END 91#endif
92#else //KAB_EMBEDDED 92#else //KAB_EMBEDDED
93class ExtensionFactory 93class ExtensionFactory
94#endif //KAB_EMBEDDED 94#endif //KAB_EMBEDDED
95{ 95{
96 public: 96 public:
97 virtual ExtensionWidget *extension( KABCore *core, QWidget *parent, 97 virtual ExtensionWidget *extension( KABCore *core, QWidget *parent,
98 const char *name = 0 ) = 0; 98 const char *name = 0 ) = 0;
99 99
100 virtual ConfigureWidget *configureWidget( QWidget *parent, 100 virtual ConfigureWidget *configureWidget( QWidget *parent,
101 const char *name = 0 ); 101 const char *name = 0 );
102 102
103 virtual bool configureWidgetAvailable() { return false; } 103 virtual bool configureWidgetAvailable() { return false; }
104 104
105 /** 105 /**
106 This method should return the same identifier like the config 106 This method should return the same identifier like the config
107 widget. 107 widget.
108 */ 108 */
109 virtual QString identifier() const = 0; 109 virtual QString identifier() const = 0;
110 110
111 protected: 111 protected:
112 virtual QObject* createObject( QObject*, const char*, const char*, 112 virtual QObject* createObject( QObject*, const char*, const char*,
113 const QStringList & ) 113 const QStringList & )
114 { 114 {
115 return 0; 115 return 0;
116 } 116 }
117}; 117};
118 118
119#endif 119#endif
diff --git a/kaddressbook/features/distributionlistwidget.cpp b/kaddressbook/features/distributionlistwidget.cpp
index bfcb121..996177b 100644
--- a/kaddressbook/features/distributionlistwidget.cpp
+++ b/kaddressbook/features/distributionlistwidget.cpp
@@ -1,501 +1,508 @@
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 <qbuttongroup.h> 24#include <q3buttongroup.h>
25#include <qcombobox.h> 25#include <qcombobox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qlistview.h> 28#include <q3listview.h>
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30#include <qradiobutton.h> 30#include <qradiobutton.h>
31//Added by qt3to4:
32#include <QDragMoveEvent>
33#include <QDropEvent>
34#include <Q3GridLayout>
35#include <Q3Frame>
36#include <Q3VBoxLayout>
37#include <QDragEnterEvent>
31 38
32#ifndef KAB_EMBEDDED 39#ifndef KAB_EMBEDDED
33#include <kaccelmanager.h> 40#include <kaccelmanager.h>
34#endif //KAB_EMBEDDED 41#endif //KAB_EMBEDDED
35 42
36 43
37#include <kdebug.h> 44#include <kdebug.h>
38#include <klineeditdlg.h> 45#include <klineeditdlg.h>
39#include <klocale.h> 46#include <klocale.h>
40#include <kglobal.h> 47#include <kglobal.h>
41#include <kmessagebox.h> 48#include <kmessagebox.h>
42 49
43#include <kabc/addressbook.h> 50#include <kabc/addressbook.h>
44#include <kabc/addresseedialog.h> 51#include <kabc/addresseedialog.h>
45#include <kabc/distributionlist.h> 52#include <kabc/distributionlist.h>
46#include <kabc/vcardconverter.h> 53#include <kabc/vcardconverter.h>
47 54
48#ifndef KAB_EMBEDDED 55#ifndef KAB_EMBEDDED
49#include <libkdepim/kvcarddrag.h> 56#include <libkdepim/kvcarddrag.h>
50#endif //KAB_EMBEDDED 57#endif //KAB_EMBEDDED
51 58
52#include "kabcore.h" 59#include "kabcore.h"
53 60
54#include "distributionlistwidget.h" 61#include "distributionlistwidget.h"
55 62
56#ifndef KAB_EMBEDDED 63#ifndef KAB_EMBEDDED
57 64
58class DistributionListFactory : public ExtensionFactory 65class DistributionListFactory : public ExtensionFactory
59{ 66{
60 public: 67 public:
61 ExtensionWidget *extension( KABCore *core, QWidget *parent, const char *name ) 68 ExtensionWidget *extension( KABCore *core, QWidget *parent, const char *name )
62 { 69 {
63 return new DistributionListWidget( core, parent, name ); 70 return new DistributionListWidget( core, parent, name );
64 } 71 }
65 72
66 QString identifier() const 73 QString identifier() const
67 { 74 {
68 return "distribution_list_editor"; 75 return "distribution_list_editor";
69 } 76 }
70}; 77};
71 78
72extern "C" { 79extern "C" {
73 void *init_libkaddrbk_distributionlist() 80 void *init_libkaddrbk_distributionlist()
74 { 81 {
75 return ( new DistributionListFactory ); 82 return ( new DistributionListFactory );
76 } 83 }
77} 84}
78#endif //KAB_EMBEDDED 85#endif //KAB_EMBEDDED
79 86
80class ContactItem : public QListViewItem 87class ContactItem : public Q3ListViewItem
81{ 88{
82 public: 89 public:
83 ContactItem( DistributionListView *parent, const KABC::Addressee &addressee, 90 ContactItem( DistributionListView *parent, const KABC::Addressee &addressee,
84 const QString &email = QString::null ) : 91 const QString &email = QString::null ) :
85 QListViewItem( parent ), 92 Q3ListViewItem( parent ),
86 mAddressee( addressee ), 93 mAddressee( addressee ),
87 mEmail( email ) 94 mEmail( email )
88 { 95 {
89 setText( 0, addressee.realName() ); 96 setText( 0, addressee.realName() );
90 if( email.isEmpty() ) { 97 if( email.isEmpty() ) {
91 setText( 1, addressee.preferredEmail() ); 98 setText( 1, addressee.preferredEmail() );
92 setText( 2, i18n( "Yes" ) ); 99 setText( 2, i18n( "Yes" ) );
93 } else { 100 } else {
94 setText( 1, email ); 101 setText( 1, email );
95 setText( 2, i18n( "No" ) ); 102 setText( 2, i18n( "No" ) );
96 } 103 }
97 } 104 }
98 105
99 KABC::Addressee addressee() const 106 KABC::Addressee addressee() const
100 { 107 {
101 return mAddressee; 108 return mAddressee;
102 } 109 }
103 110
104 QString email() const 111 QString email() const
105 { 112 {
106 return mEmail; 113 return mEmail;
107 } 114 }
108 115
109 protected: 116 protected:
110 bool acceptDrop( const QMimeSource* ) 117 bool acceptDrop( const QMimeSource* )
111 { 118 {
112 return true; 119 return true;
113 } 120 }
114 121
115 private: 122 private:
116 KABC::Addressee mAddressee; 123 KABC::Addressee mAddressee;
117 QString mEmail; 124 QString mEmail;
118}; 125};
119 126
120DistributionListWidget::DistributionListWidget( KABCore *core, QWidget *parent, 127DistributionListWidget::DistributionListWidget( KABCore *core, QWidget *parent,
121 const char *name ) 128 const char *name )
122 : ExtensionWidget( core, parent, name ), mManager( 0 ) 129 : ExtensionWidget( core, parent, name ), mManager( 0 )
123{ 130{
124 QGridLayout *topLayout = new QGridLayout( this, 3, 4, KDialog::marginHint(), 131 Q3GridLayout *topLayout = new Q3GridLayout( this, 3, 4, KDialog::marginHint(),
125 KDialog::spacingHint() ); 132 KDialog::spacingHint() );
126 133
127 if (KGlobal::getOrientation() == KGlobal::Portrait) 134 if (KGlobal::getOrientation() == KGlobal::Portrait)
128 { 135 {
129 mCreateListButton = new QPushButton( i18n( "New List" ), this ); 136 mCreateListButton = new QPushButton( i18n( "New List" ), this );
130 mEditListButton = new QPushButton( i18n( "Ren List" ), this ); 137 mEditListButton = new QPushButton( i18n( "Ren List" ), this );
131 mRemoveListButton = new QPushButton( i18n( "Del List" ), this ); 138 mRemoveListButton = new QPushButton( i18n( "Del List" ), this );
132 mAddContactButton = new QPushButton( i18n( "Add Cont." ), this ); 139 mAddContactButton = new QPushButton( i18n( "Add Cont." ), this );
133 mChangeEmailButton = new QPushButton( i18n( "Chge Email" ), this ); 140 mChangeEmailButton = new QPushButton( i18n( "Chge Email" ), this );
134 mRemoveContactButton = new QPushButton( i18n( "Del Cont." ), this ); 141 mRemoveContactButton = new QPushButton( i18n( "Del Cont." ), this );
135 } 142 }
136 else 143 else
137 { 144 {
138 mCreateListButton = new QPushButton( i18n( "New List..." ), this ); 145 mCreateListButton = new QPushButton( i18n( "New List..." ), this );
139 mEditListButton = new QPushButton( i18n( "Rename List..." ), this ); 146 mEditListButton = new QPushButton( i18n( "Rename List..." ), this );
140 mRemoveListButton = new QPushButton( i18n( "Remove List" ), this ); 147 mRemoveListButton = new QPushButton( i18n( "Remove List" ), this );
141 mAddContactButton = new QPushButton( i18n( "Add Contact" ), this ); 148 mAddContactButton = new QPushButton( i18n( "Add Contact" ), this );
142 mChangeEmailButton = new QPushButton( i18n( "Change Email..." ), this ); 149 mChangeEmailButton = new QPushButton( i18n( "Change Email..." ), this );
143 mRemoveContactButton = new QPushButton( i18n( "Remove Contact" ), this ); 150 mRemoveContactButton = new QPushButton( i18n( "Remove Contact" ), this );
144 } 151 }
145 mNameCombo = new QComboBox( this ); 152 mNameCombo = new QComboBox( this );
146 topLayout->addWidget( mNameCombo, 0, 0 ); 153 topLayout->addWidget( mNameCombo, 0, 0 );
147 connect( mNameCombo, SIGNAL( activated( int ) ), SLOT( updateContactView() ) ); 154 connect( mNameCombo, SIGNAL( activated( int ) ), SLOT( updateContactView() ) );
148 155
149 topLayout->addWidget( mCreateListButton, 0, 1 ); 156 topLayout->addWidget( mCreateListButton, 0, 1 );
150 connect( mCreateListButton, SIGNAL( clicked() ), SLOT( createList() ) ); 157 connect( mCreateListButton, SIGNAL( clicked() ), SLOT( createList() ) );
151 158
152 topLayout->addWidget( mEditListButton, 0, 2 ); 159 topLayout->addWidget( mEditListButton, 0, 2 );
153 connect( mEditListButton, SIGNAL( clicked() ), SLOT( editList() ) ); 160 connect( mEditListButton, SIGNAL( clicked() ), SLOT( editList() ) );
154 161
155 topLayout->addWidget( mRemoveListButton, 0, 3 ); 162 topLayout->addWidget( mRemoveListButton, 0, 3 );
156 connect( mRemoveListButton, SIGNAL( clicked() ), SLOT( removeList() ) ); 163 connect( mRemoveListButton, SIGNAL( clicked() ), SLOT( removeList() ) );
157 164
158 mContactView = new DistributionListView( this ); 165 mContactView = new DistributionListView( this );
159 mContactView->addColumn( i18n( "Name" ) ); 166 mContactView->addColumn( i18n( "Name" ) );
160 mContactView->addColumn( i18n( "Email" ) ); 167 mContactView->addColumn( i18n( "Email" ) );
161 mContactView->addColumn( i18n( "Use Preferred" ) ); 168 mContactView->addColumn( i18n( "Use Preferred" ) );
162 mContactView->setEnabled( false ); 169 mContactView->setEnabled( false );
163 mContactView->setAllColumnsShowFocus( true ); 170 mContactView->setAllColumnsShowFocus( true );
164 mContactView->setMinimumHeight( 30 ); 171 mContactView->setMinimumHeight( 30 );
165 172
166 topLayout->addMultiCellWidget( mContactView, 1, 1, 0, 3 ); 173 topLayout->addMultiCellWidget( mContactView, 1, 1, 0, 3 );
167 connect( mContactView, SIGNAL( selectionChanged() ), 174 connect( mContactView, SIGNAL( selectionChanged() ),
168 SLOT( selectionContactViewChanged() ) ); 175 SLOT( selectionContactViewChanged() ) );
169 connect( mContactView, SIGNAL( dropped( QDropEvent*, QListViewItem* ) ), 176 connect( mContactView, SIGNAL( dropped( QDropEvent*, Q3ListViewItem* ) ),
170 SLOT( dropped( QDropEvent*, QListViewItem* ) ) ); 177 SLOT( dropped( QDropEvent*, Q3ListViewItem* ) ) );
171 178
172 mAddContactButton->setEnabled( false ); 179 mAddContactButton->setEnabled( false );
173 topLayout->addWidget( mAddContactButton, 2, 0 ); 180 topLayout->addWidget( mAddContactButton, 2, 0 );
174 connect( mAddContactButton, SIGNAL( clicked() ), SLOT( addContact() ) ); 181 connect( mAddContactButton, SIGNAL( clicked() ), SLOT( addContact() ) );
175 182
176 topLayout->addWidget( mChangeEmailButton, 2, 2 ); 183 topLayout->addWidget( mChangeEmailButton, 2, 2 );
177 connect( mChangeEmailButton, SIGNAL( clicked() ), SLOT( changeEmail() ) ); 184 connect( mChangeEmailButton, SIGNAL( clicked() ), SLOT( changeEmail() ) );
178 185
179 topLayout->addWidget( mRemoveContactButton, 2, 3 ); 186 topLayout->addWidget( mRemoveContactButton, 2, 3 );
180 connect( mRemoveContactButton, SIGNAL( clicked() ), SLOT( removeContact() ) ); 187 connect( mRemoveContactButton, SIGNAL( clicked() ), SLOT( removeContact() ) );
181 188
182 mManager = new KABC::DistributionListManager( core->addressBook() ); 189 mManager = new KABC::DistributionListManager( core->addressBook() );
183 mManager->load(); 190 mManager->load();
184 191
185 updateNameCombo(); 192 updateNameCombo();
186 193
187#ifdef KAB_EMBEDDED 194#ifdef KAB_EMBEDDED
188// if (KGlobal::getOrientation() == KGlobal::Portrait) 195// if (KGlobal::getOrientation() == KGlobal::Portrait)
189// parent->setMaximumSize( KGlobal::getDesktopWidth() , 150); 196// parent->setMaximumSize( KGlobal::getDesktopWidth() , 150);
190#endif //KAB_EMBEDDED 197#endif //KAB_EMBEDDED
191 198
192#ifndef KAB_EMBEDDED 199#ifndef KAB_EMBEDDED
193 KAcceleratorManager::manage( this ); 200 KAcceleratorManager::manage( this );
194#endif //KAB_EMBEDDED 201#endif //KAB_EMBEDDED
195} 202}
196 203
197DistributionListWidget::~DistributionListWidget() 204DistributionListWidget::~DistributionListWidget()
198{ 205{
199 delete mManager; 206 delete mManager;
200} 207}
201 208
202void DistributionListWidget::save() 209void DistributionListWidget::save()
203{ 210{
204qDebug("DistributionListWidget::save"); 211qDebug("DistributionListWidget::save");
205 mManager->save(); 212 mManager->save();
206} 213}
207 214
208void DistributionListWidget::selectionContactViewChanged() 215void DistributionListWidget::selectionContactViewChanged()
209{ 216{
210 ContactItem *contactItem = 217 ContactItem *contactItem =
211 static_cast<ContactItem *>( mContactView->selectedItem() ); 218 static_cast<ContactItem *>( mContactView->selectedItem() );
212 bool state = contactItem; 219 bool state = contactItem;
213 220
214 mChangeEmailButton->setEnabled( state ); 221 mChangeEmailButton->setEnabled( state );
215 mRemoveContactButton->setEnabled( state ); 222 mRemoveContactButton->setEnabled( state );
216} 223}
217 224
218void DistributionListWidget::createList() 225void DistributionListWidget::createList()
219{ 226{
220 KLineEditDlg dlg( i18n( "Please enter name:" ), QString::null, this ); 227 KLineEditDlg dlg( i18n( "Please enter name:" ), QString::null, this );
221#ifdef KAB_EMBEDDED 228#ifdef KAB_EMBEDDED
222 dlg.setFixedSize(200, 50); 229 dlg.setFixedSize(200, 50);
223#endif //KAB_EMBEDDED 230#endif //KAB_EMBEDDED
224 dlg.setCaption( i18n( "New Distribution List" ) ); 231 dlg.setCaption( i18n( "New Distribution List" ) );
225 if ( !dlg.exec() ) 232 if ( !dlg.exec() )
226 return; 233 return;
227 234
228 new KABC::DistributionList( mManager, dlg.text() ); 235 new KABC::DistributionList( mManager, dlg.text() );
229 236
230 mNameCombo->clear(); 237 mNameCombo->clear();
231 mNameCombo->insertStringList( mManager->listNames() ); 238 mNameCombo->insertStringList( mManager->listNames() );
232 mNameCombo->setCurrentItem( mNameCombo->count() - 1 ); 239 mNameCombo->setCurrentItem( mNameCombo->count() - 1 );
233 240
234 updateContactView(); 241 updateContactView();
235 242
236 changed(); 243 changed();
237} 244}
238 245
239void DistributionListWidget::editList() 246void DistributionListWidget::editList()
240{ 247{
241 QString oldName = mNameCombo->currentText(); 248 QString oldName = mNameCombo->currentText();
242 249
243 KLineEditDlg dlg( i18n( "Please change name:" ), oldName, this ); 250 KLineEditDlg dlg( i18n( "Please change name:" ), oldName, this );
244#ifdef KAB_EMBEDDED 251#ifdef KAB_EMBEDDED
245 dlg.setFixedSize(200, 50); 252 dlg.setFixedSize(200, 50);
246#endif //KAB_EMBEDDED 253#endif //KAB_EMBEDDED
247 dlg.setCaption( i18n("Distribution List") ); 254 dlg.setCaption( i18n("Distribution List") );
248 if ( !dlg.exec() ) 255 if ( !dlg.exec() )
249 return; 256 return;
250 257
251 KABC::DistributionList *list = mManager->list( oldName ); 258 KABC::DistributionList *list = mManager->list( oldName );
252 list->setName( dlg.text() ); 259 list->setName( dlg.text() );
253 260
254 mNameCombo->clear(); 261 mNameCombo->clear();
255 mNameCombo->insertStringList( mManager->listNames() ); 262 mNameCombo->insertStringList( mManager->listNames() );
256 mNameCombo->setCurrentItem( mNameCombo->count() - 1 ); 263 mNameCombo->setCurrentItem( mNameCombo->count() - 1 );
257 264
258 updateContactView(); 265 updateContactView();
259 266
260 changed(); 267 changed();
261} 268}
262 269
263void DistributionListWidget::removeList() 270void DistributionListWidget::removeList()
264{ 271{
265 int result = KMessageBox::warningContinueCancel( this, 272 int result = KMessageBox::warningContinueCancel( this,
266 i18n( "<qt>Delete distribution list <b>%1</b>?</qt>" ) .arg( mNameCombo->currentText() ), 273 i18n( "<qt>Delete distribution list <b>%1</b>?</qt>" ) .arg( mNameCombo->currentText() ),
267 QString::null, i18n( "Delete" ) ); 274 QString::null, i18n( "Delete" ) );
268 275
269 if ( result != KMessageBox::Continue ) 276 if ( result != KMessageBox::Continue )
270 return; 277 return;
271 278
272 delete mManager->list( mNameCombo->currentText() ); 279 delete mManager->list( mNameCombo->currentText() );
273 mNameCombo->removeItem( mNameCombo->currentItem() ); 280 mNameCombo->removeItem( mNameCombo->currentItem() );
274 281
275 updateContactView(); 282 updateContactView();
276 283
277 changed(); 284 changed();
278} 285}
279 286
280void DistributionListWidget::addContact() 287void DistributionListWidget::addContact()
281{ 288{
282 KABC::DistributionList *list = mManager->list( mNameCombo->currentText() ); 289 KABC::DistributionList *list = mManager->list( mNameCombo->currentText() );
283 if ( !list ) 290 if ( !list )
284 return; 291 return;
285 292
286 KABC::Addressee::List addrList = selectedContacts(); 293 KABC::Addressee::List addrList = selectedContacts();
287 KABC::Addressee::List::Iterator it; 294 KABC::Addressee::List::Iterator it;
288 for ( it = addrList.begin(); it != addrList.end(); ++it ) 295 for ( it = addrList.begin(); it != addrList.end(); ++it )
289 list->insertEntry( *it ); 296 list->insertEntry( *it );
290 297
291 updateContactView(); 298 updateContactView();
292 299
293 changed(); 300 changed();
294} 301}
295 302
296void DistributionListWidget::removeContact() 303void DistributionListWidget::removeContact()
297{ 304{
298 KABC::DistributionList *list = mManager->list( mNameCombo->currentText() ); 305 KABC::DistributionList *list = mManager->list( mNameCombo->currentText() );
299 if ( !list ) 306 if ( !list )
300 return; 307 return;
301 308
302 ContactItem *contactItem = 309 ContactItem *contactItem =
303 static_cast<ContactItem *>( mContactView->selectedItem() ); 310 static_cast<ContactItem *>( mContactView->selectedItem() );
304 if ( !contactItem ) 311 if ( !contactItem )
305 return; 312 return;
306 313
307 list->removeEntry( contactItem->addressee(), contactItem->email() ); 314 list->removeEntry( contactItem->addressee(), contactItem->email() );
308 delete contactItem; 315 delete contactItem;
309 316
310 changed(); 317 changed();
311} 318}
312 319
313void DistributionListWidget::changeEmail() 320void DistributionListWidget::changeEmail()
314{ 321{
315 KABC::DistributionList *list = mManager->list( mNameCombo->currentText() ); 322 KABC::DistributionList *list = mManager->list( mNameCombo->currentText() );
316 if ( !list ) 323 if ( !list )
317 return; 324 return;
318 325
319 ContactItem *contactItem = 326 ContactItem *contactItem =
320 static_cast<ContactItem *>( mContactView->selectedItem() ); 327 static_cast<ContactItem *>( mContactView->selectedItem() );
321 if ( !contactItem ) 328 if ( !contactItem )
322 return; 329 return;
323 330
324 QString email = EmailSelector::getEmail( contactItem->addressee().emails(), 331 QString email = EmailSelector::getEmail( contactItem->addressee().emails(),
325 contactItem->email(), this ); 332 contactItem->email(), this );
326 list->removeEntry( contactItem->addressee(), contactItem->email() ); 333 list->removeEntry( contactItem->addressee(), contactItem->email() );
327 list->insertEntry( contactItem->addressee(), email ); 334 list->insertEntry( contactItem->addressee(), email );
328 335
329 updateContactView(); 336 updateContactView();
330 337
331 changed(); 338 changed();
332} 339}
333 340
334void DistributionListWidget::updateContactView() 341void DistributionListWidget::updateContactView()
335{ 342{
336 mContactView->clear(); 343 mContactView->clear();
337 344
338 KABC::DistributionList *list = mManager->list( mNameCombo->currentText() ); 345 KABC::DistributionList *list = mManager->list( mNameCombo->currentText() );
339 if ( !list ) { 346 if ( !list ) {
340 mEditListButton->setEnabled( false ); 347 mEditListButton->setEnabled( false );
341 mRemoveListButton->setEnabled( false ); 348 mRemoveListButton->setEnabled( false );
342 mChangeEmailButton->setEnabled( false ); 349 mChangeEmailButton->setEnabled( false );
343 mRemoveContactButton->setEnabled( false ); 350 mRemoveContactButton->setEnabled( false );
344 mContactView->setEnabled( false ); 351 mContactView->setEnabled( false );
345 return; 352 return;
346 } else { 353 } else {
347 mEditListButton->setEnabled( true ); 354 mEditListButton->setEnabled( true );
348 mRemoveListButton->setEnabled( true ); 355 mRemoveListButton->setEnabled( true );
349 mContactView->setEnabled( true ); 356 mContactView->setEnabled( true );
350 } 357 }
351 358
352 KABC::DistributionList::Entry::List entries = list->entries(); 359 KABC::DistributionList::Entry::List entries = list->entries();
353 KABC::DistributionList::Entry::List::ConstIterator it; 360 KABC::DistributionList::Entry::List::ConstIterator it;
354 for( it = entries.begin(); it != entries.end(); ++it ) 361 for( it = entries.begin(); it != entries.end(); ++it )
355 new ContactItem( mContactView, (*it).addressee, (*it).email ); 362 new ContactItem( mContactView, (*it).addressee, (*it).email );
356 363
357 ContactItem *contactItem = 364 ContactItem *contactItem =
358 static_cast<ContactItem *>( mContactView->selectedItem() ); 365 static_cast<ContactItem *>( mContactView->selectedItem() );
359 bool state = contactItem; 366 bool state = contactItem;
360 367
361 mChangeEmailButton->setEnabled( state ); 368 mChangeEmailButton->setEnabled( state );
362 mRemoveContactButton->setEnabled( state ); 369 mRemoveContactButton->setEnabled( state );
363} 370}
364 371
365void DistributionListWidget::updateNameCombo() 372void DistributionListWidget::updateNameCombo()
366{ 373{
367 mNameCombo->insertStringList( mManager->listNames() ); 374 mNameCombo->insertStringList( mManager->listNames() );
368 375
369 updateContactView(); 376 updateContactView();
370} 377}
371 378
372void DistributionListWidget::dropEvent( QDropEvent *e ) 379void DistributionListWidget::dropEvent( QDropEvent *e )
373{ 380{
374 KABC::DistributionList *distributionList = mManager->list( mNameCombo->currentText() ); 381 KABC::DistributionList *distributionList = mManager->list( mNameCombo->currentText() );
375 if ( !distributionList ) 382 if ( !distributionList )
376 return; 383 return;
377 384
378 QString vcards; 385 QString vcards;
379#ifndef KAB_EMBEDDED 386#ifndef KAB_EMBEDDED
380 if ( KVCardDrag::decode( e, vcards ) ) { 387 if ( KVCardDrag::decode( e, vcards ) ) {
381#endif //KAB_EMBEDDED 388#endif //KAB_EMBEDDED
382 QStringList list = QStringList::split( "\r\n\r\n", vcards ); 389 QStringList list = QStringList::split( "\r\n\r\n", vcards );
383 QStringList::Iterator it; 390 QStringList::Iterator it;
384 KABC::VCardConverter converter; 391 KABC::VCardConverter converter;
385 for ( it = list.begin(); it != list.end(); ++it ) { 392 for ( it = list.begin(); it != list.end(); ++it ) {
386 KABC::Addressee addr; 393 KABC::Addressee addr;
387 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) 394 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) )
388 distributionList->insertEntry( addr ); 395 distributionList->insertEntry( addr );
389 } 396 }
390 397
391 changed(); 398 changed();
392 updateContactView(); 399 updateContactView();
393#ifndef KAB_EMBEDDED 400#ifndef KAB_EMBEDDED
394 } 401 }
395#endif //KAB_EMBEDDED 402#endif //KAB_EMBEDDED
396} 403}
397 404
398void DistributionListWidget::contactsSelectionChanged() 405void DistributionListWidget::contactsSelectionChanged()
399{ 406{
400 mAddContactButton->setEnabled( contactsSelected() && mNameCombo->count() > 0 ); 407 mAddContactButton->setEnabled( contactsSelected() && mNameCombo->count() > 0 );
401} 408}
402 409
403QString DistributionListWidget::title() const 410QString DistributionListWidget::title() const
404{ 411{
405 return i18n( "Distribution List Editor" ); 412 return i18n( "Distribution List Editor" );
406} 413}
407 414
408QString DistributionListWidget::identifier() const 415QString DistributionListWidget::identifier() const
409{ 416{
410 return "distribution_list_editor"; 417 return "distribution_list_editor";
411} 418}
412 419
413void DistributionListWidget::dropped( QDropEvent *e, QListViewItem* ) 420void DistributionListWidget::dropped( QDropEvent *e, Q3ListViewItem* )
414{ 421{
415 dropEvent( e ); 422 dropEvent( e );
416} 423}
417 424
418void DistributionListWidget::changed() 425void DistributionListWidget::changed()
419{ 426{
420 save(); 427 save();
421} 428}
422 429
423 430
424DistributionListView::DistributionListView( QWidget *parent, const char* name ) 431DistributionListView::DistributionListView( QWidget *parent, const char* name )
425 : KListView( parent, name ) 432 : KListView( parent, name )
426{ 433{
427 setDragEnabled( true ); 434 setDragEnabled( true );
428 setAcceptDrops( true ); 435 setAcceptDrops( true );
429 setAllColumnsShowFocus( true ); 436 setAllColumnsShowFocus( true );
430} 437}
431 438
432void DistributionListView::dragEnterEvent( QDragEnterEvent* e ) 439void DistributionListView::dragEnterEvent( QDragEnterEvent* e )
433{ 440{
434#ifndef KAB_EMBEDDED 441#ifndef KAB_EMBEDDED
435 bool canDecode = QTextDrag::canDecode( e ); 442 bool canDecode = Q3TextDrag::canDecode( e );
436 e->accept( canDecode ); 443 e->accept( canDecode );
437#endif //KAB_EMBEDDED 444#endif //KAB_EMBEDDED
438} 445}
439 446
440void DistributionListView::viewportDragMoveEvent( QDragMoveEvent *e ) 447void DistributionListView::viewportDragMoveEvent( QDragMoveEvent *e )
441{ 448{
442#ifndef KAB_EMBEDDED 449#ifndef KAB_EMBEDDED
443 bool canDecode = QTextDrag::canDecode( e ); 450 bool canDecode = Q3TextDrag::canDecode( e );
444 e->accept( canDecode ); 451 e->accept( canDecode );
445#endif //KAB_EMBEDDED 452#endif //KAB_EMBEDDED
446} 453}
447 454
448void DistributionListView::viewportDropEvent( QDropEvent *e ) 455void DistributionListView::viewportDropEvent( QDropEvent *e )
449{ 456{
450 emit dropped( e, 0 ); 457 emit dropped( e, 0 );
451} 458}
452 459
453void DistributionListView::dropEvent( QDropEvent *e ) 460void DistributionListView::dropEvent( QDropEvent *e )
454{ 461{
455 emit dropped( e, 0 ); 462 emit dropped( e, 0 );
456} 463}
457 464
458 465
459EmailSelector::EmailSelector( const QStringList &emails, 466EmailSelector::EmailSelector( const QStringList &emails,
460 const QString &current, QWidget *parent ) 467 const QString &current, QWidget *parent )
461 : KDialogBase( KDialogBase::Plain, i18n("Select Email Address"), Ok, Ok, 468 : KDialogBase( KDialogBase::Plain, i18n("Select Email Address"), Ok, Ok,
462 parent ) 469 parent )
463{ 470{
464 QFrame *topFrame = plainPage(); 471 Q3Frame *topFrame = plainPage();
465 QBoxLayout *topLayout = new QVBoxLayout( topFrame ); 472 Q3BoxLayout *topLayout = new Q3VBoxLayout( topFrame );
466 473
467 mButtonGroup = new QButtonGroup( 1, Horizontal, i18n("Email Addresses"), 474 mButtonGroup = new Q3ButtonGroup( 1, Qt::Horizontal, i18n("Email Addresses"),
468 topFrame ); 475 topFrame );
469 topLayout->addWidget( mButtonGroup ); 476 topLayout->addWidget( mButtonGroup );
470 477
471 QStringList::ConstIterator it; 478 QStringList::ConstIterator it;
472 for( it = emails.begin(); it != emails.end(); ++it ) { 479 for( it = emails.begin(); it != emails.end(); ++it ) {
473 QRadioButton *button = new QRadioButton( *it, mButtonGroup ); 480 QRadioButton *button = new QRadioButton( *it, mButtonGroup );
474 if ( (*it) == current ) { 481 if ( (*it) == current ) {
475 button->setDown( true ); 482 button->setDown( true );
476 } 483 }
477 } 484 }
478} 485}
479 486
480QString EmailSelector::selected() 487QString EmailSelector::selected()
481{ 488{
482 QButton *button = mButtonGroup->selected(); 489 QAbstractButton *button = mButtonGroup->selected();
483 if ( button ) 490 if ( button )
484 return button->text(); 491 return button->text();
485 492
486 return QString::null; 493 return QString::null;
487} 494}
488 495
489QString EmailSelector::getEmail( const QStringList &emails, 496QString EmailSelector::getEmail( const QStringList &emails,
490 const QString &current, QWidget *parent ) 497 const QString &current, QWidget *parent )
491{ 498{
492 EmailSelector dlg( emails, current, parent ); 499 EmailSelector dlg( emails, current, parent );
493 dlg.exec(); 500 dlg.exec();
494 501
495 return dlg.selected(); 502 return dlg.selected();
496} 503}
497 504
498 505
499#ifndef KAB_EMBEDDED 506#ifndef KAB_EMBEDDED_
500#include "distributionlistwidget.moc" 507#include "moc_distributionlistwidget.cpp"
501#endif //KAB_EMBEDDED 508#endif //KAB_EMBEDDED
diff --git a/kaddressbook/features/distributionlistwidget.h b/kaddressbook/features/distributionlistwidget.h
index 82bac3d..f619389 100644
--- a/kaddressbook/features/distributionlistwidget.h
+++ b/kaddressbook/features/distributionlistwidget.h
@@ -1,143 +1,148 @@
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#ifndef DISTRIBUTIONLISTWIDGET_H 24#ifndef DISTRIBUTIONLISTWIDGET_H
25#define DISTRIBUTIONLISTWIDGET_H 25#define DISTRIBUTIONLISTWIDGET_H
26 26
27#include <kdialogbase.h> 27#include <kdialogbase.h>
28#include <klistview.h> 28#include <klistview.h>
29 29
30#include "extensionwidget.h" 30#include "extensionwidget.h"
31//Added by qt3to4:
32#include <QDragEnterEvent>
33#include <QDropEvent>
34#include <QLabel>
35#include <QDragMoveEvent>
31 36
32class QButtonGroup; 37class Q3ButtonGroup;
33class QComboBox; 38class QComboBox;
34class QLabel; 39class QLabel;
35class QListView; 40class Q3ListView;
36 41
37class DistributionListView; 42class DistributionListView;
38class KABCore; 43class KABCore;
39 44
40namespace KABC { 45namespace KABC {
41class AddressBook; 46class AddressBook;
42class DistributionListManager; 47class DistributionListManager;
43} 48}
44 49
45class DistributionListWidget : public ExtensionWidget 50class DistributionListWidget : public ExtensionWidget
46{ 51{
47 Q_OBJECT 52 Q_OBJECT
48 53
49 public: 54 public:
50 DistributionListWidget( KABCore*, QWidget *parent, const char *name = 0 ); 55 DistributionListWidget( KABCore*, QWidget *parent, const char *name = 0 );
51 virtual ~DistributionListWidget(); 56 virtual ~DistributionListWidget();
52 57
53 void contactsSelectionChanged(); 58 void contactsSelectionChanged();
54 59
55 QString title() const; 60 QString title() const;
56 QString identifier() const; 61 QString identifier() const;
57 62
58 public slots: 63 public slots:
59 void save(); 64 void save();
60 void dropped( QDropEvent*, QListViewItem* ); 65 void dropped( QDropEvent*, Q3ListViewItem* );
61 66
62 private slots: 67 private slots:
63 void createList(); 68 void createList();
64 void editList(); 69 void editList();
65 void removeList(); 70 void removeList();
66 void addContact(); 71 void addContact();
67 void removeContact(); 72 void removeContact();
68 void changeEmail(); 73 void changeEmail();
69 void updateNameCombo(); 74 void updateNameCombo();
70 void updateContactView(); 75 void updateContactView();
71 void selectionContactViewChanged(); 76 void selectionContactViewChanged();
72 void changed(); 77 void changed();
73 78
74 protected: 79 protected:
75 void dropEvent( QDropEvent* ); 80 void dropEvent( QDropEvent* );
76 81
77 private: 82 private:
78 QComboBox *mNameCombo; 83 QComboBox *mNameCombo;
79 QLabel *mListLabel; 84 QLabel *mListLabel;
80 DistributionListView *mContactView; 85 DistributionListView *mContactView;
81 86
82 KABC::DistributionListManager *mManager; 87 KABC::DistributionListManager *mManager;
83 QPushButton *mCreateListButton; 88 QPushButton *mCreateListButton;
84 QPushButton *mEditListButton; 89 QPushButton *mEditListButton;
85 QPushButton *mRemoveListButton; 90 QPushButton *mRemoveListButton;
86 QPushButton *mChangeEmailButton; 91 QPushButton *mChangeEmailButton;
87 QPushButton *mAddContactButton; 92 QPushButton *mAddContactButton;
88 QPushButton *mRemoveContactButton; 93 QPushButton *mRemoveContactButton;
89}; 94};
90 95
91/** 96/**
92 @short Helper class 97 @short Helper class
93*/ 98*/
94class DistributionListView : public KListView 99class DistributionListView : public KListView
95{ 100{
96 Q_OBJECT 101 Q_OBJECT
97 102
98 public: 103 public:
99 DistributionListView( QWidget *parent, const char* name = 0 ); 104 DistributionListView( QWidget *parent, const char* name = 0 );
100 105
101 protected: 106 protected:
102 void dragEnterEvent( QDragEnterEvent *e ); 107 void dragEnterEvent( QDragEnterEvent *e );
103 void dropEvent( QDropEvent *e ); 108 void dropEvent( QDropEvent *e );
104 void viewportDragMoveEvent( QDragMoveEvent *e ); 109 void viewportDragMoveEvent( QDragMoveEvent *e );
105 void viewportDropEvent( QDropEvent *e ); 110 void viewportDropEvent( QDropEvent *e );
106}; 111};
107 112
108/** 113/**
109 @short Helper class 114 @short Helper class
110*/ 115*/
111class EmailSelector : public KDialogBase 116class EmailSelector : public KDialogBase
112{ 117{
113 public: 118 public:
114 EmailSelector( const QStringList &emails, const QString &current, 119 EmailSelector( const QStringList &emails, const QString &current,
115 QWidget *parent ); 120 QWidget *parent );
116 121
117 QString selected(); 122 QString selected();
118 123
119 static QString getEmail( const QStringList &emails, const QString &current, 124 static QString getEmail( const QStringList &emails, const QString &current,
120 QWidget *parent ); 125 QWidget *parent );
121 126
122 private: 127 private:
123 QButtonGroup *mButtonGroup; 128 Q3ButtonGroup *mButtonGroup;
124}; 129};
125 130
126 131
127#ifdef KAB_EMBEDDED 132#ifdef KAB_EMBEDDED
128class DistributionListFactory : public ExtensionFactory 133class DistributionListFactory : public ExtensionFactory
129{ 134{
130 public: 135 public:
131 ExtensionWidget *extension( KABCore *core, QWidget *parent, const char *name ) 136 ExtensionWidget *extension( KABCore *core, QWidget *parent, const char *name )
132 { 137 {
133 return new DistributionListWidget( core, parent, name ); 138 return new DistributionListWidget( core, parent, name );
134 } 139 }
135 140
136 QString identifier() const 141 QString identifier() const
137 { 142 {
138 return "distribution_list_editor"; 143 return "distribution_list_editor";
139 } 144 }
140}; 145};
141#endif //KAB_EMBEDDED 146#endif //KAB_EMBEDDED
142 147
143#endif 148#endif
diff --git a/kaddressbook/features/mergewidget.cpp b/kaddressbook/features/mergewidget.cpp
index 2476e42..1becc2f 100644
--- a/kaddressbook/features/mergewidget.cpp
+++ b/kaddressbook/features/mergewidget.cpp
@@ -1,374 +1,376 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 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 <qlayout.h> 24#include <qlayout.h>
25#include <qpushbutton.h> 25#include <qpushbutton.h>
26//Added by qt3to4:
27#include <Q3GridLayout>
26 28
27#ifndef KAB_EMBEDDED 29#ifndef KAB_EMBEDDED
28#include <kaccelmanager.h> 30#include <kaccelmanager.h>
29#endif //KAB_EMBEDDED 31#endif //KAB_EMBEDDED
30 32
31#include <kdebug.h> 33#include <kdebug.h>
32#include <klistview.h> 34#include <klistview.h>
33#include <klocale.h> 35#include <klocale.h>
34#include <kglobal.h> 36#include <kglobal.h>
35#include <kmessagebox.h> 37#include <kmessagebox.h>
36 38
37#include <kabc/addressbook.h> 39#include <kabc/addressbook.h>
38 40
39#include "kabcore.h" 41#include "kabcore.h"
40 42
41#include "mergewidget.h" 43#include "mergewidget.h"
42 44
43#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
44class MergeFactory : public ExtensionFactory 46class MergeFactory : public ExtensionFactory
45{ 47{
46 public: 48 public:
47 ExtensionWidget *extension( KABCore *core, QWidget *parent, const char *name ) 49 ExtensionWidget *extension( KABCore *core, QWidget *parent, const char *name )
48 { 50 {
49 return new MergeWidget( core, parent, name ); 51 return new MergeWidget( core, parent, name );
50 } 52 }
51 53
52 QString identifier() const 54 QString identifier() const
53 { 55 {
54 return "merge"; 56 return "merge";
55 } 57 }
56}; 58};
57 59
58extern "C" { 60extern "C" {
59 void *init_libkaddrbk_merge() 61 void *init_libkaddrbk_merge()
60 { 62 {
61 return ( new MergeFactory ); 63 return ( new MergeFactory );
62 } 64 }
63} 65}
64#endif //KAB_EMBEDDED 66#endif //KAB_EMBEDDED
65 67
66class ContactItem : public QListViewItem 68class ContactItem : public Q3ListViewItem
67{ 69{
68 public: 70 public:
69 ContactItem( KListView *parent, const KABC::Addressee &addressee ) 71 ContactItem( KListView *parent, const KABC::Addressee &addressee )
70 : QListViewItem( parent ), mAddressee( addressee ) 72 : Q3ListViewItem( parent ), mAddressee( addressee )
71 { 73 {
72 KABC::Field::List fieldList = KABC::Field::defaultFields(); 74 KABC::Field::List fieldList = KABC::Field::defaultFields();
73 KABC::Field::List::ConstIterator it; 75 KABC::Field::List::ConstIterator it;
74 76
75 int i = 0; 77 int i = 0;
76 for ( it = fieldList.begin(); it != fieldList.end(); ++it ) 78 for ( it = fieldList.begin(); it != fieldList.end(); ++it )
77 setText( i++, (*it)->value( mAddressee ) ); 79 setText( i++, (*it)->value( mAddressee ) );
78 } 80 }
79 81
80 KABC::Addressee addressee() const 82 KABC::Addressee addressee() const
81 { 83 {
82 return mAddressee; 84 return mAddressee;
83 } 85 }
84 86
85 private: 87 private:
86 KABC::Addressee mAddressee; 88 KABC::Addressee mAddressee;
87}; 89};
88 90
89MergeWidget::MergeWidget( KABCore *core, QWidget *parent, const char *name ) 91MergeWidget::MergeWidget( KABCore *core, QWidget *parent, const char *name )
90 : ExtensionWidget( core, parent, name ), mBlockUpdate( false ) 92 : ExtensionWidget( core, parent, name ), mBlockUpdate( false )
91{ 93{
92#ifdef KAB_EMBEDDED 94#ifdef KAB_EMBEDDED
93 if (KGlobal::getOrientation() == KGlobal::Portrait) 95 if (KGlobal::getOrientation() == KGlobal::Portrait)
94 parent->setMaximumSize( KGlobal::getDesktopWidth() , 180); 96 parent->setMaximumSize( KGlobal::getDesktopWidth() , 180);
95#endif //KAB_EMBEDDED 97#endif //KAB_EMBEDDED
96 98
97 QGridLayout *topLayout = new QGridLayout( this, 3, 2, KDialog::marginHint(), 99 Q3GridLayout *topLayout = new Q3GridLayout( this, 3, 2, KDialog::marginHint(),
98 KDialog::spacingHint() ); 100 KDialog::spacingHint() );
99 101
100 mContactView = new KListView( this ); 102 mContactView = new KListView( this );
101 KABC::Field::List fieldList = KABC::Field::defaultFields(); 103 KABC::Field::List fieldList = KABC::Field::defaultFields();
102 KABC::Field::List::ConstIterator it; 104 KABC::Field::List::ConstIterator it;
103 105
104 for ( it = fieldList.begin(); it != fieldList.end(); ++it ) 106 for ( it = fieldList.begin(); it != fieldList.end(); ++it )
105 mContactView->addColumn( (*it)->label() ); 107 mContactView->addColumn( (*it)->label() );
106 108
107 mContactView->setEnabled( false ); 109 mContactView->setEnabled( false );
108 mContactView->setAllColumnsShowFocus( true ); 110 mContactView->setAllColumnsShowFocus( true );
109 topLayout->addMultiCellWidget( mContactView, 0, 2, 0, 0 ); 111 topLayout->addMultiCellWidget( mContactView, 0, 2, 0, 0 );
110 112
111 connect( mContactView, SIGNAL( selectionChanged() ), 113 connect( mContactView, SIGNAL( selectionChanged() ),
112 SLOT( selectionContactViewChanged() ) ); 114 SLOT( selectionContactViewChanged() ) );
113 115
114 mMergeAndRemoveButton = new QPushButton( i18n( "Merge and Remove" ), this ); 116 mMergeAndRemoveButton = new QPushButton( i18n( "Merge and Remove" ), this );
115 mMergeAndRemoveButton->setEnabled( false ); 117 mMergeAndRemoveButton->setEnabled( false );
116 topLayout->addWidget( mMergeAndRemoveButton, 0, 1 ); 118 topLayout->addWidget( mMergeAndRemoveButton, 0, 1 );
117 connect( mMergeAndRemoveButton, SIGNAL( clicked() ), SLOT( mergeAndRemove() ) ); 119 connect( mMergeAndRemoveButton, SIGNAL( clicked() ), SLOT( mergeAndRemove() ) );
118 120
119 mMergeButton = new QPushButton( i18n( "Merge" ), this ); 121 mMergeButton = new QPushButton( i18n( "Merge" ), this );
120 mMergeButton->setEnabled( false ); 122 mMergeButton->setEnabled( false );
121 topLayout->addWidget( mMergeButton, 1, 1 ); 123 topLayout->addWidget( mMergeButton, 1, 1 );
122 connect( mMergeButton, SIGNAL( clicked() ), SLOT( merge() ) ); 124 connect( mMergeButton, SIGNAL( clicked() ), SLOT( merge() ) );
123 125
124#ifndef KAB_EMBEDDED 126#ifndef KAB_EMBEDDED
125 KAcceleratorManager::manage( this ); 127 KAcceleratorManager::manage( this );
126#endif //KAB_EMBEDDED 128#endif //KAB_EMBEDDED
127} 129}
128 130
129MergeWidget::~MergeWidget() 131MergeWidget::~MergeWidget()
130{ 132{
131} 133}
132 134
133void MergeWidget::selectionContactViewChanged() 135void MergeWidget::selectionContactViewChanged()
134{ 136{
135#ifndef KAB_EMBEDDED 137#ifndef KAB_EMBEDDED
136 ContactItem *contactItem = 138 ContactItem *contactItem =
137 dynamic_cast<ContactItem*>( mContactView->selectedItem() ); 139 dynamic_cast<ContactItem*>( mContactView->selectedItem() );
138#else //KAB_EMBEDDED 140#else //KAB_EMBEDDED
139 ContactItem *contactItem =(ContactItem*)( mContactView->selectedItem() ); 141 ContactItem *contactItem =(ContactItem*)( mContactView->selectedItem() );
140#endif //KAB_EMBEDDED 142#endif //KAB_EMBEDDED
141 143
142 bool state = (contactItem != 0); 144 bool state = (contactItem != 0);
143 145
144 mMergeAndRemoveButton->setEnabled( state ); 146 mMergeAndRemoveButton->setEnabled( state );
145 mMergeButton->setEnabled( state ); 147 mMergeButton->setEnabled( state );
146} 148}
147 149
148void MergeWidget::contactsSelectionChanged() 150void MergeWidget::contactsSelectionChanged()
149{ 151{
150 if ( mBlockUpdate ) 152 if ( mBlockUpdate )
151 return; 153 return;
152 154
153 if ( !contactsSelected() ) { 155 if ( !contactsSelected() ) {
154 mContactView->setEnabled( false ); 156 mContactView->setEnabled( false );
155 mContactView->clear(); 157 mContactView->clear();
156 mMergeAndRemoveButton->setEnabled( false ); 158 mMergeAndRemoveButton->setEnabled( false );
157 mMergeButton->setEnabled( false ); 159 mMergeButton->setEnabled( false );
158 } else { 160 } else {
159 KABC::Addressee::List list = selectedContacts(); 161 KABC::Addressee::List list = selectedContacts();
160 if ( list.count() > 1 ) { 162 if ( list.count() > 1 ) {
161 mContactView->setEnabled( false ); 163 mContactView->setEnabled( false );
162 mContactView->clear(); 164 mContactView->clear();
163 mMergeAndRemoveButton->setEnabled( false ); 165 mMergeAndRemoveButton->setEnabled( false );
164 mMergeButton->setEnabled( false ); 166 mMergeButton->setEnabled( false );
165 return; 167 return;
166 } else { 168 } else {
167 mContactView->setEnabled( true ); 169 mContactView->setEnabled( true );
168 mMasterAddressee = list[ 0 ]; 170 mMasterAddressee = list[ 0 ];
169 updateView(); 171 updateView();
170 } 172 }
171 } 173 }
172} 174}
173 175
174void MergeWidget::updateView() 176void MergeWidget::updateView()
175{ 177{
176 mContactView->clear(); 178 mContactView->clear();
177 179
178 KABC::AddressBook::Iterator it; 180 KABC::AddressBook::Iterator it;
179 KABC::AddressBook *ab = core()->addressBook(); 181 KABC::AddressBook *ab = core()->addressBook();
180 if ( !ab ) 182 if ( !ab )
181 return; 183 return;
182 184
183 for ( it = ab->begin(); it != ab->end(); ++it ) 185 for ( it = ab->begin(); it != ab->end(); ++it )
184 if ( (*it).uid() != mMasterAddressee.uid() ) 186 if ( (*it).uid() != mMasterAddressee.uid() )
185 new ContactItem( mContactView, *it ); 187 new ContactItem( mContactView, *it );
186} 188}
187 189
188QString MergeWidget::title() const 190QString MergeWidget::title() const
189{ 191{
190 return i18n( "Merge Contacts Editor" ); 192 return i18n( "Merge Contacts Editor" );
191} 193}
192 194
193QString MergeWidget::identifier() const 195QString MergeWidget::identifier() const
194{ 196{
195 return "merge"; 197 return "merge";
196} 198}
197 199
198void MergeWidget::mergeAndRemove() 200void MergeWidget::mergeAndRemove()
199{ 201{
200#ifndef KAB_EMBEDDED 202#ifndef KAB_EMBEDDED
201 ContactItem *item = dynamic_cast<ContactItem*>( mContactView->currentItem() ); 203 ContactItem *item = dynamic_cast<ContactItem*>( mContactView->currentItem() );
202#else //KAB_EMBEDDED 204#else //KAB_EMBEDDED
203 ContactItem *item = (ContactItem*)( mContactView->currentItem() ); 205 ContactItem *item = (ContactItem*)( mContactView->currentItem() );
204#endif //KAB_EMBEDDED 206#endif //KAB_EMBEDDED
205 if ( !item ) 207 if ( !item )
206 return; 208 return;
207 209
208 QString oldUID = item->addressee().uid(); 210 QString oldUID = item->addressee().uid();
209 211
210 doMerge( item->addressee() ); 212 doMerge( item->addressee() );
211 213
212 KABC::Addressee::List retval; 214 KABC::Addressee::List retval;
213 retval << mMasterAddressee; 215 retval << mMasterAddressee;
214 emit modified( retval ); 216 emit modified( retval );
215 217
216 mBlockUpdate = true; 218 mBlockUpdate = true;
217 core()->deleteContacts( oldUID ); 219 core()->deleteContacts( QStringList(oldUID) );
218 core()->setContactSelected( mMasterAddressee.uid() ); 220 core()->setContactSelected( mMasterAddressee.uid() );
219 mBlockUpdate = false; 221 mBlockUpdate = false;
220 222
221 updateView(); 223 updateView();
222} 224}
223 225
224void MergeWidget::merge() 226void MergeWidget::merge()
225{ 227{
226#ifndef KAB_EMBEDDED 228#ifndef KAB_EMBEDDED
227 ContactItem *item = dynamic_cast<ContactItem*>( mContactView->currentItem() ); 229 ContactItem *item = dynamic_cast<ContactItem*>( mContactView->currentItem() );
228#else //KAB_EMBEDDED 230#else //KAB_EMBEDDED
229 ContactItem *item = (ContactItem*)( mContactView->currentItem() ); 231 ContactItem *item = (ContactItem*)( mContactView->currentItem() );
230#endif //KAB_EMBEDDED 232#endif //KAB_EMBEDDED
231 if ( !item ) 233 if ( !item )
232 return; 234 return;
233 235
234 doMerge( item->addressee() ); 236 doMerge( item->addressee() );
235 237
236 KABC::Addressee::List retval; 238 KABC::Addressee::List retval;
237 retval << mMasterAddressee; 239 retval << mMasterAddressee;
238 emit modified( retval ); 240 emit modified( retval );
239 241
240 mBlockUpdate = true; 242 mBlockUpdate = true;
241 core()->setContactSelected( mMasterAddressee.uid() ); 243 core()->setContactSelected( mMasterAddressee.uid() );
242 mBlockUpdate = false; 244 mBlockUpdate = false;
243 245
244 updateView(); 246 updateView();
245} 247}
246 248
247void MergeWidget::doMerge( const KABC::Addressee &addr ) 249void MergeWidget::doMerge( const KABC::Addressee &addr )
248{ 250{
249 // ADR + LABEL 251 // ADR + LABEL
250 KABC::Address::List addresses = addr.addresses(); 252 KABC::Address::List addresses = addr.addresses();
251 KABC::Address::List masterAddresses = mMasterAddressee.addresses(); 253 KABC::Address::List masterAddresses = mMasterAddressee.addresses();
252 KABC::Address::List::Iterator addrIt ; 254 KABC::Address::List::Iterator addrIt ;
253 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { 255 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) {
254 if ( !masterAddresses.contains( *addrIt ) ) 256 if ( !masterAddresses.contains( *addrIt ) )
255 mMasterAddressee.insertAddress( *addrIt ); 257 mMasterAddressee.insertAddress( *addrIt );
256 } 258 }
257 259
258 if ( mMasterAddressee.birthday().isNull() && !addr.birthday().isNull() ) 260 if ( mMasterAddressee.birthday().isNull() && !addr.birthday().isNull() )
259 mMasterAddressee.setBirthday( addr.birthday() ); 261 mMasterAddressee.setBirthday( addr.birthday() );
260 262
261 263
262 // CATEGORIES 264 // CATEGORIES
263 QStringList::Iterator it; 265 QStringList::Iterator it;
264 QStringList categories = addr.categories(); 266 QStringList categories = addr.categories();
265 QStringList masterCategories = mMasterAddressee.categories(); 267 QStringList masterCategories = mMasterAddressee.categories();
266 QStringList newCategories( masterCategories ); 268 QStringList newCategories( masterCategories );
267 for ( it = categories.begin(); it != categories.end(); ++it ) 269 for ( it = categories.begin(); it != categories.end(); ++it )
268 if ( !masterCategories.contains( *it ) ) 270 if ( !masterCategories.contains( *it ) )
269 newCategories.append( *it ); 271 newCategories.append( *it );
270 mMasterAddressee.setCategories( newCategories ); 272 mMasterAddressee.setCategories( newCategories );
271 273
272 // CLASS 274 // CLASS
273 if ( !mMasterAddressee.secrecy().isValid() && addr.secrecy().isValid() ) 275 if ( !mMasterAddressee.secrecy().isValid() && addr.secrecy().isValid() )
274 mMasterAddressee.setSecrecy( addr.secrecy() ); 276 mMasterAddressee.setSecrecy( addr.secrecy() );
275 277
276 // EMAIL 278 // EMAIL
277 QStringList emails = addr.emails(); 279 QStringList emails = addr.emails();
278 QStringList masterEmails = mMasterAddressee.emails(); 280 QStringList masterEmails = mMasterAddressee.emails();
279 for ( it = emails.begin(); it != emails.end(); ++it ) 281 for ( it = emails.begin(); it != emails.end(); ++it )
280 if ( !masterEmails.contains( *it ) ) 282 if ( !masterEmails.contains( *it ) )
281 mMasterAddressee.insertEmail( *it, false ); 283 mMasterAddressee.insertEmail( *it, false );
282 284
283 // FN 285 // FN
284 if ( mMasterAddressee.formattedName().isEmpty() && !addr.formattedName().isEmpty() ) 286 if ( mMasterAddressee.formattedName().isEmpty() && !addr.formattedName().isEmpty() )
285 mMasterAddressee.setFormattedName( addr.formattedName() ); 287 mMasterAddressee.setFormattedName( addr.formattedName() );
286 288
287 // GEO 289 // GEO
288 if ( !mMasterAddressee.geo().isValid() && addr.geo().isValid() ) 290 if ( !mMasterAddressee.geo().isValid() && addr.geo().isValid() )
289 mMasterAddressee.setGeo( addr.geo() ); 291 mMasterAddressee.setGeo( addr.geo() );
290 292
291/* 293/*
292 // KEY 294 // KEY
293 // LOGO 295 // LOGO
294*/ 296*/
295 297
296 // MAILER 298 // MAILER
297 if ( mMasterAddressee.mailer().isEmpty() && !addr.mailer().isEmpty() ) 299 if ( mMasterAddressee.mailer().isEmpty() && !addr.mailer().isEmpty() )
298 mMasterAddressee.setMailer( addr.mailer() ); 300 mMasterAddressee.setMailer( addr.mailer() );
299 301
300 // N 302 // N
301 if ( mMasterAddressee.assembledName().isEmpty() && !addr.assembledName().isEmpty() ) 303 if ( mMasterAddressee.assembledName().isEmpty() && !addr.assembledName().isEmpty() )
302 mMasterAddressee.setNameFromString( addr.assembledName() ); 304 mMasterAddressee.setNameFromString( addr.assembledName() );
303 305
304 // NICKNAME 306 // NICKNAME
305 if ( mMasterAddressee.nickName().isEmpty() && !addr.nickName().isEmpty() ) 307 if ( mMasterAddressee.nickName().isEmpty() && !addr.nickName().isEmpty() )
306 mMasterAddressee.setNickName( addr.nickName() ); 308 mMasterAddressee.setNickName( addr.nickName() );
307 309
308 // NOTE 310 // NOTE
309 if ( mMasterAddressee.note().isEmpty() && !addr.note().isEmpty() ) 311 if ( mMasterAddressee.note().isEmpty() && !addr.note().isEmpty() )
310 mMasterAddressee.setNote( addr.note() ); 312 mMasterAddressee.setNote( addr.note() );
311 313
312 // ORG 314 // ORG
313 if ( mMasterAddressee.organization().isEmpty() && !addr.organization().isEmpty() ) 315 if ( mMasterAddressee.organization().isEmpty() && !addr.organization().isEmpty() )
314 mMasterAddressee.setOrganization( addr.organization() ); 316 mMasterAddressee.setOrganization( addr.organization() );
315 317
316/* 318/*
317 // PHOTO 319 // PHOTO
318*/ 320*/
319 321
320 // PROID 322 // PROID
321 if ( mMasterAddressee.productId().isEmpty() && !addr.productId().isEmpty() ) 323 if ( mMasterAddressee.productId().isEmpty() && !addr.productId().isEmpty() )
322 mMasterAddressee.setProductId( addr.productId() ); 324 mMasterAddressee.setProductId( addr.productId() );
323 325
324 // REV 326 // REV
325 if ( mMasterAddressee.revision().isNull() && !addr.revision().isNull() ) 327 if ( mMasterAddressee.revision().isNull() && !addr.revision().isNull() )
326 mMasterAddressee.setRevision( addr.revision() ); 328 mMasterAddressee.setRevision( addr.revision() );
327 329
328 // ROLE 330 // ROLE
329 if ( mMasterAddressee.role().isEmpty() && !addr.role().isEmpty() ) 331 if ( mMasterAddressee.role().isEmpty() && !addr.role().isEmpty() )
330 mMasterAddressee.setRole( addr.role() ); 332 mMasterAddressee.setRole( addr.role() );
331 333
332 // SORT-STRING 334 // SORT-STRING
333 if ( mMasterAddressee.sortString().isEmpty() && !addr.sortString().isEmpty() ) 335 if ( mMasterAddressee.sortString().isEmpty() && !addr.sortString().isEmpty() )
334 mMasterAddressee.setSortString( addr.sortString() ); 336 mMasterAddressee.setSortString( addr.sortString() );
335 337
336/* 338/*
337 // SOUND 339 // SOUND
338*/ 340*/
339 341
340 // TEL 342 // TEL
341 KABC::PhoneNumber::List phones = addr.phoneNumbers(); 343 KABC::PhoneNumber::List phones = addr.phoneNumbers();
342 KABC::PhoneNumber::List masterPhones = mMasterAddressee.phoneNumbers(); 344 KABC::PhoneNumber::List masterPhones = mMasterAddressee.phoneNumbers();
343 KABC::PhoneNumber::List::ConstIterator phoneIt; 345 KABC::PhoneNumber::List::ConstIterator phoneIt;
344 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) 346 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt )
345 if ( !masterPhones.contains( *it ) ) 347 if ( !masterPhones.contains( *it ) )
346 mMasterAddressee.insertPhoneNumber( *it ); 348 mMasterAddressee.insertPhoneNumber( *it );
347 349
348 // TITLE 350 // TITLE
349 if ( mMasterAddressee.title().isEmpty() && !addr.title().isEmpty() ) 351 if ( mMasterAddressee.title().isEmpty() && !addr.title().isEmpty() )
350 mMasterAddressee.setTitle( addr.title() ); 352 mMasterAddressee.setTitle( addr.title() );
351 353
352 // TZ 354 // TZ
353 if ( !mMasterAddressee.timeZone().isValid() && addr.timeZone().isValid() ) 355 if ( !mMasterAddressee.timeZone().isValid() && addr.timeZone().isValid() )
354 mMasterAddressee.setTimeZone( addr.timeZone() ); 356 mMasterAddressee.setTimeZone( addr.timeZone() );
355 357
356 // UID // ignore UID 358 // UID // ignore UID
357 359
358 // URL 360 // URL
359 if ( mMasterAddressee.url().isEmpty() && !addr.url().isEmpty() ) 361 if ( mMasterAddressee.url().isEmpty() && !addr.url().isEmpty() )
360 mMasterAddressee.setUrl( addr.url() ); 362 mMasterAddressee.setUrl( addr.url() );
361 363
362 // X- 364 // X-
363 QStringList customs = addr.customs(); 365 QStringList customs = addr.customs();
364 QStringList masterCustoms = mMasterAddressee.customs(); 366 QStringList masterCustoms = mMasterAddressee.customs();
365 QStringList newCustoms( masterCustoms ); 367 QStringList newCustoms( masterCustoms );
366 for ( it = customs.begin(); it != customs.end(); ++it ) 368 for ( it = customs.begin(); it != customs.end(); ++it )
367 if ( !masterCustoms.contains( *it ) ) 369 if ( !masterCustoms.contains( *it ) )
368 newCustoms.append( *it ); 370 newCustoms.append( *it );
369 mMasterAddressee.setCustoms( newCustoms ); 371 mMasterAddressee.setCustoms( newCustoms );
370} 372}
371 373
372#ifndef KAB_EMBEDDED 374#ifndef KAB_EMBEDDED_
373#include "mergewidget.moc" 375#include "moc_mergewidget.cpp"
374#endif //KAB_EMBEDDED 376#endif //KAB_EMBEDDED
diff --git a/kaddressbook/features/mergewidget.h b/kaddressbook/features/mergewidget.h
index 1063c80..bb16282 100644
--- a/kaddressbook/features/mergewidget.h
+++ b/kaddressbook/features/mergewidget.h
@@ -1,87 +1,87 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 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#ifndef MERGEWIDGET_H 24#ifndef MERGEWIDGET_H
25#define MERGEWIDGET_H 25#define MERGEWIDGET_H
26 26
27#include <kdialogbase.h> 27#include <kdialogbase.h>
28#include <klistview.h> 28#include <klistview.h>
29 29
30#include "extensionwidget.h" 30#include "extensionwidget.h"
31 31
32class QListView; 32class Q3ListView;
33 33
34class KABCore; 34class KABCore;
35 35
36namespace KABC { 36namespace KABC {
37class AddressBook; 37class AddressBook;
38} 38}
39 39
40class MergeWidget : public ExtensionWidget 40class MergeWidget : public ExtensionWidget
41{ 41{
42 Q_OBJECT 42 Q_OBJECT
43 43
44 public: 44 public:
45 MergeWidget( KABCore*, QWidget *parent, const char *name = 0 ); 45 MergeWidget( KABCore*, QWidget *parent, const char *name = 0 );
46 virtual ~MergeWidget(); 46 virtual ~MergeWidget();
47 47
48 void contactsSelectionChanged(); 48 void contactsSelectionChanged();
49 49
50 QString title() const; 50 QString title() const;
51 QString identifier() const; 51 QString identifier() const;
52 52
53 private slots: 53 private slots:
54 void mergeAndRemove(); 54 void mergeAndRemove();
55 void merge(); 55 void merge();
56 56
57 void selectionContactViewChanged(); 57 void selectionContactViewChanged();
58 58
59 private: 59 private:
60 void updateView(); 60 void updateView();
61 void doMerge( const KABC::Addressee &addr ); 61 void doMerge( const KABC::Addressee &addr );
62 62
63 KListView *mContactView; 63 KListView *mContactView;
64 QPushButton *mMergeAndRemoveButton; 64 QPushButton *mMergeAndRemoveButton;
65 QPushButton *mMergeButton; 65 QPushButton *mMergeButton;
66 66
67 KABC::Addressee mMasterAddressee; 67 KABC::Addressee mMasterAddressee;
68 bool mBlockUpdate; 68 bool mBlockUpdate;
69}; 69};
70 70
71#ifdef KAB_EMBEDDED 71#ifdef KAB_EMBEDDED
72class MergeFactory : public ExtensionFactory 72class MergeFactory : public ExtensionFactory
73{ 73{
74 public: 74 public:
75 ExtensionWidget *extension( KABCore *core, QWidget *parent, const char *name ) 75 ExtensionWidget *extension( KABCore *core, QWidget *parent, const char *name )
76 { 76 {
77 return new MergeWidget( core, parent, name ); 77 return new MergeWidget( core, parent, name );
78 } 78 }
79 79
80 QString identifier() const 80 QString identifier() const
81 { 81 {
82 return "merge"; 82 return "merge";
83 } 83 }
84}; 84};
85#endif //KAB_EMBEDDED 85#endif //KAB_EMBEDDED
86 86
87#endif 87#endif
diff --git a/kaddressbook/filter.cpp b/kaddressbook/filter.cpp
index 12ab1e3..6462310 100644
--- a/kaddressbook/filter.cpp
+++ b/kaddressbook/filter.cpp
@@ -1,238 +1,238 @@
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#include <kconfig.h> 24#include <kconfig.h>
25#include <kconfigbase.h> 25#include <kconfigbase.h>
26#include <kdebug.h> 26#include <kdebug.h>
27 27
28#include "kabprefs.h" 28#include "kabprefs.h"
29 29
30#include "filter.h" 30#include "filter.h"
31#include <secrecy.h> 31#include <secrecy.h>
32 32
33Filter::Filter() 33Filter::Filter()
34 : mName( QString::null ), mMatchRule( NotMatching ), mEnabled( true ), 34 : mName( QString::null ), mMatchRule( NotMatching ), mEnabled( true ),
35 mInternal( false ) 35 mInternal( false )
36{ 36{
37 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; 37 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ;
38 noName = true; 38 noName = true;
39} 39}
40 40
41Filter::Filter( const QString &name ) 41Filter::Filter( const QString &name )
42 : mName( name ), mMatchRule( NotMatching ), mEnabled( true ), 42 : mName( name ), mMatchRule( NotMatching ), mEnabled( true ),
43 mInternal( false ) 43 mInternal( false )
44{ 44{
45 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; 45 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ;
46 noName = false; 46 noName = false;
47} 47}
48 48
49Filter::~Filter() 49Filter::~Filter()
50{ 50{
51} 51}
52 52
53void Filter::setName( const QString &name ) 53void Filter::setName( const QString &name )
54{ 54{
55 mName = name; 55 mName = name;
56 noName = false; 56 noName = false;
57} 57}
58 58
59const QString &Filter::name() const 59const QString &Filter::name() const
60{ 60{
61 return mName; 61 return mName;
62} 62}
63 63
64bool Filter::isInternal() const 64bool Filter::isInternal() const
65{ 65{
66 return mInternal; 66 return mInternal;
67} 67}
68 68
69void Filter::apply( KABC::Addressee::List &addresseeList ) 69void Filter::apply( KABC::Addressee::List &addresseeList )
70{ 70{
71 if ( noName ) 71 if ( noName )
72 return; 72 return;
73 KABC::Addressee::List::Iterator iter; 73 KABC::Addressee::List::Iterator iter;
74 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ) { 74 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ) {
75 if ( filterAddressee( *iter ) ) 75 if ( filterAddressee( *iter ) )
76 ++iter; 76 ++iter;
77 else 77 else
78 { 78 {
79#ifndef KAB_EMBEDDED 79#ifndef KAB_EMBEDDED
80 iter = addresseeList.erase( iter ); 80 iter = addresseeList.erase( iter );
81#else //KAB_EMBEDDED 81#else //KAB_EMBEDDED
82 iter = addresseeList.remove( iter ); 82 iter = addresseeList.remove( iter );
83#endif //KAB_EMBEDDED 83#endif //KAB_EMBEDDED
84 } 84 }
85 } 85 }
86} 86}
87 87
88bool Filter::filterAddressee( const KABC::Addressee &a ) 88bool Filter::filterAddressee( const KABC::Addressee &a )
89{ 89{
90 90
91 if ( noName ) 91 if ( noName )
92 return true; 92 return true;
93 //qDebug("Filter::filterAddressee %s",mName.latin1() ); 93 //qDebug("Filter::filterAddressee %s",mName.latin1() );
94 switch ( a.secrecy().type()) { 94 switch ( a.secrecy().type()) {
95 case KABC::Secrecy::Public: 95 case KABC::Secrecy::Public:
96 if (! (mCriteria & ShowPublic )) 96 if (! (mCriteria & ShowPublic ))
97 return false; 97 return false;
98 break; 98 break;
99 case KABC::Secrecy::Private: 99 case KABC::Secrecy::Private:
100 if (! (mCriteria & ShowPrivate )) 100 if (! (mCriteria & ShowPrivate ))
101 return false; 101 return false;
102 break; 102 break;
103 case KABC::Secrecy::Confidential: 103 case KABC::Secrecy::Confidential:
104 if (! (mCriteria & ShowConfidential )) 104 if (! (mCriteria & ShowConfidential ))
105 return false; 105 return false;
106 break; 106 break;
107 default: 107 default:
108 return false; 108 return false;
109 break; 109 break;
110 } 110 }
111 QStringList::Iterator iter; 111 QStringList::Iterator iter;
112 iter = mCategoryList.begin(); 112 iter = mCategoryList.begin();
113 113
114 if ( iter == mCategoryList.end() ) 114 if ( iter == mCategoryList.end() )
115 return ( !(mMatchRule == Matching) ); 115 return ( !(mMatchRule == Matching) );
116 116
117 for ( ; iter != mCategoryList.end(); ++iter ) { 117 for ( ; iter != mCategoryList.end(); ++iter ) {
118 if ( a.hasCategory( *iter ) ) 118 if ( a.hasCategory( *iter ) )
119 return ( mMatchRule == Matching ); 119 return ( mMatchRule == Matching );
120 } 120 }
121 121
122 return !( mMatchRule == Matching ); 122 return !( mMatchRule == Matching );
123} 123}
124 124
125void Filter::setEnabled( bool on ) 125void Filter::setEnabled( bool on )
126{ 126{
127 mEnabled = on; 127 mEnabled = on;
128} 128}
129 129
130bool Filter::isEnabled() const 130bool Filter::isEnabled() const
131{ 131{
132 return mEnabled; 132 return mEnabled;
133} 133}
134 134
135void Filter::setCategories( const QStringList &list ) 135void Filter::setCategories( const QStringList &list )
136{ 136{
137 mCategoryList = list; 137 mCategoryList = list;
138} 138}
139 139
140const QStringList &Filter::categories() const 140const QStringList &Filter::categories() const
141{ 141{
142 return mCategoryList; 142 return mCategoryList;
143} 143}
144 144
145void Filter::save( KConfig *config ) 145void Filter::save( KConfig *config )
146{ 146{
147 config->writeEntry( "Name", mName ); 147 config->writeEntry( "Name", mName );
148 config->writeEntry( "Enabled", mEnabled ); 148 config->writeEntry( "Enabled", mEnabled );
149 config->writeEntry( "Categories", mCategoryList ); 149 config->writeEntry( "Categories", mCategoryList );
150 config->writeEntry( "MatchRule", (int)mMatchRule ); 150 config->writeEntry( "MatchRule", (int)mMatchRule );
151 config->writeEntry( "Criteria", (int)mCriteria ); 151 config->writeEntry( "Criteria", (int)mCriteria );
152} 152}
153 153
154void Filter::restore( KConfig *config ) 154void Filter::restore( KConfig *config )
155{ 155{
156 noName = false; 156 noName = false;
157 mName = config->readEntry( "Name", "<internal error>" ); 157 mName = config->readEntry( "Name", "<internal error>" );
158 mEnabled = config->readBoolEntry( "Enabled", true ); 158 mEnabled = config->readBoolEntry( "Enabled", true );
159 mCategoryList = config->readListEntry( "Categories" ); 159 mCategoryList = config->readListEntry( "Categories" );
160 mMatchRule = (MatchRule)config->readNumEntry( "MatchRule", Matching ); 160 mMatchRule = (MatchRule)config->readNumEntry( "MatchRule", Matching );
161 mCriteria = config->readNumEntry( "Criteria", (ShowPublic | ShowPrivate| ShowConfidential ) ); 161 mCriteria = config->readNumEntry( "Criteria", (ShowPublic | ShowPrivate| ShowConfidential ) );
162} 162}
163 163
164void Filter::save( KConfig *config, QString baseGroup, Filter::List &list ) 164void Filter::save( KConfig *config, QString baseGroup, Filter::List &list )
165{ 165{
166 { 166 {
167 KConfigGroupSaver s( config, baseGroup ); 167 KConfigGroupSaver s( config, baseGroup );
168 168
169 // remove the old filters 169 // remove the old filters
170 uint count = config->readNumEntry( "Count" ); 170 uint count = config->readNumEntry( "Count" );
171 /* // memory access violation here 171 /* // memory access violation here
172 for ( uint i = 0; i < count; ++i ) 172 for ( uint i = 0; i < count; ++i )
173 config->deleteGroup( QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); 173 config->deleteGroup( QString( "%1_%2" ).arg( baseGroup ).arg( i ) );
174 */ 174 */
175 } 175 }
176 176
177 int index = 0; 177 int index = 0;
178 Filter::List::Iterator iter; 178 Filter::List::Iterator iter;
179 for ( iter = list.begin(); iter != list.end(); ++iter ) { 179 for ( iter = list.begin(); iter != list.end(); ++iter ) {
180 if ( !(*iter).mInternal ) { 180 if ( !(*iter).mInternal ) {
181 KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( index ) ); 181 KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( index ) );
182 182
183 (*iter).save( config ); 183 (*iter).save( config );
184 index++; 184 index++;
185 } 185 }
186 } 186 }
187 187
188 KConfigGroupSaver s( config, baseGroup ); 188 KConfigGroupSaver s( config, baseGroup );
189 189
190 config->writeEntry( "Count", index ); 190 config->writeEntry( "Count", index );
191 191
192} 192}
193 193
194Filter::List Filter::restore( KConfig *config, QString baseGroup ) 194Filter::List Filter::restore( KConfig *config, QString baseGroup )
195{ 195{
196 Filter::List list; 196 Filter::List list;
197 int count = 0; 197 int count = 0;
198 Filter f; 198 Filter f;
199 199
200 { 200 {
201 KConfigGroupSaver s( config, baseGroup ); 201 KConfigGroupSaver s( config, baseGroup );
202 count = config->readNumEntry( "Count", 0 ); 202 count = config->readNumEntry( "Count", 0 );
203 } 203 }
204 204
205 for ( int i = 0; i < count; i++ ) { 205 for ( int i = 0; i < count; i++ ) {
206 { 206 {
207 KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); 207 KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( i ) );
208 f.restore( config ); 208 f.restore( config );
209 } 209 }
210 210
211 list.append( f ); 211 list.append( f );
212 } 212 }
213 213
214 if ( list.isEmpty()) { 214 if ( list.isEmpty()) {
215 QStringList cats = KABPrefs::instance()->mCustomCategories; 215 QStringList cats = KABPrefs::instance()->mCustomCategories;
216 for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { 216 for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) {
217 Filter filter; 217 Filter filter;
218 filter.noName = false; 218 filter.noName = false;
219 filter.mName = *it; 219 filter.mName = *it;
220 filter.mEnabled = true; 220 filter.mEnabled = true;
221 filter.mCategoryList = *it; 221 filter.mCategoryList = QStringList(*it);
222 filter.mMatchRule = Matching; 222 filter.mMatchRule = Matching;
223 filter.mInternal = true; 223 filter.mInternal = true;
224 list.append( filter ); 224 list.append( filter );
225 } 225 }
226 } 226 }
227 return list; 227 return list;
228} 228}
229 229
230void Filter::setMatchRule( MatchRule rule ) 230void Filter::setMatchRule( MatchRule rule )
231{ 231{
232 mMatchRule = rule; 232 mMatchRule = rule;
233} 233}
234 234
235Filter::MatchRule Filter::matchRule() const 235Filter::MatchRule Filter::matchRule() const
236{ 236{
237 return mMatchRule; 237 return mMatchRule;
238} 238}
diff --git a/kaddressbook/filter.h b/kaddressbook/filter.h
index f4ae123..508436d 100644
--- a/kaddressbook/filter.h
+++ b/kaddressbook/filter.h
@@ -1,158 +1,158 @@
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 FILTER_H 24#ifndef FILTER_H
25#define FILTER_H 25#define FILTER_H
26 26
27#include <qstring.h> 27#include <qstring.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <qvaluelist.h> 29#include <q3valuelist.h>
30 30
31#include <kabc/addressee.h> 31#include <kabc/addressee.h>
32#include <kconfig.h> 32#include <kconfig.h>
33 33
34/** 34/**
35 Filter for AddressBook related objects (Addressees) 35 Filter for AddressBook related objects (Addressees)
36 36
37 @todo This class should be switched to use shared data. 37 @todo This class should be switched to use shared data.
38 */ 38 */
39class Filter 39class Filter
40{ 40{
41 public: 41 public:
42 enum { ShowPublic = 1, ShowPrivate = 2, ShowConfidential = 4 }; 42 enum { ShowPublic = 1, ShowPrivate = 2, ShowConfidential = 4 };
43 void setCriteria(int c) { mCriteria = c ;} 43 void setCriteria(int c) { mCriteria = c ;}
44 int criteria() const { return mCriteria;} 44 int criteria() const { return mCriteria;}
45 typedef QValueList<Filter> List; 45 typedef Q3ValueList<Filter> List;
46 46
47 enum MatchRule { Matching = 0, NotMatching = 1 }; 47 enum MatchRule { Matching = 0, NotMatching = 1 };
48 48
49 Filter(); 49 Filter();
50 Filter( const QString& name ); 50 Filter( const QString& name );
51 ~Filter(); 51 ~Filter();
52 52
53 /** 53 /**
54 Set the name of the filter. 54 Set the name of the filter.
55 */ 55 */
56 void setName( const QString &name ); 56 void setName( const QString &name );
57 57
58 /** 58 /**
59 @return The name of the filter. 59 @return The name of the filter.
60 */ 60 */
61 const QString &name() const; 61 const QString &name() const;
62 62
63 /** 63 /**
64 @return Whether the filter is an internal one. 64 @return Whether the filter is an internal one.
65 */ 65 */
66 bool isInternal() const; 66 bool isInternal() const;
67 67
68 /** 68 /**
69 Apply the filter to the addressee list. All addressees not passing 69 Apply the filter to the addressee list. All addressees not passing
70 the filter criterias will be removed from the list. 70 the filter criterias will be removed from the list.
71 71
72 If the MatchRule is NotMatch, then all the addressees matching the 72 If the MatchRule is NotMatch, then all the addressees matching the
73 filter will be removed from the list. 73 filter will be removed from the list.
74 */ 74 */
75 void apply( KABC::Addressee::List &addresseeList ); 75 void apply( KABC::Addressee::List &addresseeList );
76 76
77 /** 77 /**
78 Apply the filter to the addressee. 78 Apply the filter to the addressee.
79 79
80 @return True if the addressee passes the criteria, false otherwise. 80 @return True if the addressee passes the criteria, false otherwise.
81 The return values are opposite if the MatchRule is NotMatch. 81 The return values are opposite if the MatchRule is NotMatch.
82 */ 82 */
83 bool filterAddressee( const KABC::Addressee &a ); 83 bool filterAddressee( const KABC::Addressee &a );
84 84
85 /** 85 /**
86 Enable or disable the filter 86 Enable or disable the filter
87 */ 87 */
88 void setEnabled( bool on ); 88 void setEnabled( bool on );
89 89
90 /** 90 /**
91 @return True if this filter is enabled, false otherwise. 91 @return True if this filter is enabled, false otherwise.
92 */ 92 */
93 bool isEnabled() const; 93 bool isEnabled() const;
94 94
95 /** 95 /**
96 Set the list of categories. This list is used to filter addressees. 96 Set the list of categories. This list is used to filter addressees.
97 */ 97 */
98 void setCategories( const QStringList &list ); 98 void setCategories( const QStringList &list );
99 99
100 /** 100 /**
101 @return The list of categories. 101 @return The list of categories.
102 */ 102 */
103 const QStringList &categories() const; 103 const QStringList &categories() const;
104 104
105 /** 105 /**
106 Saves the filter to the config file. The group should already be set. 106 Saves the filter to the config file. The group should already be set.
107 */ 107 */
108 void save( KConfig *config ); 108 void save( KConfig *config );
109 109
110 /** 110 /**
111 Loads the filter from the config file. The group should already be set. 111 Loads the filter from the config file. The group should already be set.
112 */ 112 */
113 void restore( KConfig *config ); 113 void restore( KConfig *config );
114 114
115 /** 115 /**
116 Saves a list of filters to the config file. 116 Saves a list of filters to the config file.
117 117
118 @param config The config file to use 118 @param config The config file to use
119 @param baseGroup The base groupname to use. The number of filters 119 @param baseGroup The base groupname to use. The number of filters
120 will be written to this group, then a _1, _2, etc 120 will be written to this group, then a _1, _2, etc
121 will be append for each filter saved. 121 will be append for each filter saved.
122 @param list The list of filters to be saved. 122 @param list The list of filters to be saved.
123 */ 123 */
124 static void save( KConfig *config, QString baseGroup, Filter::List &list ); 124 static void save( KConfig *config, QString baseGroup, Filter::List &list );
125 125
126 /** 126 /**
127 Restores a list of filters from a config file. 127 Restores a list of filters from a config file.
128 128
129 @param config The config file to read from. 129 @param config The config file to read from.
130 @param baseGroup The base group name to be used to find the filters 130 @param baseGroup The base group name to be used to find the filters
131 131
132 @return The list of filters. 132 @return The list of filters.
133 */ 133 */
134 static Filter::List restore( KConfig *config, QString baseGroup ); 134 static Filter::List restore( KConfig *config, QString baseGroup );
135 135
136 /** 136 /**
137 Sets the filter rule. If the rule is Filter::Matching (default), 137 Sets the filter rule. If the rule is Filter::Matching (default),
138 then the filter will return true on items that match the filter. 138 then the filter will return true on items that match the filter.
139 If the rule is Filter::NotMatching, then the filter will return 139 If the rule is Filter::NotMatching, then the filter will return
140 true on items that do not match the filter. 140 true on items that do not match the filter.
141 */ 141 */
142 void setMatchRule( MatchRule rule ); 142 void setMatchRule( MatchRule rule );
143 143
144 /** @return The current match rule. 144 /** @return The current match rule.
145 */ 145 */
146 MatchRule matchRule() const; 146 MatchRule matchRule() const;
147 147
148 private: 148 private:
149 bool noName; 149 bool noName;
150 int mCriteria; 150 int mCriteria;
151 QString mName; 151 QString mName;
152 QStringList mCategoryList; 152 QStringList mCategoryList;
153 MatchRule mMatchRule; 153 MatchRule mMatchRule;
154 bool mEnabled; 154 bool mEnabled;
155 bool mInternal; 155 bool mInternal;
156}; 156};
157 157
158#endif 158#endif
diff --git a/kaddressbook/filtereditdialog.cpp b/kaddressbook/filtereditdialog.cpp
index ef9b979..40698a7 100644
--- a/kaddressbook/filtereditdialog.cpp
+++ b/kaddressbook/filtereditdialog.cpp
@@ -1,315 +1,317 @@
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/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <qbuttongroup.h> 31#include <q3buttongroup.h>
32#include <qhbox.h> 32#include <q3hbox.h>
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qpushbutton.h> 35#include <qpushbutton.h>
36#include <qradiobutton.h> 36#include <qradiobutton.h>
37#include <qcheckbox.h> 37#include <qcheckbox.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qstring.h> 39#include <qstring.h>
40#include <qtoolbutton.h> 40#include <qtoolbutton.h>
41#include <qtooltip.h> 41#include <qtooltip.h>
42#include <qwidget.h> 42#include <qwidget.h>
43//Added by qt3to4:
44#include <Q3GridLayout>
43 45
44#include <kapplication.h> 46#include <kapplication.h>
45#include <kbuttonbox.h> 47#include <kbuttonbox.h>
46#include <kdebug.h> 48#include <kdebug.h>
47#include <kiconloader.h> 49#include <kiconloader.h>
48#include <klineedit.h> 50#include <klineedit.h>
49#include <klistbox.h> 51#include <klistbox.h>
50#include <klistview.h> 52#include <klistview.h>
51#include <klocale.h> 53#include <klocale.h>
52#include <kglobal.h> 54#include <kglobal.h>
53 55
54#include "kabprefs.h" 56#include "kabprefs.h"
55#include "filtereditdialog.h" 57#include "filtereditdialog.h"
56 58
57FilterEditDialog::FilterEditDialog( QWidget *parent, const char *name ) 59FilterEditDialog::FilterEditDialog( QWidget *parent, const char *name )
58 : KDialogBase( Plain, i18n( "Edit Address Book Filter" ), 60 : KDialogBase( Plain, i18n( "Edit Address Book Filter" ),
59 Help | Ok | Cancel, Ok, parent, name, /*US false*/ true, true ) 61 Help | Ok | Cancel, Ok, parent, name, /*US false*/ true, true )
60{ 62{
61 initGUI(); 63 initGUI();
62 64
63 QStringList cats = KABPrefs::instance()->mCustomCategories; 65 QStringList cats = KABPrefs::instance()->mCustomCategories;
64 66
65 QStringList::Iterator iter; 67 QStringList::Iterator iter;
66 for ( iter = cats.begin(); iter != cats.end(); ++iter ) 68 for ( iter = cats.begin(); iter != cats.end(); ++iter )
67 mCategoriesView->insertItem( new QCheckListItem( mCategoriesView, (*iter), QCheckListItem::CheckBox ) ); 69 mCategoriesView->insertItem( new Q3CheckListItem( mCategoriesView, (*iter), Q3CheckListItem::CheckBox ) );
68 filterNameTextChanged( mNameEdit->text() ); 70 filterNameTextChanged( mNameEdit->text() );
69} 71}
70 72
71FilterEditDialog::~FilterEditDialog() 73FilterEditDialog::~FilterEditDialog()
72{ 74{
73} 75}
74 76
75void FilterEditDialog::setFilter( const Filter &filter ) 77void FilterEditDialog::setFilter( const Filter &filter )
76{ 78{
77 mNameEdit->setText( filter.name() ); 79 mNameEdit->setText( filter.name() );
78 80
79 QStringList categories = filter.categories(); 81 QStringList categories = filter.categories();
80 QListViewItem *item = mCategoriesView->firstChild(); 82 Q3ListViewItem *item = mCategoriesView->firstChild();
81 while ( item != 0 ) { 83 while ( item != 0 ) {
82 if ( categories.contains( item->text( 0 ) ) ) { 84 if ( categories.contains( item->text( 0 ) ) ) {
83 QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); 85 Q3CheckListItem *checkItem = static_cast<Q3CheckListItem*>( item );
84 checkItem->setOn( true ); 86 checkItem->setOn( true );
85 } 87 }
86 88
87 item = item->nextSibling(); 89 item = item->nextSibling();
88 } 90 }
89 91
90 if ( filter.matchRule() == Filter::Matching ) 92 if ( filter.matchRule() == Filter::Matching )
91 mMatchRuleGroup->setButton( 0 ); 93 mMatchRuleGroup->setButton( 0 );
92 else 94 else
93 mMatchRuleGroup->setButton( 1 ); 95 mMatchRuleGroup->setButton( 1 );
94 96
95 int c = filter.criteria() ; 97 int c = filter.criteria() ;
96 mPublic->setChecked(c &Filter::ShowPublic); 98 mPublic->setChecked(c &Filter::ShowPublic);
97 mPrivate->setChecked(c & Filter::ShowPrivate); 99 mPrivate->setChecked(c & Filter::ShowPrivate);
98 mConfidential->setChecked(c & Filter::ShowConfidential); 100 mConfidential->setChecked(c & Filter::ShowConfidential);
99} 101}
100 102
101Filter FilterEditDialog::filter() 103Filter FilterEditDialog::filter()
102{ 104{
103 Filter filter; 105 Filter filter;
104 106
105 filter.setName( mNameEdit->text() ); 107 filter.setName( mNameEdit->text() );
106 108
107 QStringList categories; 109 QStringList categories;
108 QListViewItem *item = mCategoriesView->firstChild(); 110 Q3ListViewItem *item = mCategoriesView->firstChild();
109 while ( item != 0 ) { 111 while ( item != 0 ) {
110 QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); 112 Q3CheckListItem *checkItem = static_cast<Q3CheckListItem*>( item );
111 if ( checkItem->isOn() ) 113 if ( checkItem->isOn() )
112 categories.append( item->text( 0 ) ); 114 categories.append( item->text( 0 ) );
113 115
114 item = item->nextSibling(); 116 item = item->nextSibling();
115 } 117 }
116 filter.setCategories( categories ); 118 filter.setCategories( categories );
117 119
118 if ( mMatchRuleGroup->find( 0 )->isOn() ) 120 if ( mMatchRuleGroup->find( 0 )->isOn() )
119 filter.setMatchRule( Filter::Matching ); 121 filter.setMatchRule( Filter::Matching );
120 else 122 else
121 filter.setMatchRule( Filter::NotMatching ); 123 filter.setMatchRule( Filter::NotMatching );
122 124
123 int c = 0; 125 int c = 0;
124 if (mPublic->isChecked()) c |= Filter::ShowPublic; 126 if (mPublic->isChecked()) c |= Filter::ShowPublic;
125 if (mPrivate->isChecked()) c |= Filter::ShowPrivate; 127 if (mPrivate->isChecked()) c |= Filter::ShowPrivate;
126 if (mConfidential->isChecked()) c |= Filter::ShowConfidential; 128 if (mConfidential->isChecked()) c |= Filter::ShowConfidential;
127 filter.setCriteria( c ) ; 129 filter.setCriteria( c ) ;
128 130
129 return filter; 131 return filter;
130} 132}
131 133
132void FilterEditDialog::initGUI() 134void FilterEditDialog::initGUI()
133{ 135{
134#ifndef KAB_EMBEDDED 136#ifndef KAB_EMBEDDED
135 resize( 490, 300 ); 137 resize( 490, 300 );
136#else //KAB_EMBEDDED 138#else //KAB_EMBEDDED
137 resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300)); 139 resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300));
138#endif //KAB_EMBEDDED 140#endif //KAB_EMBEDDED
139 141
140 142
141 QWidget *page = plainPage(); 143 QWidget *page = plainPage();
142 QLabel *label; 144 QLabel *label;
143 145
144 QGridLayout *topLayout = new QGridLayout( page, 3, 2, 0, spacingHint() ); 146 Q3GridLayout *topLayout = new Q3GridLayout( page, 3, 2, 0, spacingHint() );
145 147
146 label = new QLabel( i18n( "Name" ), page ); 148 label = new QLabel( i18n( "Name" ), page );
147 mNameEdit = new KLineEdit( page ); 149 mNameEdit = new KLineEdit( page );
148 mNameEdit->setFocus(); 150 mNameEdit->setFocus();
149 topLayout->addWidget( label, 0, 0 ); 151 topLayout->addWidget( label, 0, 0 );
150 topLayout->addWidget( mNameEdit, 0, 1 ); 152 topLayout->addWidget( mNameEdit, 0, 1 );
151 connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), 153 connect( mNameEdit, SIGNAL( textChanged( const QString& ) ),
152 SLOT( filterNameTextChanged( const QString&) ) ); 154 SLOT( filterNameTextChanged( const QString&) ) );
153 155
154 mCategoriesView = new KListView( page ); 156 mCategoriesView = new KListView( page );
155 mCategoriesView->addColumn( i18n( "Categories" ) ); 157 mCategoriesView->addColumn( i18n( "Categories" ) );
156 topLayout->addMultiCellWidget( mCategoriesView, 1, 1, 0, 1 ); 158 topLayout->addMultiCellWidget( mCategoriesView, 1, 1, 0, 1 );
157 159
158 mMatchRuleGroup = new QHButtonGroup( i18n( "Category rule" ), page ); 160 mMatchRuleGroup = new Q3HButtonGroup( i18n( "Category rule" ), page );
159 mMatchRuleGroup->setExclusive( true ); 161 mMatchRuleGroup->setExclusive( true );
160 QRadioButton *radio = new QRadioButton( i18n( "Include categories" ), mMatchRuleGroup ); 162 QRadioButton *radio = new QRadioButton( i18n( "Include categories" ), mMatchRuleGroup );
161 //mMatchRuleGroup->insert( radio ); 163 //mMatchRuleGroup->insert( radio );
162 radio = new QRadioButton( i18n( "Exclude categories" ), mMatchRuleGroup ); 164 radio = new QRadioButton( i18n( "Exclude categories" ), mMatchRuleGroup );
163 radio->setChecked( true ); 165 radio->setChecked( true );
164 //mMatchRuleGroup->insert( radio ); 166 //mMatchRuleGroup->insert( radio );
165 topLayout->addMultiCellWidget( mMatchRuleGroup, 2, 2, 0, 1 ); 167 topLayout->addMultiCellWidget( mMatchRuleGroup, 2, 2, 0, 1 );
166 168
167 QHButtonGroup * mMatchPPCGroup = new QHButtonGroup(i18n( "Include contacts, that are:" ), page ); 169 Q3HButtonGroup * mMatchPPCGroup = new Q3HButtonGroup(i18n( "Include contacts, that are:" ), page );
168 mPublic = new QCheckBox( i18n( "public" ), mMatchPPCGroup ); 170 mPublic = new QCheckBox( i18n( "public" ), mMatchPPCGroup );
169 mPrivate = new QCheckBox( i18n( "private" ), mMatchPPCGroup ); 171 mPrivate = new QCheckBox( i18n( "private" ), mMatchPPCGroup );
170 mConfidential = new QCheckBox( i18n( "confidential" ), mMatchPPCGroup ); 172 mConfidential = new QCheckBox( i18n( "confidential" ), mMatchPPCGroup );
171 mPublic->setChecked( true ); 173 mPublic->setChecked( true );
172 mPrivate->setChecked( true ); 174 mPrivate->setChecked( true );
173 mConfidential->setChecked( true ); 175 mConfidential->setChecked( true );
174 topLayout->addMultiCellWidget( mMatchPPCGroup, 3, 3, 0, 1 ); 176 topLayout->addMultiCellWidget( mMatchPPCGroup, 3, 3, 0, 1 );
175 177
176} 178}
177 179
178void FilterEditDialog::filterNameTextChanged( const QString &text ) 180void FilterEditDialog::filterNameTextChanged( const QString &text )
179{ 181{
180 enableButtonOK( !text.isEmpty() ); 182 enableButtonOK( !text.isEmpty() );
181} 183}
182 184
183void FilterEditDialog::slotHelp() 185void FilterEditDialog::slotHelp()
184{ 186{
185#ifndef KAB_EMBEDDED 187#ifndef KAB_EMBEDDED
186 kapp->invokeHelp( "using-filters" ); 188 kapp->invokeHelp( "using-filters" );
187#endif //KAB_EMBEDDED 189#endif //KAB_EMBEDDED
188} 190}
189 191
190FilterDialog::FilterDialog( QWidget *parent, const char *name ) 192FilterDialog::FilterDialog( QWidget *parent, const char *name )
191 : KDialogBase( Plain, i18n( "Edit Address Book Filters" ), 193 : KDialogBase( Plain, i18n( "Edit Address Book Filters" ),
192 Ok | Cancel, Ok, parent, name, /*US false*/true, true ) 194 Ok | Cancel, Ok, parent, name, /*US false*/true, true )
193{ 195{
194 initGUI(); 196 initGUI();
195} 197}
196 198
197FilterDialog::~FilterDialog() 199FilterDialog::~FilterDialog()
198{ 200{
199} 201}
200 202
201void FilterDialog::setFilters( const Filter::List &list ) 203void FilterDialog::setFilters( const Filter::List &list )
202{ 204{
203 mFilterList.clear(); 205 mFilterList.clear();
204 mInternalFilterList.clear(); 206 mInternalFilterList.clear();
205 207
206 Filter::List::ConstIterator it; 208 Filter::List::ConstIterator it;
207 for ( it = list.begin(); it != list.end(); ++it ) { 209 for ( it = list.begin(); it != list.end(); ++it ) {
208 if ( (*it).isInternal() ) 210 if ( (*it).isInternal() )
209 mInternalFilterList.append( *it ); 211 mInternalFilterList.append( *it );
210 else 212 else
211 mFilterList.append( *it ); 213 mFilterList.append( *it );
212 } 214 }
213 215
214 refresh(); 216 refresh();
215} 217}
216 218
217Filter::List FilterDialog::filters() const 219Filter::List FilterDialog::filters() const
218{ 220{
219 Filter::List list = mFilterList + mInternalFilterList; 221 Filter::List list = mFilterList + mInternalFilterList;
220 return list; 222 return list;
221} 223}
222 224
223void FilterDialog::add() 225void FilterDialog::add()
224{ 226{
225#ifndef KAB_EMBEDDED 227#ifndef KAB_EMBEDDED
226 FilterEditDialog dlg( this ); 228 FilterEditDialog dlg( this );
227#else //KAB_EMBEDDED 229#else //KAB_EMBEDDED
228 FilterEditDialog dlg( this->parentWidget() ); 230 FilterEditDialog dlg( this->parentWidget() );
229#endif //KAB_EMBEDDED 231#endif //KAB_EMBEDDED
230 232
231 if ( dlg.exec() ) 233 if ( dlg.exec() )
232 mFilterList.append( dlg.filter() ); 234 mFilterList.append( dlg.filter() );
233 235
234 refresh(); 236 refresh();
235 237
236 mFilterListBox->setCurrentItem( mFilterListBox->count() - 1 ); 238 mFilterListBox->setCurrentItem( mFilterListBox->count() - 1 );
237} 239}
238 240
239void FilterDialog::edit() 241void FilterDialog::edit()
240{ 242{
241 FilterEditDialog dlg( this ); 243 FilterEditDialog dlg( this );
242 244
243 uint pos = mFilterListBox->currentItem(); 245 uint pos = mFilterListBox->currentItem();
244 246
245 dlg.setFilter( mFilterList[ pos ] ); 247 dlg.setFilter( mFilterList[ pos ] );
246 248
247 if ( dlg.exec() ) { 249 if ( dlg.exec() ) {
248 mFilterList.remove( mFilterList.at( pos ) ); 250 mFilterList.remove( mFilterList.at( pos ) );
249 mFilterList.insert( mFilterList.at( pos ), dlg.filter() ); 251 mFilterList.insert( mFilterList.at( pos ), dlg.filter() );
250 } 252 }
251 253
252 refresh(); 254 refresh();
253 255
254 mFilterListBox->setCurrentItem( pos ); 256 mFilterListBox->setCurrentItem( pos );
255} 257}
256 258
257void FilterDialog::remove() 259void FilterDialog::remove()
258{ 260{
259 mFilterList.remove( mFilterList.at( mFilterListBox->currentItem() ) ); 261 mFilterList.remove( mFilterList.at( mFilterListBox->currentItem() ) );
260 262
261 selectionChanged( 0 ); 263 selectionChanged( 0 );
262 264
263 refresh(); 265 refresh();
264} 266}
265 267
266void FilterDialog::refresh() 268void FilterDialog::refresh()
267{ 269{
268 mFilterListBox->clear(); 270 mFilterListBox->clear();
269 271
270 Filter::List::Iterator iter; 272 Filter::List::Iterator iter;
271 for ( iter = mFilterList.begin(); iter != mFilterList.end(); ++iter ) 273 for ( iter = mFilterList.begin(); iter != mFilterList.end(); ++iter )
272 mFilterListBox->insertItem( (*iter).name() ); 274 mFilterListBox->insertItem( (*iter).name() );
273} 275}
274 276
275void FilterDialog::selectionChanged( QListBoxItem *item ) 277void FilterDialog::selectionChanged( Q3ListBoxItem *item )
276{ 278{
277 bool state = ( item != 0 ); 279 bool state = ( item != 0 );
278 280
279 mEditButton->setEnabled( state ); 281 mEditButton->setEnabled( state );
280 mRemoveButton->setEnabled( state ); 282 mRemoveButton->setEnabled( state );
281} 283}
282 284
283void FilterDialog::initGUI() 285void FilterDialog::initGUI()
284{ 286{
285#ifndef KAB_EMBEDDED 287#ifndef KAB_EMBEDDED
286 resize( 330, 200 ); 288 resize( 330, 200 );
287#else //KAB_EMBEDDED 289#else //KAB_EMBEDDED
288 resize( KMIN(KGlobal::getDesktopWidth()-10, 330), KMIN(KGlobal::getDesktopHeight()-50, 200)); 290 resize( KMIN(KGlobal::getDesktopWidth()-10, 330), KMIN(KGlobal::getDesktopHeight()-50, 200));
289#endif //KAB_EMBEDDED 291#endif //KAB_EMBEDDED
290 292
291 QWidget *page = plainPage(); 293 QWidget *page = plainPage();
292 294
293 QGridLayout *topLayout = new QGridLayout( page, 1, 2, 0, spacingHint() ); 295 Q3GridLayout *topLayout = new Q3GridLayout( page, 1, 2, 0, spacingHint() );
294 296
295 mFilterListBox = new KListBox( page ); 297 mFilterListBox = new KListBox( page );
296 topLayout->addWidget( mFilterListBox, 0, 0 ); 298 topLayout->addWidget( mFilterListBox, 0, 0 );
297 connect( mFilterListBox, SIGNAL( selectionChanged( QListBoxItem * ) ), 299 connect( mFilterListBox, SIGNAL( selectionChanged( Q3ListBoxItem * ) ),
298 SLOT( selectionChanged( QListBoxItem * ) ) ); 300 SLOT( selectionChanged( Q3ListBoxItem * ) ) );
299 connect( mFilterListBox, SIGNAL( doubleClicked ( QListBoxItem * ) ), 301 connect( mFilterListBox, SIGNAL( doubleClicked ( Q3ListBoxItem * ) ),
300 SLOT( edit() ) ); 302 SLOT( edit() ) );
301 303
302 KButtonBox *buttonBox = new KButtonBox( page, Vertical ); 304 KButtonBox *buttonBox = new KButtonBox( page, Qt::Vertical );
303 buttonBox->addButton( i18n( "&Add..." ), this, SLOT( add() ) ); 305 buttonBox->addButton( i18n( "&Add..." ), this, SLOT( add() ) );
304 mEditButton = buttonBox->addButton( i18n( "&Edit..." ), this, SLOT( edit() ) ); 306 mEditButton = buttonBox->addButton( i18n( "&Edit..." ), this, SLOT( edit() ) );
305 mEditButton->setEnabled( false ); 307 mEditButton->setEnabled( false );
306 mRemoveButton = buttonBox->addButton( i18n( "&Remove" ), this, SLOT( remove() ) ); 308 mRemoveButton = buttonBox->addButton( i18n( "&Remove" ), this, SLOT( remove() ) );
307 mRemoveButton->setEnabled( false ); 309 mRemoveButton->setEnabled( false );
308 310
309 buttonBox->layout(); 311 buttonBox->layout();
310 topLayout->addWidget( buttonBox, 0, 1 ); 312 topLayout->addWidget( buttonBox, 0, 1 );
311} 313}
312 314
313#ifndef KAB_EMBEDDED 315#ifndef KAB_EMBEDDED_
314#include "filtereditdialog.moc" 316#include "moc_filtereditdialog.cpp"
315#endif //KAB_EMBEDDED 317#endif //KAB_EMBEDDED
diff --git a/kaddressbook/filtereditdialog.h b/kaddressbook/filtereditdialog.h
index 5a8bad1..64d2976 100644
--- a/kaddressbook/filtereditdialog.h
+++ b/kaddressbook/filtereditdialog.h
@@ -1,109 +1,108 @@
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/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#ifndef FILTEREDITDIALOG_H 31#ifndef FILTEREDITDIALOG_H
32#define FILTEREDITDIALOG_H 32#define FILTEREDITDIALOG_H
33 33
34class QButtonGroup; 34#include <Q3HButtonGroup>
35class QString; 35class QString;
36class QToolButton; 36class QToolButton;
37class QWidget; 37class QWidget;
38class QListBoxItem; 38class Q3ListBoxItem;
39class QCheckBox; 39class QCheckBox;
40 40
41class KLineEdit; 41class KLineEdit;
42class KListBox; 42class KListBox;
43class KListView; 43class KListView;
44 44
45#include <kdialogbase.h> 45#include <kdialogbase.h>
46#include <qhbuttongroup.h>
47 46
48#include "filter.h" 47#include "filter.h"
49 48
50class FilterDialog : public KDialogBase 49class FilterDialog : public KDialogBase
51{ 50{
52 Q_OBJECT 51 Q_OBJECT
53 52
54 public: 53 public:
55 FilterDialog( QWidget *parent, const char *name = 0 ); 54 FilterDialog( QWidget *parent, const char *name = 0 );
56 ~FilterDialog(); 55 ~FilterDialog();
57 56
58 void setFilters( const Filter::List &list ); 57 void setFilters( const Filter::List &list );
59 Filter::List filters() const; 58 Filter::List filters() const;
60 59
61 protected slots: 60 protected slots:
62 void add(); 61 void add();
63 void edit(); 62 void edit();
64 void remove(); 63 void remove();
65 void selectionChanged( QListBoxItem* ); 64 void selectionChanged( Q3ListBoxItem* );
66 65
67 private: 66 private:
68 void initGUI(); 67 void initGUI();
69 void refresh(); 68 void refresh();
70 69
71 Filter::List mFilterList; 70 Filter::List mFilterList;
72 Filter::List mInternalFilterList; 71 Filter::List mInternalFilterList;
73 72
74 KListBox *mFilterListBox; 73 KListBox *mFilterListBox;
75 QPushButton *mAddButton; 74 QPushButton *mAddButton;
76 QPushButton *mEditButton; 75 QPushButton *mEditButton;
77 QPushButton *mRemoveButton; 76 QPushButton *mRemoveButton;
78}; 77};
79 78
80class FilterEditDialog : public KDialogBase 79class FilterEditDialog : public KDialogBase
81{ 80{
82 Q_OBJECT 81 Q_OBJECT
83 public: 82 public:
84 FilterEditDialog( QWidget *parent, const char *name = 0 ); 83 FilterEditDialog( QWidget *parent, const char *name = 0 );
85 ~FilterEditDialog(); 84 ~FilterEditDialog();
86 85
87 void setFilter( const Filter &filter ); 86 void setFilter( const Filter &filter );
88 Filter filter(); 87 Filter filter();
89 88
90 protected slots: 89 protected slots:
91 void filterNameTextChanged( const QString& ); 90 void filterNameTextChanged( const QString& );
92 void slotHelp(); 91 void slotHelp();
93 92
94 private: 93 private:
95 void initGUI(); 94 void initGUI();
96 95
97 Filter mFilter; 96 Filter mFilter;
98 97
99 KLineEdit *mNameEdit; 98 KLineEdit *mNameEdit;
100 KListView *mCategoriesView; 99 KListView *mCategoriesView;
101 QHButtonGroup *mMatchRuleGroup; 100 Q3HButtonGroup *mMatchRuleGroup;
102 QCheckBox *mPrivate; 101 QCheckBox *mPrivate;
103 QCheckBox *mPublic; 102 QCheckBox *mPublic;
104 QCheckBox *mConfidential; 103 QCheckBox *mConfidential;
105 QPushButton *mEditButton; 104 QPushButton *mEditButton;
106 QPushButton *mRemoveButton; 105 QPushButton *mRemoveButton;
107}; 106};
108 107
109#endif 108#endif
diff --git a/kaddressbook/geowidget.cpp b/kaddressbook/geowidget.cpp
index 13cd084..caff3b2 100644
--- a/kaddressbook/geowidget.cpp
+++ b/kaddressbook/geowidget.cpp
@@ -1,629 +1,636 @@
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 <kabc/geo.h> 24#include <kabc/geo.h>
25 25
26#ifndef KAB_EMBEDDED 26#ifndef KAB_EMBEDDED
27#include <kaccelmanager.h> 27#include <kaccelmanager.h>
28#else //KAB_EMBEDDED 28#else //KAB_EMBEDDED
29 29
30#include <qtextstream.h> 30#include <q3textstream.h>
31//Added by qt3to4:
32#include <QPaintEvent>
33#include <Q3GridLayout>
34#include <Q3Frame>
35#include <QMouseEvent>
31#include <kglobal.h> 36#include <kglobal.h>
32#endif //KAB_EMBEDDED 37#endif //KAB_EMBEDDED
33 38
39#include <QDesktopWidget>
40
34#include <knuminput.h> 41#include <knuminput.h>
35#include <kcombobox.h> 42#include <kcombobox.h>
36#include <kdebug.h> 43#include <kdebug.h>
37#include <kiconloader.h> 44#include <kiconloader.h>
38#include <klocale.h> 45#include <klocale.h>
39#include <kstandarddirs.h> 46#include <kstandarddirs.h>
40 47
41#include <qcheckbox.h> 48#include <qcheckbox.h>
42#include <qfile.h> 49#include <qfile.h>
43#include <qapplication.h> 50#include <qapplication.h>
44#include <qgroupbox.h> 51#include <q3groupbox.h>
45#include <qlabel.h> 52#include <qlabel.h>
46#include <qlayout.h> 53#include <qlayout.h>
47#include <qlistbox.h> 54#include <q3listbox.h>
48#include <qpainter.h> 55#include <qpainter.h>
49#include <qpixmap.h> 56#include <qpixmap.h>
50#include <qpushbutton.h> 57#include <qpushbutton.h>
51#include <qregexp.h> 58#include <qregexp.h>
52#include <qstring.h> 59#include <qstring.h>
53#include <stdlib.h> 60#include <stdlib.h>
54 61
55#include "geowidget.h" 62#include "geowidget.h"
56 63
57GeoWidget::GeoWidget( QWidget *parent, const char *name ) 64GeoWidget::GeoWidget( QWidget *parent, const char *name )
58 : QWidget( parent, name ) 65 : QWidget( parent, name )
59{ 66{
60 QLabel *label = 0; 67 QLabel *label = 0;
61 68
62 QGridLayout *topLayout = new QGridLayout( this, 4, 3 ); 69 Q3GridLayout *topLayout = new Q3GridLayout( this, 4, 3 );
63 topLayout->setMargin( KDialog::marginHint() ); 70 topLayout->setMargin( KDialog::marginHint() );
64 topLayout->setSpacing( KDialog::spacingHint() ); 71 topLayout->setSpacing( KDialog::spacingHint() );
65 72
66 label = new QLabel( this ); 73 label = new QLabel( this );
67//US ambiguous call to loadIcon. Add an additional parameter 74//US ambiguous call to loadIcon. Add an additional parameter
68//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "package_network", KIcon::Desktop ) ); 75//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "package_network", KIcon::Desktop ) );
69 label->setPixmap( KGlobal::iconLoader()->loadIcon( "package_network", KIcon::Desktop, 0 ) ); 76 label->setPixmap( KGlobal::iconLoader()->loadIcon( "package_network", KIcon::Desktop, 0 ) );
70 label->setAlignment( Qt::AlignTop ); 77 label->setAlignment( Qt::AlignTop );
71 topLayout->addMultiCellWidget( label, 0, 3, 0, 0 ); 78 topLayout->addMultiCellWidget( label, 0, 3, 0, 0 );
72 label->setAlignment( AlignCenter ); 79 label->setAlignment( Qt::AlignCenter );
73 mGeoIsValid = new QCheckBox( i18n( "Use geo data" ), this ); 80 mGeoIsValid = new QCheckBox( i18n( "Use geo data" ), this );
74 topLayout->addMultiCellWidget( mGeoIsValid, 0, 0, 1, 2 ); 81 topLayout->addMultiCellWidget( mGeoIsValid, 0, 0, 1, 2 );
75 82
76 label = new QLabel( i18n( "Latitude:" ), this ); 83 label = new QLabel( i18n( "Latitude:" ), this );
77 topLayout->addWidget( label, 1, 1 ); 84 topLayout->addWidget( label, 1, 1 );
78 85
79 mLatitudeBox = new KDoubleSpinBox( -90, 90, 1, 0, 6, this ); 86 mLatitudeBox = new KDoubleSpinBox( -90, 90, 1, 0, 6, this );
80 mLatitudeBox->setEnabled( false ); 87 mLatitudeBox->setEnabled( false );
81 mLatitudeBox->setSuffix( "" ); 88 mLatitudeBox->setSuffix( "" );
82 topLayout->addWidget( mLatitudeBox, 1, 2 ); 89 topLayout->addWidget( mLatitudeBox, 1, 2 );
83 label->setBuddy( mLatitudeBox ); 90 label->setBuddy( mLatitudeBox );
84 91
85 label = new QLabel( i18n( "Longitude:" ), this ); 92 label = new QLabel( i18n( "Longitude:" ), this );
86 topLayout->addWidget( label, 2, 1 ); 93 topLayout->addWidget( label, 2, 1 );
87 94
88 mLongitudeBox = new KDoubleSpinBox( -180, 180, 1, 0, 6, this ); 95 mLongitudeBox = new KDoubleSpinBox( -180, 180, 1, 0, 6, this );
89 mLongitudeBox->setEnabled( false ); 96 mLongitudeBox->setEnabled( false );
90 mLongitudeBox->setSuffix( "" ); 97 mLongitudeBox->setSuffix( "" );
91 topLayout->addWidget( mLongitudeBox, 2, 2 ); 98 topLayout->addWidget( mLongitudeBox, 2, 2 );
92 label->setBuddy( mLongitudeBox ); 99 label->setBuddy( mLongitudeBox );
93 100
94 mExtendedButton = new QPushButton( i18n( "Edit Geo Data..." ), this ); 101 mExtendedButton = new QPushButton( i18n( "Edit Geo Data..." ), this );
95 mExtendedButton->setEnabled( false ); 102 mExtendedButton->setEnabled( false );
96 topLayout->addMultiCellWidget( mExtendedButton, 3, 3, 1, 2 ); 103 topLayout->addMultiCellWidget( mExtendedButton, 3, 3, 1, 2 );
97 104
98 connect( mLatitudeBox, SIGNAL( valueChanged( double ) ), 105 connect( mLatitudeBox, SIGNAL( valueChanged( double ) ),
99 SIGNAL( changed() ) ); 106 SIGNAL( changed() ) );
100 connect( mLongitudeBox, SIGNAL( valueChanged( double ) ), 107 connect( mLongitudeBox, SIGNAL( valueChanged( double ) ),
101 SIGNAL( changed() ) ); 108 SIGNAL( changed() ) );
102 connect( mExtendedButton, SIGNAL( clicked() ), 109 connect( mExtendedButton, SIGNAL( clicked() ),
103 SLOT( editGeoData() ) ); 110 SLOT( editGeoData() ) );
104 111
105 connect( mGeoIsValid, SIGNAL( toggled( bool ) ), 112 connect( mGeoIsValid, SIGNAL( toggled( bool ) ),
106 mLatitudeBox, SLOT( setEnabled( bool ) ) ); 113 mLatitudeBox, SLOT( setEnabled( bool ) ) );
107 connect( mGeoIsValid, SIGNAL( toggled( bool ) ), 114 connect( mGeoIsValid, SIGNAL( toggled( bool ) ),
108 mLongitudeBox, SLOT( setEnabled( bool ) ) ); 115 mLongitudeBox, SLOT( setEnabled( bool ) ) );
109 connect( mGeoIsValid, SIGNAL( toggled( bool ) ), 116 connect( mGeoIsValid, SIGNAL( toggled( bool ) ),
110 mExtendedButton, SLOT( setEnabled( bool ) ) ); 117 mExtendedButton, SLOT( setEnabled( bool ) ) );
111 connect( mGeoIsValid, SIGNAL( toggled( bool ) ), 118 connect( mGeoIsValid, SIGNAL( toggled( bool ) ),
112 SIGNAL( changed() ) ); 119 SIGNAL( changed() ) );
113 120
114#ifndef KAB_EMBEDDED 121#ifndef KAB_EMBEDDED
115 KAcceleratorManager::manage( this ); 122 KAcceleratorManager::manage( this );
116#endif //KAB_EMBEDDED 123#endif //KAB_EMBEDDED
117} 124}
118 125
119GeoWidget::~GeoWidget() 126GeoWidget::~GeoWidget()
120{ 127{
121} 128}
122 129
123void GeoWidget::setGeo( const KABC::Geo &geo ) 130void GeoWidget::setGeo( const KABC::Geo &geo )
124{ 131{
125 if ( geo.isValid() ) { 132 if ( geo.isValid() ) {
126 mGeoIsValid->setChecked( true ); 133 mGeoIsValid->setChecked( true );
127 mLatitudeBox->setValue( geo.latitude() ); 134 mLatitudeBox->setValue( geo.latitude() );
128 mLongitudeBox->setValue( geo.longitude() ); 135 mLongitudeBox->setValue( geo.longitude() );
129 } else 136 } else
130 mGeoIsValid->setChecked( false ); 137 mGeoIsValid->setChecked( false );
131} 138}
132 139
133KABC::Geo GeoWidget::geo() const 140KABC::Geo GeoWidget::geo() const
134{ 141{
135 KABC::Geo geo; 142 KABC::Geo geo;
136 143
137 if ( mGeoIsValid->isChecked() ) { 144 if ( mGeoIsValid->isChecked() ) {
138 geo.setLatitude( mLatitudeBox->value() ); 145 geo.setLatitude( mLatitudeBox->value() );
139 geo.setLongitude( mLongitudeBox->value() ); 146 geo.setLongitude( mLongitudeBox->value() );
140 } else { 147 } else {
141 geo.setLatitude( 91 ); 148 geo.setLatitude( 91 );
142 geo.setLongitude( 181 ); 149 geo.setLongitude( 181 );
143 } 150 }
144 151
145 return geo; 152 return geo;
146} 153}
147 154
148void GeoWidget::editGeoData() 155void GeoWidget::editGeoData()
149{ 156{
150 GeoDialog dlg( this ); 157 GeoDialog dlg( this );
151 158
152 dlg.setLatitude( mLatitudeBox->value() ); 159 dlg.setLatitude( mLatitudeBox->value() );
153 dlg.setLongitude( mLongitudeBox->value() ); 160 dlg.setLongitude( mLongitudeBox->value() );
154 161
155 if ( dlg.exec() ) { 162 if ( dlg.exec() ) {
156 mLatitudeBox->setValue( dlg.latitude() ); 163 mLatitudeBox->setValue( dlg.latitude() );
157 mLongitudeBox->setValue( dlg.longitude() ); 164 mLongitudeBox->setValue( dlg.longitude() );
158 165
159 emit changed(); 166 emit changed();
160 } 167 }
161} 168}
162 169
163 170
164 171
165GeoDialog::GeoDialog( QWidget *parent, const char *name ) 172GeoDialog::GeoDialog( QWidget *parent, const char *name )
166 : KDialogBase( Plain, i18n( "Geo Data Input" ), Ok | Cancel, Ok, 173 : KDialogBase( Plain, i18n( "Geo Data Input" ), Ok | Cancel, Ok,
167 parent, name, true, true ), 174 parent, name, true, true ),
168 mUpdateSexagesimalInput( true ) 175 mUpdateSexagesimalInput( true )
169{ 176{
170 QFrame *page = plainPage(); 177 Q3Frame *page = plainPage();
171 178
172 QGridLayout *topLayout = new QGridLayout( page, 1, 1, marginHintSmall(), 179 Q3GridLayout *topLayout = new Q3GridLayout( page, 1, 1, marginHintSmall(),
173 spacingHint() ); 180 spacingHint() );
174 //topLayout->setRowStretch( 1, 1 ); 181 //topLayout->setRowStretch( 1, 1 );
175 182
176 mMapWidget = new GeoMapWidget( page ); 183 mMapWidget = new GeoMapWidget( page );
177 mCityCombo = new KComboBox( page ); 184 mCityCombo = new KComboBox( page );
178 QGroupBox *sexagesimalGroup = new QGroupBox( 0, Vertical, i18n( "Sexagesimal" ), page ); 185 Q3GroupBox *sexagesimalGroup = new Q3GroupBox( 0, Qt::Vertical, i18n( "Sexagesimal" ), page );
179 QGridLayout *sexagesimalLayout = new QGridLayout( sexagesimalGroup->layout(), 186 Q3GridLayout *sexagesimalLayout = new Q3GridLayout( sexagesimalGroup->layout(),
180 2, 5, spacingHint() ); 187 2, 5, spacingHint() );
181 QLabel *label; 188 QLabel *label;
182 if ( QApplication::desktop()->width() < 320 ) { 189 if ( QApplication::desktop()->width() < 320 ) {
183 label = new QLabel( i18n( "La." ), sexagesimalGroup ); 190 label = new QLabel( i18n( "La." ), sexagesimalGroup );
184 sexagesimalLayout->setSpacing ( spacingHintSmall() ); 191 sexagesimalLayout->setSpacing ( spacingHintSmall() );
185 sexagesimalLayout->setMargin ( marginHintSmall() ); 192 sexagesimalLayout->setMargin ( marginHintSmall() );
186 topLayout->setMargin ( 0 ); 193 topLayout->setMargin ( 0 );
187 mCityCombo->setMaximumWidth( 220 ); 194 mCityCombo->setMaximumWidth( 220 );
188 sexagesimalGroup->setMaximumWidth( 220 ); 195 sexagesimalGroup->setMaximumWidth( 220 );
189 } 196 }
190 else 197 else
191 label = new QLabel( i18n( "Latitude:" ), sexagesimalGroup ); 198 label = new QLabel( i18n( "Latitude:" ), sexagesimalGroup );
192 sexagesimalLayout->addWidget( label, 0, 0 ); 199 sexagesimalLayout->addWidget( label, 0, 0 );
193 200
194 int maxWid = 60; 201 int maxWid = 60;
195 if ( QApplication::desktop()->width() < 320 ) 202 if ( QApplication::desktop()->width() < 320 )
196 maxWid = 40; 203 maxWid = 40;
197 mLatDegrees = new QSpinBox( 0, 90, 1, sexagesimalGroup ); 204 mLatDegrees = new QSpinBox( 0, 90, 1, sexagesimalGroup );
198 mLatDegrees->setSuffix( "" ); 205 mLatDegrees->setSuffix( "" );
199 mLatDegrees->setWrapping( false ); 206 mLatDegrees->setWrapping( false );
200 sexagesimalLayout->addWidget( mLatDegrees, 0, 1 ); 207 sexagesimalLayout->addWidget( mLatDegrees, 0, 1 );
201 mLatDegrees->setMaximumWidth( maxWid ); 208 mLatDegrees->setMaximumWidth( maxWid );
202 209
203 mLatMinutes = new QSpinBox( 0, 59, 1, sexagesimalGroup ); 210 mLatMinutes = new QSpinBox( 0, 59, 1, sexagesimalGroup );
204 mLatMinutes->setSuffix( "'" ); 211 mLatMinutes->setSuffix( "'" );
205 sexagesimalLayout->addWidget( mLatMinutes, 0, 2 ); 212 sexagesimalLayout->addWidget( mLatMinutes, 0, 2 );
206 mLatMinutes->setMaximumWidth( maxWid ); 213 mLatMinutes->setMaximumWidth( maxWid );
207 214
208 mLatSeconds = new QSpinBox( 0, 59, 1, sexagesimalGroup ); 215 mLatSeconds = new QSpinBox( 0, 59, 1, sexagesimalGroup );
209 mLatSeconds->setSuffix( "\"" ); 216 mLatSeconds->setSuffix( "\"" );
210 sexagesimalLayout->addWidget( mLatSeconds, 0, 3 ); 217 sexagesimalLayout->addWidget( mLatSeconds, 0, 3 );
211 mLatSeconds->setMaximumWidth( maxWid ); 218 mLatSeconds->setMaximumWidth( maxWid );
212 219
213 mLatDirection = new KComboBox( sexagesimalGroup ); 220 mLatDirection = new KComboBox( sexagesimalGroup );
214 mLatDirection->insertItem( i18n( "North" ) ); 221 mLatDirection->insertItem( i18n( "North" ) );
215 mLatDirection->insertItem( i18n( "South" ) ); 222 mLatDirection->insertItem( i18n( "South" ) );
216 sexagesimalLayout->addWidget( mLatDirection, 0, 4 ); 223 sexagesimalLayout->addWidget( mLatDirection, 0, 4 );
217 224
218 225
219 if ( QApplication::desktop()->width() < 320 ) 226 if ( QApplication::desktop()->width() < 320 )
220 label = new QLabel( i18n( "Lo." ), sexagesimalGroup ); 227 label = new QLabel( i18n( "Lo." ), sexagesimalGroup );
221 else 228 else
222 label = new QLabel( i18n( "Longitude:" ), sexagesimalGroup ); 229 label = new QLabel( i18n( "Longitude:" ), sexagesimalGroup );
223 230
224 231
225 sexagesimalLayout->addWidget( label, 1, 0 ); 232 sexagesimalLayout->addWidget( label, 1, 0 );
226 233
227 mLongDegrees = new QSpinBox( 0, 180, 1, sexagesimalGroup ); 234 mLongDegrees = new QSpinBox( 0, 180, 1, sexagesimalGroup );
228 mLongDegrees->setSuffix( "" ); 235 mLongDegrees->setSuffix( "" );
229 sexagesimalLayout->addWidget( mLongDegrees, 1, 1 ); 236 sexagesimalLayout->addWidget( mLongDegrees, 1, 1 );
230 mLongDegrees->setMaximumWidth( maxWid ); 237 mLongDegrees->setMaximumWidth( maxWid );
231 238
232 mLongMinutes = new QSpinBox( 0, 59, 1, sexagesimalGroup ); 239 mLongMinutes = new QSpinBox( 0, 59, 1, sexagesimalGroup );
233 mLongMinutes->setSuffix( "'" ); 240 mLongMinutes->setSuffix( "'" );
234 sexagesimalLayout->addWidget( mLongMinutes, 1, 2 ); 241 sexagesimalLayout->addWidget( mLongMinutes, 1, 2 );
235 mLongMinutes->setMaximumWidth( maxWid ); 242 mLongMinutes->setMaximumWidth( maxWid );
236 243
237 mLongSeconds = new QSpinBox( 0, 59, 1, sexagesimalGroup ); 244 mLongSeconds = new QSpinBox( 0, 59, 1, sexagesimalGroup );
238 mLongSeconds->setSuffix( "\"" ); 245 mLongSeconds->setSuffix( "\"" );
239 sexagesimalLayout->addWidget( mLongSeconds, 1, 3 ); 246 sexagesimalLayout->addWidget( mLongSeconds, 1, 3 );
240 mLongSeconds->setMaximumWidth( maxWid ); 247 mLongSeconds->setMaximumWidth( maxWid );
241 248
242 mLongDirection = new KComboBox( sexagesimalGroup ); 249 mLongDirection = new KComboBox( sexagesimalGroup );
243 mLongDirection->insertItem( i18n( "East" ) ); 250 mLongDirection->insertItem( i18n( "East" ) );
244 mLongDirection->insertItem( i18n( "West" ) ); 251 mLongDirection->insertItem( i18n( "West" ) );
245 sexagesimalLayout->addWidget( mLongDirection, 1, 4 ); 252 sexagesimalLayout->addWidget( mLongDirection, 1, 4 );
246 if ( true /*QApplication::desktop()->width() < 640*/ ) { 253 if ( true /*QApplication::desktop()->width() < 640*/ ) {
247 254
248 topLayout->addWidget( mMapWidget, 0, 0 ); 255 topLayout->addWidget( mMapWidget, 0, 0 );
249 topLayout->addWidget( mCityCombo, 1, 0 ); 256 topLayout->addWidget( mCityCombo, 1, 0 );
250 topLayout->addWidget( sexagesimalGroup, 2, 0 ); 257 topLayout->addWidget( sexagesimalGroup, 2, 0 );
251 258
252 } else { 259 } else {
253 topLayout->addMultiCellWidget( mMapWidget, 0, 1, 0, 0 ); 260 topLayout->addMultiCellWidget( mMapWidget, 0, 1, 0, 0 );
254 topLayout->addWidget( mCityCombo, 0, 1 ); 261 topLayout->addWidget( mCityCombo, 0, 1 );
255 topLayout->addWidget( sexagesimalGroup, 1, 1 ); 262 topLayout->addWidget( sexagesimalGroup, 1, 1 );
256 } 263 }
257 264
258 loadCityList(); 265 loadCityList();
259 266
260 connect( mMapWidget, SIGNAL( changed() ), 267 connect( mMapWidget, SIGNAL( changed() ),
261 SLOT( geoMapChanged() ) ); 268 SLOT( geoMapChanged() ) );
262 connect( mCityCombo, SIGNAL( activated( int ) ), 269 connect( mCityCombo, SIGNAL( activated( int ) ),
263 SLOT( cityInputChanged() ) ); 270 SLOT( cityInputChanged() ) );
264 connect( mLatDegrees, SIGNAL( valueChanged( int ) ), 271 connect( mLatDegrees, SIGNAL( valueChanged( int ) ),
265 SLOT( sexagesimalInputChanged() ) ); 272 SLOT( sexagesimalInputChanged() ) );
266 connect( mLatMinutes, SIGNAL( valueChanged( int ) ), 273 connect( mLatMinutes, SIGNAL( valueChanged( int ) ),
267 SLOT( sexagesimalInputChanged() ) ); 274 SLOT( sexagesimalInputChanged() ) );
268 connect( mLatSeconds, SIGNAL( valueChanged( int ) ), 275 connect( mLatSeconds, SIGNAL( valueChanged( int ) ),
269 SLOT( sexagesimalInputChanged() ) ); 276 SLOT( sexagesimalInputChanged() ) );
270 connect( mLatDirection, SIGNAL( activated( int ) ), 277 connect( mLatDirection, SIGNAL( activated( int ) ),
271 SLOT( sexagesimalInputChanged() ) ); 278 SLOT( sexagesimalInputChanged() ) );
272 connect( mLongDegrees, SIGNAL( valueChanged( int ) ), 279 connect( mLongDegrees, SIGNAL( valueChanged( int ) ),
273 SLOT( sexagesimalInputChanged() ) ); 280 SLOT( sexagesimalInputChanged() ) );
274 connect( mLongMinutes, SIGNAL( valueChanged( int ) ), 281 connect( mLongMinutes, SIGNAL( valueChanged( int ) ),
275 SLOT( sexagesimalInputChanged() ) ); 282 SLOT( sexagesimalInputChanged() ) );
276 connect( mLongSeconds, SIGNAL( valueChanged( int ) ), 283 connect( mLongSeconds, SIGNAL( valueChanged( int ) ),
277 SLOT( sexagesimalInputChanged() ) ); 284 SLOT( sexagesimalInputChanged() ) );
278 connect( mLongDirection, SIGNAL( activated( int ) ), 285 connect( mLongDirection, SIGNAL( activated( int ) ),
279 SLOT( sexagesimalInputChanged() ) ); 286 SLOT( sexagesimalInputChanged() ) );
280 mLongitude = 0.0; 287 mLongitude = 0.0;
281 mLatitude = 0.0; 288 mLatitude = 0.0;
282#ifndef DESKTOP_VERSION 289#ifndef DESKTOP_VERSION
283 showMaximized(); 290 showMaximized();
284#endif 291#endif
285} 292}
286 293
287GeoDialog::~GeoDialog() 294GeoDialog::~GeoDialog()
288{ 295{
289} 296}
290 297
291void GeoDialog::setLatitude( double latitude ) 298void GeoDialog::setLatitude( double latitude )
292{ 299{
293 mLatitude = latitude; 300 mLatitude = latitude;
294 updateInputs(); 301 updateInputs();
295} 302}
296 303
297double GeoDialog::latitude() const 304double GeoDialog::latitude() const
298{ 305{
299 return mLatitude; 306 return mLatitude;
300} 307}
301 308
302void GeoDialog::setLongitude( double longitude ) 309void GeoDialog::setLongitude( double longitude )
303{ 310{
304 mLongitude = longitude; 311 mLongitude = longitude;
305 updateInputs(); 312 updateInputs();
306} 313}
307 314
308double GeoDialog::longitude() const 315double GeoDialog::longitude() const
309{ 316{
310 return mLongitude; 317 return mLongitude;
311} 318}
312 319
313void GeoDialog::sexagesimalInputChanged() 320void GeoDialog::sexagesimalInputChanged()
314{ 321{
315 mLatitude = (double)( mLatDegrees->value() + (double)mLatMinutes->value() / 322 mLatitude = (double)( mLatDegrees->value() + (double)mLatMinutes->value() /
316 60 + (double)mLatSeconds->value() / 3600 ); 323 60 + (double)mLatSeconds->value() / 3600 );
317 324
318 mLatitude *= ( mLatDirection->currentItem() == 1 ? -1 : 1 ); 325 mLatitude *= ( mLatDirection->currentItem() == 1 ? -1 : 1 );
319 326
320 mLongitude = (double)( mLongDegrees->value() + (double)mLongMinutes->value() / 327 mLongitude = (double)( mLongDegrees->value() + (double)mLongMinutes->value() /
321 60 + (double)mLongSeconds->value() / 3600 ); 328 60 + (double)mLongSeconds->value() / 3600 );
322 329
323 mLongitude *= ( mLongDirection->currentItem() == 1 ? -1 : 1 ); 330 mLongitude *= ( mLongDirection->currentItem() == 1 ? -1 : 1 );
324 331
325 mUpdateSexagesimalInput = false; 332 mUpdateSexagesimalInput = false;
326 333
327 updateInputs(); 334 updateInputs();
328} 335}
329 336
330void GeoDialog::geoMapChanged() 337void GeoDialog::geoMapChanged()
331{ 338{
332 mLatitude = mMapWidget->latitude(); 339 mLatitude = mMapWidget->latitude();
333 mLongitude = mMapWidget->longitude(); 340 mLongitude = mMapWidget->longitude();
334 341
335 updateInputs(); 342 updateInputs();
336} 343}
337 344
338void GeoDialog::cityInputChanged() 345void GeoDialog::cityInputChanged()
339{ 346{
340 if ( mCityCombo->currentItem() != 0 ) { 347 if ( mCityCombo->currentItem() != 0 ) {
341 GeoData data = mGeoDataMap[ mCityCombo->currentText() ]; 348 GeoData data = mGeoDataMap[ mCityCombo->currentText() ];
342 mLatitude = data.latitude; 349 mLatitude = data.latitude;
343 mLongitude = data.longitude; 350 mLongitude = data.longitude;
344 } else 351 } else
345 mLatitude = mLongitude = 0; 352 mLatitude = mLongitude = 0;
346 353
347 updateInputs(); 354 updateInputs();
348} 355}
349 356
350void GeoDialog::updateInputs() 357void GeoDialog::updateInputs()
351{ 358{
352 // hmm, doesn't look nice, but there is no better way AFAIK 359 // hmm, doesn't look nice, but there is no better way AFAIK
353 mCityCombo->blockSignals( true ); 360 mCityCombo->blockSignals( true );
354 mLatDegrees->blockSignals( true ); 361 mLatDegrees->blockSignals( true );
355 mLatMinutes->blockSignals( true ); 362 mLatMinutes->blockSignals( true );
356 mLatSeconds->blockSignals( true ); 363 mLatSeconds->blockSignals( true );
357 mLatDirection->blockSignals( true ); 364 mLatDirection->blockSignals( true );
358 mLongDegrees->blockSignals( true ); 365 mLongDegrees->blockSignals( true );
359 mLongMinutes->blockSignals( true ); 366 mLongMinutes->blockSignals( true );
360 mLongSeconds->blockSignals( true ); 367 mLongSeconds->blockSignals( true );
361 mLongDirection->blockSignals( true ); 368 mLongDirection->blockSignals( true );
362 369
363 mMapWidget->setLatitude( mLatitude ); 370 mMapWidget->setLatitude( mLatitude );
364 mMapWidget->setLongitude( mLongitude ); 371 mMapWidget->setLongitude( mLongitude );
365 mMapWidget->update(); 372 mMapWidget->update();
366 373
367 if ( mUpdateSexagesimalInput ) { 374 if ( mUpdateSexagesimalInput ) {
368 int degrees, minutes, seconds; 375 int degrees, minutes, seconds;
369 double latitude = mLatitude; 376 double latitude = mLatitude;
370 double longitude = mLongitude; 377 double longitude = mLongitude;
371 378
372 latitude *= ( mLatitude < 0 ? -1 : 1 ); 379 latitude *= ( mLatitude < 0 ? -1 : 1 );
373 longitude *= ( mLongitude < 0 ? -1 : 1 ); 380 longitude *= ( mLongitude < 0 ? -1 : 1 );
374 381
375 degrees = (int)( latitude * 1 ); 382 degrees = (int)( latitude * 1 );
376 minutes = (int)( ( latitude - degrees ) * 60 ); 383 minutes = (int)( ( latitude - degrees ) * 60 );
377 seconds = (int)( (double)( (double)latitude - (double)degrees - ( (double)minutes / (double)60 ) ) * (double)3600 ); 384 seconds = (int)( (double)( (double)latitude - (double)degrees - ( (double)minutes / (double)60 ) ) * (double)3600 );
378 385
379 mLatDegrees->setValue( degrees ); 386 mLatDegrees->setValue( degrees );
380 mLatMinutes->setValue( minutes ); 387 mLatMinutes->setValue( minutes );
381 mLatSeconds->setValue( seconds ); 388 mLatSeconds->setValue( seconds );
382 389
383 mLatDirection->setCurrentItem( mLatitude < 0 ? 1 : 0 ); 390 mLatDirection->setCurrentItem( mLatitude < 0 ? 1 : 0 );
384 391
385 degrees = (int)( longitude * 1 ); 392 degrees = (int)( longitude * 1 );
386 minutes = (int)( ( longitude - degrees ) * 60 ); 393 minutes = (int)( ( longitude - degrees ) * 60 );
387 seconds = (int)( (double)( longitude - (double)degrees - ( (double)minutes / 60 ) ) * 3600 ); 394 seconds = (int)( (double)( longitude - (double)degrees - ( (double)minutes / 60 ) ) * 3600 );
388 395
389 mLongDegrees->setValue( degrees ); 396 mLongDegrees->setValue( degrees );
390 mLongMinutes->setValue( minutes ); 397 mLongMinutes->setValue( minutes );
391 mLongSeconds->setValue( seconds ); 398 mLongSeconds->setValue( seconds );
392 mLongDirection->setCurrentItem( mLongitude < 0 ? 1 : 0 ); 399 mLongDirection->setCurrentItem( mLongitude < 0 ? 1 : 0 );
393 } 400 }
394 mUpdateSexagesimalInput = true; 401 mUpdateSexagesimalInput = true;
395 402
396 int pos = nearestCity( mLongitude, mLatitude ); 403 int pos = nearestCity( mLongitude, mLatitude );
397 if ( pos != -1 ) 404 if ( pos != -1 )
398 mCityCombo->setCurrentItem( pos + 1 ); 405 mCityCombo->setCurrentItem( pos + 1 );
399 else 406 else
400 mCityCombo->setCurrentItem( 0 ); 407 mCityCombo->setCurrentItem( 0 );
401 408
402 mCityCombo->blockSignals( false ); 409 mCityCombo->blockSignals( false );
403 mLatDegrees->blockSignals( false ); 410 mLatDegrees->blockSignals( false );
404 mLatMinutes->blockSignals( false ); 411 mLatMinutes->blockSignals( false );
405 mLatSeconds->blockSignals( false ); 412 mLatSeconds->blockSignals( false );
406 mLatDirection->blockSignals( false ); 413 mLatDirection->blockSignals( false );
407 mLongDegrees->blockSignals( false ); 414 mLongDegrees->blockSignals( false );
408 mLongMinutes->blockSignals( false ); 415 mLongMinutes->blockSignals( false );
409 mLongSeconds->blockSignals( false ); 416 mLongSeconds->blockSignals( false );
410 mLongDirection->blockSignals( false ); 417 mLongDirection->blockSignals( false );
411} 418}
412 419
413void GeoDialog::loadCityList() 420void GeoDialog::loadCityList()
414{ 421{
415 mCityCombo->clear(); 422 mCityCombo->clear();
416 mGeoDataMap.clear(); 423 mGeoDataMap.clear();
417 424
418 QString fileName ; 425 QString fileName ;
419#ifdef DESKTOP_VERSION 426#ifdef DESKTOP_VERSION
420#ifndef _WIN32_ 427#ifndef _WIN32_
421 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/zone.tab"; 428 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/zone.tab";
422#else 429#else
423 fileName = qApp->applicationDirPath () + "\\kdepim\\kaddressbook\\zone.tab"; 430 fileName = qApp->applicationDirPath () + "\\kdepim\\kaddressbook\\zone.tab";
424#endif 431#endif
425#else 432#else
426 fileName = getenv("QPEDIR"); 433 fileName = getenv("QPEDIR");
427 fileName += "/pics/kdepim/kaddressbook/zone.tab"; 434 fileName += "/pics/kdepim/kaddressbook/zone.tab";
428#endif 435#endif
429 436
430 QFile file( fileName); 437 QFile file( fileName);
431 438
432 if ( file.open( IO_ReadOnly ) ) { 439 if ( file.open( QIODevice::ReadOnly ) ) {
433 QTextStream s( &file ); 440 Q3TextStream s( &file );
434 441
435 QString line, country; 442 QString line, country;
436 QRegExp coord( "[+-]\\d+[+-]\\d+" ); 443 QRegExp coord( "[+-]\\d+[+-]\\d+" );
437 QRegExp name( "[^\\s]+/[^\\s]+" ); 444 QRegExp name( "[^\\s]+/[^\\s]+" );
438 int posc, posn, pos; 445 int posc, posn, pos;
439 446
440 while ( !s.eof() ) { 447 while ( !s.eof() ) {
441 line = s.readLine().stripWhiteSpace(); 448 line = s.readLine().stripWhiteSpace();
442 if ( line.isEmpty() || line[ 0 ] == '#' ) 449 if ( line.isEmpty() || line[ 0 ] == '#' )
443 continue; 450 continue;
444 451
445 country = line.left( 2 ); 452 country = line.left( 2 );
446 QString c, n; 453 QString c, n;
447#ifdef DESKTOP_VERSION 454#ifdef DESKTOP_VERSION
448 posc = coord.search( line, 0 ); 455 posc = coord.search( line, 0 );
449#else 456#else
450 posc = coord.find( line, 0 ); 457 posc = coord.find( line, 0 );
451#endif 458#endif
452 // if ( pos >= 0 ) 459 // if ( pos >= 0 )
453 //c = line.mid( pos, coord.matchedLength() ); 460 //c = line.mid( pos, coord.matchedLength() );
454 461
455#ifdef DESKTOP_VERSION 462#ifdef DESKTOP_VERSION
456 posn = name.search(line, posc); 463 posn = name.search(line, posc);
457#else 464#else
458 posn = name.find(line, posc); 465 posn = name.find(line, posc);
459#endif 466#endif
460 if ( posn > 0 ) { 467 if ( posn > 0 ) {
461 c = line.mid( posc, posn-posc ).stripWhiteSpace(); 468 c = line.mid( posc, posn-posc ).stripWhiteSpace();
462 //qDebug("*%s* ", c.latin1()); 469 //qDebug("*%s* ", c.latin1());
463 int nend = line.find(" ", posn ); 470 int nend = line.find(" ", posn );
464 if ( nend < 0 ) 471 if ( nend < 0 )
465 nend = line.length(); 472 nend = line.length();
466 n = line.mid( posn, nend-posn).stripWhiteSpace(); 473 n = line.mid( posn, nend-posn).stripWhiteSpace();
467 //n.replace( '_', " " ); 474 //n.replace( '_', " " );
468 } 475 }
469 476
470 if ( !c.isEmpty() && !n.isEmpty() ) { 477 if ( !c.isEmpty() && !n.isEmpty() ) {
471 pos = c.find( "+", 1 ); 478 pos = c.find( "+", 1 );
472 if ( pos < 0 ) 479 if ( pos < 0 )
473 pos = c.find( "-", 1 ); 480 pos = c.find( "-", 1 );
474 if ( pos > 0 ) { 481 if ( pos > 0 ) {
475 GeoData data; 482 GeoData data;
476 data.latitude = calculateCoordinate( c.left( pos ) ); 483 data.latitude = calculateCoordinate( c.left( pos ) );
477 data.longitude = calculateCoordinate( c.mid( pos ) ); 484 data.longitude = calculateCoordinate( c.mid( pos ) );
478 data.country = country; 485 data.country = country;
479 486
480 mGeoDataMap.insert( n, data ); 487 mGeoDataMap.insert( n, data );
481 } 488 }
482 } 489 }
483 } 490 }
484//US I have no mGeoDataMap.keys(). 491//US I have no mGeoDataMap.keys().
485//US QStringList items( mGeoDataMap.keys() ); 492//US QStringList items( mGeoDataMap.keys() );
486 QStringList items; 493 QStringList items;
487 494
488 QMap<QString, GeoData>::ConstIterator it; 495 QMap<QString, GeoData>::ConstIterator it;
489 for( it = mGeoDataMap.begin(); it != mGeoDataMap.end(); ++it ) 496 for( it = mGeoDataMap.begin(); it != mGeoDataMap.end(); ++it )
490 items << it.key().latin1(); 497 items << it.key().latin1();
491 498
492 items.prepend( i18n( "Undefined" ) ); 499 items.prepend( i18n( "Undefined" ) );
493 mCityCombo->insertStringList( items ); 500 mCityCombo->insertStringList( items );
494 501
495 file.close(); 502 file.close();
496 } 503 }
497} 504}
498 505
499double GeoDialog::calculateCoordinate( const QString &coordinate ) 506double GeoDialog::calculateCoordinate( const QString &coordinate )
500{ 507{
501 int neg; 508 int neg;
502 int d = 0, m = 0, s = 0; 509 int d = 0, m = 0, s = 0;
503 QString str = coordinate; 510 QString str = coordinate;
504 511
505 neg = str.left( 1 ) == "-"; 512 neg = str.left( 1 ) == "-";
506 str.remove( 0, 1 ); 513 str.remove( 0, 1 );
507 514
508 switch ( str.length() ) { 515 switch ( str.length() ) {
509 case 4: 516 case 4:
510 d = str.left( 2 ).toInt(); 517 d = str.left( 2 ).toInt();
511 m = str.mid( 2 ).toInt(); 518 m = str.mid( 2 ).toInt();
512 break; 519 break;
513 case 5: 520 case 5:
514 d = str.left( 3 ).toInt(); 521 d = str.left( 3 ).toInt();
515 m = str.mid( 3 ).toInt(); 522 m = str.mid( 3 ).toInt();
516 break; 523 break;
517 case 6: 524 case 6:
518 d = str.left( 2 ).toInt(); 525 d = str.left( 2 ).toInt();
519 m = str.mid( 2, 2 ).toInt(); 526 m = str.mid( 2, 2 ).toInt();
520 s = str.right( 2 ).toInt(); 527 s = str.right( 2 ).toInt();
521 break; 528 break;
522 case 7: 529 case 7:
523 d = str.left( 3 ).toInt(); 530 d = str.left( 3 ).toInt();
524 m = str.mid( 3, 2 ).toInt(); 531 m = str.mid( 3, 2 ).toInt();
525 s = str.right( 2 ).toInt(); 532 s = str.right( 2 ).toInt();
526 break; 533 break;
527 default: 534 default:
528 break; 535 break;
529 } 536 }
530 537
531 if ( neg ) 538 if ( neg )
532 return - ( d + m / 60.0 + s / 3600.0 ); 539 return - ( d + m / 60.0 + s / 3600.0 );
533 else 540 else
534 return d + m / 60.0 + s / 3600.0; 541 return d + m / 60.0 + s / 3600.0;
535} 542}
536 543
537int GeoDialog::nearestCity( double x, double y ) 544int GeoDialog::nearestCity( double x, double y )
538{ 545{
539 QMap<QString, GeoData>::Iterator it; 546 QMap<QString, GeoData>::Iterator it;
540 int pos = 0; 547 int pos = 0;
541 for ( it = mGeoDataMap.begin(); it != mGeoDataMap.end(); ++it, pos++ ) { 548 for ( it = mGeoDataMap.begin(); it != mGeoDataMap.end(); ++it, pos++ ) {
542 double dist = ( (*it).longitude - x ) * ( (*it).longitude - x ) + 549 double dist = ( (*it).longitude - x ) * ( (*it).longitude - x ) +
543 ( (*it).latitude - y ) * ( (*it).latitude - y ); 550 ( (*it).latitude - y ) * ( (*it).latitude - y );
544 if ( dist < 1.5 ) 551 if ( dist < 1.5 )
545 return pos; 552 return pos;
546 } 553 }
547 554
548 return -1; 555 return -1;
549} 556}
550 557
551 558
552GeoMapWidget::GeoMapWidget( QWidget *parent, const char *name ) 559GeoMapWidget::GeoMapWidget( QWidget *parent, const char *name )
553 : QWidget( parent, name ), mLatitude( 0 ), mLongitude( 0 ) 560 : QWidget( parent, name ), mLatitude( 0 ), mLongitude( 0 )
554{ 561{
555 setBackgroundMode( NoBackground ); 562 setBackgroundMode( Qt::NoBackground );
556 563
557 setFixedSize( 240, 120 ); 564 setFixedSize( 240, 120 );
558 565
559 update(); 566 update();
560} 567}
561 568
562GeoMapWidget::~GeoMapWidget() 569GeoMapWidget::~GeoMapWidget()
563{ 570{
564} 571}
565 572
566void GeoMapWidget::setLatitude( double latitude ) 573void GeoMapWidget::setLatitude( double latitude )
567{ 574{
568 mLatitude = latitude; 575 mLatitude = latitude;
569} 576}
570 577
571double GeoMapWidget::latitude()const 578double GeoMapWidget::latitude()const
572{ 579{
573 return mLatitude; 580 return mLatitude;
574} 581}
575 582
576void GeoMapWidget::setLongitude( double longitude ) 583void GeoMapWidget::setLongitude( double longitude )
577{ 584{
578 mLongitude = longitude; 585 mLongitude = longitude;
579} 586}
580 587
581double GeoMapWidget::longitude()const 588double GeoMapWidget::longitude()const
582{ 589{
583 return mLongitude; 590 return mLongitude;
584} 591}
585 592
586void GeoMapWidget::mousePressEvent( QMouseEvent *event ) 593void GeoMapWidget::mousePressEvent( QMouseEvent *event )
587{ 594{
588 double latMid = height() / 2; 595 double latMid = height() / 2;
589 double longMid = width() / 2; 596 double longMid = width() / 2;
590 597
591 double latOffset = latMid - event->y(); 598 double latOffset = latMid - event->y();
592 double longOffset = event->x() - longMid; 599 double longOffset = event->x() - longMid;
593 600
594 mLatitude = ( latOffset * 90 ) / latMid; 601 mLatitude = ( latOffset * 90 ) / latMid;
595 mLongitude = ( longOffset * 180 ) / longMid; 602 mLongitude = ( longOffset * 180 ) / longMid;
596 603
597 emit changed(); 604 emit changed();
598} 605}
599 606
600void GeoMapWidget::paintEvent( QPaintEvent* ) 607void GeoMapWidget::paintEvent( QPaintEvent* )
601{ 608{
602 uint w = width(); 609 uint w = width();
603 uint h = height(); 610 uint h = height();
604 611
605 QPixmap world = KGlobal::iconLoader()->loadIcon( "world", KIcon::Desktop, 0 ); 612 QPixmap world = KGlobal::iconLoader()->loadIcon( "world", KIcon::Desktop, 0 );
606 613
607 QPainter p; 614 QPainter p;
608 p.begin( &world, this ); 615 p.begin( &world, this );
609 616
610 p.setPen( QColor( 255, 0, 0 ) ); 617 p.setPen( QColor( 255, 0, 0 ) );
611 p.setBrush( QColor( 255, 0, 0 ) ); 618 p.setBrush( QColor( 255, 0, 0 ) );
612 619
613 double latMid = h / 2; 620 double latMid = h / 2;
614 double longMid = w / 2; 621 double longMid = w / 2;
615 622
616 double latOffset = ( mLatitude * latMid ) / 90; 623 double latOffset = ( mLatitude * latMid ) / 90;
617 double longOffset = ( mLongitude * longMid ) / 180; 624 double longOffset = ( mLongitude * longMid ) / 180;
618 625
619 int x = (int)(longMid + longOffset); 626 int x = (int)(longMid + longOffset);
620 int y = (int)(latMid - latOffset); 627 int y = (int)(latMid - latOffset);
621 p.drawEllipse( x, y, 4, 4 ); 628 p.drawEllipse( x, y, 4, 4 );
622 629
623 p.end(); 630 p.end();
624 bitBlt( this, 0, 0, &world ); 631 bitBlt( this, 0, 0, &world );
625} 632}
626 633
627#ifndef KAB_EMBEDDED 634#ifndef KAB_EMBEDDED_
628#include "geowidget.moc" 635#include "moc_geowidget.cpp"
629#endif //KAB_EMBEDDED 636#endif //KAB_EMBEDDED
diff --git a/kaddressbook/geowidget.h b/kaddressbook/geowidget.h
index 3d39691..5b64370 100644
--- a/kaddressbook/geowidget.h
+++ b/kaddressbook/geowidget.h
@@ -1,155 +1,159 @@
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#ifndef GEOWIDGET_H 24#ifndef GEOWIDGET_H
25#define GEOWIDGET_H 25#define GEOWIDGET_H
26 26
27#include <qmap.h> 27#include <qmap.h>
28 28
29#include <qwidget.h> 29#include <qwidget.h>
30//Added by qt3to4:
31#include <QLabel>
32#include <QMouseEvent>
33#include <QPaintEvent>
30#include <kdialogbase.h> 34#include <kdialogbase.h>
31 35
32namespace KABC { 36namespace KABC {
33class Geo; 37class Geo;
34} 38}
35 39
36class GeoMapWidget; 40class GeoMapWidget;
37 41
38class KComboBox; 42class KComboBox;
39class KDoubleSpinBox; 43class KDoubleSpinBox;
40 44
41class QCheckBox; 45class QCheckBox;
42class QLabel; 46class QLabel;
43class QSpinBox; 47class QSpinBox;
44class QPushButton; 48class QPushButton;
45 49
46typedef struct { 50typedef struct {
47 double latitude; 51 double latitude;
48 double longitude; 52 double longitude;
49 QString country; 53 QString country;
50} GeoData; 54} GeoData;
51 55
52class GeoWidget : public QWidget 56class GeoWidget : public QWidget
53{ 57{
54 Q_OBJECT 58 Q_OBJECT
55 59
56 public: 60 public:
57 GeoWidget( QWidget *parent, const char *name = 0 ); 61 GeoWidget( QWidget *parent, const char *name = 0 );
58 ~GeoWidget(); 62 ~GeoWidget();
59 63
60 /** 64 /**
61 Sets the geo object. 65 Sets the geo object.
62 */ 66 */
63 void setGeo( const KABC::Geo &geo ); 67 void setGeo( const KABC::Geo &geo );
64 68
65 /** 69 /**
66 Returns a geo object. 70 Returns a geo object.
67 */ 71 */
68 KABC::Geo geo() const; 72 KABC::Geo geo() const;
69 73
70 signals: 74 signals:
71 void changed(); 75 void changed();
72 76
73 private slots: 77 private slots:
74 void editGeoData(); 78 void editGeoData();
75 79
76 private: 80 private:
77 KDoubleSpinBox *mLatitudeBox; 81 KDoubleSpinBox *mLatitudeBox;
78 KDoubleSpinBox *mLongitudeBox; 82 KDoubleSpinBox *mLongitudeBox;
79 83
80 QCheckBox *mGeoIsValid; 84 QCheckBox *mGeoIsValid;
81 QPushButton *mExtendedButton; 85 QPushButton *mExtendedButton;
82}; 86};
83 87
84class GeoDialog : public KDialogBase 88class GeoDialog : public KDialogBase
85{ 89{
86 Q_OBJECT 90 Q_OBJECT
87 91
88 public: 92 public:
89 GeoDialog( QWidget *parent, const char *name = 0 ); 93 GeoDialog( QWidget *parent, const char *name = 0 );
90 ~GeoDialog(); 94 ~GeoDialog();
91 95
92 void setLatitude( double latitude ); 96 void setLatitude( double latitude );
93 double latitude() const; 97 double latitude() const;
94 98
95 void setLongitude( double longitude ); 99 void setLongitude( double longitude );
96 double longitude() const; 100 double longitude() const;
97 101
98 private slots: 102 private slots:
99 void updateInputs(); 103 void updateInputs();
100 104
101 void sexagesimalInputChanged(); 105 void sexagesimalInputChanged();
102 void geoMapChanged(); 106 void geoMapChanged();
103 void cityInputChanged(); 107 void cityInputChanged();
104 108
105 private: 109 private:
106 void loadCityList(); 110 void loadCityList();
107 double calculateCoordinate( const QString& ); 111 double calculateCoordinate( const QString& );
108 int nearestCity( double, double ); 112 int nearestCity( double, double );
109 113
110 GeoMapWidget *mMapWidget; 114 GeoMapWidget *mMapWidget;
111 KComboBox *mCityCombo; 115 KComboBox *mCityCombo;
112 116
113 QSpinBox *mLatDegrees; 117 QSpinBox *mLatDegrees;
114 QSpinBox *mLatMinutes; 118 QSpinBox *mLatMinutes;
115 QSpinBox *mLatSeconds; 119 QSpinBox *mLatSeconds;
116 KComboBox *mLatDirection; 120 KComboBox *mLatDirection;
117 121
118 QSpinBox *mLongDegrees; 122 QSpinBox *mLongDegrees;
119 QSpinBox *mLongMinutes; 123 QSpinBox *mLongMinutes;
120 QSpinBox *mLongSeconds; 124 QSpinBox *mLongSeconds;
121 KComboBox *mLongDirection; 125 KComboBox *mLongDirection;
122 126
123 double mLatitude; 127 double mLatitude;
124 double mLongitude; 128 double mLongitude;
125 QMap<QString, GeoData> mGeoDataMap; 129 QMap<QString, GeoData> mGeoDataMap;
126 bool mUpdateSexagesimalInput; 130 bool mUpdateSexagesimalInput;
127}; 131};
128 132
129class GeoMapWidget : public QWidget 133class GeoMapWidget : public QWidget
130{ 134{
131 Q_OBJECT 135 Q_OBJECT
132 136
133 public: 137 public:
134 GeoMapWidget( QWidget *parent, const char *name = 0 ); 138 GeoMapWidget( QWidget *parent, const char *name = 0 );
135 ~GeoMapWidget(); 139 ~GeoMapWidget();
136 140
137 void setLatitude( double latitude ); 141 void setLatitude( double latitude );
138 double latitude()const; 142 double latitude()const;
139 143
140 void setLongitude( double longitude ); 144 void setLongitude( double longitude );
141 double longitude()const; 145 double longitude()const;
142 146
143 signals: 147 signals:
144 void changed(); 148 void changed();
145 149
146 protected: 150 protected:
147 virtual void mousePressEvent( QMouseEvent* ); 151 virtual void mousePressEvent( QMouseEvent* );
148 virtual void paintEvent( QPaintEvent* ); 152 virtual void paintEvent( QPaintEvent* );
149 153
150 private: 154 private:
151 double mLatitude; 155 double mLatitude;
152 double mLongitude; 156 double mLongitude;
153}; 157};
154 158
155#endif 159#endif
diff --git a/kaddressbook/imagewidget.cpp b/kaddressbook/imagewidget.cpp
index eec5e08..6ecf66d 100644
--- a/kaddressbook/imagewidget.cpp
+++ b/kaddressbook/imagewidget.cpp
@@ -1,297 +1,301 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 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 <kabc/picture.h> 24#include <kabc/picture.h>
25 25
26#ifndef KAB_EMBEDDED 26#ifndef KAB_EMBEDDED
27#include <kaccelmanager.h> 27#include <kaccelmanager.h>
28#include <kio/netaccess.h> 28#include <kio/netaccess.h>
29#include <kimageio.h> 29#include <kimageio.h>
30#endif //KAB_EMBEDDED 30#endif //KAB_EMBEDDED
31 31
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kdialog.h> 33#include <kdialog.h>
34#include <kiconloader.h> 34#include <kiconloader.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kurlrequester.h> 36#include <kurlrequester.h>
37#include <kurl.h> 37#include <kurl.h>
38 38
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qgroupbox.h> 40#include <q3groupbox.h>
41#include <qlabel.h> 41#include <qlabel.h>
42#include <qlayout.h> 42#include <qlayout.h>
43#include <qpixmap.h> 43#include <qpixmap.h>
44#include <qpushbutton.h> 44#include <qpushbutton.h>
45#include <qapplication.h> 45#include <qapplication.h>
46#include <QDesktopWidget>
47//Added by qt3to4:
48#include <Q3GridLayout>
49#include <Q3Frame>
46 50
47#include "imagewidget.h" 51#include "imagewidget.h"
48 52
49ImageWidget::ImageWidget( QWidget *parent, const char *name ) 53ImageWidget::ImageWidget( QWidget *parent, const char *name )
50 : QWidget( parent, name ) 54 : QWidget( parent, name )
51{ 55{
52 QGridLayout *topLayout = new QGridLayout( this, 2, 1, KDialog::marginHint(), 56 Q3GridLayout *topLayout = new Q3GridLayout( this, 2, 1, KDialog::marginHint(),
53 KDialog::spacingHint() ); 57 KDialog::spacingHint() );
54 58
55 QGroupBox *photoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Photo" ), this ); 59 Q3GroupBox *photoBox = new Q3GroupBox( 0, Qt::Vertical, i18n( "Photo" ), this );
56 QGridLayout *boxLayout = new QGridLayout( photoBox->layout(), 3, 2, 60 Q3GridLayout *boxLayout = new Q3GridLayout( photoBox->layout(), 3, 2,
57 KDialog::spacingHint() ); 61 KDialog::spacingHint() );
58 boxLayout->setRowStretch( 2, 1 ); 62 boxLayout->setRowStretch( 2, 1 );
59 63
60 mPhotoLabel = new QLabel( photoBox ); 64 mPhotoLabel = new QLabel( photoBox );
61 int fac = 9; 65 int fac = 9;
62 if ( QApplication::desktop()->width() > 320 ) 66 if ( QApplication::desktop()->width() > 320 )
63 fac = 6; 67 fac = 6;
64 mPhotoLabel->setFixedSize( 50*9/fac, 70*9/fac ); 68 mPhotoLabel->setFixedSize( 50*9/fac, 70*9/fac );
65 mPhotoLabel->setScaledContents( true ); 69 mPhotoLabel->setScaledContents( true );
66 mPhotoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 70 mPhotoLabel->setFrameStyle( Q3Frame::Panel | Q3Frame::Sunken );
67 boxLayout->addMultiCellWidget( mPhotoLabel, 0, 3, 0, 0 ); 71 boxLayout->addMultiCellWidget( mPhotoLabel, 0, 3, 0, 0 );
68 72
69 mPhotoUrl = new KURLRequester( photoBox ); 73 mPhotoUrl = new KURLRequester( photoBox );
70#ifndef KAB_EMBEDDED 74#ifndef KAB_EMBEDDED
71 mPhotoUrl->setFilter( KImageIO::pattern() ); 75 mPhotoUrl->setFilter( KImageIO::pattern() );
72#else //KAB_EMBEDDED 76#else //KAB_EMBEDDED
73//US qDebug("ImageWidget::ImageWidget KImageIO not defined. Does this harm ???"); 77//US qDebug("ImageWidget::ImageWidget KImageIO not defined. Does this harm ???");
74#endif //KAB_EMBEDDED 78#endif //KAB_EMBEDDED
75 79
76 80
77 boxLayout->addWidget( mPhotoUrl, 0, 1 ); 81 boxLayout->addWidget( mPhotoUrl, 0, 1 );
78 QHBox *hb1 = new QHBox ( photoBox ); 82 Q3HBox *hb1 = new Q3HBox ( photoBox );
79 mUsePhotoUrl = new QCheckBox( i18n( "Store as URL" ), hb1 ); 83 mUsePhotoUrl = new QCheckBox( i18n( "Store as URL" ), hb1 );
80 mUsePhotoUrl->setEnabled( false ); 84 mUsePhotoUrl->setEnabled( false );
81 boxLayout->addWidget( hb1, 1, 1 ); 85 boxLayout->addWidget( hb1, 1, 1 );
82 86
83 QPushButton * pb = new QPushButton( i18n( "Remove" ), hb1 ); 87 QPushButton * pb = new QPushButton( i18n( "Remove" ), hb1 );
84 connect( pb, SIGNAL( clicked() ),this, SLOT( removePhoto() ) ); 88 connect( pb, SIGNAL( clicked() ),this, SLOT( removePhoto() ) );
85 boxLayout->addWidget( new QLabel( photoBox ), 2, 1 ); 89 boxLayout->addWidget( new QLabel( photoBox ), 2, 1 );
86 90
87 topLayout->addWidget( photoBox, 0, 0 ); 91 topLayout->addWidget( photoBox, 0, 0 );
88 92
89 QGroupBox *logoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Logo" ), this ); 93 Q3GroupBox *logoBox = new Q3GroupBox( 0, Qt::Vertical, i18n( "Logo" ), this );
90 boxLayout = new QGridLayout( logoBox->layout(), 3, 2, KDialog::spacingHint() ); 94 boxLayout = new Q3GridLayout( logoBox->layout(), 3, 2, KDialog::spacingHint() );
91 boxLayout->setRowStretch( 2, 1 ); 95 boxLayout->setRowStretch( 2, 1 );
92 96
93 mLogoLabel = new QLabel( logoBox ); 97 mLogoLabel = new QLabel( logoBox );
94 mLogoLabel->setFixedSize( 50*9/fac, 70*9/fac ); 98 mLogoLabel->setFixedSize( 50*9/fac, 70*9/fac );
95 mLogoLabel->setScaledContents( true ); 99 mLogoLabel->setScaledContents( true );
96 mLogoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 100 mLogoLabel->setFrameStyle( Q3Frame::Panel | Q3Frame::Sunken );
97 boxLayout->addMultiCellWidget( mLogoLabel, 0, 3, 0, 0 ); 101 boxLayout->addMultiCellWidget( mLogoLabel, 0, 3, 0, 0 );
98 102
99 mLogoUrl = new KURLRequester( logoBox ); 103 mLogoUrl = new KURLRequester( logoBox );
100#ifndef KAB_EMBEDDED 104#ifndef KAB_EMBEDDED
101 mLogoUrl->setFilter( KImageIO::pattern() ); 105 mLogoUrl->setFilter( KImageIO::pattern() );
102#else //KAB_EMBEDDED 106#else //KAB_EMBEDDED
103//US qDebug("ImageWidget::ImageWidget KImageIO not defined 2"); 107//US qDebug("ImageWidget::ImageWidget KImageIO not defined 2");
104#endif //KAB_EMBEDDED 108#endif //KAB_EMBEDDED
105 boxLayout->addWidget( mLogoUrl, 0, 1 ); 109 boxLayout->addWidget( mLogoUrl, 0, 1 );
106 110
107 QHBox *hb2 = new QHBox ( logoBox ); 111 Q3HBox *hb2 = new Q3HBox ( logoBox );
108 mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), hb2 ); 112 mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), hb2 );
109 mUseLogoUrl->setEnabled( false ); 113 mUseLogoUrl->setEnabled( false );
110 boxLayout->addWidget( hb2, 1, 1 ); 114 boxLayout->addWidget( hb2, 1, 1 );
111 115
112 pb = new QPushButton( i18n( "Remove" ), hb2 ); 116 pb = new QPushButton( i18n( "Remove" ), hb2 );
113 connect( pb, SIGNAL( clicked() ),this, SLOT( removeLogo() ) ); 117 connect( pb, SIGNAL( clicked() ),this, SLOT( removeLogo() ) );
114 boxLayout->addWidget( new QLabel( logoBox ), 2, 1 ); 118 boxLayout->addWidget( new QLabel( logoBox ), 2, 1 );
115 topLayout->addWidget( logoBox, 1, 0 ); 119 topLayout->addWidget( logoBox, 1, 0 );
116 120
117 connect( mPhotoUrl, SIGNAL( textChanged( const QString& ) ), 121 connect( mPhotoUrl, SIGNAL( textChanged( const QString& ) ),
118 SIGNAL( changed() ) ); 122 SIGNAL( changed() ) );
119 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), 123 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ),
120 SLOT( loadPhoto() ) ); 124 SLOT( loadPhoto() ) );
121 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), 125 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ),
122 SIGNAL( changed() ) ); 126 SIGNAL( changed() ) );
123 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), 127 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ),
124 SLOT( updateGUI() ) ); 128 SLOT( updateGUI() ) );
125 connect( mUsePhotoUrl, SIGNAL( toggled( bool ) ), 129 connect( mUsePhotoUrl, SIGNAL( toggled( bool ) ),
126 SIGNAL( changed() ) ); 130 SIGNAL( changed() ) );
127 131
128 connect( mLogoUrl, SIGNAL( textChanged( const QString& ) ), 132 connect( mLogoUrl, SIGNAL( textChanged( const QString& ) ),
129 SIGNAL( changed() ) ); 133 SIGNAL( changed() ) );
130 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), 134 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ),
131 SLOT( loadLogo() ) ); 135 SLOT( loadLogo() ) );
132 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), 136 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ),
133 SIGNAL( changed() ) ); 137 SIGNAL( changed() ) );
134 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), 138 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ),
135 SLOT( updateGUI() ) ); 139 SLOT( updateGUI() ) );
136 connect( mUseLogoUrl, SIGNAL( toggled( bool ) ), 140 connect( mUseLogoUrl, SIGNAL( toggled( bool ) ),
137 SIGNAL( changed() ) ); 141 SIGNAL( changed() ) );
138 142
139#ifndef KAB_EMBEDDED 143#ifndef KAB_EMBEDDED
140 KAcceleratorManager::manage( this ); 144 KAcceleratorManager::manage( this );
141#endif //KAB_EMBEDDED 145#endif //KAB_EMBEDDED
142 146
143} 147}
144 148
145ImageWidget::~ImageWidget() 149ImageWidget::~ImageWidget()
146{ 150{
147} 151}
148 152
149void ImageWidget::setPhoto( const KABC::Picture &photo ) 153void ImageWidget::setPhoto( const KABC::Picture &photo )
150{ 154{
151 bool blocked = signalsBlocked(); 155 bool blocked = signalsBlocked();
152 blockSignals( true ); 156 blockSignals( true );
153 157
154 if ( photo.isIntern() ) { 158 if ( photo.isIntern() ) {
155//US 159//US
156//US mPhotoLabel->setPixmap( photo.data() ); 160//US mPhotoLabel->setPixmap( photo.data() );
157 if (photo.data().isNull() != true) 161 if (photo.data().isNull() != true)
158 { 162 {
159 QPixmap pm; 163 QPixmap pm;
160 pm.convertFromImage(photo.data()); 164 pm.convertFromImage(photo.data());
161 165
162 mPhotoLabel->setPixmap( pm ); 166 mPhotoLabel->setPixmap( pm );
163 } 167 }
164 168
165 mUsePhotoUrl->setChecked( false ); 169 mUsePhotoUrl->setChecked( false );
166 } else { 170 } else {
167 mPhotoUrl->setURL( photo.url() ); 171 mPhotoUrl->setURL( photo.url() );
168 if ( !photo.url().isEmpty() ) 172 if ( !photo.url().isEmpty() )
169 mUsePhotoUrl->setChecked( true ); 173 mUsePhotoUrl->setChecked( true );
170 loadPhoto(); 174 loadPhoto();
171 } 175 }
172 176
173 blockSignals( blocked ); 177 blockSignals( blocked );
174} 178}
175 179
176KABC::Picture ImageWidget::photo() const 180KABC::Picture ImageWidget::photo() const
177{ 181{
178 KABC::Picture photo; 182 KABC::Picture photo;
179 183
180 if ( mUsePhotoUrl->isChecked() ) 184 if ( mUsePhotoUrl->isChecked() )
181 photo.setUrl( mPhotoUrl->url() ); 185 photo.setUrl( mPhotoUrl->url() );
182 else { 186 else {
183 QPixmap *px = mPhotoLabel->pixmap(); 187 const QPixmap *px = mPhotoLabel->pixmap();
184 if ( px ) { 188 if ( px ) {
185#ifndef KAB_EMBEDDED 189#ifndef KAB_EMBEDDED
186 if ( px->height() > px->width() ) 190 if ( px->height() > px->width() )
187 photo.setData( px->convertToImage().scaleHeight( 140 ) ); 191 photo.setData( px->convertToImage().scaleHeight( 140 ) );
188 else 192 else
189 photo.setData( px->convertToImage().scaleWidth( 100 ) ); 193 photo.setData( px->convertToImage().scaleWidth( 100 ) );
190#else //KAB_EMBEDDED 194#else //KAB_EMBEDDED
191//US add teh nullcheck 195//US add teh nullcheck
192 if (px->isNull() != true ) 196 if (px->isNull() != true )
193 photo.setData( px->convertToImage() ); 197 photo.setData( px->convertToImage() );
194#endif //KAB_EMBEDDED 198#endif //KAB_EMBEDDED
195 199
196 photo.setType( "PNG" ); 200 photo.setType( "PNG" );
197 } 201 }
198 } 202 }
199 203
200 return photo; 204 return photo;
201} 205}
202 206
203void ImageWidget::setLogo( const KABC::Picture &logo ) 207void ImageWidget::setLogo( const KABC::Picture &logo )
204{ 208{
205 bool blocked = signalsBlocked(); 209 bool blocked = signalsBlocked();
206 blockSignals( true ); 210 blockSignals( true );
207 211
208 if ( logo.isIntern() ) { 212 if ( logo.isIntern() ) {
209//US 213//US
210//US mLogoLabel->setPixmap( logo.data() ); 214//US mLogoLabel->setPixmap( logo.data() );
211 if (logo.data().isNull() != true) 215 if (logo.data().isNull() != true)
212 { 216 {
213 QPixmap pm; 217 QPixmap pm;
214 pm.convertFromImage(logo.data()); 218 pm.convertFromImage(logo.data());
215 mLogoLabel->setPixmap( pm ); 219 mLogoLabel->setPixmap( pm );
216 } 220 }
217 mUseLogoUrl->setChecked( false ); 221 mUseLogoUrl->setChecked( false );
218 } else { 222 } else {
219 mLogoUrl->setURL( logo.url() ); 223 mLogoUrl->setURL( logo.url() );
220 if ( !logo.url().isEmpty() ) 224 if ( !logo.url().isEmpty() )
221 mUseLogoUrl->setChecked( true ); 225 mUseLogoUrl->setChecked( true );
222 loadLogo(); 226 loadLogo();
223 } 227 }
224 228
225 blockSignals( blocked ); 229 blockSignals( blocked );
226} 230}
227 231
228KABC::Picture ImageWidget::logo() const 232KABC::Picture ImageWidget::logo() const
229{ 233{
230 KABC::Picture logo; 234 KABC::Picture logo;
231 235
232 if ( mUseLogoUrl->isChecked() ) 236 if ( mUseLogoUrl->isChecked() )
233 logo.setUrl( mLogoUrl->url() ); 237 logo.setUrl( mLogoUrl->url() );
234 else { 238 else {
235 QPixmap *px = mLogoLabel->pixmap(); 239 const QPixmap *px = mLogoLabel->pixmap();
236 if ( px ) { 240 if ( px ) {
237#ifndef KAB_EMBEDDED 241#ifndef KAB_EMBEDDED
238 if ( px->height() > px->width() ) 242 if ( px->height() > px->width() )
239 logo.setData( px->convertToImage().scaleHeight( 140 ) ); 243 logo.setData( px->convertToImage().scaleHeight( 140 ) );
240 else 244 else
241 logo.setData( px->convertToImage().scaleWidth( 100 ) ); 245 logo.setData( px->convertToImage().scaleWidth( 100 ) );
242#else //KAB_EMBEDDED 246#else //KAB_EMBEDDED
243 if (px->isNull() != true ) 247 if (px->isNull() != true )
244 logo.setData( px->convertToImage() ); 248 logo.setData( px->convertToImage() );
245#endif //KAB_EMBEDDED 249#endif //KAB_EMBEDDED
246 250
247 logo.setType( "PNG" ); 251 logo.setType( "PNG" );
248 252
249 } 253 }
250 } 254 }
251 return logo; 255 return logo;
252} 256}
253void ImageWidget::removePhoto() 257void ImageWidget::removePhoto()
254{ 258{
255 setPhoto(KABC::Picture() ); 259 setPhoto(KABC::Picture() );
256} 260}
257 261
258void ImageWidget::removeLogo() 262void ImageWidget::removeLogo()
259{ 263{
260 setLogo(KABC::Picture() ); 264 setLogo(KABC::Picture() );
261} 265}
262 266
263void ImageWidget::loadPhoto() 267void ImageWidget::loadPhoto()
264{ 268{
265 mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) ); 269 mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) );
266} 270}
267 271
268void ImageWidget::loadLogo() 272void ImageWidget::loadLogo()
269{ 273{
270 mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) ); 274 mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) );
271} 275}
272 276
273void ImageWidget::updateGUI() 277void ImageWidget::updateGUI()
274{ 278{
275 KURLRequester *ptr = (KURLRequester*)sender(); 279 KURLRequester *ptr = (KURLRequester*)sender();
276 280
277 281
278 if ( ptr == mPhotoUrl ) 282 if ( ptr == mPhotoUrl )
279 mUsePhotoUrl->setEnabled( true ); 283 mUsePhotoUrl->setEnabled( true );
280 else if ( ptr == mLogoUrl ) 284 else if ( ptr == mLogoUrl )
281 mUseLogoUrl->setEnabled( true ); 285 mUseLogoUrl->setEnabled( true );
282} 286}
283 287
284QPixmap ImageWidget::loadPixmap( const QString &url ) 288QPixmap ImageWidget::loadPixmap( const QString &url )
285{ 289{
286 290
287 QPixmap pixmap; 291 QPixmap pixmap;
288 292
289 if ( url.isEmpty() ) 293 if ( url.isEmpty() )
290 return pixmap; 294 return pixmap;
291 pixmap.load( url ); 295 pixmap.load( url );
292 return pixmap; 296 return pixmap;
293} 297}
294 298
295#ifndef KAB_EMBEDDED 299#ifndef KAB_EMBEDDED_
296#include "imagewidget.moc" 300#include "moc_imagewidget.cpp"
297#endif //KAB_EMBEDDED 301#endif //KAB_EMBEDDED
diff --git a/kaddressbook/imagewidget.h b/kaddressbook/imagewidget.h
index bbfba58..9320a6b 100644
--- a/kaddressbook/imagewidget.h
+++ b/kaddressbook/imagewidget.h
@@ -1,88 +1,91 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 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#ifndef IMAGEWIDGET_H 24#ifndef IMAGEWIDGET_H
25#define IMAGEWIDGET_H 25#define IMAGEWIDGET_H
26 26
27#include <qwidget.h> 27#include <qwidget.h>
28//Added by qt3to4:
29#include <QPixmap>
30#include <QLabel>
28 31
29#include <kabc/picture.h> 32#include <kabc/picture.h>
30#include <kdialogbase.h> 33#include <kdialogbase.h>
31 34
32class KURL; 35class KURL;
33class KURLRequester; 36class KURLRequester;
34 37
35class QCheckBox; 38class QCheckBox;
36class QLabel; 39class QLabel;
37 40
38class ImageWidget : public QWidget 41class ImageWidget : public QWidget
39{ 42{
40 Q_OBJECT 43 Q_OBJECT
41 44
42 public: 45 public:
43 ImageWidget( QWidget *parent, const char *name = 0 ); 46 ImageWidget( QWidget *parent, const char *name = 0 );
44 ~ImageWidget(); 47 ~ImageWidget();
45 48
46 /** 49 /**
47 Sets the photo object. 50 Sets the photo object.
48 */ 51 */
49 void setPhoto( const KABC::Picture &photo ); 52 void setPhoto( const KABC::Picture &photo );
50 53
51 /** 54 /**
52 Returns a photo object. 55 Returns a photo object.
53 */ 56 */
54 KABC::Picture photo() const; 57 KABC::Picture photo() const;
55 58
56 /** 59 /**
57 Sets the logo object. 60 Sets the logo object.
58 */ 61 */
59 void setLogo( const KABC::Picture &photo ); 62 void setLogo( const KABC::Picture &photo );
60 63
61 /** 64 /**
62 Returns a logo object. 65 Returns a logo object.
63 */ 66 */
64 KABC::Picture logo() const; 67 KABC::Picture logo() const;
65 68
66 signals: 69 signals:
67 void changed(); 70 void changed();
68 71
69 private slots: 72 private slots:
70 void loadPhoto(); 73 void loadPhoto();
71 void loadLogo(); 74 void loadLogo();
72 void removePhoto(); 75 void removePhoto();
73 void removeLogo(); 76 void removeLogo();
74 void updateGUI(); 77 void updateGUI();
75 78
76 private: 79 private:
77 QPixmap loadPixmap( const QString &url ); 80 QPixmap loadPixmap( const QString &url );
78 81
79 KURLRequester *mPhotoUrl; 82 KURLRequester *mPhotoUrl;
80 KURLRequester *mLogoUrl; 83 KURLRequester *mLogoUrl;
81 84
82 QCheckBox *mUsePhotoUrl; 85 QCheckBox *mUsePhotoUrl;
83 QCheckBox *mUseLogoUrl; 86 QCheckBox *mUseLogoUrl;
84 QLabel *mPhotoLabel; 87 QLabel *mPhotoLabel;
85 QLabel *mLogoLabel; 88 QLabel *mLogoLabel;
86}; 89};
87 90
88#endif 91#endif
diff --git a/kaddressbook/incsearchwidget.cpp b/kaddressbook/incsearchwidget.cpp
index 5f8b83d..a54d1cd 100644
--- a/kaddressbook/incsearchwidget.cpp
+++ b/kaddressbook/incsearchwidget.cpp
@@ -1,181 +1,185 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qlayout.h> 25#include <qlayout.h>
26#include <qtooltip.h> 26#include <qtooltip.h>
27#include <qapplication.h> 27#include <qapplication.h>
28#include <QDesktopWidget>
28#include <qcombobox.h> 29#include <qcombobox.h>
30//Added by qt3to4:
31#include <Q3HBoxLayout>
29 32
30#include <kdialog.h> 33#include <kdialog.h>
31#include <klineedit.h> 34#include <klineedit.h>
32#include <klocale.h> 35#include <klocale.h>
33#include <kglobal.h> 36#include <kglobal.h>
34#include <kglobal.h> 37#include <kglobal.h>
35#include "kabprefs.h" 38#include "kabprefs.h"
36 39
37#include "incsearchwidget.h" 40#include "incsearchwidget.h"
38 41
39IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name ) 42IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name )
40 : QWidget( parent, name )
41{ 43{
44 setObjectName(name);
45 setParent(parent);
42#ifndef KAB_EMBEDDED 46#ifndef KAB_EMBEDDED
43//US setCaption( i18n( "Incremental Search" ) ); 47//US setCaption( i18n( "Incremental Search" ) );
44#endif //KAB_EMBEDDED 48#endif //KAB_EMBEDDED
45 49
46 QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() ); 50 Q3HBoxLayout *layout = new Q3HBoxLayout( this, 2, KDialog::spacingHint() );
47 51
48#ifdef DESKTOP_VERSION 52#ifdef DESKTOP_VERSION
49 QLabel *label = new QLabel( i18n( "Search:" ), this ); 53 QLabel *label = new QLabel( i18n( "Search:" ), this );
50 label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight ); 54 label->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
51 layout->addWidget( label ); 55 layout->addWidget( label );
52#endif //KAB_EMBEDDED 56#endif //KAB_EMBEDDED
53 57
54 mSearchText = new KLineEdit( this ); 58 mSearchText = new KLineEdit( this );
55 layout->addWidget( mSearchText ); 59 layout->addWidget( mSearchText );
56// #ifdef KAB_EMBEDDED 60// #ifdef KAB_EMBEDDED
57// if (KGlobal::getOrientation() == KGlobal::Portrait) 61// if (KGlobal::getOrientation() == KGlobal::Portrait)
58// mSearchText->setMaximumWidth(30); 62// mSearchText->setMaximumWidth(30);
59// #endif //KAB_EMBEDDED 63// #endif //KAB_EMBEDDED
60 //mSearchText->setMaximumWidth(60); 64 //mSearchText->setMaximumWidth(60);
61 65
62 66
63 mFieldCombo = new QComboBox( false, this ); 67 mFieldCombo = new QComboBox( false, this );
64 layout->addWidget( mFieldCombo ); 68 layout->addWidget( mFieldCombo );
65 mFieldCombo->setMaximumHeight( 34 ); 69 mFieldCombo->setMaximumHeight( 34 );
66 QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) ); 70 QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) );
67 71
68// #ifndef KAB_EMBEDDED 72// #ifndef KAB_EMBEDDED
69// resize( QSize(420, 50).expandedTo( sizeHint() ) ); 73// resize( QSize(420, 50).expandedTo( sizeHint() ) );
70// #else //KAB_EMBEDDED 74// #else //KAB_EMBEDDED
71// resize( QSize(30, 10).expandedTo( sizeHint() ) ); 75// resize( QSize(30, 10).expandedTo( sizeHint() ) );
72// #endif //KAB_EMBEDDED 76// #endif //KAB_EMBEDDED
73 77
74 78
75 // for performance reasons, we do a search on the pda only after return is pressed 79 // for performance reasons, we do a search on the pda only after return is pressed
76 connect( mSearchText, SIGNAL( textChanged( const QString& ) ), 80 connect( mSearchText, SIGNAL( textChanged( const QString& ) ),
77 SLOT( announceDoSearch2() ) ); 81 SLOT( announceDoSearch2() ) );
78 connect( mFieldCombo, SIGNAL( activated( const QString& ) ), 82 connect( mFieldCombo, SIGNAL( activated( const QString& ) ),
79 SLOT( announceDoSearch2() ) ); 83 SLOT( announceDoSearch2() ) );
80 84
81 connect( mSearchText, SIGNAL( returnPressed() ), 85 connect( mSearchText, SIGNAL( returnPressed() ),
82 SLOT( announceDoSearch() ) ); 86 SLOT( announceDoSearch() ) );
83 connect( mFieldCombo, SIGNAL( activated( const QString& ) ), 87 connect( mFieldCombo, SIGNAL( activated( const QString& ) ),
84 SLOT( announceFieldChanged() ) ); 88 SLOT( announceFieldChanged() ) );
85 89
86 90
87 91
88 connect( mSearchText, SIGNAL( scrollUP() ), this, SIGNAL( scrollUP() )); 92 connect( mSearchText, SIGNAL( scrollUP() ), this, SIGNAL( scrollUP() ));
89 connect( mSearchText, SIGNAL( scrollDOWN() ), this, SIGNAL( scrollDOWN() )); 93 connect( mSearchText, SIGNAL( scrollDOWN() ), this, SIGNAL( scrollDOWN() ));
90 94
91 95
92 setFocusProxy( mSearchText ); 96 setFocusProxy( mSearchText );
93} 97}
94 98
95IncSearchWidget::~IncSearchWidget() 99IncSearchWidget::~IncSearchWidget()
96{ 100{
97 101
98} 102}
99void IncSearchWidget::announceDoSearch2() 103void IncSearchWidget::announceDoSearch2()
100{ 104{
101 if ( KABPrefs::instance()->mSearchWithReturn ) 105 if ( KABPrefs::instance()->mSearchWithReturn )
102 return; 106 return;
103 emit doSearch( mSearchText->text() ); 107 emit doSearch( mSearchText->text() );
104 //qDebug("emit dosreach "); 108 //qDebug("emit dosreach ");
105} 109}
106 110
107void IncSearchWidget::announceDoSearch() 111void IncSearchWidget::announceDoSearch()
108{ 112{
109 113
110 emit doSearch( mSearchText->text() ); 114 emit doSearch( mSearchText->text() );
111 // qDebug("emit dosreach "); 115 // qDebug("emit dosreach ");
112} 116}
113 117
114void IncSearchWidget::announceFieldChanged() 118void IncSearchWidget::announceFieldChanged()
115{ 119{
116 emit fieldChanged(); 120 emit fieldChanged();
117} 121}
118void IncSearchWidget::setSize() 122void IncSearchWidget::setSize()
119{ 123{
120 if ( KABPrefs::instance()->mHideSearchOnSwitch && QApplication::desktop()->width() == 480) { 124 if ( KABPrefs::instance()->mHideSearchOnSwitch && QApplication::desktop()->width() == 480) {
121 setCurrentItem( 0 ); 125 setCurrentItem( 0 );
122 //mFieldCombo->setMaximumWidth( 0 ); 126 //mFieldCombo->setMaximumWidth( 0 );
123 mFieldCombo->hide(); 127 mFieldCombo->hide();
124 mSearchText->setMaximumWidth( 200 ); 128 mSearchText->setMaximumWidth( 200 );
125 } else { 129 } else {
126 mFieldCombo->show(); 130 mFieldCombo->show();
127 QFontMetrics fm ( mFieldCombo->font() ); 131 QFontMetrics fm ( mFieldCombo->font() );
128 int wid = fm.width(i18n( "All Fields" ) ); 132 int wid = fm.width(i18n( "All Fields" ) );
129#ifdef DESKTOP_VERSION 133#ifdef DESKTOP_VERSION
130 mFieldCombo->setMinimumWidth( wid+60 ); 134 mFieldCombo->setMinimumWidth( wid+60 );
131 wid = wid * 2; 135 wid = wid * 2;
132#endif 136#endif
133 mFieldCombo->setMaximumWidth( wid+60 ); 137 mFieldCombo->setMaximumWidth( wid+60 );
134 mSearchText->setMaximumWidth( 1024 ); 138 mSearchText->setMaximumWidth( 1024 );
135 } 139 }
136} 140}
137void IncSearchWidget::setFields( const KABC::Field::List &list ) 141void IncSearchWidget::setFields( const KABC::Field::List &list )
138{ 142{
139 143
140 mFieldCombo->clear(); 144 mFieldCombo->clear();
141 mFieldCombo->insertItem( i18n( "All Fields" ) ); 145 mFieldCombo->insertItem( i18n( "All Fields" ) );
142 146
143 KABC::Field::List::ConstIterator it; 147 KABC::Field::List::ConstIterator it;
144 for ( it = list.begin(); it != list.end(); ++it ) { 148 for ( it = list.begin(); it != list.end(); ++it ) {
145 mFieldCombo->insertItem( (*it)->label() ); 149 mFieldCombo->insertItem( (*it)->label() );
146 } 150 }
147 151
148 mFieldList = list; 152 mFieldList = list;
149 153
150 announceDoSearch(); 154 announceDoSearch();
151 announceFieldChanged(); 155 announceFieldChanged();
152 setSize(); 156 setSize();
153} 157}
154 158
155KABC::Field::List IncSearchWidget::fields() const 159KABC::Field::List IncSearchWidget::fields() const
156{ 160{
157 return mFieldList; 161 return mFieldList;
158} 162}
159 163
160KABC::Field *IncSearchWidget::currentField()const 164KABC::Field *IncSearchWidget::currentField()const
161{ 165{
162 if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 ) 166 if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 )
163 return 0; // for error or 'use all fields' 167 return 0; // for error or 'use all fields'
164 else 168 else
165 return mFieldList[ mFieldCombo->currentItem() - 1 ]; 169 return mFieldList[ mFieldCombo->currentItem() - 1 ];
166} 170}
167 171
168void IncSearchWidget::setCurrentItem( int pos ) 172void IncSearchWidget::setCurrentItem( int pos )
169{ 173{
170 mFieldCombo->setCurrentItem( pos ); 174 mFieldCombo->setCurrentItem( pos );
171 announceFieldChanged(); 175 announceFieldChanged();
172} 176}
173 177
174int IncSearchWidget::currentItem() const 178int IncSearchWidget::currentItem() const
175{ 179{
176 180
177 return mFieldCombo->currentItem(); 181 return mFieldCombo->currentItem();
178} 182}
179#ifndef KAB_EMBEDDED 183#ifndef KAB_EMBEDDED_
180#include "incsearchwidget.moc" 184#include "moc_incsearchwidget.cpp"
181#endif //KAB_EMBEDDED 185#endif //KAB_EMBEDDED
diff --git a/kaddressbook/jumpbuttonbar.cpp b/kaddressbook/jumpbuttonbar.cpp
index aebf8a6..740b7db 100644
--- a/kaddressbook/jumpbuttonbar.cpp
+++ b/kaddressbook/jumpbuttonbar.cpp
@@ -1,257 +1,260 @@
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#include <qevent.h> 24#include <qevent.h>
25#include <qlayout.h> 25#include <qlayout.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qstring.h> 27#include <qstring.h>
28#include <qtl.h> 28#include <q3tl.h>
29#include <qapplication.h> 29#include <qapplication.h>
30#include <QDesktopWidget>
31//Added by qt3to4:
32#include <Q3GridLayout>
30 33
31#include <kabc/addressbook.h> 34#include <kabc/addressbook.h>
32#include <kabc/field.h> 35#include <kabc/field.h>
33#include <kdebug.h> 36#include <kdebug.h>
34#include <klocale.h> 37#include <klocale.h>
35 38
36#include "kabcore.h" 39#include "kabcore.h"
37 40
38#include "jumpbuttonbar.h" 41#include "jumpbuttonbar.h"
39 42
40class JumpButton : public QPushButton 43class JumpButton : public QPushButton
41{ 44{
42 public: 45 public:
43 JumpButton( const QString &text, QWidget *parent, 46 JumpButton( const QString &text, QWidget *parent,
44 const QString &character ); 47 const QString &character );
45 48
46 void setCharacter( const QString &character ); 49 void setCharacter( const QString &character );
47 QString character() const; 50 QString character() const;
48 51
49 private: 52 private:
50 QString mCharacter; 53 QString mCharacter;
51}; 54};
52 55
53JumpButton::JumpButton( const QString &text, QWidget *parent, 56JumpButton::JumpButton( const QString &text, QWidget *parent,
54 const QString &character ) 57 const QString &character )
55 : QPushButton( text, parent ) 58 : QPushButton( text, parent )
56{ 59{
57 mCharacter = character; 60 mCharacter = character;
58} 61}
59 62
60void JumpButton::setCharacter( const QString &character ) 63void JumpButton::setCharacter( const QString &character )
61{ 64{
62 mCharacter = character; 65 mCharacter = character;
63 setText(mCharacter.upper() ); 66 setText(mCharacter.upper() );
64} 67}
65 68
66QString JumpButton::character() const 69QString JumpButton::character() const
67{ 70{
68 return mCharacter; 71 return mCharacter;
69} 72}
70 73
71JumpButtonBar::JumpButtonBar( KABCore *core, QWidget *parent, const char *name ) 74JumpButtonBar::JumpButtonBar( KABCore *core, QWidget *parent, const char *name )
72 : QWidget( parent, name ), mCore( core ) 75 : QWidget( parent, name ), mCore( core )
73{ 76{
74 if ( QApplication::desktop()->width() < 480 ) 77 if ( QApplication::desktop()->width() < 480 )
75 78
76 mButtonLayout = new QGridLayout( this, 1, 18 ); 79 mButtonLayout = new Q3GridLayout( this, 1, 18 );
77 else 80 else
78 mButtonLayout = new QGridLayout( this, 1, 20 ); 81 mButtonLayout = new Q3GridLayout( this, 1, 20 );
79 mButtonLayout->setAlignment( Qt::AlignTop ); 82 mButtonLayout->setAlignment( Qt::AlignTop );
80 83
81 recreateButtons(); 84 recreateButtons();
82} 85}
83 86
84JumpButtonBar::~JumpButtonBar() 87JumpButtonBar::~JumpButtonBar()
85{ 88{
86} 89}
87 90
88QSizePolicy JumpButtonBar::sizePolicy() const 91QSizePolicy JumpButtonBar::sizePolicy() const
89{ 92{
90#ifndef KAB_EMBEDDED 93#ifndef KAB_EMBEDDED
91 return QSizePolicy( QSizePolicy::Maximum, QSizePolicy::Minimum, 94 return QSizePolicy( QSizePolicy::Maximum, QSizePolicy::Minimum,
92 QSizePolicy::Vertically ); 95 QSizePolicy::Vertically );
93#else //KAB_EMBEDDED 96#else //KAB_EMBEDDED
94 return QSizePolicy( QSizePolicy::Maximum, QSizePolicy::Minimum); 97 return QSizePolicy( QSizePolicy::Maximum, QSizePolicy::Minimum);
95#endif //KAB_EMBEDDED 98#endif //KAB_EMBEDDED
96} 99}
97 100
98void JumpButtonBar::letterClicked() 101void JumpButtonBar::letterClicked()
99{ 102{
100 JumpButton *button = (JumpButton*)sender(); 103 JumpButton *button = (JumpButton*)sender();
101 QString character = button->character(); 104 QString character = button->character();
102 if ( character.length() == 2 ) 105 if ( character.length() == 2 )
103 character = character.left(1) +"-"+character.right(1); 106 character = character.left(1) +"-"+character.right(1);
104 if ( !character.isNull() ) 107 if ( !character.isNull() )
105 emit jumpToLetter( character ); 108 emit jumpToLetter( character );
106 //qDebug("emit *%s* ",character.latin1()); 109 //qDebug("emit *%s* ",character.latin1());
107} 110}
108 111
109void JumpButtonBar::recreateButtons() 112void JumpButtonBar::recreateButtons()
110{ 113{
111 // the easiest way to remove all buttons ;) 114 // the easiest way to remove all buttons ;)
112 //mButtons.setAutoDelete( true ); 115 //mButtons.setAutoDelete( true );
113 //mButtons.clear(); 116 //mButtons.clear();
114 //mButtons.setAutoDelete( false ); 117 //mButtons.setAutoDelete( false );
115 mCharacters.clear(); 118 mCharacters.clear();
116 119
117 QString character; 120 QString character;
118 121
119 KABC::AddressBook *ab = mCore->addressBook(); 122 KABC::AddressBook *ab = mCore->addressBook();
120 KABC::AddressBook::Iterator it; 123 KABC::AddressBook::Iterator it;
121 KABC::Field *field = mCore->currentSearchField(); 124 KABC::Field *field = mCore->currentSearchField();
122 if ( field ) { 125 if ( field ) {
123 setEnabled( true ); 126 setEnabled( true );
124 } else { 127 } else {
125 setEnabled( false ); 128 setEnabled( false );
126 return; 129 return;
127 } 130 }
128 mCharacters.append( "*"); 131 mCharacters.append( "*");
129 for ( it = ab->begin(); it != ab->end(); ++it ) { 132 for ( it = ab->begin(); it != ab->end(); ++it ) {
130 if ( !field->value( *it ).isEmpty() ) 133 if ( !field->value( *it ).isEmpty() )
131 character = field->value( *it )[ 0 ].lower(); 134 character = field->value( *it )[ 0 ].lower();
132 if ( character != "!" ) { 135 if ( character != "!" ) {
133 if ( !character.isEmpty() && !mCharacters.contains( character ) && character.at( 0 ).isLetter ()) 136 if ( !character.isEmpty() && !mCharacters.contains( character ) && character.at( 0 ).isLetter ())
134 mCharacters.append( character ); 137 mCharacters.append( character );
135 } 138 }
136 } 139 }
137 if ( mCharacters.count() == 0 ) { 140 if ( mCharacters.count() == 0 ) {
138 setEnabled( false ); 141 setEnabled( false );
139 return; 142 return;
140 } 143 }
141 144
142 int maxRows = mCharacters.count() / 2; // we use 2 columns 145 int maxRows = mCharacters.count() / 2; // we use 2 columns
143 if ( mCharacters.count() % 2 ) 146 if ( mCharacters.count() % 2 )
144 maxRows++; 147 maxRows++;
145 sortListLocaleAware( mCharacters ); 148 sortListLocaleAware( mCharacters );
146 bool skip2 = false; 149 bool skip2 = false;
147 int skipcount = 0; 150 int skipcount = 0;
148 int maxHei = 0; 151 int maxHei = 0;
149#ifdef DESKTOP_VERSION 152#ifdef DESKTOP_VERSION
150 int maxChar = 16; 153 int maxChar = 16;
151 int heightDiff = 200; 154 int heightDiff = 200;
152 int fixwid = 36; 155 int fixwid = 36;
153#else 156#else
154 //default for 240x320 diaplay: 157 //default for 240x320 diaplay:
155 int maxChar = 16; 158 int maxChar = 16;
156 int heightDiff = 64; 159 int heightDiff = 64;
157 int fixwid = 20; 160 int fixwid = 20;
158 161
159 if ( QApplication::desktop()->height() == 480 ) { 162 if ( QApplication::desktop()->height() == 480 ) {
160 maxChar = 16; 163 maxChar = 16;
161 heightDiff = 135; 164 heightDiff = 135;
162 fixwid = 34; 165 fixwid = 34;
163 } else if ( QApplication::desktop()->height() >= 640 ) { 166 } else if ( QApplication::desktop()->height() >= 640 ) {
164 maxChar = 20; 167 maxChar = 20;
165 heightDiff = 135; 168 heightDiff = 135;
166 fixwid = 34; 169 fixwid = 34;
167 } 170 }
168#endif 171#endif
169 172
170 if ( mCharacters.count() > maxChar ) 173 if ( mCharacters.count() > maxChar )
171 skipcount = mCharacters.count()- maxChar; 174 skipcount = mCharacters.count()- maxChar;
172 maxHei = (QApplication::desktop()->height()-heightDiff)/(maxChar); 175 maxHei = (QApplication::desktop()->height()-heightDiff)/(maxChar);
173 176
174 177
175 maxRows = 28; 178 maxRows = 28;
176 bool skipcurrent = false; 179 bool skipcurrent = false;
177 bool state = isUpdatesEnabled(); 180 bool state = isUpdatesEnabled();
178 setUpdatesEnabled( false ); 181 setUpdatesEnabled( false );
179 //qDebug("cc %d ",mCharacters.count() ); 182 //qDebug("cc %d ",mCharacters.count() );
180 JumpButton *button = 0; 183 JumpButton *button = 0;
181 int row = 0, col = 0; 184 int row = 0, col = 0;
182 JumpButton* cur = mButtons.first(); 185 JumpButton* cur = mButtons.first();
183 for ( uint i = 0; i < mCharacters.count(); ++i ) { 186 for ( uint i = 0; i < mCharacters.count(); ++i ) {
184 if ( skipcount > 0 && skipcurrent ) { 187 if ( skipcount > 0 && skipcurrent ) {
185 --skipcount; 188 --skipcount;
186 if ( button ) { 189 if ( button ) {
187 button->setCharacter( button->character() + mCharacters[ i ]); 190 button->setCharacter( button->character() + mCharacters[ i ]);
188 } 191 }
189 } else { 192 } else {
190 if ( cur ) { 193 if ( cur ) {
191 button = cur ; 194 button = cur ;
192 cur = mButtons.next(); 195 cur = mButtons.next();
193 button->setCharacter(mCharacters[ i ]); 196 button->setCharacter(mCharacters[ i ]);
194 } else { 197 } else {
195 button = new JumpButton( mCharacters[ i ].upper(), this, mCharacters[ i ] ); 198 button = new JumpButton( mCharacters[ i ].upper(), this, mCharacters[ i ] );
196 if ( fixwid ) 199 if ( fixwid )
197 button->setFixedWidth( fixwid ); 200 button->setFixedWidth( fixwid );
198 mButtons.append( button ); 201 mButtons.append( button );
199 connect( button, SIGNAL( clicked() ), this, SLOT( letterClicked() ) ); 202 connect( button, SIGNAL( clicked() ), this, SLOT( letterClicked() ) );
200 mButtonLayout->addWidget( button, row, col ); 203 mButtonLayout->addWidget( button, row, col );
201 } 204 }
202 if ( maxHei ) 205 if ( maxHei )
203 button->setMaximumHeight( maxHei ); 206 button->setMaximumHeight( maxHei );
204 button->show(); 207 button->show();
205 208
206 if ( col == maxRows ) { 209 if ( col == maxRows ) {
207 row = 0; 210 row = 0;
208 col++; 211 col++;
209 } else 212 } else
210 row++; 213 row++;
211 } 214 }
212 if ( i > 0 ) 215 if ( i > 0 )
213 skipcurrent = !skipcurrent; 216 skipcurrent = !skipcurrent;
214 } 217 }
215 while ( cur ) { 218 while ( cur ) {
216 cur->hide(); 219 cur->hide();
217 cur = mButtons.next(); 220 cur = mButtons.next();
218 } 221 }
219 222
220 mButtonLayout->activate(); 223 mButtonLayout->activate();
221 setUpdatesEnabled( state ); 224 setUpdatesEnabled( state );
222 update(); 225 update();
223} 226}
224 227
225void JumpButtonBar::sortListLocaleAware( QStringList &list ) 228void JumpButtonBar::sortListLocaleAware( QStringList &list )
226{ 229{
227 QStringList::Iterator beginIt = list.begin(); 230 QStringList::Iterator beginIt = list.begin();
228 QStringList::Iterator endIt = list.end(); 231 QStringList::Iterator endIt = list.end();
229 232
230 --endIt; 233 --endIt;
231 if ( beginIt == endIt ) // don't need sorting 234 if ( beginIt == endIt ) // don't need sorting
232 return; 235 return;
233 236
234 QStringList::Iterator walkBackIt = endIt; 237 QStringList::Iterator walkBackIt = endIt;
235 while ( beginIt != endIt ) { 238 while ( beginIt != endIt ) {
236 QStringList::Iterator j1 = list.begin(); 239 QStringList::Iterator j1 = list.begin();
237 QStringList::Iterator j2 = j1; 240 QStringList::Iterator j2 = j1;
238 ++j2; 241 ++j2;
239 while ( j1 != walkBackIt ) { 242 while ( j1 != walkBackIt ) {
240#ifndef KAB_EMBEDDED 243#ifndef KAB_EMBEDDED
241 if ( QString::localeAwareCompare( *j2, *j1 ) < 0 ) 244 if ( QString::localeAwareCompare( *j2, *j1 ) < 0 )
242#else //KAB_EMBEDDED 245#else //KAB_EMBEDDED
243 if ( QString::compare( *j2, *j1 ) < 0 ) 246 if ( QString::compare( *j2, *j1 ) < 0 )
244#endif //KAB_EMBEDDED 247#endif //KAB_EMBEDDED
245 qSwap( *j1, *j2 ); 248 qSwap( *j1, *j2 );
246 249
247 ++j1; 250 ++j1;
248 ++j2; 251 ++j2;
249 } 252 }
250 ++beginIt; 253 ++beginIt;
251 --walkBackIt; 254 --walkBackIt;
252 } 255 }
253} 256}
254 257
255#ifndef KAB_EMBEDDED 258#ifndef KAB_EMBEDDED_
256#include "jumpbuttonbar.moc" 259#include "moc_jumpbuttonbar.cpp"
257#endif //KAB_EMBEDDED 260#endif //KAB_EMBEDDED
diff --git a/kaddressbook/jumpbuttonbar.h b/kaddressbook/jumpbuttonbar.h
index d534f2b..0589812 100644
--- a/kaddressbook/jumpbuttonbar.h
+++ b/kaddressbook/jumpbuttonbar.h
@@ -1,84 +1,87 @@
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 JUMPBUTTONBAR_H 24#ifndef JUMPBUTTONBAR_H
25#define JUMPBUTTONBAR_H 25#define JUMPBUTTONBAR_H
26 26
27#include <qsizepolicy.h> 27#include <qsizepolicy.h>
28#include <qwidget.h> 28#include <qwidget.h>
29#include <qptrlist.h> 29#include <q3ptrlist.h>
30#include <qstringlist.h> 30#include <qstringlist.h>
31//Added by qt3to4:
32#include <QResizeEvent>
33#include <Q3GridLayout>
31 34
32class QChar; 35class QChar;
33class QGridLayout; 36class Q3GridLayout;
34class QResizeEvent; 37class QResizeEvent;
35class QPushButton; 38class QPushButton;
36class JumpButton; 39class JumpButton;
37 40
38namespace KABC { 41namespace KABC {
39class Field; 42class Field;
40} 43}
41 44
42class KABCore; 45class KABCore;
43 46
44/** 47/**
45 Used to draw the jump button bar on the right of the view. 48 Used to draw the jump button bar on the right of the view.
46 */ 49 */
47class JumpButtonBar : public QWidget 50class JumpButtonBar : public QWidget
48{ 51{
49 Q_OBJECT 52 Q_OBJECT
50 53
51 public: 54 public:
52 JumpButtonBar( KABCore *core, QWidget *parent, const char *name = 0 ); 55 JumpButtonBar( KABCore *core, QWidget *parent, const char *name = 0 );
53 ~JumpButtonBar(); 56 ~JumpButtonBar();
54 57
55 QSizePolicy sizePolicy() const; 58 QSizePolicy sizePolicy() const;
56 59
57 public slots: 60 public slots:
58 /** 61 /**
59 This method removes all buttons from the GUI and recreates them 62 This method removes all buttons from the GUI and recreates them
60 according to the current global search field and the content of 63 according to the current global search field and the content of
61 the address book. 64 the address book.
62 */ 65 */
63 void recreateButtons(); 66 void recreateButtons();
64 67
65 signals: 68 signals:
66 /** 69 /**
67 Emitted whenever a letter is selected by the user. 70 Emitted whenever a letter is selected by the user.
68 */ 71 */
69 void jumpToLetter( const QString &character ); 72 void jumpToLetter( const QString &character );
70 73
71 protected slots: 74 protected slots:
72 void letterClicked(); 75 void letterClicked();
73 76
74 private: 77 private:
75 void sortListLocaleAware( QStringList &list ); 78 void sortListLocaleAware( QStringList &list );
76 79
77 KABCore *mCore; 80 KABCore *mCore;
78 81
79 QGridLayout *mButtonLayout; 82 Q3GridLayout *mButtonLayout;
80 QStringList mCharacters; 83 QStringList mCharacters;
81 QPtrList<JumpButton> mButtons; 84 Q3PtrList<JumpButton> mButtons;
82}; 85};
83 86
84#endif 87#endif
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index ab2824c..03b44d1 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,3486 +1,3496 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 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 Async a special exception, permission is given to link this program 19 Async 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/*s 24/*s
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <q3progressbar.h>
43#include <QDesktopWidget>
44//Added by qt3to4:
45#include <QResizeEvent>
46#include <QPixmap>
47#include <Q3ValueList>
48#include <Q3HBoxLayout>
49#include <Q3VBoxLayout>
50#include <Q3CString>
51#include <Q3PopupMenu>
52#include <Q3PtrList>
43#include <libkdepim/phoneaccess.h> 53#include <libkdepim/phoneaccess.h>
44 54
45#ifndef KAB_EMBEDDED 55#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 56#include <qclipboard.h>
47#include <qdir.h> 57#include <qdir.h>
48#include <qfile.h> 58#include <qfile.h>
49#include <qapplicaton.h> 59#include <qapplicaton.h>
50#include <qprogressbar.h> 60#include <q3progressbar.h>
51#include <qlayout.h> 61#include <qlayout.h>
52#include <qregexp.h> 62#include <qregexp.h>
53#include <qvbox.h> 63#include <q3vbox.h>
54#include <kabc/addresseelist.h> 64#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 65#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 66#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 67#include <kabc/vcardconverter.h>
58#include <kapplication.h> 68#include <kapplication.h>
59#include <kactionclasses.h> 69#include <kactionclasses.h>
60#include <kcmultidialog.h> 70#include <kcmultidialog.h>
61#include <kdebug.h> 71#include <kdebug.h>
62#include <kdeversion.h> 72#include <kdeversion.h>
63#include <kkeydialog.h> 73#include <kkeydialog.h>
64#include <kmessagebox.h> 74#include <kmessagebox.h>
65#include <kprinter.h> 75#include <kprinter.h>
66#include <kprotocolinfo.h> 76#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 77#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 78#include <kstandarddirs.h>
69#include <ktempfile.h> 79#include <ktempfile.h>
70#include <kxmlguiclient.h> 80#include <kxmlguiclient.h>
71#include <kaboutdata.h> 81#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 82#include <libkdepim/categoryselectdialog.h>
73 83
74#include "addresseeutil.h" 84#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 85#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 86#include "extensionmanager.h"
77#include "kstdaction.h" 87#include "kstdaction.h"
78#include "kaddressbookservice.h" 88#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 89#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 90#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 91#else // KAB_EMBEDDED
82 92
83#include <kapplication.h> 93#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 94#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 95#include "kaddressbookmain.h"
86#include "kactioncollection.h" 96#include "kactioncollection.h"
87#include "addresseedialog.h" 97#include "addresseedialog.h"
88//US 98//US
89#include <addresseeview.h> 99#include <addresseeview.h>
90 100
91#include <qapp.h> 101#include <qapplication.h>
92#include <qmenubar.h> 102#include <qmenubar.h>
93//#include <qtoolbar.h> 103//#include <qtoolbar.h>
94#include <qmessagebox.h> 104#include <qmessagebox.h>
95#include <kdebug.h> 105#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 106#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 107#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 108#include <ktoolbar.h>
99#include <kprefsdialog.h> 109#include <kprefsdialog.h>
100 110
101 111
102//#include <qlabel.h> 112//#include <qlabel.h>
103 113
104 114
105#ifndef DESKTOP_VERSION 115#ifndef DESKTOP_VERSION
106#include <qpe/ir.h> 116#include <qpe/ir.h>
107#include <qpe/qpemenubar.h> 117#include <qpe/qpemenubar.h>
108#include <qtopia/qcopenvelope_qws.h> 118#include <qtopia/qcopenvelope_qws.h>
109#else 119#else
110 120
111#include <qmenubar.h> 121#include <qmenubar.h>
112#endif 122#endif
113 123
114#endif // KAB_EMBEDDED 124#endif // KAB_EMBEDDED
115#include "kcmconfigs/kcmkabconfig.h" 125#include "kcmconfigs/kcmkabconfig.h"
116#include "kcmconfigs/kcmkdepimconfig.h" 126#include "kcmconfigs/kcmkdepimconfig.h"
117#include "kpimglobalprefs.h" 127#include "kpimglobalprefs.h"
118#include "externalapphandler.h" 128#include "externalapphandler.h"
119#include "xxportselectdialog.h" 129#include "xxportselectdialog.h"
120 130
121 131
122#include <kresources/selectdialog.h> 132#include <kresources/selectdialog.h>
123#include <kmessagebox.h> 133#include <kmessagebox.h>
124 134
125#include <picture.h> 135#include <picture.h>
126#include <resource.h> 136#include <resource.h>
127 137
128//US#include <qsplitter.h> 138//US#include <qsplitter.h>
129#include <qmap.h> 139#include <qmap.h>
130#include <qdir.h> 140#include <qdir.h>
131#include <qfile.h> 141#include <qfile.h>
132#include <qvbox.h> 142#include <q3vbox.h>
133#include <qlayout.h> 143#include <qlayout.h>
134#include <qclipboard.h> 144#include <qclipboard.h>
135#include <qtextstream.h> 145#include <q3textstream.h>
136#include <qradiobutton.h> 146#include <qradiobutton.h>
137#include <qbuttongroup.h> 147#include <q3buttongroup.h>
138 148
139#include <libkdepim/categoryselectdialog.h> 149#include <libkdepim/categoryselectdialog.h>
140#include <libkdepim/categoryeditdialog.h> 150#include <libkdepim/categoryeditdialog.h>
141#include <kabc/vcardconverter.h> 151#include <kabc/vcardconverter.h>
142 152
143 153
144#include "addresseeutil.h" 154#include "addresseeutil.h"
145#include "undocmds.h" 155#include "undocmds.h"
146#include "addresseeeditordialog.h" 156#include "addresseeeditordialog.h"
147#include "viewmanager.h" 157#include "viewmanager.h"
148#include "details/detailsviewcontainer.h" 158#include "details/detailsviewcontainer.h"
149#include "kabprefs.h" 159#include "kabprefs.h"
150#include "xxportmanager.h" 160#include "xxportmanager.h"
151#include "incsearchwidget.h" 161#include "incsearchwidget.h"
152#include "jumpbuttonbar.h" 162#include "jumpbuttonbar.h"
153#include "extensionmanager.h" 163#include "extensionmanager.h"
154#include "addresseeconfig.h" 164#include "addresseeconfig.h"
155#include "nameeditdialog.h" 165#include "nameeditdialog.h"
156#include <kcmultidialog.h> 166#include <kcmultidialog.h>
157 167
158#ifdef _WIN32_ 168#ifdef _WIN32_
159#ifdef _OL_IMPORT_ 169#ifdef _OL_IMPORT_
160#include "kaimportoldialog.h" 170#include "kaimportoldialog.h"
161#include <libkdepim/ol_access.h> 171#include <libkdepim/ol_access.h>
162#endif 172#endif
163#else 173#else
164#include <unistd.h> 174#include <unistd.h>
165#endif 175#endif
166// sync includes 176// sync includes
167#include <libkdepim/ksyncprofile.h> 177#include <libkdepim/ksyncprofile.h>
168#include <libkdepim/ksyncprefsdialog.h> 178#include <libkdepim/ksyncprefsdialog.h>
169 179
170 180
171class KABCatPrefs : public QDialog 181class KABCatPrefs : public QDialog
172{ 182{
173 public: 183 public:
174 KABCatPrefs( QWidget *parent=0, const char *name=0 ) : 184 KABCatPrefs( QWidget *parent=0, const char *name=0 ) :
175 QDialog( parent, name, true ) 185 QDialog( parent, name, true )
176 { 186 {
177 setCaption( i18n("Manage new Categories") ); 187 setCaption( i18n("Manage new Categories") );
178 QVBoxLayout* lay = new QVBoxLayout( this ); 188 Q3VBoxLayout* lay = new Q3VBoxLayout( this );
179 lay->setSpacing( 3 ); 189 lay->setSpacing( 3 );
180 lay->setMargin( 3 ); 190 lay->setMargin( 3 );
181 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 191 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
182 lay->addWidget( lab ); 192 lay->addWidget( lab );
183 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 193 Q3ButtonGroup* format = new Q3ButtonGroup( 1, Qt::Horizontal, i18n("New categories not in list:"), this );
184 lay->addWidget( format ); 194 lay->addWidget( format );
185 format->setExclusive ( true ) ; 195 format->setExclusive ( true ) ;
186 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 196 addCatBut = new QRadioButton(i18n("Add to category list"), format );
187 new QRadioButton(i18n("Remove from addressees"), format ); 197 new QRadioButton(i18n("Remove from addressees"), format );
188 addCatBut->setChecked( true ); 198 addCatBut->setChecked( true );
189 QPushButton * ok = new QPushButton( i18n("OK"), this ); 199 QPushButton * ok = new QPushButton( i18n("OK"), this );
190 lay->addWidget( ok ); 200 lay->addWidget( ok );
191 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 201 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
192 lay->addWidget( cancel ); 202 lay->addWidget( cancel );
193 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 203 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
194 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 204 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
195 resize( 200, 200 ); 205 resize( 200, 200 );
196 } 206 }
197 207
198 bool addCat() { return addCatBut->isChecked(); } 208 bool addCat() { return addCatBut->isChecked(); }
199private: 209private:
200 QRadioButton* addCatBut; 210 QRadioButton* addCatBut;
201}; 211};
202 212
203class KABFormatPrefs : public QDialog 213class KABFormatPrefs : public QDialog
204{ 214{
205 public: 215 public:
206 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : 216 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) :
207 QDialog( parent, name, true ) 217 QDialog( parent, name, true )
208 { 218 {
209 setCaption( i18n("Set formatted name") ); 219 setCaption( i18n("Set formatted name") );
210 QVBoxLayout* lay = new QVBoxLayout( this ); 220 Q3VBoxLayout* lay = new Q3VBoxLayout( this );
211 lay->setSpacing( 3 ); 221 lay->setSpacing( 3 );
212 lay->setMargin( 3 ); 222 lay->setMargin( 3 );
213 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); 223 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this );
214 lay->addWidget( lab ); 224 lay->addWidget( lab );
215 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); 225 Q3ButtonGroup* format = new Q3ButtonGroup( 1, Qt::Horizontal, i18n("Set formatted name to:"), this );
216 lay->addWidget( format ); 226 lay->addWidget( format );
217 format->setExclusive ( true ) ; 227 format->setExclusive ( true ) ;
218 simple = new QRadioButton(i18n("Simple: James Bond"), format ); 228 simple = new QRadioButton(i18n("Simple: James Bond"), format );
219 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); 229 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format );
220 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); 230 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format );
221 company = new QRadioButton(i18n("Organization: MI6"), format ); 231 company = new QRadioButton(i18n("Organization: MI6"), format );
222 simple->setChecked( true ); 232 simple->setChecked( true );
223 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); 233 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this);
224 lay->addWidget( setCompany ); 234 lay->addWidget( setCompany );
225 QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); 235 QPushButton * ok = new QPushButton( i18n("Select contact list"), this );
226 lay->addWidget( ok ); 236 lay->addWidget( ok );
227 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 237 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
228 lay->addWidget( cancel ); 238 lay->addWidget( cancel );
229 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 239 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
230 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 240 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
231 //resize( 200, 200 ); 241 //resize( 200, 200 );
232 242
233 } 243 }
234public: 244public:
235 QRadioButton* simple, *full, *reverse, *company; 245 QRadioButton* simple, *full, *reverse, *company;
236 QCheckBox* setCompany; 246 QCheckBox* setCompany;
237}; 247};
238 248
239 249
240 250
241class KAex2phonePrefs : public QDialog 251class KAex2phonePrefs : public QDialog
242{ 252{
243 public: 253 public:
244 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 254 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
245 QDialog( parent, name, true ) 255 QDialog( parent, name, true )
246 { 256 {
247 setCaption( i18n("Export to phone options") ); 257 setCaption( i18n("Export to phone options") );
248 QVBoxLayout* lay = new QVBoxLayout( this ); 258 Q3VBoxLayout* lay = new Q3VBoxLayout( this );
249 lay->setSpacing( 3 ); 259 lay->setSpacing( 3 );
250 lay->setMargin( 3 ); 260 lay->setMargin( 3 );
251 QLabel *lab; 261 QLabel *lab;
252 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 262 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
253 lab->setAlignment (AlignHCenter ); 263 lab->setAlignment (Qt::AlignHCenter );
254 QHBox* temphb; 264 Q3HBox* temphb;
255 temphb = new QHBox( this ); 265 temphb = new Q3HBox( this );
256 new QLabel( i18n("I/O device: "), temphb ); 266 new QLabel( i18n("I/O device: "), temphb );
257 mPhoneDevice = new QLineEdit( temphb); 267 mPhoneDevice = new QLineEdit( temphb);
258 lay->addWidget( temphb ); 268 lay->addWidget( temphb );
259 temphb = new QHBox( this ); 269 temphb = new Q3HBox( this );
260 new QLabel( i18n("Connection: "), temphb ); 270 new QLabel( i18n("Connection: "), temphb );
261 mPhoneConnection = new QLineEdit( temphb); 271 mPhoneConnection = new QLineEdit( temphb);
262 lay->addWidget( temphb ); 272 lay->addWidget( temphb );
263 temphb = new QHBox( this ); 273 temphb = new Q3HBox( this );
264 new QLabel( i18n("Model(opt.): "), temphb ); 274 new QLabel( i18n("Model(opt.): "), temphb );
265 mPhoneModel = new QLineEdit( temphb); 275 mPhoneModel = new QLineEdit( temphb);
266 lay->addWidget( temphb ); 276 lay->addWidget( temphb );
267 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 277 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
268 // lay->addWidget( mWriteToSim ); 278 // lay->addWidget( mWriteToSim );
269 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 279 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
270 lab->setAlignment (AlignHCenter); 280 lab->setAlignment (Qt::AlignHCenter);
271 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 281 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
272 lay->addWidget( ok ); 282 lay->addWidget( ok );
273 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 283 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
274 lay->addWidget( cancel ); 284 lay->addWidget( cancel );
275 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 285 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
276 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 286 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
277 resize( 220, 240 ); 287 resize( 220, 240 );
278 288
279 } 289 }
280 290
281public: 291public:
282 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 292 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
283 QCheckBox* mWriteToSim; 293 QCheckBox* mWriteToSim;
284}; 294};
285 295
286 296
287bool pasteWithNewUid = true; 297bool pasteWithNewUid = true;
288 298
289#ifdef KAB_EMBEDDED 299#ifdef KAB_EMBEDDED
290KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 300KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
291 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 301 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
292 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 302 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
293 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 303 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
294#else //KAB_EMBEDDED 304#else //KAB_EMBEDDED
295KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 305KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
296 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 306 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
297 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 307 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
298 mReadWrite( readWrite ), mModified( false ) 308 mReadWrite( readWrite ), mModified( false )
299#endif //KAB_EMBEDDED 309#endif //KAB_EMBEDDED
300{ 310{
301 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 311 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
302 // syncManager->setBlockSave(false); 312 // syncManager->setBlockSave(false);
303 mIncSearchWidget = 0; 313 mIncSearchWidget = 0;
304 mMiniSplitter = 0; 314 mMiniSplitter = 0;
305 mExtensionBarSplitter = 0; 315 mExtensionBarSplitter = 0;
306 mIsPart = !parent->inherits( "KAddressBookMain" ); 316 mIsPart = !parent->inherits( "KAddressBookMain" );
307 mAddressBook = KABC::StdAddressBook::selfNoLoad(); 317 mAddressBook = KABC::StdAddressBook::selfNoLoad();
308 KABC::StdAddressBook::setAutomaticSave( false ); 318 KABC::StdAddressBook::setAutomaticSave( false );
309 319
310#ifndef KAB_EMBEDDED 320#ifndef KAB_EMBEDDED
311 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 321 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
312#endif //KAB_EMBEDDED 322#endif //KAB_EMBEDDED
313 323
314 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 324 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
315 SLOT( addressBookChanged() ) ); 325 SLOT( addressBookChanged() ) );
316 326
317#if 0 327#if 0
318 // LR moved to addressbook init method 328 // LR moved to addressbook init method
319 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 329 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
320 "X-Department", "KADDRESSBOOK" ); 330 "X-Department", "KADDRESSBOOK" );
321 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 331 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
322 "X-Profession", "KADDRESSBOOK" ); 332 "X-Profession", "KADDRESSBOOK" );
323 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 333 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
324 "X-AssistantsName", "KADDRESSBOOK" ); 334 "X-AssistantsName", "KADDRESSBOOK" );
325 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 335 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
326 "X-ManagersName", "KADDRESSBOOK" ); 336 "X-ManagersName", "KADDRESSBOOK" );
327 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 337 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
328 "X-SpousesName", "KADDRESSBOOK" ); 338 "X-SpousesName", "KADDRESSBOOK" );
329 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 339 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
330 "X-Office", "KADDRESSBOOK" ); 340 "X-Office", "KADDRESSBOOK" );
331 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 341 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
332 "X-IMAddress", "KADDRESSBOOK" ); 342 "X-IMAddress", "KADDRESSBOOK" );
333 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 343 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
334 "X-Anniversary", "KADDRESSBOOK" ); 344 "X-Anniversary", "KADDRESSBOOK" );
335 345
336 //US added this field to become compatible with Opie/qtopia addressbook 346 //US added this field to become compatible with Opie/qtopia addressbook
337 // values can be "female" or "male" or "". An empty field represents undefined. 347 // values can be "female" or "male" or "". An empty field represents undefined.
338 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 348 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
339 "X-Gender", "KADDRESSBOOK" ); 349 "X-Gender", "KADDRESSBOOK" );
340 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 350 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
341 "X-Children", "KADDRESSBOOK" ); 351 "X-Children", "KADDRESSBOOK" );
342 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 352 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
343 "X-FreeBusyUrl", "KADDRESSBOOK" ); 353 "X-FreeBusyUrl", "KADDRESSBOOK" );
344#endif 354#endif
345 initGUI(); 355 initGUI();
346 356
347 mIncSearchWidget->setFocus(); 357 mIncSearchWidget->setFocus();
348 358
349 359
350 connect( mViewManager, SIGNAL( selected( const QString& ) ), 360 connect( mViewManager, SIGNAL( selected( const QString& ) ),
351 SLOT( setContactSelected( const QString& ) ) ); 361 SLOT( setContactSelected( const QString& ) ) );
352 connect( mViewManager, SIGNAL( executed( const QString& ) ), 362 connect( mViewManager, SIGNAL( executed( const QString& ) ),
353 SLOT( executeContact( const QString& ) ) ); 363 SLOT( executeContact( const QString& ) ) );
354 364
355 connect( mViewManager, SIGNAL( deleteRequest( ) ), 365 connect( mViewManager, SIGNAL( deleteRequest( ) ),
356 SLOT( deleteContacts( ) ) ); 366 SLOT( deleteContacts( ) ) );
357 connect( mViewManager, SIGNAL( modified() ), 367 connect( mViewManager, SIGNAL( modified() ),
358 SLOT( setModified() ) ); 368 SLOT( setModified() ) );
359 369
360 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 370 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
361 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 371 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
362 372
363 connect( mXXPortManager, SIGNAL( modified() ), 373 connect( mXXPortManager, SIGNAL( modified() ),
364 SLOT( setModified() ) ); 374 SLOT( setModified() ) );
365 375
366 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 376 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
367 SLOT( incrementalSearchJump( const QString& ) ) ); 377 SLOT( incrementalSearchJump( const QString& ) ) );
368 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 378 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
369 mJumpButtonBar, SLOT( recreateButtons() ) ); 379 mJumpButtonBar, SLOT( recreateButtons() ) );
370 380
371 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 381 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
372 SLOT( sendMail( const QString& ) ) ); 382 SLOT( sendMail( const QString& ) ) );
373 383
374 384
375 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 385 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
376 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&))); 386 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&)));
377 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 387 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
378 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 388 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
379 connect( ExternalAppHandler::instance(), SIGNAL (doRingSync()),this, SLOT( doRingSync())); 389 connect( ExternalAppHandler::instance(), SIGNAL (doRingSync()),this, SLOT( doRingSync()));
380 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog())); 390 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog()));
381 391
382 392
383#ifndef KAB_EMBEDDED 393#ifndef KAB_EMBEDDED
384 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 394 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
385 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 395 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
386 396
387 connect( mDetails, SIGNAL( browse( const QString& ) ), 397 connect( mDetails, SIGNAL( browse( const QString& ) ),
388 SLOT( browse( const QString& ) ) ); 398 SLOT( browse( const QString& ) ) );
389 399
390 400
391 mAddressBookService = new KAddressBookService( this ); 401 mAddressBookService = new KAddressBookService( this );
392 402
393#endif //KAB_EMBEDDED 403#endif //KAB_EMBEDDED
394 404
395 mMessageTimer = new QTimer( this ); 405 mMessageTimer = new QTimer( this );
396 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 406 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
397 mEditorDialog = 0; 407 mEditorDialog = 0;
398 createAddresseeEditorDialog( this ); 408 createAddresseeEditorDialog( this );
399 setModified( false ); 409 setModified( false );
400 mBRdisabled = false; 410 mBRdisabled = false;
401#ifndef DESKTOP_VERSION 411#ifndef DESKTOP_VERSION
402 infrared = 0; 412 infrared = 0;
403#endif 413#endif
404 //toggleBeamReceive( ); 414 //toggleBeamReceive( );
405 mMainWindow->toolBar()->show(); 415 mMainWindow->toolBar()->show();
406 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 416 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
407 //QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 417 //QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
408 QTimer::singleShot( 100, this, SLOT ( loadDataAfterStart() )); 418 QTimer::singleShot( 100, this, SLOT ( loadDataAfterStart() ));
409} 419}
410void KABCore::receiveStart( const QCString& cmsg, const QByteArray& data ) 420void KABCore::receiveStart( const Q3CString& cmsg, const QByteArray& data )
411{ 421{
412 //qDebug("KO: QCOP start message received: %s ", cmsg.data() ); 422 //qDebug("KO: QCOP start message received: %s ", cmsg.data() );
413 mCStringMess = cmsg; 423 mCStringMess = cmsg;
414 mByteData = data; 424 mByteData = data;
415} 425}
416 426
417void KABCore::loadDataAfterStart() 427void KABCore::loadDataAfterStart()
418{ 428{
419 //qDebug("KABCore::loadDataAfterStart() "); 429 //qDebug("KABCore::loadDataAfterStart() ");
420 ((StdAddressBook*)mAddressBook)->init( true ); 430 ((StdAddressBook*)mAddressBook)->init( true );
421 mViewManager->refreshView(); 431 mViewManager->refreshView();
422 432
423#ifndef DESKTOP_VERSION 433#ifndef DESKTOP_VERSION
424 disconnect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT (receiveStart ( const QCString &, const QByteArray & ))); 434 disconnect(qApp, SIGNAL (appMessage ( const Q3CString &, const QByteArray & )), this, SLOT (receiveStart ( const Q3CString &, const QByteArray & )));
425 435
426 QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 436 QObject::connect(qApp, SIGNAL (appMessage ( const Q3CString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const Q3CString &, const QByteArray & )));
427 if ( !mCStringMess.isEmpty() ) 437 if ( !mCStringMess.isEmpty() )
428 ExternalAppHandler::instance()->appMessage( mCStringMess, mByteData ); 438 ExternalAppHandler::instance()->appMessage( mCStringMess, mByteData );
429#endif 439#endif
430 // QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 440 // QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
431 setCaptionBack(); 441 setCaptionBack();
432} 442}
433void KABCore::updateToolBar() 443void KABCore::updateToolBar()
434{ 444{
435 static int iii = 0; 445 static int iii = 0;
436 ++iii; 446 ++iii;
437 mMainWindow->toolBar()->repaintMe(); 447 mMainWindow->toolBar()->repaintMe();
438 if ( iii < 4 ) 448 if ( iii < 4 )
439 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); 449 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar()));
440} 450}
441KABCore::~KABCore() 451KABCore::~KABCore()
442{ 452{
443 // save(); 453 // save();
444 //saveSettings(); 454 //saveSettings();
445 //KABPrefs::instance()->writeConfig(); 455 //KABPrefs::instance()->writeConfig();
446 delete AddresseeConfig::instance(); 456 delete AddresseeConfig::instance();
447 mAddressBook = 0; 457 mAddressBook = 0;
448 KABC::StdAddressBook::close(); 458 KABC::StdAddressBook::close();
449 459
450 delete syncManager; 460 delete syncManager;
451#ifndef DESKTOP_VERSION 461#ifndef DESKTOP_VERSION
452 if ( infrared ) 462 if ( infrared )
453 delete infrared; 463 delete infrared;
454#endif 464#endif
455} 465}
456void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 466void KABCore::receive( const Q3CString& cmsg, const QByteArray& data )
457{ 467{
458 //qDebug("KA: QCOP message received: %s ", cmsg.data() ); 468 //qDebug("KA: QCOP message received: %s ", cmsg.data() );
459 if ( cmsg == "setDocument(QString)" ) { 469 if ( cmsg == "setDocument(QString)" ) {
460 QDataStream stream( data, IO_ReadOnly ); 470 QDataStream stream( const_cast<QByteArray*>(&data), QIODevice::ReadOnly );
461 QString fileName; 471 QString fileName;
462 stream >> fileName; 472 stream >> fileName;
463 recieve( fileName ); 473 recieve( fileName );
464 return; 474 return;
465 } 475 }
466} 476}
467void KABCore::toggleBeamReceive( ) 477void KABCore::toggleBeamReceive( )
468{ 478{
469 if ( mBRdisabled ) 479 if ( mBRdisabled )
470 return; 480 return;
471#ifndef DESKTOP_VERSION 481#ifndef DESKTOP_VERSION
472 if ( infrared ) { 482 if ( infrared ) {
473 qDebug("KA: AB disable BeamReceive "); 483 qDebug("KA: AB disable BeamReceive ");
474 delete infrared; 484 delete infrared;
475 infrared = 0; 485 infrared = 0;
476 mActionBR->setChecked(false); 486 mActionBR->setChecked(false);
477 return; 487 return;
478 } 488 }
479 qDebug("KA: AB enable BeamReceive "); 489 qDebug("KA: AB enable BeamReceive ");
480 mActionBR->setChecked(true); 490 mActionBR->setChecked(true);
481 491
482 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 492 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
483 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 493 QObject::connect( infrared, SIGNAL (received ( const Q3CString &, const QByteArray & )),this, SLOT(receive( const Q3CString&, const QByteArray& )));
484#endif 494#endif
485} 495}
486 496
487 497
488void KABCore::disableBR(bool b) 498void KABCore::disableBR(bool b)
489{ 499{
490#ifndef DESKTOP_VERSION 500#ifndef DESKTOP_VERSION
491 if ( b ) { 501 if ( b ) {
492 if ( infrared ) { 502 if ( infrared ) {
493 toggleBeamReceive( ); 503 toggleBeamReceive( );
494 } 504 }
495 mBRdisabled = true; 505 mBRdisabled = true;
496 } else { 506 } else {
497 if ( mBRdisabled ) { 507 if ( mBRdisabled ) {
498 mBRdisabled = false; 508 mBRdisabled = false;
499 //toggleBeamReceive( ); 509 //toggleBeamReceive( );
500 } 510 }
501 } 511 }
502#endif 512#endif
503 513
504} 514}
505void KABCore::recieve( QString fn ) 515void KABCore::recieve( QString fn )
506{ 516{
507 //qDebug("KABCore::recieve "); 517 //qDebug("KABCore::recieve ");
508 int count = mAddressBook->importFromFile( fn, true ); 518 int count = mAddressBook->importFromFile( fn, true );
509 if ( count ) 519 if ( count )
510 setModified( true ); 520 setModified( true );
511 mViewManager->refreshView(); 521 mViewManager->refreshView();
512 message(i18n("%1 contact(s) received!").arg( count )); 522 message(i18n("%1 contact(s) received!").arg( count ));
513 topLevelWidget()->showMaximized(); 523 topLevelWidget()->showMaximized();
514 topLevelWidget()->raise(); 524 topLevelWidget()->raise();
515} 525}
516void KABCore::restoreSettings() 526void KABCore::restoreSettings()
517{ 527{
518 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 528 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
519 529
520 bool state; 530 bool state;
521 531
522 if (mMultipleViewsAtOnce) 532 if (mMultipleViewsAtOnce)
523 state = KABPrefs::instance()->mDetailsPageVisible; 533 state = KABPrefs::instance()->mDetailsPageVisible;
524 else 534 else
525 state = false; 535 state = false;
526 536
527 mActionDetails->setChecked( state ); 537 mActionDetails->setChecked( state );
528 setDetailsVisible( state ); 538 setDetailsVisible( state );
529 539
530 state = KABPrefs::instance()->mJumpButtonBarVisible; 540 state = KABPrefs::instance()->mJumpButtonBarVisible;
531 541
532 mActionJumpBar->setChecked( state ); 542 mActionJumpBar->setChecked( state );
533 setJumpButtonBarVisible( state ); 543 setJumpButtonBarVisible( state );
534/*US 544/*US
535 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 545 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
536 if ( splitterSize.count() == 0 ) { 546 if ( splitterSize.count() == 0 ) {
537 splitterSize.append( width() / 2 ); 547 splitterSize.append( width() / 2 );
538 splitterSize.append( width() / 2 ); 548 splitterSize.append( width() / 2 );
539 } 549 }
540 mMiniSplitter->setSizes( splitterSize ); 550 mMiniSplitter->setSizes( splitterSize );
541 if ( mExtensionBarSplitter ) { 551 if ( mExtensionBarSplitter ) {
542 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 552 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
543 if ( splitterSize.count() == 0 ) { 553 if ( splitterSize.count() == 0 ) {
544 splitterSize.append( width() / 2 ); 554 splitterSize.append( width() / 2 );
545 splitterSize.append( width() / 2 ); 555 splitterSize.append( width() / 2 );
546 } 556 }
547 mExtensionBarSplitter->setSizes( splitterSize ); 557 mExtensionBarSplitter->setSizes( splitterSize );
548 558
549 } 559 }
550*/ 560*/
551 mViewManager->restoreSettings(); 561 mViewManager->restoreSettings();
552 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 562 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
553 mExtensionManager->restoreSettings(); 563 mExtensionManager->restoreSettings();
554#ifdef DESKTOP_VERSION 564#ifdef DESKTOP_VERSION
555 int wid = width(); 565 int wid = width();
556 if ( wid < 10 ) 566 if ( wid < 10 )
557 wid = 400; 567 wid = 400;
558#else 568#else
559 int wid = QApplication::desktop()->width(); 569 int wid = QApplication::desktop()->width();
560 if ( wid < 640 ) 570 if ( wid < 640 )
561 wid = QApplication::desktop()->height(); 571 wid = QApplication::desktop()->height();
562#endif 572#endif
563 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 573 Q3ValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
564 if ( true /*splitterSize.count() == 0*/ ) { 574 if ( true /*splitterSize.count() == 0*/ ) {
565 splitterSize.append( wid / 2 ); 575 splitterSize.append( wid / 2 );
566 splitterSize.append( wid / 2 ); 576 splitterSize.append( wid / 2 );
567 } 577 }
568 mMiniSplitter->setSizes( splitterSize ); 578 mMiniSplitter->setSizes( splitterSize );
569 if ( mExtensionBarSplitter ) { 579 if ( mExtensionBarSplitter ) {
570 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 580 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
571 if ( true /*splitterSize.count() == 0*/ ) { 581 if ( true /*splitterSize.count() == 0*/ ) {
572 splitterSize.append( wid / 2 ); 582 splitterSize.append( wid / 2 );
573 splitterSize.append( wid / 2 ); 583 splitterSize.append( wid / 2 );
574 } 584 }
575 mExtensionBarSplitter->setSizes( splitterSize ); 585 mExtensionBarSplitter->setSizes( splitterSize );
576 586
577 } 587 }
578#ifdef DESKTOP_VERSION 588#ifdef DESKTOP_VERSION
579 KConfig *config = KABPrefs::instance()->getConfig(); 589 KConfig *config = KABPrefs::instance()->getConfig();
580 config->setGroup("WidgetLayout"); 590 config->setGroup("WidgetLayout");
581 QStringList list; 591 QStringList list;
582 list = config->readListEntry("MainLayout"); 592 list = config->readListEntry("MainLayout");
583 int x,y,w,h; 593 int x,y,w,h;
584 if ( ! list.isEmpty() ) { 594 if ( ! list.isEmpty() ) {
585 x = list[0].toInt(); 595 x = list[0].toInt();
586 y = list[1].toInt(); 596 y = list[1].toInt();
587 w = list[2].toInt(); 597 w = list[2].toInt();
588 h = list[3].toInt(); 598 h = list[3].toInt();
589 KApplication::testCoords( &x,&y,&w,&h ); 599 KApplication::testCoords( &x,&y,&w,&h );
590 topLevelWidget()->setGeometry(x,y,w,h); 600 topLevelWidget()->setGeometry(x,y,w,h);
591 601
592 } else { 602 } else {
593 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 603 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
594 } 604 }
595#endif 605#endif
596} 606}
597 607
598void KABCore::saveSettings() 608void KABCore::saveSettings()
599{ 609{
600 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 610 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
601 if ( mExtensionBarSplitter ) 611 if ( mExtensionBarSplitter )
602 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 612 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
603 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 613 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
604 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 614 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
605#ifndef KAB_EMBEDDED 615#ifndef KAB_EMBEDDED
606 616
607 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 617 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
608 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 618 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
609#endif //KAB_EMBEDDED 619#endif //KAB_EMBEDDED
610 mExtensionManager->saveSettings(); 620 mExtensionManager->saveSettings();
611 mViewManager->saveSettings(); 621 mViewManager->saveSettings();
612 622
613 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 623 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
614 624
615 KABPrefs::instance()->writeConfig(); 625 KABPrefs::instance()->writeConfig();
616 //qDebug("KA: KABCore::saveSettings() "); 626 //qDebug("KA: KABCore::saveSettings() ");
617} 627}
618 628
619KABC::AddressBook *KABCore::addressBook() const 629KABC::AddressBook *KABCore::addressBook() const
620{ 630{
621 return mAddressBook; 631 return mAddressBook;
622} 632}
623 633
624KConfig *KABCore::config() 634KConfig *KABCore::config()
625{ 635{
626#ifndef KAB_EMBEDDED 636#ifndef KAB_EMBEDDED
627 return KABPrefs::instance()->config(); 637 return KABPrefs::instance()->config();
628#else //KAB_EMBEDDED 638#else //KAB_EMBEDDED
629 return KABPrefs::instance()->getConfig(); 639 return KABPrefs::instance()->getConfig();
630#endif //KAB_EMBEDDED 640#endif //KAB_EMBEDDED
631} 641}
632 642
633KActionCollection *KABCore::actionCollection() const 643KActionCollection *KABCore::actionCollection() const
634{ 644{
635 return mGUIClient->actionCollection(); 645 return mGUIClient->actionCollection();
636} 646}
637 647
638KABC::Field *KABCore::currentSearchField() const 648KABC::Field *KABCore::currentSearchField() const
639{ 649{
640 if (mIncSearchWidget) 650 if (mIncSearchWidget)
641 return mIncSearchWidget->currentField(); 651 return mIncSearchWidget->currentField();
642 else 652 else
643 return 0; 653 return 0;
644} 654}
645 655
646QStringList KABCore::selectedUIDs() const 656QStringList KABCore::selectedUIDs() const
647{ 657{
648 return mViewManager->selectedUids(); 658 return mViewManager->selectedUids();
649} 659}
650 660
651KABC::Resource *KABCore::requestResource( QWidget *parent ) 661KABC::Resource *KABCore::requestResource( QWidget *parent )
652{ 662{
653 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 663 Q3PtrList<KABC::Resource> kabcResources = addressBook()->resources();
654 664
655 QPtrList<KRES::Resource> kresResources; 665 Q3PtrList<KRES::Resource> kresResources;
656 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 666 Q3PtrListIterator<KABC::Resource> resIt( kabcResources );
657 KABC::Resource *resource; 667 KABC::Resource *resource;
658 while ( ( resource = resIt.current() ) != 0 ) { 668 while ( ( resource = resIt.current() ) != 0 ) {
659 ++resIt; 669 ++resIt;
660 if ( !resource->readOnly() ) { 670 if ( !resource->readOnly() ) {
661 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 671 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
662 if ( res ) 672 if ( res )
663 kresResources.append( res ); 673 kresResources.append( res );
664 } 674 }
665 } 675 }
666 676
667 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 677 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
668 return static_cast<KABC::Resource*>( res ); 678 return static_cast<KABC::Resource*>( res );
669} 679}
670 680
671#ifndef KAB_EMBEDDED 681#ifndef KAB_EMBEDDED
672KAboutData *KABCore::createAboutData() 682KAboutData *KABCore::createAboutData()
673#else //KAB_EMBEDDED 683#else //KAB_EMBEDDED
674void KABCore::createAboutData() 684void KABCore::createAboutData()
675#endif //KAB_EMBEDDED 685#endif //KAB_EMBEDDED
676{ 686{
677 687
678 688
679 QString version; 689 QString version;
680#include <../version> 690#include <../version>
681 QMessageBox::about( this, "About KAddressbook/Pi", 691 QMessageBox::about( this, "About KAddressbook/Pi",
682 "KAddressbook/Platform-independent\n" 692 "KAddressbook/Platform-independent\n"
683 "(KA/Pi) " +version + " - " + 693 "(KA/Pi) " +version + " - " +
684#ifdef DESKTOP_VERSION 694#ifdef DESKTOP_VERSION
685 "Desktop Edition\n" 695 "Desktop Edition\n"
686#else 696#else
687 "PDA-Edition\n" 697 "PDA-Edition\n"
688 "for: Zaurus 5500 / 7x0 / 8x0\n" 698 "for: Zaurus 5500 / 7x0 / 8x0\n"
689#endif 699#endif
690 700
691 "(c) 2004 Ulf Schenk\n" 701 "(c) 2004 Ulf Schenk\n"
692 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n" 702 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n"
693 "(c) 1997-2003, The KDE PIM Team\n" 703 "(c) 1997-2003, The KDE PIM Team\n"
694 "Tobias Koenig Maintainer\n" 704 "Tobias Koenig Maintainer\n"
695 "Don Sanders Original author\n" 705 "Don Sanders Original author\n"
696 "Cornelius Schumacher Co-maintainer\n" 706 "Cornelius Schumacher Co-maintainer\n"
697 "Mike Pilone GUI and framework redesign\n" 707 "Mike Pilone GUI and framework redesign\n"
698 "Greg Stern DCOP interface\n" 708 "Greg Stern DCOP interface\n"
699 "Mark Westcot Contact pinning\n" 709 "Mark Westcot Contact pinning\n"
700 "Michel Boyer de la Giroday LDAP Lookup\n" 710 "Michel Boyer de la Giroday LDAP Lookup\n"
701 "Steffen Hansen LDAP Lookup" 711 "Steffen Hansen LDAP Lookup"
702#ifdef _WIN32_ 712#ifdef _WIN32_
703 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 713 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
704#endif 714#endif
705 ); 715 );
706} 716}
707 717
708void KABCore::setContactSelected( const QString &uid ) 718void KABCore::setContactSelected( const QString &uid )
709{ 719{
710 KABC::Addressee addr = mAddressBook->findByUid( uid ); 720 KABC::Addressee addr = mAddressBook->findByUid( uid );
711 if ( !mDetails->isHidden() ) 721 if ( !mDetails->isHidden() )
712 mDetails->setAddressee( addr ); 722 mDetails->setAddressee( addr );
713 723
714 if ( !addr.isEmpty() ) { 724 if ( !addr.isEmpty() ) {
715 emit contactSelected( addr.formattedName() ); 725 emit contactSelected( addr.formattedName() );
716 KABC::Picture pic = addr.photo(); 726 KABC::Picture pic = addr.photo();
717 if ( pic.isIntern() ) { 727 if ( pic.isIntern() ) {
718//US emit contactSelected( pic.data() ); 728//US emit contactSelected( pic.data() );
719//US instead use: 729//US instead use:
720 QPixmap px; 730 QPixmap px;
721 if (pic.data().isNull() != true) 731 if (pic.data().isNull() != true)
722 { 732 {
723 px.convertFromImage(pic.data()); 733 px.convertFromImage(pic.data());
724 } 734 }
725 735
726 emit contactSelected( px ); 736 emit contactSelected( px );
727 } 737 }
728 } 738 }
729 739
730 740
731 mExtensionManager->setSelectionChanged(); 741 mExtensionManager->setSelectionChanged();
732 742
733 // update the actions 743 // update the actions
734 bool selected = !uid.isEmpty(); 744 bool selected = !uid.isEmpty();
735 745
736 if ( mReadWrite ) { 746 if ( mReadWrite ) {
737 mActionCut->setEnabled( selected ); 747 mActionCut->setEnabled( selected );
738 mActionPaste->setEnabled( selected ); 748 mActionPaste->setEnabled( selected );
739 } 749 }
740 750
741 mActionCopy->setEnabled( selected ); 751 mActionCopy->setEnabled( selected );
742 mActionDelete->setEnabled( selected ); 752 mActionDelete->setEnabled( selected );
743 mActionEditAddressee->setEnabled( selected ); 753 mActionEditAddressee->setEnabled( selected );
744 mActionMail->setEnabled( selected ); 754 mActionMail->setEnabled( selected );
745 mActionMailVCard->setEnabled( selected ); 755 mActionMailVCard->setEnabled( selected );
746 //if (mActionBeam) 756 //if (mActionBeam)
747 //mActionBeam->setEnabled( selected ); 757 //mActionBeam->setEnabled( selected );
748 mActionWhoAmI->setEnabled( selected ); 758 mActionWhoAmI->setEnabled( selected );
749} 759}
750 760
751void KABCore::sendMail() 761void KABCore::sendMail()
752{ 762{
753 sendMail( mViewManager->selectedEmails().join( ", " ) ); 763 sendMail( mViewManager->selectedEmails().join( ", " ) );
754} 764}
755 765
756void KABCore::sendMail( const QString& emaillist ) 766void KABCore::sendMail( const QString& emaillist )
757{ 767{
758 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 768 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
759 if (emaillist.contains(",") > 0) 769 if (emaillist.contains(",") > 0)
760 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 770 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
761 else 771 else
762 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 772 ExternalAppHandler::instance()->mailToOneContact( emaillist );
763} 773}
764 774
765 775
766 776
767void KABCore::mailVCard() 777void KABCore::mailVCard()
768{ 778{
769 QStringList uids = mViewManager->selectedUids(); 779 QStringList uids = mViewManager->selectedUids();
770 if ( !uids.isEmpty() ) 780 if ( !uids.isEmpty() )
771 mailVCard( uids ); 781 mailVCard( uids );
772} 782}
773 783
774void KABCore::mailVCard( const QStringList& uids ) 784void KABCore::mailVCard( const QStringList& uids )
775{ 785{
776 QStringList urls; 786 QStringList urls;
777 787
778// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 788// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
779 789
780 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 790 QString dirName = "/tmp/" + KApplication::randomString( 8 );
781 791
782 792
783 793
784 QDir().mkdir( dirName, true ); 794 QDir().mkdir( dirName, true );
785 795
786 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 796 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
787 KABC::Addressee a = mAddressBook->findByUid( *it ); 797 KABC::Addressee a = mAddressBook->findByUid( *it );
788 798
789 if ( a.isEmpty() ) 799 if ( a.isEmpty() )
790 continue; 800 continue;
791 801
792 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 802 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
793 803
794 QString fileName = dirName + "/" + name; 804 QString fileName = dirName + "/" + name;
795 805
796 QFile outFile(fileName); 806 QFile outFile(fileName);
797 807
798 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 808 if ( outFile.open(QIODevice::WriteOnly) ) { // file opened successfully
799 KABC::VCardConverter converter; 809 KABC::VCardConverter converter;
800 QString vcard; 810 QString vcard;
801 811
802 converter.addresseeToVCard( a, vcard ); 812 converter.addresseeToVCard( a, vcard );
803 813
804 QTextStream t( &outFile ); // use a text stream 814 Q3TextStream t( &outFile ); // use a text stream
805 t.setEncoding( QTextStream::UnicodeUTF8 ); 815 t.setEncoding( Q3TextStream::UnicodeUTF8 );
806 t << vcard; 816 t << vcard;
807 817
808 outFile.close(); 818 outFile.close();
809 819
810 urls.append( fileName ); 820 urls.append( fileName );
811 } 821 }
812 } 822 }
813 823
814 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 824 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
815 825
816 826
817/*US 827/*US
818 kapp->invokeMailer( QString::null, QString::null, QString::null, 828 kapp->invokeMailer( QString::null, QString::null, QString::null,
819 QString::null, // subject 829 QString::null, // subject
820 QString::null, // body 830 QString::null, // body
821 QString::null, 831 QString::null,
822 urls ); // attachments 832 urls ); // attachments
823*/ 833*/
824 834
825} 835}
826 836
827/** 837/**
828 Beams the "WhoAmI contact. 838 Beams the "WhoAmI contact.
829*/ 839*/
830void KABCore::beamMySelf() 840void KABCore::beamMySelf()
831{ 841{
832 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 842 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
833 if (!a.isEmpty()) 843 if (!a.isEmpty())
834 { 844 {
835 QStringList uids; 845 QStringList uids;
836 uids << a.uid(); 846 uids << a.uid();
837 847
838 beamVCard(uids); 848 beamVCard(uids);
839 } else { 849 } else {
840 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 850 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
841 851
842 852
843 } 853 }
844} 854}
845void KABCore::updateMainWindow() 855void KABCore::updateMainWindow()
846{ 856{
847 mMainWindow->showMaximized(); 857 mMainWindow->showMaximized();
848 //mMainWindow->repaint(); 858 //mMainWindow->repaint();
849} 859}
850void KABCore::resizeEvent(QResizeEvent* e ) 860void KABCore::resizeEvent(QResizeEvent* e )
851{ 861{
852 if ( !mMiniSplitter ) { 862 if ( !mMiniSplitter ) {
853 QWidget::resizeEvent( e ); 863 QWidget::resizeEvent( e );
854 return; 864 return;
855 } 865 }
856#ifndef DESKTOP_VERSION 866#ifndef DESKTOP_VERSION
857 static int desktop_width = 0; 867 static int desktop_width = 0;
858 //qDebug("KABCore::resizeEvent %d %d ",desktop_width,QApplication::desktop()->width() ); 868 //qDebug("KABCore::resizeEvent %d %d ",desktop_width,QApplication::desktop()->width() );
859 if ( desktop_width != QApplication::desktop()->width() ) 869 if ( desktop_width != QApplication::desktop()->width() )
860 if ( QApplication::desktop()->width() >= 480 ) { 870 if ( QApplication::desktop()->width() >= 480 ) {
861 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 871 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
862 //qDebug("640 "); 872 //qDebug("640 ");
863 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 873 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
864 //qDebug("switch V->H "); 874 //qDebug("switch V->H ");
865 mMiniSplitter->setOrientation( Qt::Horizontal); 875 mMiniSplitter->setOrientation( Qt::Horizontal);
866 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 876 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
867 } 877 }
868 if ( QApplication::desktop()->width() <= 640 ) { 878 if ( QApplication::desktop()->width() <= 640 ) {
869 bool shot = mMainWindow->isVisible(); 879 bool shot = mMainWindow->isVisible();
870 mMainWindow->showMinimized(); 880 mMainWindow->showMinimized();
871 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 881 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
872 mViewManager->getFilterAction()->setComboWidth( 150 ); 882 mViewManager->getFilterAction()->setComboWidth( 150 );
873 if ( mIncSearchWidget ) 883 if ( mIncSearchWidget )
874 mIncSearchWidget->setSize(); 884 mIncSearchWidget->setSize();
875 if ( shot ) 885 if ( shot )
876 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 886 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
877 } 887 }
878 888
879 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 889 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
880 //qDebug("480 "); 890 //qDebug("480 ");
881 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 891 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
882 //qDebug("switch H->V "); 892 //qDebug("switch H->V ");
883 mMiniSplitter->setOrientation( Qt::Vertical ); 893 mMiniSplitter->setOrientation( Qt::Vertical );
884 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 894 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
885 } 895 }
886 if ( QApplication::desktop()->width() <= 640 ) { 896 if ( QApplication::desktop()->width() <= 640 ) {
887 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 897 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
888 bool shot = mMainWindow->isVisible(); 898 bool shot = mMainWindow->isVisible();
889 mMainWindow->showMinimized(); 899 mMainWindow->showMinimized();
890 if ( KABPrefs::instance()->mHideSearchOnSwitch ) { 900 if ( KABPrefs::instance()->mHideSearchOnSwitch ) {
891 if ( mIncSearchWidget ) { 901 if ( mIncSearchWidget ) {
892 mIncSearchWidget->setSize(); 902 mIncSearchWidget->setSize();
893 } 903 }
894 } else { 904 } else {
895 mViewManager->getFilterAction()->setComboWidth( 0 ); 905 mViewManager->getFilterAction()->setComboWidth( 0 );
896 } 906 }
897 if ( shot ) 907 if ( shot )
898 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 908 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
899 } 909 }
900 } 910 }
901 } 911 }
902 desktop_width = QApplication::desktop()->width(); 912 desktop_width = QApplication::desktop()->width();
903#endif 913#endif
904 QWidget::resizeEvent( e ); 914 QWidget::resizeEvent( e );
905 915
906} 916}
907void KABCore::export2phone() 917void KABCore::export2phone()
908{ 918{
909 919
910 QStringList uids; 920 QStringList uids;
911 XXPortSelectDialog dlg( this, false, this ); 921 XXPortSelectDialog dlg( this, false, this );
912 if ( dlg.exec() ) 922 if ( dlg.exec() )
913 uids = dlg.uids(); 923 uids = dlg.uids();
914 else 924 else
915 return; 925 return;
916 if ( uids.isEmpty() ) 926 if ( uids.isEmpty() )
917 return; 927 return;
918 // qDebug("count %d ", uids.count()); 928 // qDebug("count %d ", uids.count());
919 929
920 KAex2phonePrefs ex2phone; 930 KAex2phonePrefs ex2phone;
921 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 931 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
922 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 932 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
923 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 933 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
924 934
925 if ( !ex2phone.exec() ) { 935 if ( !ex2phone.exec() ) {
926 return; 936 return;
927 } 937 }
928 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 938 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
929 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 939 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
930 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 940 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
931 941
932 942
933 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 943 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
934 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 944 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
935 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 945 KPimGlobalPrefs::instance()->mEx2PhoneModel );
936 946
937 QString fileName = getPhoneFile(); 947 QString fileName = getPhoneFile();
938 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 948 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
939 return; 949 return;
940 950
941 message(i18n("Exporting to phone...")); 951 message(i18n("Exporting to phone..."));
942 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 952 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
943 953
944} 954}
945QString KABCore::getPhoneFile() 955QString KABCore::getPhoneFile()
946{ 956{
947#ifdef DESKTOP_VERSION 957#ifdef DESKTOP_VERSION
948 return locateLocal("tmp", "phonefile.vcf"); 958 return locateLocal("tmp", "phonefile.vcf");
949#else 959#else
950 return "/tmp/phonefile.vcf"; 960 return "/tmp/phonefile.vcf";
951#endif 961#endif
952 962
953} 963}
954void KABCore::writeToPhone( ) 964void KABCore::writeToPhone( )
955{ 965{
956 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 966 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
957 message(i18n("Export to phone finished!")); 967 message(i18n("Export to phone finished!"));
958 else 968 else
959 qDebug(i18n("KA: Error exporting to phone")); 969 qDebug(i18n("KA: Error exporting to phone"));
960} 970}
961void KABCore::beamVCard() 971void KABCore::beamVCard()
962{ 972{
963 QStringList uids; 973 QStringList uids;
964 XXPortSelectDialog dlg( this, false, this ); 974 XXPortSelectDialog dlg( this, false, this );
965 if ( dlg.exec() ) 975 if ( dlg.exec() )
966 uids = dlg.uids(); 976 uids = dlg.uids();
967 else 977 else
968 return; 978 return;
969 if ( uids.isEmpty() ) 979 if ( uids.isEmpty() )
970 return; 980 return;
971 beamVCard( uids ); 981 beamVCard( uids );
972} 982}
973 983
974 984
975void KABCore::beamVCard(const QStringList& uids) 985void KABCore::beamVCard(const QStringList& uids)
976{ 986{
977 987
978 // LR: we should use the /tmp dir on the Zaurus, 988 // LR: we should use the /tmp dir on the Zaurus,
979 // because: /tmp = RAM, (HOME)/kdepim = flash memory 989 // because: /tmp = RAM, (HOME)/kdepim = flash memory
980 990
981#ifdef DESKTOP_VERSION 991#ifdef DESKTOP_VERSION
982 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 992 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
983#else 993#else
984 QString fileName = "/tmp/kapibeamfile.vcf"; 994 QString fileName = "/tmp/kapibeamfile.vcf";
985#endif 995#endif
986 996
987 KABC::VCardConverter converter; 997 KABC::VCardConverter converter;
988 QString description; 998 QString description;
989 QString datastream; 999 QString datastream;
990 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 1000 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
991 KABC::Addressee a = mAddressBook->findByUid( *it ); 1001 KABC::Addressee a = mAddressBook->findByUid( *it );
992 1002
993 if ( a.isEmpty() ) 1003 if ( a.isEmpty() )
994 continue; 1004 continue;
995 1005
996 if (description.isEmpty()) 1006 if (description.isEmpty())
997 description = a.formattedName(); 1007 description = a.formattedName();
998 1008
999 QString vcard; 1009 QString vcard;
1000 converter.addresseeToVCard( a, vcard ); 1010 converter.addresseeToVCard( a, vcard );
1001 int start = 0; 1011 int start = 0;
1002 int next; 1012 int next;
1003 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 1013 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
1004 int semi = vcard.find(";", next); 1014 int semi = vcard.find(";", next);
1005 int dopp = vcard.find(":", next); 1015 int dopp = vcard.find(":", next);
1006 int sep; 1016 int sep;
1007 if ( semi < dopp && semi >= 0 ) 1017 if ( semi < dopp && semi >= 0 )
1008 sep = semi ; 1018 sep = semi ;
1009 else 1019 else
1010 sep = dopp; 1020 sep = dopp;
1011 datastream +=vcard.mid( start, next - start); 1021 datastream +=vcard.mid( start, next - start);
1012 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 1022 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
1013 start = sep; 1023 start = sep;
1014 } 1024 }
1015 datastream += vcard.mid( start,vcard.length() ); 1025 datastream += vcard.mid( start,vcard.length() );
1016 } 1026 }
1017#ifndef DESKTOP_VERSION 1027#ifndef DESKTOP_VERSION
1018 QFile outFile(fileName); 1028 QFile outFile(fileName);
1019 if ( outFile.open(IO_WriteOnly) ) { 1029 if ( outFile.open(QIODevice::WriteOnly) ) {
1020 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 1030 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
1021 QTextStream t( &outFile ); // use a text stream 1031 Q3TextStream t( &outFile ); // use a text stream
1022 //t.setEncoding( QTextStream::UnicodeUTF8 ); 1032 //t.setEncoding( QTextStream::UnicodeUTF8 );
1023 t.setEncoding( QTextStream::Latin1 ); 1033 t.setEncoding( Q3TextStream::Latin1 );
1024 t <<datastream.latin1(); 1034 t <<datastream.latin1();
1025 outFile.close(); 1035 outFile.close();
1026 Ir *ir = new Ir( this ); 1036 Ir *ir = new Ir( this );
1027 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 1037 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
1028 ir->send( fileName, description, "text/x-vCard" ); 1038 ir->send( fileName, description, "text/x-vCard" );
1029 } else { 1039 } else {
1030 qDebug("KA: Error open temp beam file "); 1040 qDebug("KA: Error open temp beam file ");
1031 return; 1041 return;
1032 } 1042 }
1033#endif 1043#endif
1034 1044
1035} 1045}
1036 1046
1037void KABCore::beamDone( Ir *ir ) 1047void KABCore::beamDone( Ir *ir )
1038{ 1048{
1039#ifndef DESKTOP_VERSION 1049#ifndef DESKTOP_VERSION
1040 delete ir; 1050 delete ir;
1041#endif 1051#endif
1042 topLevelWidget()->raise(); 1052 topLevelWidget()->raise();
1043 message( i18n("Beaming finished!") ); 1053 message( i18n("Beaming finished!") );
1044} 1054}
1045 1055
1046 1056
1047void KABCore::browse( const QString& url ) 1057void KABCore::browse( const QString& url )
1048{ 1058{
1049#ifndef KAB_EMBEDDED 1059#ifndef KAB_EMBEDDED
1050 kapp->invokeBrowser( url ); 1060 kapp->invokeBrowser( url );
1051#else //KAB_EMBEDDED 1061#else //KAB_EMBEDDED
1052 qDebug("KABCore::browse must be fixed"); 1062 qDebug("KABCore::browse must be fixed");
1053#endif //KAB_EMBEDDED 1063#endif //KAB_EMBEDDED
1054} 1064}
1055 1065
1056void KABCore::selectAllContacts() 1066void KABCore::selectAllContacts()
1057{ 1067{
1058 mViewManager->setSelected( QString::null, true ); 1068 mViewManager->setSelected( QString::null, true );
1059} 1069}
1060 1070
1061void KABCore::deleteContacts() 1071void KABCore::deleteContacts()
1062{ 1072{
1063 QStringList uidList = mViewManager->selectedUids(); 1073 QStringList uidList = mViewManager->selectedUids();
1064 deleteContacts( uidList ); 1074 deleteContacts( uidList );
1065} 1075}
1066 1076
1067void KABCore::deleteContacts( const QStringList &uids ) 1077void KABCore::deleteContacts( const QStringList &uids )
1068{ 1078{
1069 1079
1070 if ( uids.count() > 0 ) { 1080 if ( uids.count() > 0 ) {
1071 1081
1072 if ( KABPrefs::instance()->mAskForDelete ) { 1082 if ( KABPrefs::instance()->mAskForDelete ) {
1073 int count = uids.count(); 1083 int count = uids.count();
1074 if ( count > 5 ) count = 5; 1084 if ( count > 5 ) count = 5;
1075 QString cNames; 1085 QString cNames;
1076 int i; 1086 int i;
1077 for ( i = 0; i < count ; ++i ) { 1087 for ( i = 0; i < count ; ++i ) {
1078 cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n"; 1088 cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n";
1079 } 1089 }
1080 if ( uids.count() > 5 ) 1090 if ( uids.count() > 5 )
1081 cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 ); 1091 cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 );
1082 QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ; 1092 QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ;
1083 if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes ) 1093 if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes )
1084 return; 1094 return;
1085 } 1095 }
1086 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 1096 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
1087 UndoStack::instance()->push( command ); 1097 UndoStack::instance()->push( command );
1088 RedoStack::instance()->clear(); 1098 RedoStack::instance()->clear();
1089 1099
1090 // now if we deleted anything, refresh 1100 // now if we deleted anything, refresh
1091 setContactSelected( QString::null ); 1101 setContactSelected( QString::null );
1092 setModified( true ); 1102 setModified( true );
1093 } 1103 }
1094} 1104}
1095 1105
1096void KABCore::copyContacts() 1106void KABCore::copyContacts()
1097{ 1107{
1098 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1108 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1099 1109
1100 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 1110 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
1101 1111
1102 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 1112 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
1103 1113
1104 QClipboard *cb = QApplication::clipboard(); 1114 QClipboard *cb = QApplication::clipboard();
1105 cb->setText( clipText ); 1115 cb->setText( clipText );
1106} 1116}
1107 1117
1108void KABCore::cutContacts() 1118void KABCore::cutContacts()
1109{ 1119{
1110 QStringList uidList = mViewManager->selectedUids(); 1120 QStringList uidList = mViewManager->selectedUids();
1111 1121
1112//US if ( uidList.size() > 0 ) { 1122//US if ( uidList.size() > 0 ) {
1113 if ( uidList.count() > 0 ) { 1123 if ( uidList.count() > 0 ) {
1114 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1124 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1115 UndoStack::instance()->push( command ); 1125 UndoStack::instance()->push( command );
1116 RedoStack::instance()->clear(); 1126 RedoStack::instance()->clear();
1117 1127
1118 setModified( true ); 1128 setModified( true );
1119 } 1129 }
1120} 1130}
1121 1131
1122void KABCore::pasteContacts() 1132void KABCore::pasteContacts()
1123{ 1133{
1124 QClipboard *cb = QApplication::clipboard(); 1134 QClipboard *cb = QApplication::clipboard();
1125 1135
1126 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1136 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1127 1137
1128 pasteContacts( list ); 1138 pasteContacts( list );
1129} 1139}
1130 1140
1131void KABCore::pasteContacts( KABC::Addressee::List &list ) 1141void KABCore::pasteContacts( KABC::Addressee::List &list )
1132{ 1142{
1133 KABC::Resource *resource = requestResource( this ); 1143 KABC::Resource *resource = requestResource( this );
1134 KABC::Addressee::List::Iterator it; 1144 KABC::Addressee::List::Iterator it;
1135 for ( it = list.begin(); it != list.end(); ++it ) 1145 for ( it = list.begin(); it != list.end(); ++it )
1136 (*it).setResource( resource ); 1146 (*it).setResource( resource );
1137 1147
1138 PwPasteCommand *command = new PwPasteCommand( this, list ); 1148 PwPasteCommand *command = new PwPasteCommand( this, list );
1139 UndoStack::instance()->push( command ); 1149 UndoStack::instance()->push( command );
1140 RedoStack::instance()->clear(); 1150 RedoStack::instance()->clear();
1141 1151
1142 setModified( true ); 1152 setModified( true );
1143} 1153}
1144 1154
1145void KABCore::setWhoAmI() 1155void KABCore::setWhoAmI()
1146{ 1156{
1147 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1157 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1148 1158
1149 if ( addrList.count() > 1 ) { 1159 if ( addrList.count() > 1 ) {
1150 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1160 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1151 return; 1161 return;
1152 } 1162 }
1153 1163
1154 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1164 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1155 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes ) 1165 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes )
1156 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1166 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1157} 1167}
1158void KABCore::editCategories() 1168void KABCore::editCategories()
1159{ 1169{
1160 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1170 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1161 dlg.exec(); 1171 dlg.exec();
1162} 1172}
1163void KABCore::setCategories() 1173void KABCore::setCategories()
1164{ 1174{
1165 1175
1166 QStringList uids; 1176 QStringList uids;
1167 XXPortSelectDialog dlgx( this, false, this ); 1177 XXPortSelectDialog dlgx( this, false, this );
1168 if ( dlgx.exec() ) 1178 if ( dlgx.exec() )
1169 uids = dlgx.uids(); 1179 uids = dlgx.uids();
1170 else 1180 else
1171 return; 1181 return;
1172 if ( uids.isEmpty() ) 1182 if ( uids.isEmpty() )
1173 return; 1183 return;
1174 // qDebug("count %d ", uids.count()); 1184 // qDebug("count %d ", uids.count());
1175 1185
1176 1186
1177 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1187 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1178 if ( !dlg.exec() ) { 1188 if ( !dlg.exec() ) {
1179 message( i18n("Setting categories cancelled") ); 1189 message( i18n("Setting categories cancelled") );
1180 return; 1190 return;
1181 } 1191 }
1182 bool merge = false; 1192 bool merge = false;
1183 QString msg = i18n( "Merge with existing categories?" ); 1193 QString msg = i18n( "Merge with existing categories?" );
1184 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1194 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1185 merge = true; 1195 merge = true;
1186 1196
1187 message( i18n("Setting categories ... please wait!") ); 1197 message( i18n("Setting categories ... please wait!") );
1188 QStringList categories = dlg.selectedCategories(); 1198 QStringList categories = dlg.selectedCategories();
1189 1199
1190 //QStringList uids = mViewManager->selectedUids(); 1200 //QStringList uids = mViewManager->selectedUids();
1191 QStringList::Iterator it; 1201 QStringList::Iterator it;
1192 for ( it = uids.begin(); it != uids.end(); ++it ) { 1202 for ( it = uids.begin(); it != uids.end(); ++it ) {
1193 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1203 KABC::Addressee addr = mAddressBook->findByUid( *it );
1194 if ( !addr.isEmpty() ) { 1204 if ( !addr.isEmpty() ) {
1195 if ( !merge ) 1205 if ( !merge )
1196 addr.setCategories( categories ); 1206 addr.setCategories( categories );
1197 else { 1207 else {
1198 QStringList addrCategories = addr.categories(); 1208 QStringList addrCategories = addr.categories();
1199 QStringList::Iterator catIt; 1209 QStringList::Iterator catIt;
1200 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1210 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1201 if ( !addrCategories.contains( *catIt ) ) 1211 if ( !addrCategories.contains( *catIt ) )
1202 addrCategories.append( *catIt ); 1212 addrCategories.append( *catIt );
1203 } 1213 }
1204 addr.setCategories( addrCategories ); 1214 addr.setCategories( addrCategories );
1205 } 1215 }
1206 mAddressBook->insertAddressee( addr ); 1216 mAddressBook->insertAddressee( addr );
1207 } 1217 }
1208 } 1218 }
1209 1219
1210 if ( uids.count() > 0 ) 1220 if ( uids.count() > 0 )
1211 setModified( true ); 1221 setModified( true );
1212 message( i18n("Setting categories completed!") ); 1222 message( i18n("Setting categories completed!") );
1213} 1223}
1214 1224
1215void KABCore::setSearchFields( const KABC::Field::List &fields ) 1225void KABCore::setSearchFields( const KABC::Field::List &fields )
1216{ 1226{
1217 mIncSearchWidget->setFields( fields ); 1227 mIncSearchWidget->setFields( fields );
1218} 1228}
1219 1229
1220void KABCore::incrementalSearch( const QString& text ) 1230void KABCore::incrementalSearch( const QString& text )
1221{ 1231{
1222 QString stext; 1232 QString stext;
1223 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { 1233 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) {
1224 stext = "*" + text; 1234 stext = "*" + text;
1225 } else { 1235 } else {
1226 stext = text; 1236 stext = text;
1227 } 1237 }
1228 mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); 1238 mViewManager->doSearch( stext, mIncSearchWidget->currentField() );
1229} 1239}
1230void KABCore::incrementalSearchJump( const QString& text ) 1240void KABCore::incrementalSearchJump( const QString& text )
1231{ 1241{
1232 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1242 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1233} 1243}
1234 1244
1235void KABCore::setModified() 1245void KABCore::setModified()
1236{ 1246{
1237 setModified( true ); 1247 setModified( true );
1238} 1248}
1239 1249
1240void KABCore::setModifiedWOrefresh() 1250void KABCore::setModifiedWOrefresh()
1241{ 1251{
1242 // qDebug("KABCore::setModifiedWOrefresh() "); 1252 // qDebug("KABCore::setModifiedWOrefresh() ");
1243 mModified = true; 1253 mModified = true;
1244 mActionSave->setEnabled( mModified ); 1254 mActionSave->setEnabled( mModified );
1245 1255
1246 1256
1247} 1257}
1248void KABCore::setModified( bool modified ) 1258void KABCore::setModified( bool modified )
1249{ 1259{
1250 mModified = modified; 1260 mModified = modified;
1251 mActionSave->setEnabled( mModified ); 1261 mActionSave->setEnabled( mModified );
1252 1262
1253 if ( modified ) 1263 if ( modified )
1254 mJumpButtonBar->recreateButtons(); 1264 mJumpButtonBar->recreateButtons();
1255 1265
1256 mViewManager->refreshView(); 1266 mViewManager->refreshView();
1257 1267
1258} 1268}
1259 1269
1260bool KABCore::modified() const 1270bool KABCore::modified() const
1261{ 1271{
1262 return mModified; 1272 return mModified;
1263} 1273}
1264 1274
1265void KABCore::contactModified( const KABC::Addressee &addr ) 1275void KABCore::contactModified( const KABC::Addressee &addr )
1266{ 1276{
1267 addrModified( addr ); 1277 addrModified( addr );
1268#if 0 // debug only 1278#if 0 // debug only
1269 KABC::Addressee ad = addr; 1279 KABC::Addressee ad = addr;
1270 ad.computeCsum( "123"); 1280 ad.computeCsum( "123");
1271#endif 1281#endif
1272} 1282}
1273 1283
1274void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) 1284void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails )
1275{ 1285{
1276 1286
1277 Command *command = 0; 1287 Command *command = 0;
1278 QString uid; 1288 QString uid;
1279 1289
1280 // check if it exists already 1290 // check if it exists already
1281 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1291 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1282 if ( origAddr.isEmpty() ) 1292 if ( origAddr.isEmpty() )
1283 command = new PwNewCommand( mAddressBook, addr ); 1293 command = new PwNewCommand( mAddressBook, addr );
1284 else { 1294 else {
1285 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1295 command = new PwEditCommand( mAddressBook, origAddr, addr );
1286 uid = addr.uid(); 1296 uid = addr.uid();
1287 } 1297 }
1288 1298
1289 UndoStack::instance()->push( command ); 1299 UndoStack::instance()->push( command );
1290 RedoStack::instance()->clear(); 1300 RedoStack::instance()->clear();
1291 if ( updateDetails ) 1301 if ( updateDetails )
1292 mDetails->setAddressee( addr ); 1302 mDetails->setAddressee( addr );
1293 setModified( true ); 1303 setModified( true );
1294} 1304}
1295 1305
1296void KABCore::newContact() 1306void KABCore::newContact()
1297{ 1307{
1298 1308
1299 1309
1300 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1310 Q3PtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1301 1311
1302 QPtrList<KRES::Resource> kresResources; 1312 Q3PtrList<KRES::Resource> kresResources;
1303 QPtrListIterator<KABC::Resource> it( kabcResources ); 1313 Q3PtrListIterator<KABC::Resource> it( kabcResources );
1304 KABC::Resource *resource; 1314 KABC::Resource *resource;
1305 while ( ( resource = it.current() ) != 0 ) { 1315 while ( ( resource = it.current() ) != 0 ) {
1306 ++it; 1316 ++it;
1307 if ( !resource->readOnly() ) { 1317 if ( !resource->readOnly() ) {
1308 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1318 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1309 if ( res ) 1319 if ( res )
1310 kresResources.append( res ); 1320 kresResources.append( res );
1311 } 1321 }
1312 } 1322 }
1313 1323
1314 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1324 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1315 resource = static_cast<KABC::Resource*>( res ); 1325 resource = static_cast<KABC::Resource*>( res );
1316 1326
1317 if ( resource ) { 1327 if ( resource ) {
1318 KABC::Addressee addr; 1328 KABC::Addressee addr;
1319 addr.setResource( resource ); 1329 addr.setResource( resource );
1320 mEditorDialog->setAddressee( addr ); 1330 mEditorDialog->setAddressee( addr );
1321 mEditorDialog->setCaption( i18n("Edit new contact")); 1331 mEditorDialog->setCaption( i18n("Edit new contact"));
1322 KApplication::execDialog ( mEditorDialog ); 1332 KApplication::execDialog ( mEditorDialog );
1323 1333
1324 } else 1334 } else
1325 return; 1335 return;
1326 1336
1327 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1337 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1328 1338
1329 1339
1330} 1340}
1331 1341
1332void KABCore::addEmail( QString aStr ) 1342void KABCore::addEmail( QString aStr )
1333{ 1343{
1334#ifndef KAB_EMBEDDED 1344#ifndef KAB_EMBEDDED
1335 QString fullName, email; 1345 QString fullName, email;
1336 1346
1337 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1347 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1338 1348
1339 // Try to lookup the addressee matching the email address 1349 // Try to lookup the addressee matching the email address
1340 bool found = false; 1350 bool found = false;
1341 QStringList emailList; 1351 QStringList emailList;
1342 KABC::AddressBook::Iterator it; 1352 KABC::AddressBook::Iterator it;
1343 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1353 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1344 emailList = (*it).emails(); 1354 emailList = (*it).emails();
1345 if ( emailList.contains( email ) > 0 ) { 1355 if ( emailList.contains( email ) > 0 ) {
1346 found = true; 1356 found = true;
1347 (*it).setNameFromString( fullName ); 1357 (*it).setNameFromString( fullName );
1348 editContact( (*it).uid() ); 1358 editContact( (*it).uid() );
1349 } 1359 }
1350 } 1360 }
1351 1361
1352 if ( !found ) { 1362 if ( !found ) {
1353 KABC::Addressee addr; 1363 KABC::Addressee addr;
1354 addr.setNameFromString( fullName ); 1364 addr.setNameFromString( fullName );
1355 addr.insertEmail( email, true ); 1365 addr.insertEmail( email, true );
1356 1366
1357 mAddressBook->insertAddressee( addr ); 1367 mAddressBook->insertAddressee( addr );
1358 mViewManager->refreshView( addr.uid() ); 1368 mViewManager->refreshView( addr.uid() );
1359 editContact( addr.uid() ); 1369 editContact( addr.uid() );
1360 } 1370 }
1361#else //KAB_EMBEDDED 1371#else //KAB_EMBEDDED
1362 qDebug("KABCore::addEmail finsih method"); 1372 qDebug("KABCore::addEmail finsih method");
1363#endif //KAB_EMBEDDED 1373#endif //KAB_EMBEDDED
1364} 1374}
1365 1375
1366void KABCore::importVCard( const KURL &url, bool showPreview ) 1376void KABCore::importVCard( const KURL &url, bool showPreview )
1367{ 1377{
1368 mXXPortManager->importVCard( url, showPreview ); 1378 mXXPortManager->importVCard( url, showPreview );
1369} 1379}
1370void KABCore::importFromOL() 1380void KABCore::importFromOL()
1371{ 1381{
1372#ifdef _OL_IMPORT_ 1382#ifdef _OL_IMPORT_
1373 KABC::Addressee::List list = OL_access::instance()->importOLcontacts(); 1383 KABC::Addressee::List list = OL_access::instance()->importOLcontacts();
1374 if ( list.count() > 0 ) { 1384 if ( list.count() > 0 ) {
1375 KABC::Addressee::List listNew; 1385 KABC::Addressee::List listNew;
1376 KABC::Addressee::List listExisting; 1386 KABC::Addressee::List listExisting;
1377 KABC::Addressee::List::Iterator it; 1387 KABC::Addressee::List::Iterator it;
1378 KABC::AddressBook::Iterator iter; 1388 KABC::AddressBook::Iterator iter;
1379 for ( it = list.begin(); it != list.end(); ++it ) { 1389 for ( it = list.begin(); it != list.end(); ++it ) {
1380 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1390 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1381 listNew.append( (*it) ); 1391 listNew.append( (*it) );
1382 else 1392 else
1383 listExisting.append( (*it) ); 1393 listExisting.append( (*it) );
1384 } 1394 }
1385 QString mess = i18n("%1 contacts read from OL.\n\n%2 contacts added to addressbook!").arg( list.count()).arg( listNew.count() ); 1395 QString mess = i18n("%1 contacts read from OL.\n\n%2 contacts added to addressbook!").arg( list.count()).arg( listNew.count() );
1386 if ( listExisting.count() > 0 ) 1396 if ( listExisting.count() > 0 )
1387 mess += "\n\n"+ i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ); 1397 mess += "\n\n"+ i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() );
1388 1398
1389 KMessageBox::information( this, mess ); 1399 KMessageBox::information( this, mess );
1390 if ( listNew.count() > 0 ) { 1400 if ( listNew.count() > 0 ) {
1391 pasteWithNewUid = false; 1401 pasteWithNewUid = false;
1392 pasteContacts( listNew ); 1402 pasteContacts( listNew );
1393 pasteWithNewUid = true; 1403 pasteWithNewUid = true;
1394 } 1404 }
1395 } 1405 }
1396#endif 1406#endif
1397} 1407}
1398 1408
1399bool KABCore::readOLdata( KABC::AddressBook* local ) 1409bool KABCore::readOLdata( KABC::AddressBook* local )
1400{ 1410{
1401#ifdef _OL_IMPORT_ 1411#ifdef _OL_IMPORT_
1402 QStringList folderList = OL_access::instance()->getFolderSelection( OL_CONTACT_DATA , i18n("Select Folder to sync")); 1412 QStringList folderList = OL_access::instance()->getFolderSelection( OL_CONTACT_DATA , i18n("Select Folder to sync"));
1403 KABC::Addressee::List list; 1413 KABC::Addressee::List list;
1404 if ( folderList.count() ) { 1414 if ( folderList.count() ) {
1405 OL_access::instance()->readContactData( OL_access::instance()->getFolderFromID( 0, folderList[1] ) , &list, true ); 1415 OL_access::instance()->readContactData( OL_access::instance()->getFolderFromID( 0, folderList[1] ) , &list, true );
1406 KABC::Addressee::List::Iterator it; 1416 KABC::Addressee::List::Iterator it;
1407 for ( it = list.begin(); it != list.end(); ++it ) { 1417 for ( it = list.begin(); it != list.end(); ++it ) {
1408 (*it).setExternalUID( (*it).uid() ); 1418 (*it).setExternalUID( (*it).uid() );
1409 (*it).setOriginalExternalUID( (*it).uid() ); 1419 (*it).setOriginalExternalUID( (*it).uid() );
1410 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 1420 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
1411 local->insertAddressee( (*it) , false, false ); 1421 local->insertAddressee( (*it) , false, false );
1412 } 1422 }
1413 mOLsyncFolderID = folderList[1]; 1423 mOLsyncFolderID = folderList[1];
1414 //KMessageBox::information( this, i18n("OLsync folder ID ") + mOLsyncFolderID ); 1424 //KMessageBox::information( this, i18n("OLsync folder ID ") + mOLsyncFolderID );
1415 } 1425 }
1416 return list.count() > 0; 1426 return list.count() > 0;
1417#else 1427#else
1418 return false; 1428 return false;
1419#endif 1429#endif
1420} 1430}
1421bool KABCore::writeOLdata( KABC::AddressBook* aBook ) 1431bool KABCore::writeOLdata( KABC::AddressBook* aBook )
1422{ 1432{
1423#ifdef _OL_IMPORT_ 1433#ifdef _OL_IMPORT_
1424 if ( !OL_access::instance()->setSelectedFolder( mOLsyncFolderID ) ) 1434 if ( !OL_access::instance()->setSelectedFolder( mOLsyncFolderID ) )
1425 return false; 1435 return false;
1426 KABC::AddressBook::Iterator it; 1436 KABC::AddressBook::Iterator it;
1427 for ( it = aBook->begin(); it != aBook->end(); ++it ) { 1437 for ( it = aBook->begin(); it != aBook->end(); ++it ) {
1428 if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 1438 if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
1429 KABC::Addressee addressee = (*it); 1439 KABC::Addressee addressee = (*it);
1430 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { 1440 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) {
1431 (*it) = OL_access::instance()->addAddressee( (*it) ); 1441 (*it) = OL_access::instance()->addAddressee( (*it) );
1432 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 1442 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
1433 } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 1443 } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
1434 OL_access::instance()->deleteAddressee( (*it) ); 1444 OL_access::instance()->deleteAddressee( (*it) );
1435 } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 1445 } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
1436 //changed 1446 //changed
1437 (*it) = OL_access::instance()->changeAddressee( (*it) ); 1447 (*it) = OL_access::instance()->changeAddressee( (*it) );
1438 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); 1448 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM );
1439 } 1449 }
1440 } 1450 }
1441 } 1451 }
1442 return true; 1452 return true;
1443#else 1453#else
1444 return false; 1454 return false;
1445#endif 1455#endif
1446} 1456}
1447void KABCore::importVCard( const QString &vCard, bool showPreview ) 1457void KABCore::importVCard( const QString &vCard, bool showPreview )
1448{ 1458{
1449 mXXPortManager->importVCard( vCard, showPreview ); 1459 mXXPortManager->importVCard( vCard, showPreview );
1450} 1460}
1451 1461
1452//US added a second method without defaultparameter 1462//US added a second method without defaultparameter
1453void KABCore::editContact2() { 1463void KABCore::editContact2() {
1454 editContact( QString::null ); 1464 editContact( QString::null );
1455} 1465}
1456 1466
1457void KABCore::editContact( const QString &uid ) 1467void KABCore::editContact( const QString &uid )
1458{ 1468{
1459 1469
1460 if ( mExtensionManager->isQuickEditVisible() ) 1470 if ( mExtensionManager->isQuickEditVisible() )
1461 return; 1471 return;
1462 1472
1463 // First, locate the contact entry 1473 // First, locate the contact entry
1464 QString localUID = uid; 1474 QString localUID = uid;
1465 if ( localUID.isNull() ) { 1475 if ( localUID.isNull() ) {
1466 QStringList uidList = mViewManager->selectedUids(); 1476 QStringList uidList = mViewManager->selectedUids();
1467 if ( uidList.count() > 0 ) 1477 if ( uidList.count() > 0 )
1468 localUID = *( uidList.at( 0 ) ); 1478 localUID = *( uidList.at( 0 ) );
1469 } 1479 }
1470 1480
1471 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1481 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1472 if ( !addr.isEmpty() ) { 1482 if ( !addr.isEmpty() ) {
1473 mEditorDialog->setAddressee( addr ); 1483 mEditorDialog->setAddressee( addr );
1474 KApplication::execDialog ( mEditorDialog ); 1484 KApplication::execDialog ( mEditorDialog );
1475 } 1485 }
1476} 1486}
1477 1487
1478/** 1488/**
1479 Shows or edits the detail view for the given uid. If the uid is QString::null, 1489 Shows or edits the detail view for the given uid. If the uid is QString::null,
1480 the method will try to find a selected addressee in the view. 1490 the method will try to find a selected addressee in the view.
1481 */ 1491 */
1482void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1492void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1483{ 1493{
1484 if ( mMultipleViewsAtOnce ) 1494 if ( mMultipleViewsAtOnce )
1485 { 1495 {
1486 editContact( uid ); 1496 editContact( uid );
1487 } 1497 }
1488 else 1498 else
1489 { 1499 {
1490 setDetailsVisible( true ); 1500 setDetailsVisible( true );
1491 mActionDetails->setChecked(true); 1501 mActionDetails->setChecked(true);
1492 } 1502 }
1493 1503
1494} 1504}
1495 1505
1496void KABCore::save() 1506void KABCore::save()
1497{ 1507{
1498 if (syncManager->blockSave()) 1508 if (syncManager->blockSave())
1499 return; 1509 return;
1500 if ( !mModified ) 1510 if ( !mModified )
1501 return; 1511 return;
1502 1512
1503 syncManager->setBlockSave(true); 1513 syncManager->setBlockSave(true);
1504 QString text = i18n( "There was an error while attempting to save\n the " 1514 QString text = i18n( "There was an error while attempting to save\n the "
1505 "address book. Please check that some \nother application is " 1515 "address book. Please check that some \nother application is "
1506 "not using it. " ); 1516 "not using it. " );
1507 message(i18n("Saving ... please wait! "), false); 1517 message(i18n("Saving ... please wait! "), false);
1508 //qApp->processEvents(); 1518 //qApp->processEvents();
1509#ifndef KAB_EMBEDDED 1519#ifndef KAB_EMBEDDED
1510 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1520 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1511 if ( !b || !b->save() ) { 1521 if ( !b || !b->save() ) {
1512 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1522 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1513 } 1523 }
1514#else //KAB_EMBEDDED 1524#else //KAB_EMBEDDED
1515 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1525 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1516 if ( !b || !b->save() ) { 1526 if ( !b || !b->save() ) {
1517 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1527 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1518 } 1528 }
1519#endif //KAB_EMBEDDED 1529#endif //KAB_EMBEDDED
1520 1530
1521 message(i18n("Addressbook saved!")); 1531 message(i18n("Addressbook saved!"));
1522 setModified( false ); 1532 setModified( false );
1523 syncManager->setBlockSave(false); 1533 syncManager->setBlockSave(false);
1524} 1534}
1525 1535
1526 1536
1527void KABCore::undo() 1537void KABCore::undo()
1528{ 1538{
1529 UndoStack::instance()->undo(); 1539 UndoStack::instance()->undo();
1530 1540
1531 // Refresh the view 1541 // Refresh the view
1532 mViewManager->refreshView(); 1542 mViewManager->refreshView();
1533} 1543}
1534 1544
1535void KABCore::redo() 1545void KABCore::redo()
1536{ 1546{
1537 RedoStack::instance()->redo(); 1547 RedoStack::instance()->redo();
1538 1548
1539 // Refresh the view 1549 // Refresh the view
1540 mViewManager->refreshView(); 1550 mViewManager->refreshView();
1541} 1551}
1542void KABCore::setJumpButtonBar( bool visible ) 1552void KABCore::setJumpButtonBar( bool visible )
1543{ 1553{
1544 setJumpButtonBarVisible(visible ); 1554 setJumpButtonBarVisible(visible );
1545 saveSettings(); 1555 saveSettings();
1546} 1556}
1547void KABCore::setJumpButtonBarVisible( bool visible ) 1557void KABCore::setJumpButtonBarVisible( bool visible )
1548{ 1558{
1549 if (mMultipleViewsAtOnce) 1559 if (mMultipleViewsAtOnce)
1550 { 1560 {
1551 if ( visible ) 1561 if ( visible )
1552 mJumpButtonBar->show(); 1562 mJumpButtonBar->show();
1553 else 1563 else
1554 mJumpButtonBar->hide(); 1564 mJumpButtonBar->hide();
1555 } 1565 }
1556 else 1566 else
1557 { 1567 {
1558 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1568 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1559 if (mViewManager->isVisible()) 1569 if (mViewManager->isVisible())
1560 { 1570 {
1561 if ( visible ) 1571 if ( visible )
1562 mJumpButtonBar->show(); 1572 mJumpButtonBar->show();
1563 else 1573 else
1564 mJumpButtonBar->hide(); 1574 mJumpButtonBar->hide();
1565 } 1575 }
1566 else 1576 else
1567 { 1577 {
1568 mJumpButtonBar->hide(); 1578 mJumpButtonBar->hide();
1569 } 1579 }
1570 } 1580 }
1571 if ( visible ) { 1581 if ( visible ) {
1572 if ( mIncSearchWidget->currentItem() == 0 ) { 1582 if ( mIncSearchWidget->currentItem() == 0 ) {
1573 message( i18n("Change search field enable jump bar") ); 1583 message( i18n("Change search field enable jump bar") );
1574 } 1584 }
1575 } 1585 }
1576} 1586}
1577 1587
1578 1588
1579void KABCore::setDetailsToState() 1589void KABCore::setDetailsToState()
1580{ 1590{
1581 setDetailsVisible( mActionDetails->isChecked() ); 1591 setDetailsVisible( mActionDetails->isChecked() );
1582} 1592}
1583void KABCore::setDetailsToggle() 1593void KABCore::setDetailsToggle()
1584{ 1594{
1585 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1595 mActionDetails->setChecked( !mActionDetails->isChecked() );
1586 setDetailsToState(); 1596 setDetailsToState();
1587} 1597}
1588 1598
1589 1599
1590 1600
1591void KABCore::setDetailsVisible( bool visible ) 1601void KABCore::setDetailsVisible( bool visible )
1592{ 1602{
1593 if (visible && mDetails->isHidden()) 1603 if (visible && mDetails->isHidden())
1594 { 1604 {
1595 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1605 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1596 if ( addrList.count() > 0 ) 1606 if ( addrList.count() > 0 )
1597 mDetails->setAddressee( addrList[ 0 ] ); 1607 mDetails->setAddressee( addrList[ 0 ] );
1598 } 1608 }
1599 1609
1600 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1610 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1601 // the listview and the detailview. We do that by changing the splitbar size. 1611 // the listview and the detailview. We do that by changing the splitbar size.
1602 if (mMultipleViewsAtOnce) 1612 if (mMultipleViewsAtOnce)
1603 { 1613 {
1604 if ( visible ) 1614 if ( visible )
1605 mDetails->show(); 1615 mDetails->show();
1606 else 1616 else
1607 mDetails->hide(); 1617 mDetails->hide();
1608 } 1618 }
1609 else 1619 else
1610 { 1620 {
1611 if ( visible ) { 1621 if ( visible ) {
1612 mViewManager->hide(); 1622 mViewManager->hide();
1613 mDetails->show(); 1623 mDetails->show();
1614 mIncSearchWidget->setFocus(); 1624 mIncSearchWidget->setFocus();
1615 } 1625 }
1616 else { 1626 else {
1617 mViewManager->show(); 1627 mViewManager->show();
1618 mDetails->hide(); 1628 mDetails->hide();
1619 mViewManager->setFocusAV(); 1629 mViewManager->setFocusAV();
1620 } 1630 }
1621 setJumpButtonBarVisible( !visible ); 1631 setJumpButtonBarVisible( !visible );
1622 } 1632 }
1623 1633
1624} 1634}
1625 1635
1626void KABCore::extensionChanged( int id ) 1636void KABCore::extensionChanged( int id )
1627{ 1637{
1628 //change the details view only for non desktop systems 1638 //change the details view only for non desktop systems
1629#ifndef DESKTOP_VERSION 1639#ifndef DESKTOP_VERSION
1630 1640
1631 if (id == 0) 1641 if (id == 0)
1632 { 1642 {
1633 //the user disabled the extension. 1643 //the user disabled the extension.
1634 1644
1635 if (mMultipleViewsAtOnce) 1645 if (mMultipleViewsAtOnce)
1636 { // enable detailsview again 1646 { // enable detailsview again
1637 setDetailsVisible( true ); 1647 setDetailsVisible( true );
1638 mActionDetails->setChecked( true ); 1648 mActionDetails->setChecked( true );
1639 } 1649 }
1640 else 1650 else
1641 { //go back to the listview 1651 { //go back to the listview
1642 setDetailsVisible( false ); 1652 setDetailsVisible( false );
1643 mActionDetails->setChecked( false ); 1653 mActionDetails->setChecked( false );
1644 mActionDetails->setEnabled(true); 1654 mActionDetails->setEnabled(true);
1645 } 1655 }
1646 1656
1647 } 1657 }
1648 else 1658 else
1649 { 1659 {
1650 //the user enabled the extension. 1660 //the user enabled the extension.
1651 setDetailsVisible( false ); 1661 setDetailsVisible( false );
1652 mActionDetails->setChecked( false ); 1662 mActionDetails->setChecked( false );
1653 1663
1654 if (!mMultipleViewsAtOnce) 1664 if (!mMultipleViewsAtOnce)
1655 { 1665 {
1656 mActionDetails->setEnabled(false); 1666 mActionDetails->setEnabled(false);
1657 } 1667 }
1658 1668
1659 mExtensionManager->setSelectionChanged(); 1669 mExtensionManager->setSelectionChanged();
1660 1670
1661 } 1671 }
1662 1672
1663#endif// DESKTOP_VERSION 1673#endif// DESKTOP_VERSION
1664 1674
1665} 1675}
1666 1676
1667 1677
1668void KABCore::extensionModified( const KABC::Addressee::List &list ) 1678void KABCore::extensionModified( const KABC::Addressee::List &list )
1669{ 1679{
1670 1680
1671 if ( list.count() != 0 ) { 1681 if ( list.count() != 0 ) {
1672 KABC::Addressee::List::ConstIterator it; 1682 KABC::Addressee::List::ConstIterator it;
1673 for ( it = list.begin(); it != list.end(); ++it ) 1683 for ( it = list.begin(); it != list.end(); ++it )
1674 mAddressBook->insertAddressee( *it ); 1684 mAddressBook->insertAddressee( *it );
1675 if ( list.count() > 1 ) 1685 if ( list.count() > 1 )
1676 setModified(); 1686 setModified();
1677 else 1687 else
1678 setModifiedWOrefresh(); 1688 setModifiedWOrefresh();
1679 } 1689 }
1680 if ( list.count() == 0 ) 1690 if ( list.count() == 0 )
1681 mViewManager->refreshView(); 1691 mViewManager->refreshView();
1682 else 1692 else
1683 mViewManager->refreshView( list[ 0 ].uid() ); 1693 mViewManager->refreshView( list[ 0 ].uid() );
1684 1694
1685 1695
1686 1696
1687} 1697}
1688 1698
1689QString KABCore::getNameByPhone( const QString &phone ) 1699QString KABCore::getNameByPhone( const QString &phone )
1690{ 1700{
1691#ifndef KAB_EMBEDDED 1701#ifndef KAB_EMBEDDED
1692 QRegExp r( "[/*/-/ ]" ); 1702 QRegExp r( "[/*/-/ ]" );
1693 QString localPhone( phone ); 1703 QString localPhone( phone );
1694 1704
1695 bool found = false; 1705 bool found = false;
1696 QString ownerName = ""; 1706 QString ownerName = "";
1697 KABC::AddressBook::Iterator iter; 1707 KABC::AddressBook::Iterator iter;
1698 KABC::PhoneNumber::List::Iterator phoneIter; 1708 KABC::PhoneNumber::List::Iterator phoneIter;
1699 KABC::PhoneNumber::List phoneList; 1709 KABC::PhoneNumber::List phoneList;
1700 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1710 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1701 phoneList = (*iter).phoneNumbers(); 1711 phoneList = (*iter).phoneNumbers();
1702 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1712 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1703 ++phoneIter) { 1713 ++phoneIter) {
1704 // Get rid of separator chars so just the numbers are compared. 1714 // Get rid of separator chars so just the numbers are compared.
1705 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1715 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1706 ownerName = (*iter).formattedName(); 1716 ownerName = (*iter).formattedName();
1707 found = true; 1717 found = true;
1708 } 1718 }
1709 } 1719 }
1710 } 1720 }
1711 1721
1712 return ownerName; 1722 return ownerName;
1713#else //KAB_EMBEDDED 1723#else //KAB_EMBEDDED
1714 qDebug("KABCore::getNameByPhone finsih method"); 1724 qDebug("KABCore::getNameByPhone finsih method");
1715 return ""; 1725 return "";
1716#endif //KAB_EMBEDDED 1726#endif //KAB_EMBEDDED
1717 1727
1718} 1728}
1719void KABCore::openConfigGlobalDialog() 1729void KABCore::openConfigGlobalDialog()
1720{ 1730{
1721 KPimPrefsGlobalDialog gc ( this ); 1731 KPimPrefsGlobalDialog gc ( this );
1722 gc.exec(); 1732 gc.exec();
1723} 1733}
1724void KABCore::openConfigDialog() 1734void KABCore::openConfigDialog()
1725{ 1735{
1726 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true); 1736 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true);
1727 1737
1728 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" ); 1738 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" );
1729 ConfigureDialog->setMainWidget( kabcfg ); 1739 ConfigureDialog->setMainWidget( kabcfg );
1730 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1740 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1731 this, SLOT( configurationChanged() ) ); 1741 this, SLOT( configurationChanged() ) );
1732 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1742 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1733 kabcfg, SLOT( save() ) ); 1743 kabcfg, SLOT( save() ) );
1734 connect( ConfigureDialog, SIGNAL( acceptClicked() ), 1744 connect( ConfigureDialog, SIGNAL( acceptClicked() ),
1735 this, SLOT( configurationChanged() ) ); 1745 this, SLOT( configurationChanged() ) );
1736 connect( ConfigureDialog, SIGNAL( acceptClicked() ), 1746 connect( ConfigureDialog, SIGNAL( acceptClicked() ),
1737 kabcfg, SLOT( save() ) ); 1747 kabcfg, SLOT( save() ) );
1738 connect( ConfigureDialog, SIGNAL( defaultClicked() ), 1748 connect( ConfigureDialog, SIGNAL( defaultClicked() ),
1739 kabcfg, SLOT( defaults() ) ); 1749 kabcfg, SLOT( defaults() ) );
1740 saveSettings(); 1750 saveSettings();
1741 kabcfg->load(); 1751 kabcfg->load();
1742#ifndef DESKTOP_VERSION 1752#ifndef DESKTOP_VERSION
1743 if ( QApplication::desktop()->height() <= 480 ) 1753 if ( QApplication::desktop()->height() <= 480 )
1744 ConfigureDialog->hideButtons(); 1754 ConfigureDialog->hideButtons();
1745 ConfigureDialog->showMaximized(); 1755 ConfigureDialog->showMaximized();
1746#endif 1756#endif
1747 if ( ConfigureDialog->exec() ) 1757 if ( ConfigureDialog->exec() )
1748 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1758 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1749 delete ConfigureDialog; 1759 delete ConfigureDialog;
1750} 1760}
1751 1761
1752void KABCore::openLDAPDialog() 1762void KABCore::openLDAPDialog()
1753{ 1763{
1754#ifndef KAB_EMBEDDED 1764#ifndef KAB_EMBEDDED
1755 if ( !mLdapSearchDialog ) { 1765 if ( !mLdapSearchDialog ) {
1756 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1766 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1757 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1767 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1758 SLOT( refreshView() ) ); 1768 SLOT( refreshView() ) );
1759 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1769 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1760 SLOT( setModified() ) ); 1770 SLOT( setModified() ) );
1761 } else 1771 } else
1762 mLdapSearchDialog->restoreSettings(); 1772 mLdapSearchDialog->restoreSettings();
1763 1773
1764 if ( mLdapSearchDialog->isOK() ) 1774 if ( mLdapSearchDialog->isOK() )
1765 mLdapSearchDialog->exec(); 1775 mLdapSearchDialog->exec();
1766#else //KAB_EMBEDDED 1776#else //KAB_EMBEDDED
1767 qDebug("KABCore::openLDAPDialog() finsih method"); 1777 qDebug("KABCore::openLDAPDialog() finsih method");
1768#endif //KAB_EMBEDDED 1778#endif //KAB_EMBEDDED
1769} 1779}
1770 1780
1771void KABCore::print() 1781void KABCore::print()
1772{ 1782{
1773#ifndef KAB_EMBEDDED 1783#ifndef KAB_EMBEDDED
1774 KPrinter printer; 1784 KPrinter printer;
1775 if ( !printer.setup( this ) ) 1785 if ( !printer.setup( this ) )
1776 return; 1786 return;
1777 1787
1778 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1788 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1779 mViewManager->selectedUids(), this ); 1789 mViewManager->selectedUids(), this );
1780 1790
1781 wizard.exec(); 1791 wizard.exec();
1782#else //KAB_EMBEDDED 1792#else //KAB_EMBEDDED
1783 qDebug("KABCore::print() finsih method"); 1793 qDebug("KABCore::print() finsih method");
1784#endif //KAB_EMBEDDED 1794#endif //KAB_EMBEDDED
1785 1795
1786} 1796}
1787 1797
1788 1798
1789void KABCore::addGUIClient( KXMLGUIClient *client ) 1799void KABCore::addGUIClient( KXMLGUIClient *client )
1790{ 1800{
1791 if ( mGUIClient ) 1801 if ( mGUIClient )
1792 mGUIClient->insertChildClient( client ); 1802 mGUIClient->insertChildClient( client );
1793 else 1803 else
1794 KMessageBox::error( this, "no KXMLGUICLient"); 1804 KMessageBox::error( this, "no KXMLGUICLient");
1795} 1805}
1796 1806
1797 1807
1798void KABCore::configurationChanged() 1808void KABCore::configurationChanged()
1799{ 1809{
1800 mExtensionManager->reconfigure(); 1810 mExtensionManager->reconfigure();
1801} 1811}
1802 1812
1803void KABCore::addressBookChanged() 1813void KABCore::addressBookChanged()
1804{ 1814{
1805/*US 1815/*US
1806 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1816 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1807 while ( it.current() ) { 1817 while ( it.current() ) {
1808 if ( it.current()->dirty() ) { 1818 if ( it.current()->dirty() ) {
1809 QString text = i18n( "Data has been changed externally. Unsaved " 1819 QString text = i18n( "Data has been changed externally. Unsaved "
1810 "changes will be lost." ); 1820 "changes will be lost." );
1811 KMessageBox::information( this, text ); 1821 KMessageBox::information( this, text );
1812 } 1822 }
1813 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1823 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1814 ++it; 1824 ++it;
1815 } 1825 }
1816*/ 1826*/
1817 if (mEditorDialog) 1827 if (mEditorDialog)
1818 { 1828 {
1819 if (mEditorDialog->dirty()) 1829 if (mEditorDialog->dirty())
1820 { 1830 {
1821 QString text = i18n( "Data has been changed externally. Unsaved " 1831 QString text = i18n( "Data has been changed externally. Unsaved "
1822 "changes will be lost." ); 1832 "changes will be lost." );
1823 KMessageBox::information( this, text ); 1833 KMessageBox::information( this, text );
1824 } 1834 }
1825 QString currentuid = mEditorDialog->addressee().uid(); 1835 QString currentuid = mEditorDialog->addressee().uid();
1826 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1836 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1827 } 1837 }
1828 mViewManager->refreshView(); 1838 mViewManager->refreshView();
1829 1839
1830 1840
1831} 1841}
1832 1842
1833AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1843AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1834 const char *name ) 1844 const char *name )
1835{ 1845{
1836 1846
1837 if ( mEditorDialog == 0 ) { 1847 if ( mEditorDialog == 0 ) {
1838 mEditorDialog = new AddresseeEditorDialog( this, parent, 1848 mEditorDialog = new AddresseeEditorDialog( this, parent,
1839 name ? name : "editorDialog" ); 1849 name ? name : "editorDialog" );
1840 1850
1841 1851
1842 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1852 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1843 SLOT( contactModified( const KABC::Addressee& ) ) ); 1853 SLOT( contactModified( const KABC::Addressee& ) ) );
1844 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1854 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1845 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1855 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1846 } 1856 }
1847 1857
1848 return mEditorDialog; 1858 return mEditorDialog;
1849} 1859}
1850 1860
1851void KABCore::slotEditorDestroyed( const QString &uid ) 1861void KABCore::slotEditorDestroyed( const QString &uid )
1852{ 1862{
1853 //mEditorDict.remove( uid ); 1863 //mEditorDict.remove( uid );
1854} 1864}
1855 1865
1856void KABCore::initGUI() 1866void KABCore::initGUI()
1857{ 1867{
1858#ifndef KAB_EMBEDDED 1868#ifndef KAB_EMBEDDED
1859 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1869 Q3HBoxLayout *topLayout = new Q3HBoxLayout( this );
1860 topLayout->setSpacing( KDialogBase::spacingHint() ); 1870 topLayout->setSpacing( KDialogBase::spacingHint() );
1861 1871
1862 mExtensionBarSplitter = new QSplitter( this ); 1872 mExtensionBarSplitter = new QSplitter( this );
1863 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1873 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1864 1874
1865 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1875 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1866 1876
1867 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1877 Q3VBox *viewSpace = new Q3VBox( mDetailsSplitter );
1868 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1878 mIncSearchWidget = new IncSearchWidget( viewSpace );
1869 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1879 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1870 SLOT( incrementalSearch( const QString& ) ) ); 1880 SLOT( incrementalSearch( const QString& ) ) );
1871 1881
1872 mViewManager = new ViewManager( this, viewSpace ); 1882 mViewManager = new ViewManager( this, viewSpace );
1873 viewSpace->setStretchFactor( mViewManager, 1 ); 1883 viewSpace->setStretchFactor( mViewManager, 1 );
1874 1884
1875 mDetails = new ViewContainer( mDetailsSplitter ); 1885 mDetails = new ViewContainer( mDetailsSplitter );
1876 1886
1877 mJumpButtonBar = new JumpButtonBar( this, this ); 1887 mJumpButtonBar = new JumpButtonBar( this, this );
1878 1888
1879 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1889 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1880 1890
1881 topLayout->addWidget( mExtensionBarSplitter ); 1891 topLayout->addWidget( mExtensionBarSplitter );
1882 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1892 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1883 topLayout->addWidget( mJumpButtonBar ); 1893 topLayout->addWidget( mJumpButtonBar );
1884 //topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1894 //topLayout->setStretchFactor( mJumpButtonBar, 1 );
1885 1895
1886 mXXPortManager = new XXPortManager( this, this ); 1896 mXXPortManager = new XXPortManager( this, this );
1887 1897
1888#else //KAB_EMBEDDED 1898#else //KAB_EMBEDDED
1889 //US initialize viewMenu before settingup viewmanager. 1899 //US initialize viewMenu before settingup viewmanager.
1890 // Viewmanager needs this menu to plugin submenues. 1900 // Viewmanager needs this menu to plugin submenues.
1891 viewMenu = new QPopupMenu( this ); 1901 viewMenu = new Q3PopupMenu( this );
1892 settingsMenu = new QPopupMenu( this ); 1902 settingsMenu = new Q3PopupMenu( this );
1893 //filterMenu = new QPopupMenu( this ); 1903 //filterMenu = new QPopupMenu( this );
1894 ImportMenu = new QPopupMenu( this ); 1904 ImportMenu = new Q3PopupMenu( this );
1895 ExportMenu = new QPopupMenu( this ); 1905 ExportMenu = new Q3PopupMenu( this );
1896 syncMenu = new QPopupMenu( this ); 1906 syncMenu = new Q3PopupMenu( this );
1897 changeMenu= new QPopupMenu( this ); 1907 changeMenu= new Q3PopupMenu( this );
1898 beamMenu= new QPopupMenu( this ); 1908 beamMenu= new Q3PopupMenu( this );
1899 1909
1900//US since we have no splitter for the embedded system, setup 1910//US since we have no splitter for the embedded system, setup
1901// a layout with two frames. One left and one right. 1911// a layout with two frames. One left and one right.
1902 1912
1903 QBoxLayout *topLayout; 1913 Q3BoxLayout *topLayout;
1904 1914
1905 // = new QHBoxLayout( this ); 1915 // = new QHBoxLayout( this );
1906// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1916// QBoxLayout *topLayout = (QBoxLayout*)layout();
1907 1917
1908// QWidget *mainBox = new QWidget( this ); 1918// QWidget *mainBox = new QWidget( this );
1909// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1919// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1910 1920
1911#ifdef DESKTOP_VERSION 1921#ifdef DESKTOP_VERSION
1912 topLayout = new QHBoxLayout( this ); 1922 topLayout = new Q3HBoxLayout( this );
1913 1923
1914 1924
1915 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1925 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1916 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1926 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1917 1927
1918 topLayout->addWidget(mMiniSplitter ); 1928 topLayout->addWidget(mMiniSplitter );
1919 1929
1920 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1930 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1921 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1931 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1922 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1932 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1923 mDetails = new ViewContainer( mMiniSplitter ); 1933 mDetails = new ViewContainer( mMiniSplitter );
1924 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1934 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1925#else 1935#else
1926 if ( QApplication::desktop()->width() > 480 ) { 1936 if ( QApplication::desktop()->width() > 480 ) {
1927 topLayout = new QHBoxLayout( this ); 1937 topLayout = new Q3HBoxLayout( this );
1928 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1938 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1929 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1939 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1930 } else { 1940 } else {
1931 1941
1932 topLayout = new QHBoxLayout( this ); 1942 topLayout = new Q3HBoxLayout( this );
1933 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1943 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1934 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1944 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1935 } 1945 }
1936 1946
1937 topLayout->addWidget(mMiniSplitter ); 1947 topLayout->addWidget(mMiniSplitter );
1938 mViewManager = new ViewManager( this, mMiniSplitter ); 1948 mViewManager = new ViewManager( this, mMiniSplitter );
1939 mDetails = new ViewContainer( mMiniSplitter ); 1949 mDetails = new ViewContainer( mMiniSplitter );
1940 1950
1941 1951
1942 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1952 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1943#endif 1953#endif
1944 //eh->hide(); 1954 //eh->hide();
1945 // topLayout->addWidget(mExtensionManager ); 1955 // topLayout->addWidget(mExtensionManager );
1946 1956
1947 1957
1948/*US 1958/*US
1949#ifndef KAB_NOSPLITTER 1959#ifndef KAB_NOSPLITTER
1950 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1960 QHBoxLayout *topLayout = new QHBoxLayout( this );
1951//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1961//US topLayout->setSpacing( KDialogBase::spacingHint() );
1952 topLayout->setSpacing( 10 ); 1962 topLayout->setSpacing( 10 );
1953 1963
1954 mDetailsSplitter = new QSplitter( this ); 1964 mDetailsSplitter = new QSplitter( this );
1955 1965
1956 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1966 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1957 1967
1958 mViewManager = new ViewManager( this, viewSpace ); 1968 mViewManager = new ViewManager( this, viewSpace );
1959 viewSpace->setStretchFactor( mViewManager, 1 ); 1969 viewSpace->setStretchFactor( mViewManager, 1 );
1960 1970
1961 mDetails = new ViewContainer( mDetailsSplitter ); 1971 mDetails = new ViewContainer( mDetailsSplitter );
1962 1972
1963 topLayout->addWidget( mDetailsSplitter ); 1973 topLayout->addWidget( mDetailsSplitter );
1964 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1974 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1965#else //KAB_NOSPLITTER 1975#else //KAB_NOSPLITTER
1966 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1976 QHBoxLayout *topLayout = new QHBoxLayout( this );
1967//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1977//US topLayout->setSpacing( KDialogBase::spacingHint() );
1968 topLayout->setSpacing( 10 ); 1978 topLayout->setSpacing( 10 );
1969 1979
1970// mDetailsSplitter = new QSplitter( this ); 1980// mDetailsSplitter = new QSplitter( this );
1971 1981
1972 QVBox *viewSpace = new QVBox( this ); 1982 QVBox *viewSpace = new QVBox( this );
1973 1983
1974 mViewManager = new ViewManager( this, viewSpace ); 1984 mViewManager = new ViewManager( this, viewSpace );
1975 viewSpace->setStretchFactor( mViewManager, 1 ); 1985 viewSpace->setStretchFactor( mViewManager, 1 );
1976 1986
1977 mDetails = new ViewContainer( this ); 1987 mDetails = new ViewContainer( this );
1978 1988
1979 topLayout->addWidget( viewSpace ); 1989 topLayout->addWidget( viewSpace );
1980// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1990// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1981 topLayout->addWidget( mDetails ); 1991 topLayout->addWidget( mDetails );
1982#endif //KAB_NOSPLITTER 1992#endif //KAB_NOSPLITTER
1983*/ 1993*/
1984 1994
1985 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1995 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1986 syncManager->setBlockSave(false); 1996 syncManager->setBlockSave(false);
1987 1997
1988 connect(syncManager , SIGNAL( request_file(const QString &) ), this, SLOT( syncFileRequest(const QString &) ) ); 1998 connect(syncManager , SIGNAL( request_file(const QString &) ), this, SLOT( syncFileRequest(const QString &) ) );
1989 connect(syncManager , SIGNAL( getFile( bool ,const QString &)), this, SLOT(getFile( bool ,const QString &) ) ); 1999 connect(syncManager , SIGNAL( getFile( bool ,const QString &)), this, SLOT(getFile( bool ,const QString &) ) );
1990 QString sync_file = sentSyncFile(); 2000 QString sync_file = sentSyncFile();
1991 //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); 2001 //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1());
1992 syncManager->setDefaultFileName( sync_file ); 2002 syncManager->setDefaultFileName( sync_file );
1993 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 2003 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1994 2004
1995#endif //KAB_EMBEDDED 2005#endif //KAB_EMBEDDED
1996 initActions(); 2006 initActions();
1997 2007
1998#ifdef KAB_EMBEDDED 2008#ifdef KAB_EMBEDDED
1999 addActionsManually(); 2009 addActionsManually();
2000 //US make sure the export and import menues are initialized before creating the xxPortManager. 2010 //US make sure the export and import menues are initialized before creating the xxPortManager.
2001 mXXPortManager = new XXPortManager( this, this ); 2011 mXXPortManager = new XXPortManager( this, this );
2002 2012
2003 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 2013 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
2004 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 2014 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
2005 // mActionQuit->plug ( mMainWindow->toolBar()); 2015 // mActionQuit->plug ( mMainWindow->toolBar());
2006 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 2016 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
2007 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 2017 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
2008 // mIncSearchWidget->hide(); 2018 // mIncSearchWidget->hide();
2009 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2019 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2010 SLOT( incrementalSearch( const QString& ) ) ); 2020 SLOT( incrementalSearch( const QString& ) ) );
2011 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 2021 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
2012 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 2022 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
2013 2023
2014 mJumpButtonBar = new JumpButtonBar( this, this ); 2024 mJumpButtonBar = new JumpButtonBar( this, this );
2015 2025
2016 topLayout->addWidget( mJumpButtonBar ); 2026 topLayout->addWidget( mJumpButtonBar );
2017//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 2027//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
2018 2028
2019// mMainWindow->getIconToolBar()->raise(); 2029// mMainWindow->getIconToolBar()->raise();
2020 2030
2021#endif //KAB_EMBEDDED 2031#endif //KAB_EMBEDDED
2022 2032
2023} 2033}
2024void KABCore::initActions() 2034void KABCore::initActions()
2025{ 2035{
2026//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2036//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
2027 2037
2028#ifndef KAB_EMBEDDED 2038#ifndef KAB_EMBEDDED
2029 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 2039 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
2030 SLOT( clipboardDataChanged() ) ); 2040 SLOT( clipboardDataChanged() ) );
2031#endif //KAB_EMBEDDED 2041#endif //KAB_EMBEDDED
2032 2042
2033 // file menu 2043 // file menu
2034 2044
2035 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 2045 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
2036 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 2046 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
2037 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, 2047 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", Qt::CTRL + Qt::Key_P, mViewManager,
2038 SLOT( printView() ), actionCollection(), "kaddressbook_print" ); 2048 SLOT( printView() ), actionCollection(), "kaddressbook_print" );
2039 2049
2040 2050
2041 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, 2051 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails,
2042 SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); 2052 SLOT( printView() ), actionCollection(), "kaddressbook_print2" );
2043 2053
2044 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 2054 mActionSave = new KAction( i18n( "&Save" ), "filesave", Qt::CTRL+Qt::Key_S, this,
2045 SLOT( save() ), actionCollection(), "file_sync" ); 2055 SLOT( save() ), actionCollection(), "file_sync" );
2046 2056
2047 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 2057 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", Qt::CTRL+Qt::Key_N, this,
2048 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 2058 SLOT( newContact() ), actionCollection(), "file_new_contact" );
2049 2059
2050 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 2060 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
2051 this, SLOT( mailVCard() ), 2061 this, SLOT( mailVCard() ),
2052 actionCollection(), "file_mail_vcard"); 2062 actionCollection(), "file_mail_vcard");
2053 2063
2054 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, 2064 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this,
2055 SLOT( export2phone() ), actionCollection(), 2065 SLOT( export2phone() ), actionCollection(),
2056 "kaddressbook_ex2phone" ); 2066 "kaddressbook_ex2phone" );
2057 2067
2058 mActionBeamVCard = 0; 2068 mActionBeamVCard = 0;
2059 mActionBeam = 0; 2069 mActionBeam = 0;
2060 2070
2061#ifndef DESKTOP_VERSION 2071#ifndef DESKTOP_VERSION
2062 if ( Ir::supported() ) { 2072 if ( Ir::supported() ) {
2063 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, 2073 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this,
2064 SLOT( beamVCard() ), actionCollection(), 2074 SLOT( beamVCard() ), actionCollection(),
2065 "kaddressbook_beam_vcard" ); 2075 "kaddressbook_beam_vcard" );
2066 2076
2067 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 2077 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
2068 SLOT( beamMySelf() ), actionCollection(), 2078 SLOT( beamMySelf() ), actionCollection(),
2069 "kaddressbook_beam_myself" ); 2079 "kaddressbook_beam_myself" );
2070 } 2080 }
2071#endif 2081#endif
2072 2082
2073 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 2083 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
2074 this, SLOT( editContact2() ), 2084 this, SLOT( editContact2() ),
2075 actionCollection(), "file_properties" ); 2085 actionCollection(), "file_properties" );
2076 2086
2077#ifdef KAB_EMBEDDED 2087#ifdef KAB_EMBEDDED
2078 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 2088 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
2079 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 2089 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
2080 mMainWindow, SLOT( exit() ), 2090 mMainWindow, SLOT( exit() ),
2081 actionCollection(), "quit" ); 2091 actionCollection(), "quit" );
2082#endif //KAB_EMBEDDED 2092#endif //KAB_EMBEDDED
2083 2093
2084 // edit menu 2094 // edit menu
2085 if ( mIsPart ) { 2095 if ( mIsPart ) {
2086 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 2096 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", Qt::CTRL + Qt::Key_C, this,
2087 SLOT( copyContacts() ), actionCollection(), 2097 SLOT( copyContacts() ), actionCollection(),
2088 "kaddressbook_copy" ); 2098 "kaddressbook_copy" );
2089 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 2099 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", Qt::CTRL + Qt::Key_X, this,
2090 SLOT( cutContacts() ), actionCollection(), 2100 SLOT( cutContacts() ), actionCollection(),
2091 "kaddressbook_cut" ); 2101 "kaddressbook_cut" );
2092 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 2102 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", Qt::CTRL + Qt::Key_V, this,
2093 SLOT( pasteContacts() ), actionCollection(), 2103 SLOT( pasteContacts() ), actionCollection(),
2094 "kaddressbook_paste" ); 2104 "kaddressbook_paste" );
2095 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 2105 mActionSelectAll = new KAction( i18n( "Select &All" ), Qt::CTRL + Qt::Key_A, this,
2096 SLOT( selectAllContacts() ), actionCollection(), 2106 SLOT( selectAllContacts() ), actionCollection(),
2097 "kaddressbook_select_all" ); 2107 "kaddressbook_select_all" );
2098 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 2108 mActionUndo = new KAction( i18n( "&Undo" ), "undo", Qt::CTRL + Qt::Key_Z, this,
2099 SLOT( undo() ), actionCollection(), 2109 SLOT( undo() ), actionCollection(),
2100 "kaddressbook_undo" ); 2110 "kaddressbook_undo" );
2101 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 2111 mActionRedo = new KAction( i18n( "Re&do" ), "redo", Qt::CTRL + Qt::SHIFT + Qt::Key_Z,
2102 this, SLOT( redo() ), actionCollection(), 2112 this, SLOT( redo() ), actionCollection(),
2103 "kaddressbook_redo" ); 2113 "kaddressbook_redo" );
2104 } else { 2114 } else {
2105 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 2115 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
2106 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 2116 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
2107 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 2117 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
2108 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 2118 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
2109 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 2119 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
2110 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 2120 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
2111 } 2121 }
2112 2122
2113 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 2123 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
2114 Key_Delete, this, SLOT( deleteContacts() ), 2124 Qt::Key_Delete, this, SLOT( deleteContacts() ),
2115 actionCollection(), "edit_delete" ); 2125 actionCollection(), "edit_delete" );
2116 2126
2117 mActionUndo->setEnabled( false ); 2127 mActionUndo->setEnabled( false );
2118 mActionRedo->setEnabled( false ); 2128 mActionRedo->setEnabled( false );
2119 2129
2120 // settings menu 2130 // settings menu
2121#ifdef KAB_EMBEDDED 2131#ifdef KAB_EMBEDDED
2122//US special menuentry to configure the addressbook resources. On KDE 2132//US special menuentry to configure the addressbook resources. On KDE
2123// you do that through the control center !!! 2133// you do that through the control center !!!
2124 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 2134 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
2125 SLOT( configureResources() ), actionCollection(), 2135 SLOT( configureResources() ), actionCollection(),
2126 "kaddressbook_configure_resources" ); 2136 "kaddressbook_configure_resources" );
2127#endif //KAB_EMBEDDED 2137#endif //KAB_EMBEDDED
2128 2138
2129 if ( mIsPart ) { 2139 if ( mIsPart ) {
2130 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 2140 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
2131 SLOT( openConfigDialog() ), actionCollection(), 2141 SLOT( openConfigDialog() ), actionCollection(),
2132 "kaddressbook_configure" ); 2142 "kaddressbook_configure" );
2133 2143
2134 //US not implemented yet 2144 //US not implemented yet
2135 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 2145 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
2136 // this, SLOT( configureKeyBindings() ), actionCollection(), 2146 // this, SLOT( configureKeyBindings() ), actionCollection(),
2137 // "kaddressbook_configure_shortcuts" ); 2147 // "kaddressbook_configure_shortcuts" );
2138#ifdef KAB_EMBEDDED 2148#ifdef KAB_EMBEDDED
2139 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 2149 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
2140 mActionConfigureToolbars->setEnabled( false ); 2150 mActionConfigureToolbars->setEnabled( false );
2141#endif //KAB_EMBEDDED 2151#endif //KAB_EMBEDDED
2142 2152
2143 } else { 2153 } else {
2144 mActionConfigKAddressbook = new KAction( i18n( "&Configure KA/Pi..." ), "configure", 0, this, 2154 mActionConfigKAddressbook = new KAction( i18n( "&Configure KA/Pi..." ), "configure", 0, this,
2145 SLOT( openConfigDialog() ), actionCollection(), 2155 SLOT( openConfigDialog() ), actionCollection(),
2146 "kaddressbook_configure" ); 2156 "kaddressbook_configure" );
2147 mActionConfigGlobal = new KAction( i18n( "Global Settings..." ), "configure", 0, this, 2157 mActionConfigGlobal = new KAction( i18n( "Global Settings..." ), "configure", 0, this,
2148 SLOT( openConfigGlobalDialog() ), actionCollection(), 2158 SLOT( openConfigGlobalDialog() ), actionCollection(),
2149 "kaddressbook_configure" ); 2159 "kaddressbook_configure" );
2150 } 2160 }
2151 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 2161 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
2152 actionCollection(), "options_show_jump_bar" ); 2162 actionCollection(), "options_show_jump_bar" );
2153 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); 2163 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) );
2154 2164
2155 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 2165 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
2156 actionCollection(), "options_show_details" ); 2166 actionCollection(), "options_show_details" );
2157 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 2167 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
2158 2168
2159 2169
2160 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 2170 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
2161 SLOT( toggleBeamReceive() ), actionCollection(), 2171 SLOT( toggleBeamReceive() ), actionCollection(),
2162 "kaddressbook_beam_rec" ); 2172 "kaddressbook_beam_rec" );
2163 2173
2164 2174
2165 // misc 2175 // misc
2166 // only enable LDAP lookup if we can handle the protocol 2176 // only enable LDAP lookup if we can handle the protocol
2167#ifndef KAB_EMBEDDED 2177#ifndef KAB_EMBEDDED
2168 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 2178 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
2169 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 2179 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
2170 this, SLOT( openLDAPDialog() ), actionCollection(), 2180 this, SLOT( openLDAPDialog() ), actionCollection(),
2171 "ldap_lookup" ); 2181 "ldap_lookup" );
2172 } 2182 }
2173#else //KAB_EMBEDDED 2183#else //KAB_EMBEDDED
2174 //qDebug("KABCore::initActions() LDAP has to be implemented"); 2184 //qDebug("KABCore::initActions() LDAP has to be implemented");
2175#endif //KAB_EMBEDDED 2185#endif //KAB_EMBEDDED
2176 2186
2177 2187
2178 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 2188 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
2179 SLOT( setWhoAmI() ), actionCollection(), 2189 SLOT( setWhoAmI() ), actionCollection(),
2180 "set_personal" ); 2190 "set_personal" );
2181 2191
2182 2192
2183 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, 2193 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this,
2184 SLOT( setCategories() ), actionCollection(), 2194 SLOT( setCategories() ), actionCollection(),
2185 "edit_set_categories" ); 2195 "edit_set_categories" );
2186 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, 2196 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this,
2187 SLOT( editCategories() ), actionCollection(), 2197 SLOT( editCategories() ), actionCollection(),
2188 "edit__categories" ); 2198 "edit__categories" );
2189 2199
2190 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 2200 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
2191 SLOT( removeVoice() ), actionCollection(), 2201 SLOT( removeVoice() ), actionCollection(),
2192 "remove_voice" ); 2202 "remove_voice" );
2193 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, 2203 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this,
2194 SLOT( setFormattedName() ), actionCollection(), 2204 SLOT( setFormattedName() ), actionCollection(),
2195 "set_formatted" ); 2205 "set_formatted" );
2196 2206
2197 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 2207 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
2198 SLOT( manageCategories() ), actionCollection(), 2208 SLOT( manageCategories() ), actionCollection(),
2199 "remove_voice" ); 2209 "remove_voice" );
2200 2210
2201 2211
2202 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 2212 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
2203 SLOT( importFromOL() ), actionCollection(), 2213 SLOT( importFromOL() ), actionCollection(),
2204 "import_OL" ); 2214 "import_OL" );
2205#ifdef KAB_EMBEDDED 2215#ifdef KAB_EMBEDDED
2206 mActionLicence = new KAction( i18n( "Licence" ), 0, 2216 mActionLicence = new KAction( i18n( "Licence" ), 0,
2207 this, SLOT( showLicence() ), actionCollection(), 2217 this, SLOT( showLicence() ), actionCollection(),
2208 "licence_about_data" ); 2218 "licence_about_data" );
2209 mActionFaq = new KAction( i18n( "Faq" ), 0, 2219 mActionFaq = new KAction( i18n( "Faq" ), 0,
2210 this, SLOT( faq() ), actionCollection(), 2220 this, SLOT( faq() ), actionCollection(),
2211 "faq_about_data" ); 2221 "faq_about_data" );
2212 mActionWN = new KAction( i18n( "What's New?" ), 0, 2222 mActionWN = new KAction( i18n( "What's New?" ), 0,
2213 this, SLOT( whatsnew() ), actionCollection(), 2223 this, SLOT( whatsnew() ), actionCollection(),
2214 "wn" ); 2224 "wn" );
2215 2225
2216 2226
2217 2227
2218 mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0, 2228 mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0,
2219 this, SLOT( storagehowto() ), actionCollection(), 2229 this, SLOT( storagehowto() ), actionCollection(),
2220 "storage" ); 2230 "storage" );
2221 2231
2222 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 2232 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
2223 this, SLOT( synchowto() ), actionCollection(), 2233 this, SLOT( synchowto() ), actionCollection(),
2224 "sync" ); 2234 "sync" );
2225 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 2235 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
2226 this, SLOT( kdesynchowto() ), actionCollection(), 2236 this, SLOT( kdesynchowto() ), actionCollection(),
2227 "kdesync" ); 2237 "kdesync" );
2228 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 2238 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
2229 this, SLOT( multisynchowto() ), actionCollection(), 2239 this, SLOT( multisynchowto() ), actionCollection(),
2230 "multisync" ); 2240 "multisync" );
2231 2241
2232 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 2242 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
2233 this, SLOT( createAboutData() ), actionCollection(), 2243 this, SLOT( createAboutData() ), actionCollection(),
2234 "kaddressbook_about_data" ); 2244 "kaddressbook_about_data" );
2235#endif //KAB_EMBEDDED 2245#endif //KAB_EMBEDDED
2236 2246
2237 clipboardDataChanged(); 2247 clipboardDataChanged();
2238 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2248 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2239 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2249 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2240} 2250}
2241 2251
2242//US we need this function, to plug all actions into the correct menues. 2252//US we need this function, to plug all actions into the correct menues.
2243// KDE uses a XML format to plug the actions, but we work her without this overhead. 2253// KDE uses a XML format to plug the actions, but we work her without this overhead.
2244void KABCore::addActionsManually() 2254void KABCore::addActionsManually()
2245{ 2255{
2246//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2256//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
2247 2257
2248#ifdef KAB_EMBEDDED 2258#ifdef KAB_EMBEDDED
2249 QPopupMenu *fileMenu = new QPopupMenu( this ); 2259 Q3PopupMenu *fileMenu = new Q3PopupMenu( this );
2250 QPopupMenu *editMenu = new QPopupMenu( this ); 2260 Q3PopupMenu *editMenu = new Q3PopupMenu( this );
2251 QPopupMenu *helpMenu = new QPopupMenu( this ); 2261 Q3PopupMenu *helpMenu = new Q3PopupMenu( this );
2252 2262
2253 KToolBar* tb = mMainWindow->toolBar(); 2263 KToolBar* tb = mMainWindow->toolBar();
2254 mMainWindow->setToolBarsMovable (false ); 2264 mMainWindow->setToolBarsMovable (false );
2255#ifndef DESKTOP_VERSION 2265#ifndef DESKTOP_VERSION
2256 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 2266 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
2257#endif 2267#endif
2258 QMenuBar* mb = mMainWindow->menuBar(); 2268 QMenuBar* mb = mMainWindow->menuBar();
2259 2269
2260 //US setup menubar. 2270 //US setup menubar.
2261 //Disable the following block if you do not want to have a menubar. 2271 //Disable the following block if you do not want to have a menubar.
2262 mb->insertItem( i18n("&File"), fileMenu ); 2272 mb->insertItem( i18n("&File"), fileMenu );
2263 mb->insertItem( i18n("&Edit"), editMenu ); 2273 mb->insertItem( i18n("&Edit"), editMenu );
2264 mb->insertItem( i18n("&View"), viewMenu ); 2274 mb->insertItem( i18n("&View"), viewMenu );
2265 mb->insertItem( i18n("&Settings"), settingsMenu ); 2275 mb->insertItem( i18n("&Settings"), settingsMenu );
2266#ifdef DESKTOP_VERSION 2276#ifdef DESKTOP_VERSION
2267 mb->insertItem( i18n("Synchronize"), syncMenu ); 2277 mb->insertItem( i18n("Synchronize"), syncMenu );
2268#else 2278#else
2269 mb->insertItem( i18n("Sync"), syncMenu ); 2279 mb->insertItem( i18n("Sync"), syncMenu );
2270#endif 2280#endif
2271 //mb->insertItem( i18n("&Change"), changeMenu ); 2281 //mb->insertItem( i18n("&Change"), changeMenu );
2272 mb->insertItem( i18n("&Help"), helpMenu ); 2282 mb->insertItem( i18n("&Help"), helpMenu );
2273 mIncSearchWidget = new IncSearchWidget( tb ); 2283 mIncSearchWidget = new IncSearchWidget( tb );
2274 // tb->insertWidget(-1, 0, mIncSearchWidget); 2284 // tb->insertWidget(-1, 0, mIncSearchWidget);
2275#ifndef DESKTOP_VERSION 2285#ifndef DESKTOP_VERSION
2276 } else { 2286 } else {
2277 //US setup toolbar 2287 //US setup toolbar
2278 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2288 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2279 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2289 Q3PopupMenu *popupBarTB = new Q3PopupMenu( this );
2280 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); 2290 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB);
2281 tb->insertWidget(-1, 0, menuBarTB); 2291 tb->insertWidget(-1, 0, menuBarTB);
2282 mIncSearchWidget = new IncSearchWidget( tb ); 2292 mIncSearchWidget = new IncSearchWidget( tb );
2283 tb->enableMoving(false); 2293 tb->enableMoving(false);
2284 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2294 popupBarTB->insertItem( i18n("&File"), fileMenu );
2285 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2295 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2286 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2296 popupBarTB->insertItem( i18n("&View"), viewMenu );
2287 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2297 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2288 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2298 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2289 mViewManager->getFilterAction()->plug ( popupBarTB); 2299 mViewManager->getFilterAction()->plug ( popupBarTB);
2290 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2300 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2291 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2301 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2292 if (QApplication::desktop()->width() > 320 ) { 2302 if (QApplication::desktop()->width() > 320 ) {
2293 // mViewManager->getFilterAction()->plug ( tb); 2303 // mViewManager->getFilterAction()->plug ( tb);
2294 } 2304 }
2295 } 2305 }
2296#endif 2306#endif
2297 mIncSearchWidget->setSize(); 2307 mIncSearchWidget->setSize();
2298 // mActionQuit->plug ( mMainWindow->toolBar()); 2308 // mActionQuit->plug ( mMainWindow->toolBar());
2299 2309
2300 2310
2301 2311
2302 //US Now connect the actions with the menue entries. 2312 //US Now connect the actions with the menue entries.
2303#ifdef DESKTOP_VERSION 2313#ifdef DESKTOP_VERSION
2304 mActionPrint->plug( fileMenu ); 2314 mActionPrint->plug( fileMenu );
2305 mActionPrintDetails->plug( fileMenu ); 2315 mActionPrintDetails->plug( fileMenu );
2306 fileMenu->insertSeparator(); 2316 fileMenu->insertSeparator();
2307#endif 2317#endif
2308 mActionMail->plug( fileMenu ); 2318 mActionMail->plug( fileMenu );
2309 fileMenu->insertSeparator(); 2319 fileMenu->insertSeparator();
2310 2320
2311 mActionNewContact->plug( editMenu ); 2321 mActionNewContact->plug( editMenu );
2312 mActionNewContact->plug( tb ); 2322 mActionNewContact->plug( tb );
2313 2323
2314 mActionEditAddressee->plug( editMenu ); 2324 mActionEditAddressee->plug( editMenu );
2315 editMenu->insertSeparator(); 2325 editMenu->insertSeparator();
2316 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2326 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2317 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2327 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2318 mActionEditAddressee->plug( tb ); 2328 mActionEditAddressee->plug( tb );
2319 2329
2320 // fileMenu->insertSeparator(); 2330 // fileMenu->insertSeparator();
2321 mActionSave->plug( fileMenu ); 2331 mActionSave->plug( fileMenu );
2322 fileMenu->insertItem( "&Import", ImportMenu ); 2332 fileMenu->insertItem( "&Import", ImportMenu );
2323 fileMenu->insertItem( "&Export", ExportMenu ); 2333 fileMenu->insertItem( "&Export", ExportMenu );
2324 editMenu->insertItem( i18n("&Change"), changeMenu ); 2334 editMenu->insertItem( i18n("&Change"), changeMenu );
2325 editMenu->insertSeparator(); 2335 editMenu->insertSeparator();
2326#ifndef DESKTOP_VERSION 2336#ifndef DESKTOP_VERSION
2327 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); 2337 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu );
2328#endif 2338#endif
2329#if 0 2339#if 0
2330 // PENDING fix MailVCard 2340 // PENDING fix MailVCard
2331 fileMenu->insertSeparator(); 2341 fileMenu->insertSeparator();
2332 mActionMailVCard->plug( fileMenu ); 2342 mActionMailVCard->plug( fileMenu );
2333#endif 2343#endif
2334#ifndef DESKTOP_VERSION 2344#ifndef DESKTOP_VERSION
2335 if ( Ir::supported() ) mActionBR->plug( beamMenu ); 2345 if ( Ir::supported() ) mActionBR->plug( beamMenu );
2336 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); 2346 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu );
2337 if ( Ir::supported() ) mActionBeam->plug( beamMenu ); 2347 if ( Ir::supported() ) mActionBeam->plug( beamMenu );
2338#endif 2348#endif
2339 fileMenu->insertSeparator(); 2349 fileMenu->insertSeparator();
2340 mActionQuit->plug( fileMenu ); 2350 mActionQuit->plug( fileMenu );
2341#ifdef _OL_IMPORT_ 2351#ifdef _OL_IMPORT_
2342 mActionImportOL->plug( ImportMenu ); 2352 mActionImportOL->plug( ImportMenu );
2343#endif 2353#endif
2344 // edit menu 2354 // edit menu
2345 mActionUndo->plug( editMenu ); 2355 mActionUndo->plug( editMenu );
2346 mActionRedo->plug( editMenu ); 2356 mActionRedo->plug( editMenu );
2347 editMenu->insertSeparator(); 2357 editMenu->insertSeparator();
2348 mActionCut->plug( editMenu ); 2358 mActionCut->plug( editMenu );
2349 mActionCopy->plug( editMenu ); 2359 mActionCopy->plug( editMenu );
2350 mActionPaste->plug( editMenu ); 2360 mActionPaste->plug( editMenu );
2351 mActionDelete->plug( editMenu ); 2361 mActionDelete->plug( editMenu );
2352 editMenu->insertSeparator(); 2362 editMenu->insertSeparator();
2353 mActionSelectAll->plug( editMenu ); 2363 mActionSelectAll->plug( editMenu );
2354 2364
2355 mActionSetFormattedName->plug( changeMenu ); 2365 mActionSetFormattedName->plug( changeMenu );
2356 mActionRemoveVoice->plug( changeMenu ); 2366 mActionRemoveVoice->plug( changeMenu );
2357 // settingsmings menu 2367 // settingsmings menu
2358//US special menuentry to configure the addressbook resources. On KDE 2368//US special menuentry to configure the addressbook resources. On KDE
2359// you do that through the control center !!! 2369// you do that through the control center !!!
2360 // settingsMenu->insertSeparator(); 2370 // settingsMenu->insertSeparator();
2361 2371
2362 mActionConfigKAddressbook->plug( settingsMenu, 0 ); 2372 mActionConfigKAddressbook->plug( settingsMenu, 0 );
2363 mActionConfigGlobal->plug( settingsMenu, 1 ); 2373 mActionConfigGlobal->plug( settingsMenu, 1 );
2364 mActionConfigResources->plug( settingsMenu,2 ); 2374 mActionConfigResources->plug( settingsMenu,2 );
2365 settingsMenu->insertSeparator(3); 2375 settingsMenu->insertSeparator(3);
2366 2376
2367 if ( mIsPart ) { 2377 if ( mIsPart ) {
2368 //US not implemented yet 2378 //US not implemented yet
2369 //mActionConfigShortcuts->plug( settingsMenu ); 2379 //mActionConfigShortcuts->plug( settingsMenu );
2370 //mActionConfigureToolbars->plug( settingsMenu ); 2380 //mActionConfigureToolbars->plug( settingsMenu );
2371 2381
2372 } else { 2382 } else {
2373 //US not implemented yet 2383 //US not implemented yet
2374 //mActionKeyBindings->plug( settingsMenu ); 2384 //mActionKeyBindings->plug( settingsMenu );
2375 } 2385 }
2376 2386
2377 mActionEditCategories->plug( settingsMenu ); 2387 mActionEditCategories->plug( settingsMenu );
2378 mActionManageCategories->plug( settingsMenu ); 2388 mActionManageCategories->plug( settingsMenu );
2379 mActionJumpBar->plug( viewMenu,0 ); 2389 mActionJumpBar->plug( viewMenu,0 );
2380 mActionDetails->plug( viewMenu,0 ); 2390 mActionDetails->plug( viewMenu,0 );
2381 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2391 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2382 mActionDetails->plug( tb ); 2392 mActionDetails->plug( tb );
2383 settingsMenu->insertSeparator(); 2393 settingsMenu->insertSeparator();
2384#ifndef DESKTOP_VERSION 2394#ifndef DESKTOP_VERSION
2385 if ( Ir::supported() ) mActionBR->plug(settingsMenu ); 2395 if ( Ir::supported() ) mActionBR->plug(settingsMenu );
2386 settingsMenu->insertSeparator(); 2396 settingsMenu->insertSeparator();
2387#endif 2397#endif
2388 2398
2389 mActionWhoAmI->plug( settingsMenu ); 2399 mActionWhoAmI->plug( settingsMenu );
2390 //mActionEditCategories->plug( changeMenu ); 2400 //mActionEditCategories->plug( changeMenu );
2391 mActionCategories->plug( changeMenu ); 2401 mActionCategories->plug( changeMenu );
2392 //mActionManageCategories->plug( changeMenu ); 2402 //mActionManageCategories->plug( changeMenu );
2393 2403
2394 //mActionCategories->plug( settingsMenu ); 2404 //mActionCategories->plug( settingsMenu );
2395 2405
2396 2406
2397 mActionWN->plug( helpMenu ); 2407 mActionWN->plug( helpMenu );
2398 mActionStorageHowto->plug( helpMenu ); 2408 mActionStorageHowto->plug( helpMenu );
2399 mActionSyncHowto->plug( helpMenu ); 2409 mActionSyncHowto->plug( helpMenu );
2400 mActionKdeSyncHowto->plug( helpMenu ); 2410 mActionKdeSyncHowto->plug( helpMenu );
2401 mActionMultiSyncHowto->plug( helpMenu ); 2411 mActionMultiSyncHowto->plug( helpMenu );
2402 mActionFaq->plug( helpMenu ); 2412 mActionFaq->plug( helpMenu );
2403 mActionLicence->plug( helpMenu ); 2413 mActionLicence->plug( helpMenu );
2404 mActionAboutKAddressbook->plug( helpMenu ); 2414 mActionAboutKAddressbook->plug( helpMenu );
2405 2415
2406 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2416 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2407 2417
2408 mActionSave->plug( tb ); 2418 mActionSave->plug( tb );
2409 mViewManager->getFilterAction()->plug ( tb); 2419 mViewManager->getFilterAction()->plug ( tb);
2410 //LR hide filteraction on started in 480x640 2420 //LR hide filteraction on started in 480x640
2411 if (QApplication::desktop()->width() == 480 ) { 2421 if (QApplication::desktop()->width() == 480 ) {
2412 mViewManager->getFilterAction()->setComboWidth( 0 ); 2422 mViewManager->getFilterAction()->setComboWidth( 0 );
2413 } 2423 }
2414 mActionUndo->plug( tb ); 2424 mActionUndo->plug( tb );
2415 mActionDelete->plug( tb ); 2425 mActionDelete->plug( tb );
2416 mActionRedo->plug( tb ); 2426 mActionRedo->plug( tb );
2417 } else { 2427 } else {
2418 mActionSave->plug( tb ); 2428 mActionSave->plug( tb );
2419 tb->enableMoving(false); 2429 tb->enableMoving(false);
2420 } 2430 }
2421 //mActionQuit->plug ( tb ); 2431 //mActionQuit->plug ( tb );
2422 //tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2432 //tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2423 2433
2424 //US link the searchwidget first to this. 2434 //US link the searchwidget first to this.
2425 // The real linkage to the toolbar happens later. 2435 // The real linkage to the toolbar happens later.
2426//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2436//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2427//US tb->insertItem( mIncSearchWidget ); 2437//US tb->insertItem( mIncSearchWidget );
2428/*US 2438/*US
2429 mIncSearchWidget = new IncSearchWidget( tb ); 2439 mIncSearchWidget = new IncSearchWidget( tb );
2430 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2440 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2431 SLOT( incrementalSearch( const QString& ) ) ); 2441 SLOT( incrementalSearch( const QString& ) ) );
2432 2442
2433 mJumpButtonBar = new JumpButtonBar( this, this ); 2443 mJumpButtonBar = new JumpButtonBar( this, this );
2434 2444
2435//US topLayout->addWidget( mJumpButtonBar ); 2445//US topLayout->addWidget( mJumpButtonBar );
2436 this->layout()->add( mJumpButtonBar ); 2446 this->layout()->add( mJumpButtonBar );
2437*/ 2447*/
2438 2448
2439#endif //KAB_EMBEDDED 2449#endif //KAB_EMBEDDED
2440 2450
2441 mActionExport2phone->plug( ExportMenu ); 2451 mActionExport2phone->plug( ExportMenu );
2442 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2452 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2443 syncManager->fillSyncMenu(); 2453 syncManager->fillSyncMenu();
2444 2454
2445} 2455}
2446void KABCore::showLicence() 2456void KABCore::showLicence()
2447{ 2457{
2448 KApplication::showLicence(); 2458 KApplication::showLicence();
2449} 2459}
2450 2460
2451void KABCore::manageCategories( ) 2461void KABCore::manageCategories( )
2452{ 2462{
2453 KABCatPrefs* cp = new KABCatPrefs(); 2463 KABCatPrefs* cp = new KABCatPrefs();
2454 cp->show(); 2464 cp->show();
2455 int w =cp->sizeHint().width() ; 2465 int w =cp->sizeHint().width() ;
2456 int h = cp->sizeHint().height() ; 2466 int h = cp->sizeHint().height() ;
2457 int dw = QApplication::desktop()->width(); 2467 int dw = QApplication::desktop()->width();
2458 int dh = QApplication::desktop()->height(); 2468 int dh = QApplication::desktop()->height();
2459 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2469 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2460 if ( !cp->exec() ) { 2470 if ( !cp->exec() ) {
2461 delete cp; 2471 delete cp;
2462 return; 2472 return;
2463 } 2473 }
2464 int count = 0; 2474 int count = 0;
2465 int cc = 0; 2475 int cc = 0;
2466 message( i18n("Please wait, processing categories...")); 2476 message( i18n("Please wait, processing categories..."));
2467 if ( cp->addCat() ) { 2477 if ( cp->addCat() ) {
2468 KABC::AddressBook::Iterator it; 2478 KABC::AddressBook::Iterator it;
2469 QStringList catList = KABPrefs::instance()->mCustomCategories; 2479 QStringList catList = KABPrefs::instance()->mCustomCategories;
2470 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2480 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2471 ++cc; 2481 ++cc;
2472 if ( cc %10 == 0) 2482 if ( cc %10 == 0)
2473 message(i18n("Processing contact #%1").arg(cc)); 2483 message(i18n("Processing contact #%1").arg(cc));
2474 QStringList catIncList = (*it).categories(); 2484 QStringList catIncList = (*it).categories();
2475 int i; 2485 int i;
2476 for( i = 0; i< catIncList.count(); ++i ) { 2486 for( i = 0; i< catIncList.count(); ++i ) {
2477 if ( !catList.contains (catIncList[i])) { 2487 if ( !catList.contains (catIncList[i])) {
2478 catList.append( catIncList[i] ); 2488 catList.append( catIncList[i] );
2479 //qDebug("add cat %s ", catIncList[i].latin1()); 2489 //qDebug("add cat %s ", catIncList[i].latin1());
2480 ++count; 2490 ++count;
2481 } 2491 }
2482 } 2492 }
2483 } 2493 }
2484 catList.sort(); 2494 catList.sort();
2485 KABPrefs::instance()->mCustomCategories = catList; 2495 KABPrefs::instance()->mCustomCategories = catList;
2486 KABPrefs::instance()->writeConfig(); 2496 KABPrefs::instance()->writeConfig();
2487 message(QString::number( count )+ i18n(" categories added to list! ")); 2497 message(QString::number( count )+ i18n(" categories added to list! "));
2488 } else { 2498 } else {
2489 QStringList catList = KABPrefs::instance()->mCustomCategories; 2499 QStringList catList = KABPrefs::instance()->mCustomCategories;
2490 QStringList catIncList; 2500 QStringList catIncList;
2491 QStringList newCatList; 2501 QStringList newCatList;
2492 KABC::AddressBook::Iterator it; 2502 KABC::AddressBook::Iterator it;
2493 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2503 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2494 ++cc; 2504 ++cc;
2495 if ( cc %10 == 0) 2505 if ( cc %10 == 0)
2496 message(i18n("Processing contact #%1").arg(cc)); 2506 message(i18n("Processing contact #%1").arg(cc));
2497 QStringList catIncList = (*it).categories(); 2507 QStringList catIncList = (*it).categories();
2498 int i; 2508 int i;
2499 if ( catIncList.count() ) { 2509 if ( catIncList.count() ) {
2500 newCatList.clear(); 2510 newCatList.clear();
2501 for( i = 0; i< catIncList.count(); ++i ) { 2511 for( i = 0; i< catIncList.count(); ++i ) {
2502 if ( catList.contains (catIncList[i])) { 2512 if ( catList.contains (catIncList[i])) {
2503 newCatList.append( catIncList[i] ); 2513 newCatList.append( catIncList[i] );
2504 } 2514 }
2505 } 2515 }
2506 newCatList.sort(); 2516 newCatList.sort();
2507 (*it).setCategories( newCatList ); 2517 (*it).setCategories( newCatList );
2508 mAddressBook->insertAddressee( (*it) ); 2518 mAddressBook->insertAddressee( (*it) );
2509 } 2519 }
2510 } 2520 }
2511 setModified( true ); 2521 setModified( true );
2512 mViewManager->refreshView(); 2522 mViewManager->refreshView();
2513 message( i18n("Removing categories done!")); 2523 message( i18n("Removing categories done!"));
2514 } 2524 }
2515 delete cp; 2525 delete cp;
2516} 2526}
2517void KABCore::removeVoice() 2527void KABCore::removeVoice()
2518{ 2528{
2519 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2529 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2520 return; 2530 return;
2521 XXPortSelectDialog dlg( this, false, this ); 2531 XXPortSelectDialog dlg( this, false, this );
2522 if ( !dlg.exec() ) 2532 if ( !dlg.exec() )
2523 return; 2533 return;
2524 mAddressBook->setUntagged(); 2534 mAddressBook->setUntagged();
2525 dlg.tagSelected(); 2535 dlg.tagSelected();
2526 message(i18n("Removing voice..."), false ); 2536 message(i18n("Removing voice..."), false );
2527 KABC::AddressBook::Iterator it; 2537 KABC::AddressBook::Iterator it;
2528 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2538 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2529 if ( (*it).tagged() ) { 2539 if ( (*it).tagged() ) {
2530 (*it).removeVoice(); 2540 (*it).removeVoice();
2531 } 2541 }
2532 } 2542 }
2533 message(i18n("Refreshing view...") ); 2543 message(i18n("Refreshing view...") );
2534 mViewManager->refreshView( "" ); 2544 mViewManager->refreshView( "" );
2535 Addressee add; 2545 Addressee add;
2536 mDetails->setAddressee( add ); 2546 mDetails->setAddressee( add );
2537 message(i18n("Remove voice completed!") ); 2547 message(i18n("Remove voice completed!") );
2538 2548
2539 2549
2540 2550
2541} 2551}
2542 2552
2543void KABCore::setFormattedName() 2553void KABCore::setFormattedName()
2544{ 2554{
2545 KABFormatPrefs setpref; 2555 KABFormatPrefs setpref;
2546 if ( !setpref.exec() ) { 2556 if ( !setpref.exec() ) {
2547 return; 2557 return;
2548 } 2558 }
2549 XXPortSelectDialog dlg( this, false, this ); 2559 XXPortSelectDialog dlg( this, false, this );
2550 if ( !dlg.exec() ) 2560 if ( !dlg.exec() )
2551 return; 2561 return;
2552 mAddressBook->setUntagged(); 2562 mAddressBook->setUntagged();
2553 dlg.tagSelected(); 2563 dlg.tagSelected();
2554 int count = 0; 2564 int count = 0;
2555 KABC::AddressBook::Iterator it; 2565 KABC::AddressBook::Iterator it;
2556 bool modified = false; 2566 bool modified = false;
2557 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2567 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2558 if ( (*it).tagged() ) { 2568 if ( (*it).tagged() ) {
2559 if ( (*it).uid().left( 2 ) == "la" ) 2569 if ( (*it).uid().left( 2 ) == "la" )
2560 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) 2570 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") )
2561 continue; 2571 continue;
2562 ++count; 2572 ++count;
2563 if ( count %10 == 0 ) 2573 if ( count %10 == 0 )
2564 message(i18n("Changing contact #%1").arg( count ) ); 2574 message(i18n("Changing contact #%1").arg( count ) );
2565 QString fName; 2575 QString fName;
2566 if ( setpref.simple->isChecked() ) 2576 if ( setpref.simple->isChecked() )
2567 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); 2577 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName );
2568 else if ( setpref.full->isChecked() ) 2578 else if ( setpref.full->isChecked() )
2569 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); 2579 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName );
2570 else if ( setpref.reverse->isChecked() ) 2580 else if ( setpref.reverse->isChecked() )
2571 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); 2581 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName );
2572 else 2582 else
2573 fName = (*it).organization(); 2583 fName = (*it).organization();
2574 if ( setpref.setCompany->isChecked() ) 2584 if ( setpref.setCompany->isChecked() )
2575 if ( fName.isEmpty() || fName =="," ) 2585 if ( fName.isEmpty() || fName =="," )
2576 fName = (*it).organization(); 2586 fName = (*it).organization();
2577 (*it).setFormattedName( fName ); 2587 (*it).setFormattedName( fName );
2578 (*it).setChanged( true ); 2588 (*it).setChanged( true );
2579 modified = true; 2589 modified = true;
2580 (*it).setRevision( QDateTime::currentDateTime() ); 2590 (*it).setRevision( QDateTime::currentDateTime() );
2581 } 2591 }
2582 } 2592 }
2583 message(i18n("Refreshing view...") ); 2593 message(i18n("Refreshing view...") );
2584 if ( modified ) 2594 if ( modified )
2585 setModified( true ); 2595 setModified( true );
2586 Addressee add; 2596 Addressee add;
2587 mDetails->setAddressee( add ); 2597 mDetails->setAddressee( add );
2588 if ( count == 0 ) 2598 if ( count == 0 )
2589 message(i18n("No contact changed!") ); 2599 message(i18n("No contact changed!") );
2590 else 2600 else
2591 message(i18n("%1 contacts changed!").arg( count ) ); 2601 message(i18n("%1 contacts changed!").arg( count ) );
2592} 2602}
2593 2603
2594void KABCore::clipboardDataChanged() 2604void KABCore::clipboardDataChanged()
2595{ 2605{
2596 2606
2597 if ( mReadWrite ) 2607 if ( mReadWrite )
2598 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2608 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2599 2609
2600} 2610}
2601 2611
2602void KABCore::updateActionMenu() 2612void KABCore::updateActionMenu()
2603{ 2613{
2604 UndoStack *undo = UndoStack::instance(); 2614 UndoStack *undo = UndoStack::instance();
2605 RedoStack *redo = RedoStack::instance(); 2615 RedoStack *redo = RedoStack::instance();
2606 2616
2607 if ( undo->isEmpty() ) 2617 if ( undo->isEmpty() )
2608 mActionUndo->setText( i18n( "Undo" ) ); 2618 mActionUndo->setText( i18n( "Undo" ) );
2609 else 2619 else
2610 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2620 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2611 2621
2612 mActionUndo->setEnabled( !undo->isEmpty() ); 2622 mActionUndo->setEnabled( !undo->isEmpty() );
2613 2623
2614 if ( !redo->top() ) 2624 if ( !redo->top() )
2615 mActionRedo->setText( i18n( "Redo" ) ); 2625 mActionRedo->setText( i18n( "Redo" ) );
2616 else 2626 else
2617 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2627 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2618 2628
2619 mActionRedo->setEnabled( !redo->isEmpty() ); 2629 mActionRedo->setEnabled( !redo->isEmpty() );
2620} 2630}
2621 2631
2622void KABCore::configureKeyBindings() 2632void KABCore::configureKeyBindings()
2623{ 2633{
2624#ifndef KAB_EMBEDDED 2634#ifndef KAB_EMBEDDED
2625 KKeyDialog::configure( actionCollection(), true ); 2635 KKeyDialog::configure( actionCollection(), true );
2626#else //KAB_EMBEDDED 2636#else //KAB_EMBEDDED
2627 qDebug("KABCore::configureKeyBindings() not implemented"); 2637 qDebug("KABCore::configureKeyBindings() not implemented");
2628#endif //KAB_EMBEDDED 2638#endif //KAB_EMBEDDED
2629} 2639}
2630 2640
2631#ifdef KAB_EMBEDDED 2641#ifdef KAB_EMBEDDED
2632void KABCore::configureResources() 2642void KABCore::configureResources()
2633{ 2643{
2634 KRES::KCMKResources dlg( this, "" , 0 ); 2644 KRES::KCMKResources dlg( this, "" , QStringList() );
2635 2645
2636 if ( !dlg.exec() ) 2646 if ( !dlg.exec() )
2637 return; 2647 return;
2638 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2648 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2639} 2649}
2640#endif //KAB_EMBEDDED 2650#endif //KAB_EMBEDDED
2641 2651
2642 2652
2643/* this method will be called through the QCop interface from Ko/Pi to select addresses 2653/* this method will be called through the QCop interface from Ko/Pi to select addresses
2644 * for the attendees list of an event. 2654 * for the attendees list of an event.
2645 */ 2655 */
2646void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2656void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2647{ 2657{
2648 qDebug("KABCore::requestForNameEmailUidList "); 2658 qDebug("KABCore::requestForNameEmailUidList ");
2649 bool ok = false; 2659 bool ok = false;
2650 mEmailSourceChannel = sourceChannel; 2660 mEmailSourceChannel = sourceChannel;
2651 mEmailSourceUID = uid; 2661 mEmailSourceUID = uid;
2652 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); 2662 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) );
2653 //callContactdialog(); 2663 //callContactdialog();
2654#if 0 2664#if 0
2655 int wid = uid.toInt( &ok ); 2665 int wid = uid.toInt( &ok );
2656 qDebug("UID %s ", uid.latin1()); 2666 qDebug("UID %s ", uid.latin1());
2657 if ( ok ) { 2667 if ( ok ) {
2658 if ( wid != QApplication::desktop()->width() ) { 2668 if ( wid != QApplication::desktop()->width() ) {
2659 qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); 2669 qDebug("KA/Pi: Request from different desktop geometry. Resizing ...");
2660 message( i18n("Resizing, please wait...") ); 2670 message( i18n("Resizing, please wait...") );
2661 mMainWindow->showMinimized(); 2671 mMainWindow->showMinimized();
2662 /* 2672 /*
2663 { 2673 {
2664 QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); 2674 QCopEnvelope e("QPE/Application/kapi", "callContactdialog()");
2665 } 2675 }
2666 */ 2676 */
2667 QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) ); 2677 QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) );
2668 return; 2678 return;
2669 } 2679 }
2670 2680
2671 } else { 2681 } else {
2672 qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); 2682 qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid ");
2673 } 2683 }
2674 callContactdialog(); 2684 callContactdialog();
2675 //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); 2685 //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()");
2676#endif 2686#endif
2677} 2687}
2678void KABCore::resizeAndCallContactdialog() 2688void KABCore::resizeAndCallContactdialog()
2679{ 2689{
2680 updateMainWindow(); 2690 updateMainWindow();
2681 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); 2691 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) );
2682} 2692}
2683 2693
2684void KABCore::doRingSync() 2694void KABCore::doRingSync()
2685{ 2695{
2686 topLevelWidget()->raise(); 2696 topLevelWidget()->raise();
2687 syncManager->multiSync( false ); 2697 syncManager->multiSync( false );
2688} 2698}
2689void KABCore::callContactdialog() 2699void KABCore::callContactdialog()
2690{ 2700{
2691 static bool running = false; 2701 static bool running = false;
2692 if (running) return; 2702 if (running) return;
2693 running = true; 2703 running = true;
2694 QStringList nameList; 2704 QStringList nameList;
2695 QStringList emailList; 2705 QStringList emailList;
2696 QStringList uidList; 2706 QStringList uidList;
2697 qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() ); 2707 qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() );
2698 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2708 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2699 uint i=0; 2709 uint i=0;
2700 for (i=0; i < list.count(); i++) 2710 for (i=0; i < list.count(); i++)
2701 { 2711 {
2702 nameList.append(list[i].realName()); 2712 nameList.append(list[i].realName());
2703 emailList.append(list[i].preferredEmail()); 2713 emailList.append(list[i].preferredEmail());
2704 uidList.append(list[i].uid()); 2714 uidList.append(list[i].uid());
2705 } 2715 }
2706 QString uid = mEmailSourceUID; 2716 QString uid = mEmailSourceUID;
2707 //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); 2717 //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1());
2708 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList); 2718 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList);
2709 running = false; 2719 running = false;
2710} 2720}
2711/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2721/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2712 * to put them into the calendar. 2722 * to put them into the calendar.
2713 */ 2723 */
2714void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2724void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2715{ 2725{
2716 // qDebug("KABCore::requestForBirthdayList"); 2726 // qDebug("KABCore::requestForBirthdayList");
2717 QStringList birthdayList; 2727 QStringList birthdayList;
2718 QStringList anniversaryList; 2728 QStringList anniversaryList;
2719 QStringList realNameList; 2729 QStringList realNameList;
2720 QStringList preferredEmailList; 2730 QStringList preferredEmailList;
2721 QStringList assembledNameList; 2731 QStringList assembledNameList;
2722 QStringList uidList; 2732 QStringList uidList;
2723 2733
2724 KABC::AddressBook::Iterator it; 2734 KABC::AddressBook::Iterator it;
2725 2735
2726 int count = 0; 2736 int count = 0;
2727 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2737 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2728 ++count; 2738 ++count;
2729 } 2739 }
2730 QProgressBar bar(count,0 ); 2740 Q3ProgressBar bar(count,0 );
2731 int w = 300; 2741 int w = 300;
2732 if ( QApplication::desktop()->width() < 320 ) 2742 if ( QApplication::desktop()->width() < 320 )
2733 w = 220; 2743 w = 220;
2734 int h = bar.sizeHint().height() ; 2744 int h = bar.sizeHint().height() ;
2735 int dw = QApplication::desktop()->width(); 2745 int dw = QApplication::desktop()->width();
2736 int dh = QApplication::desktop()->height(); 2746 int dh = QApplication::desktop()->height();
2737 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2747 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2738 bar.show(); 2748 bar.show();
2739 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2749 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2740 qApp->processEvents(); 2750 qApp->processEvents();
2741 2751
2742 QDate bday; 2752 QDate bday;
2743 QString anni; 2753 QString anni;
2744 QString formattedbday; 2754 QString formattedbday;
2745 2755
2746 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2756 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2747 { 2757 {
2748 if ( ! bar.isVisible() ) 2758 if ( ! bar.isVisible() )
2749 return; 2759 return;
2750 bar.setProgress( count++ ); 2760 bar.setProgress( count++ );
2751 qApp->processEvents(); 2761 qApp->processEvents();
2752 bday = (*it).birthday().date(); 2762 bday = (*it).birthday().date();
2753 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2763 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2754 2764
2755 if ( bday.isValid() || !anni.isEmpty()) 2765 if ( bday.isValid() || !anni.isEmpty())
2756 { 2766 {
2757 if (bday.isValid()) 2767 if (bday.isValid())
2758 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2768 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2759 else 2769 else
2760 formattedbday = "NOTVALID"; 2770 formattedbday = "NOTVALID";
2761 if (anni.isEmpty()) 2771 if (anni.isEmpty())
2762 anni = "INVALID"; 2772 anni = "INVALID";
2763 2773
2764 birthdayList.append(formattedbday); 2774 birthdayList.append(formattedbday);
2765 anniversaryList.append(anni); //should be ISODate 2775 anniversaryList.append(anni); //should be ISODate
2766 realNameList.append((*it).realName()); 2776 realNameList.append((*it).realName());
2767 preferredEmailList.append((*it).preferredEmail()); 2777 preferredEmailList.append((*it).preferredEmail());
2768 assembledNameList.append((*it).realName()); 2778 assembledNameList.append((*it).realName());
2769 uidList.append((*it).uid()); 2779 uidList.append((*it).uid());
2770 2780
2771 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2781 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2772 } 2782 }
2773 } 2783 }
2774 2784
2775 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2785 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2776 2786
2777} 2787}
2778 2788
2779/* this method will be called through the QCop interface from other apps to show details of a contact. 2789/* this method will be called through the QCop interface from other apps to show details of a contact.
2780 */ 2790 */
2781void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2791void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2782{ 2792{
2783 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2793 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2784 2794
2785 QString foundUid = QString::null; 2795 QString foundUid = QString::null;
2786 if ( ! uid.isEmpty() ) { 2796 if ( ! uid.isEmpty() ) {
2787 Addressee adrr = mAddressBook->findByUid( uid ); 2797 Addressee adrr = mAddressBook->findByUid( uid );
2788 if ( !adrr.isEmpty() ) { 2798 if ( !adrr.isEmpty() ) {
2789 foundUid = uid; 2799 foundUid = uid;
2790 } 2800 }
2791 if ( email == "sendbacklist" ) { 2801 if ( email == "sendbacklist" ) {
2792 //qDebug("ssssssssssssssssssssssend "); 2802 //qDebug("ssssssssssssssssssssssend ");
2793 QStringList nameList; 2803 QStringList nameList;
2794 QStringList emailList; 2804 QStringList emailList;
2795 QStringList uidList; 2805 QStringList uidList;
2796 nameList.append(adrr.realName()); 2806 nameList.append(adrr.realName());
2797 emailList = adrr.emails(); 2807 emailList = adrr.emails();
2798 uidList.append( adrr.preferredEmail()); 2808 uidList.append( adrr.preferredEmail());
2799 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2809 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2800 return; 2810 return;
2801 } 2811 }
2802 2812
2803 } 2813 }
2804 2814
2805 if ( email == "sendbacklist" ) 2815 if ( email == "sendbacklist" )
2806 return; 2816 return;
2807 if (foundUid.isEmpty()) 2817 if (foundUid.isEmpty())
2808 { 2818 {
2809 //find the uid of the person first 2819 //find the uid of the person first
2810 Addressee::List namelist; 2820 Addressee::List namelist;
2811 Addressee::List emaillist; 2821 Addressee::List emaillist;
2812 2822
2813 if (!name.isEmpty()) 2823 if (!name.isEmpty())
2814 namelist = mAddressBook->findByName( name ); 2824 namelist = mAddressBook->findByName( name );
2815 2825
2816 if (!email.isEmpty()) 2826 if (!email.isEmpty())
2817 emaillist = mAddressBook->findByEmail( email ); 2827 emaillist = mAddressBook->findByEmail( email );
2818 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2828 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2819 //check if we have a match in Namelist and Emaillist 2829 //check if we have a match in Namelist and Emaillist
2820 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2830 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2821 foundUid = emaillist[0].uid(); 2831 foundUid = emaillist[0].uid();
2822 } 2832 }
2823 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2833 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2824 foundUid = namelist[0].uid(); 2834 foundUid = namelist[0].uid();
2825 else 2835 else
2826 { 2836 {
2827 for (int i = 0; i < namelist.count(); i++) 2837 for (int i = 0; i < namelist.count(); i++)
2828 { 2838 {
2829 for (int j = 0; j < emaillist.count(); j++) 2839 for (int j = 0; j < emaillist.count(); j++)
2830 { 2840 {
2831 if (namelist[i] == emaillist[j]) 2841 if (namelist[i] == emaillist[j])
2832 { 2842 {
2833 foundUid = namelist[i].uid(); 2843 foundUid = namelist[i].uid();
2834 } 2844 }
2835 } 2845 }
2836 } 2846 }
2837 } 2847 }
2838 } 2848 }
2839 else 2849 else
2840 { 2850 {
2841 foundUid = uid; 2851 foundUid = uid;
2842 } 2852 }
2843 2853
2844 if (!foundUid.isEmpty()) 2854 if (!foundUid.isEmpty())
2845 { 2855 {
2846 2856
2847 // raise Ka/Pi if it is in the background 2857 // raise Ka/Pi if it is in the background
2848#ifndef DESKTOP_VERSION 2858#ifndef DESKTOP_VERSION
2849#ifndef KORG_NODCOP 2859#ifndef KORG_NODCOP
2850 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2860 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2851#endif 2861#endif
2852#endif 2862#endif
2853 2863
2854 mMainWindow->showMaximized(); 2864 mMainWindow->showMaximized();
2855 mMainWindow-> raise(); 2865 mMainWindow-> raise();
2856 2866
2857 mViewManager->setSelected( "", false); 2867 mViewManager->setSelected( "", false);
2858 mViewManager->refreshView( "" ); 2868 mViewManager->refreshView( "" );
2859 mViewManager->setSelected( foundUid, true ); 2869 mViewManager->setSelected( foundUid, true );
2860 mViewManager->refreshView( foundUid ); 2870 mViewManager->refreshView( foundUid );
2861 2871
2862 if ( !mMultipleViewsAtOnce ) 2872 if ( !mMultipleViewsAtOnce )
2863 { 2873 {
2864 setDetailsVisible( true ); 2874 setDetailsVisible( true );
2865 mActionDetails->setChecked(true); 2875 mActionDetails->setChecked(true);
2866 } 2876 }
2867 } 2877 }
2868} 2878}
2869void KABCore::storagehowto() 2879void KABCore::storagehowto()
2870{ 2880{
2871 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 2881 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
2872} 2882}
2873void KABCore::whatsnew() 2883void KABCore::whatsnew()
2874{ 2884{
2875 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2885 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2876} 2886}
2877void KABCore::synchowto() 2887void KABCore::synchowto()
2878{ 2888{
2879 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2889 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2880} 2890}
2881void KABCore::kdesynchowto() 2891void KABCore::kdesynchowto()
2882{ 2892{
2883 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2893 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2884} 2894}
2885void KABCore::multisynchowto() 2895void KABCore::multisynchowto()
2886{ 2896{
2887 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2897 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2888} 2898}
2889void KABCore::faq() 2899void KABCore::faq()
2890{ 2900{
2891 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2901 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2892} 2902}
2893 2903
2894#include <libkcal/syncdefines.h> 2904#include <libkcal/syncdefines.h>
2895 2905
2896KABC::Addressee KABCore::getLastSyncAddressee() 2906KABC::Addressee KABCore::getLastSyncAddressee()
2897{ 2907{
2898 Addressee lse; 2908 Addressee lse;
2899 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2909 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2900 2910
2901 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2911 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2902 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2912 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2903 if (lse.isEmpty()) { 2913 if (lse.isEmpty()) {
2904 qDebug("KA: Creating new last-syncAddressee "); 2914 qDebug("KA: Creating new last-syncAddressee ");
2905 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2915 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2906 QString sum = ""; 2916 QString sum = "";
2907 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2917 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2908 sum = "E: "; 2918 sum = "E: ";
2909 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2919 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2910 lse.setRevision( mLastAddressbookSync ); 2920 lse.setRevision( mLastAddressbookSync );
2911 lse.setCategories( i18n("SyncEvent") ); 2921 lse.setCategories( QStringList(i18n("SyncEvent")) );
2912 mAddressBook->insertAddressee( lse ); 2922 mAddressBook->insertAddressee( lse );
2913 } 2923 }
2914 return lse; 2924 return lse;
2915} 2925}
2916int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2926int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2917{ 2927{
2918 2928
2919 //void setZaurusId(int id); 2929 //void setZaurusId(int id);
2920 // int zaurusId() const; 2930 // int zaurusId() const;
2921 // void setZaurusUid(int id); 2931 // void setZaurusUid(int id);
2922 // int zaurusUid() const; 2932 // int zaurusUid() const;
2923 // void setZaurusStat(int id); 2933 // void setZaurusStat(int id);
2924 // int zaurusStat() const; 2934 // int zaurusStat() const;
2925 // 0 equal 2935 // 0 equal
2926 // 1 take local 2936 // 1 take local
2927 // 2 take remote 2937 // 2 take remote
2928 // 3 cancel 2938 // 3 cancel
2929 QDateTime lastSync = mLastAddressbookSync; 2939 QDateTime lastSync = mLastAddressbookSync;
2930 QDateTime localMod = local->revision(); 2940 QDateTime localMod = local->revision();
2931 QDateTime remoteMod = remote->revision(); 2941 QDateTime remoteMod = remote->revision();
2932 2942
2933 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2943 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2934 2944
2935 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2945 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2936 bool remCh, locCh; 2946 bool remCh, locCh;
2937 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2947 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2938 //if ( remCh ) 2948 //if ( remCh )
2939 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2949 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2940 locCh = ( localMod > mLastAddressbookSync ); 2950 locCh = ( localMod > mLastAddressbookSync );
2941 //qDebug("cahnged rem %d loc %d",remCh, locCh ); 2951 //qDebug("cahnged rem %d loc %d",remCh, locCh );
2942 if ( !remCh && ! locCh ) { 2952 if ( !remCh && ! locCh ) {
2943 //qDebug("both not changed "); 2953 //qDebug("both not changed ");
2944 lastSync = localMod.addDays(1); 2954 lastSync = localMod.addDays(1);
2945 if ( mode <= SYNC_PREF_ASK ) 2955 if ( mode <= SYNC_PREF_ASK )
2946 return 0; 2956 return 0;
2947 } else { 2957 } else {
2948 if ( locCh ) { 2958 if ( locCh ) {
2949 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2959 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2950 lastSync = localMod.addDays( -1 ); 2960 lastSync = localMod.addDays( -1 );
2951 if ( !remCh ) 2961 if ( !remCh )
2952 remoteMod =( lastSync.addDays( -1 ) ); 2962 remoteMod =( lastSync.addDays( -1 ) );
2953 } else { 2963 } else {
2954 //qDebug(" not loc changed "); 2964 //qDebug(" not loc changed ");
2955 lastSync = localMod.addDays( 1 ); 2965 lastSync = localMod.addDays( 1 );
2956 if ( remCh ) { 2966 if ( remCh ) {
2957 //qDebug("rem changed "); 2967 //qDebug("rem changed ");
2958 remoteMod =( lastSync.addDays( 1 ) ); 2968 remoteMod =( lastSync.addDays( 1 ) );
2959 } 2969 }
2960 2970
2961 } 2971 }
2962 } 2972 }
2963 full = true; 2973 full = true;
2964 if ( mode < SYNC_PREF_ASK ) 2974 if ( mode < SYNC_PREF_ASK )
2965 mode = SYNC_PREF_ASK; 2975 mode = SYNC_PREF_ASK;
2966 } else { 2976 } else {
2967 if ( localMod == remoteMod ) 2977 if ( localMod == remoteMod )
2968 return 0; 2978 return 0;
2969 2979
2970 } 2980 }
2971 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2981 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2972 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2982 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2973 //full = true; //debug only 2983 //full = true; //debug only
2974 if ( full ) { 2984 if ( full ) {
2975 bool equ = ( (*local) == (*remote) ); 2985 bool equ = ( (*local) == (*remote) );
2976 if ( equ ) { 2986 if ( equ ) {
2977 //qDebug("equal "); 2987 //qDebug("equal ");
2978 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2988 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2979 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2989 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2980 } 2990 }
2981 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2991 if ( mode < SYNC_PREF_FORCE_LOCAL )
2982 return 0; 2992 return 0;
2983 2993
2984 }//else //debug only 2994 }//else //debug only
2985 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2995 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2986 } 2996 }
2987 int result; 2997 int result;
2988 bool localIsNew; 2998 bool localIsNew;
2989 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2999 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2990 3000
2991 if ( full && mode < SYNC_PREF_NEWEST ) 3001 if ( full && mode < SYNC_PREF_NEWEST )
2992 mode = SYNC_PREF_ASK; 3002 mode = SYNC_PREF_ASK;
2993 3003
2994 switch( mode ) { 3004 switch( mode ) {
2995 case SYNC_PREF_LOCAL: 3005 case SYNC_PREF_LOCAL:
2996 if ( lastSync > remoteMod ) 3006 if ( lastSync > remoteMod )
2997 return 1; 3007 return 1;
2998 if ( lastSync > localMod ) 3008 if ( lastSync > localMod )
2999 return 2; 3009 return 2;
3000 return 1; 3010 return 1;
3001 break; 3011 break;
3002 case SYNC_PREF_REMOTE: 3012 case SYNC_PREF_REMOTE:
3003 if ( lastSync > localMod ) 3013 if ( lastSync > localMod )
3004 return 2; 3014 return 2;
3005 if ( lastSync > remoteMod ) 3015 if ( lastSync > remoteMod )
3006 return 1; 3016 return 1;
3007 return 2; 3017 return 2;
3008 break; 3018 break;
3009 case SYNC_PREF_NEWEST: 3019 case SYNC_PREF_NEWEST:
3010 if ( localMod > remoteMod ) 3020 if ( localMod > remoteMod )
3011 return 1; 3021 return 1;
3012 else 3022 else
3013 return 2; 3023 return 2;
3014 break; 3024 break;
3015 case SYNC_PREF_ASK: 3025 case SYNC_PREF_ASK:
3016 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 3026 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
3017 if ( lastSync > remoteMod && lastSync > localMod) 3027 if ( lastSync > remoteMod && lastSync > localMod)
3018 return 0; 3028 return 0;
3019 if ( lastSync > remoteMod ) 3029 if ( lastSync > remoteMod )
3020 return 1; 3030 return 1;
3021 if ( lastSync > localMod ) { 3031 if ( lastSync > localMod ) {
3022 return 2; 3032 return 2;
3023 } 3033 }
3024 localIsNew = localMod >= remoteMod; 3034 localIsNew = localMod >= remoteMod;
3025 //qDebug("conflict! ************************************** "); 3035 //qDebug("conflict! ************************************** ");
3026 { 3036 {
3027 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 3037 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this );
3028 result = acd.executeD(localIsNew); 3038 result = acd.executeD(localIsNew);
3029 return result; 3039 return result;
3030 } 3040 }
3031 break; 3041 break;
3032 case SYNC_PREF_FORCE_LOCAL: 3042 case SYNC_PREF_FORCE_LOCAL:
3033 return 1; 3043 return 1;
3034 break; 3044 break;
3035 case SYNC_PREF_FORCE_REMOTE: 3045 case SYNC_PREF_FORCE_REMOTE:
3036 return 2; 3046 return 2;
3037 break; 3047 break;
3038 3048
3039 default: 3049 default:
3040 // SYNC_PREF_TAKE_BOTH not implemented 3050 // SYNC_PREF_TAKE_BOTH not implemented
3041 break; 3051 break;
3042 } 3052 }
3043 return 0; 3053 return 0;
3044} 3054}
3045 3055
3046 3056
3047bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 3057bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
3048{ 3058{
3049 bool syncOK = true; 3059 bool syncOK = true;
3050 int addedAddressee = 0; 3060 int addedAddressee = 0;
3051 int addedAddresseeR = 0; 3061 int addedAddresseeR = 0;
3052 int deletedAddresseeR = 0; 3062 int deletedAddresseeR = 0;
3053 int deletedAddresseeL = 0; 3063 int deletedAddresseeL = 0;
3054 int changedLocal = 0; 3064 int changedLocal = 0;
3055 int changedRemote = 0; 3065 int changedRemote = 0;
3056 int filteredIN = 0; 3066 int filteredIN = 0;
3057 int filteredOUT = 0; 3067 int filteredOUT = 0;
3058 3068
3059 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 3069 QString mCurrentSyncName = syncManager->getCurrentSyncName();
3060 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3070 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3061 3071
3062 //QPtrList<Addressee> el = local->rawAddressees(); 3072 //QPtrList<Addressee> el = local->rawAddressees();
3063 Addressee addresseeR; 3073 Addressee addresseeR;
3064 QString uid; 3074 QString uid;
3065 int take; 3075 int take;
3066 Addressee addresseeL; 3076 Addressee addresseeL;
3067 Addressee addresseeRSync; 3077 Addressee addresseeRSync;
3068 Addressee addresseeLSync; 3078 Addressee addresseeLSync;
3069 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 3079 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
3070 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 3080 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
3071 bool fullDateRange = false; 3081 bool fullDateRange = false;
3072 local->resetTempSyncStat(); 3082 local->resetTempSyncStat();
3073 mLastAddressbookSync = QDateTime::currentDateTime(); 3083 mLastAddressbookSync = QDateTime::currentDateTime();
3074 if ( syncManager->syncWithDesktop() ) { 3084 if ( syncManager->syncWithDesktop() ) {
3075 // remote->removeSyncInfo( QString());//remove all info 3085 // remote->removeSyncInfo( QString());//remove all info
3076 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 3086 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
3077 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 3087 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
3078 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 3088 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
3079 } else { 3089 } else {
3080 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime "); 3090 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime ");
3081 } 3091 }
3082 } 3092 }
3083 QDateTime modifiedCalendar = mLastAddressbookSync; 3093 QDateTime modifiedCalendar = mLastAddressbookSync;
3084 addresseeLSync = getLastSyncAddressee(); 3094 addresseeLSync = getLastSyncAddressee();
3085 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1()); 3095 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1());
3086 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 3096 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
3087 if ( !addresseeR.isEmpty() ) { 3097 if ( !addresseeR.isEmpty() ) {
3088 addresseeRSync = addresseeR; 3098 addresseeRSync = addresseeR;
3089 remote->removeAddressee(addresseeR ); 3099 remote->removeAddressee(addresseeR );
3090 3100
3091 } else { 3101 } else {
3092 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3102 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3093 addresseeRSync = addresseeLSync ; 3103 addresseeRSync = addresseeLSync ;
3094 } else { 3104 } else {
3095 //qDebug("FULLDATE 1"); 3105 //qDebug("FULLDATE 1");
3096 fullDateRange = true; 3106 fullDateRange = true;
3097 Addressee newAdd; 3107 Addressee newAdd;
3098 addresseeRSync = newAdd; 3108 addresseeRSync = newAdd;
3099 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 3109 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
3100 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 3110 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
3101 addresseeRSync.setRevision( mLastAddressbookSync ); 3111 addresseeRSync.setRevision( mLastAddressbookSync );
3102 addresseeRSync.setCategories( i18n("SyncAddressee") ); 3112 addresseeRSync.setCategories( QStringList(i18n("SyncAddressee")) );
3103 } 3113 }
3104 } 3114 }
3105 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 3115 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
3106 // qDebug("FULLDATE 2"); 3116 // qDebug("FULLDATE 2");
3107 fullDateRange = true; 3117 fullDateRange = true;
3108 } 3118 }
3109 if ( ! fullDateRange ) { 3119 if ( ! fullDateRange ) {
3110 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 3120 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
3111 3121
3112 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 3122 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
3113 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 3123 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
3114 fullDateRange = true; 3124 fullDateRange = true;
3115 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 3125 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
3116 } 3126 }
3117 } 3127 }
3118 // fullDateRange = true; // debug only! 3128 // fullDateRange = true; // debug only!
3119 if ( fullDateRange ) 3129 if ( fullDateRange )
3120 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 3130 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
3121 else 3131 else
3122 mLastAddressbookSync = addresseeLSync.revision(); 3132 mLastAddressbookSync = addresseeLSync.revision();
3123 // for resyncing if own file has changed 3133 // for resyncing if own file has changed
3124 // PENDING fixme later when implemented 3134 // PENDING fixme later when implemented
3125#if 0 3135#if 0
3126 if ( mCurrentSyncDevice == "deleteaftersync" ) { 3136 if ( mCurrentSyncDevice == "deleteaftersync" ) {
3127 mLastAddressbookSync = loadedFileVersion; 3137 mLastAddressbookSync = loadedFileVersion;
3128 qDebug("setting mLastAddressbookSync "); 3138 qDebug("setting mLastAddressbookSync ");
3129 } 3139 }
3130#endif 3140#endif
3131 3141
3132 3142
3133 // ********** setting filters **************** 3143 // ********** setting filters ****************
3134 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); 3144 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB );
3135 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); 3145 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB );
3136 3146
3137 //qDebug("*************************** "); 3147 //qDebug("*************************** ");
3138 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 3148 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
3139 QStringList er = remote->uidList(); 3149 QStringList er = remote->uidList();
3140 Addressee inR ;//= er.first(); 3150 Addressee inR ;//= er.first();
3141 Addressee inL; 3151 Addressee inL;
3142 3152
3143 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 3153 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
3144 3154
3145 int modulo = (er.count()/10)+1; 3155 int modulo = (er.count()/10)+1;
3146 int incCounter = 0; 3156 int incCounter = 0;
3147 while ( incCounter < er.count()) { 3157 while ( incCounter < er.count()) {
3148 if (syncManager->isProgressBarCanceled()) 3158 if (syncManager->isProgressBarCanceled())
3149 return false; 3159 return false;
3150 if ( incCounter % modulo == 0 ) 3160 if ( incCounter % modulo == 0 )
3151 syncManager->showProgressBar(incCounter); 3161 syncManager->showProgressBar(incCounter);
3152 3162
3153 uid = er[ incCounter ]; 3163 uid = er[ incCounter ];
3154 bool skipIncidence = false; 3164 bool skipIncidence = false;
3155 if ( uid.left(19) == QString("last-syncAddressee-") ) 3165 if ( uid.left(19) == QString("last-syncAddressee-") )
3156 skipIncidence = true; 3166 skipIncidence = true;
3157 QString idS,OidS; 3167 QString idS,OidS;
3158 qApp->processEvents(); 3168 qApp->processEvents();
3159 if ( !skipIncidence ) { 3169 if ( !skipIncidence ) {
3160 inL = local->findByUid( uid ); 3170 inL = local->findByUid( uid );
3161 inR = remote->findByUid( uid ); 3171 inR = remote->findByUid( uid );
3162 //inL.setResource( 0 ); 3172 //inL.setResource( 0 );
3163 //inR.setResource( 0 ); 3173 //inR.setResource( 0 );
3164 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 3174 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
3165 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3175 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3166 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 3176 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
3167 //qDebug("take %d %s ", take, inL.summary().latin1()); 3177 //qDebug("take %d %s ", take, inL.summary().latin1());
3168 if ( take == 3 ) 3178 if ( take == 3 )
3169 return false; 3179 return false;
3170 if ( take == 1 ) {// take local ********************** 3180 if ( take == 1 ) {// take local **********************
3171 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3181 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3172 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3182 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3173 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3183 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3174 local->insertAddressee( inL, false ); 3184 local->insertAddressee( inL, false );
3175 idS = inR.externalUID(); 3185 idS = inR.externalUID();
3176 OidS = inR.originalExternalUID(); 3186 OidS = inR.originalExternalUID();
3177 } 3187 }
3178 else 3188 else
3179 idS = inR.IDStr(); 3189 idS = inR.IDStr();
3180 remote->removeAddressee( inR ); 3190 remote->removeAddressee( inR );
3181 inR = inL; 3191 inR = inL;
3182 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 3192 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
3183 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3193 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3184 inR.setOriginalExternalUID( OidS ); 3194 inR.setOriginalExternalUID( OidS );
3185 inR.setExternalUID( idS ); 3195 inR.setExternalUID( idS );
3186 if ( syncManager->syncWithDesktop() ) { 3196 if ( syncManager->syncWithDesktop() ) {
3187 inR.setIDStr("changed" ); 3197 inR.setIDStr("changed" );
3188 } 3198 }
3189 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 3199 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
3190 } else { 3200 } else {
3191 inR.setIDStr( idS ); 3201 inR.setIDStr( idS );
3192 } 3202 }
3193 inR.setResource( 0 ); 3203 inR.setResource( 0 );
3194 remote->insertAddressee( inR , false); 3204 remote->insertAddressee( inR , false);
3195 ++changedRemote; 3205 ++changedRemote;
3196 } else { // take == 2 take remote ********************** 3206 } else { // take == 2 take remote **********************
3197 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3207 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3198 if ( inR.revision().date().year() < 2004 ) 3208 if ( inR.revision().date().year() < 2004 )
3199 inR.setRevision( modifiedCalendar ); 3209 inR.setRevision( modifiedCalendar );
3200 } 3210 }
3201 idS = inL.IDStr(); 3211 idS = inL.IDStr();
3202 local->removeAddressee( inL ); 3212 local->removeAddressee( inL );
3203 inL = inR; 3213 inL = inR;
3204 inL.setIDStr( idS ); 3214 inL.setIDStr( idS );
3205 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3215 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3206 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3216 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3207 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3217 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3208 } 3218 }
3209 inL.setResource( 0 ); 3219 inL.setResource( 0 );
3210 local->insertAddressee( inL , false ); 3220 local->insertAddressee( inL , false );
3211 ++changedLocal; 3221 ++changedLocal;
3212 } 3222 }
3213 } 3223 }
3214 } 3224 }
3215 } else { // no conflict ********** add or delete remote 3225 } else { // no conflict ********** add or delete remote
3216 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { 3226 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) {
3217 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3227 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3218 QString des = addresseeLSync.note(); 3228 QString des = addresseeLSync.note();
3219 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 3229 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
3220 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 3230 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
3221 remote->insertAddressee( inR, false ); 3231 remote->insertAddressee( inR, false );
3222 ++deletedAddresseeR; 3232 ++deletedAddresseeR;
3223 } else { 3233 } else {
3224 inR.setRevision( modifiedCalendar ); 3234 inR.setRevision( modifiedCalendar );
3225 remote->insertAddressee( inR, false ); 3235 remote->insertAddressee( inR, false );
3226 inL = inR; 3236 inL = inR;
3227 inL.setIDStr( ":" ); 3237 inL.setIDStr( ":" );
3228 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3238 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3229 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3239 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3230 inL.setResource( 0 ); 3240 inL.setResource( 0 );
3231 local->insertAddressee( inL , false); 3241 local->insertAddressee( inL , false);
3232 ++addedAddressee; 3242 ++addedAddressee;
3233 } 3243 }
3234 } else { 3244 } else {
3235 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 3245 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
3236 inR.setRevision( modifiedCalendar ); 3246 inR.setRevision( modifiedCalendar );
3237 remote->insertAddressee( inR, false ); 3247 remote->insertAddressee( inR, false );
3238 inR.setResource( 0 ); 3248 inR.setResource( 0 );
3239 local->insertAddressee( inR, false ); 3249 local->insertAddressee( inR, false );
3240 ++addedAddressee; 3250 ++addedAddressee;
3241 } else { 3251 } else {
3242 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 3252 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
3243 remote->removeAddressee( inR ); 3253 remote->removeAddressee( inR );
3244 ++deletedAddresseeR; 3254 ++deletedAddresseeR;
3245 } 3255 }
3246 } 3256 }
3247 } else { 3257 } else {
3248 ++filteredIN; 3258 ++filteredIN;
3249 } 3259 }
3250 } 3260 }
3251 } 3261 }
3252 ++incCounter; 3262 ++incCounter;
3253 } 3263 }
3254 er.clear(); 3264 er.clear();
3255 QStringList el = local->uidList(); 3265 QStringList el = local->uidList();
3256 modulo = (el.count()/10)+1; 3266 modulo = (el.count()/10)+1;
3257 3267
3258 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3268 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
3259 incCounter = 0; 3269 incCounter = 0;
3260 while ( incCounter < el.count()) { 3270 while ( incCounter < el.count()) {
3261 qApp->processEvents(); 3271 qApp->processEvents();
3262 if (syncManager->isProgressBarCanceled()) 3272 if (syncManager->isProgressBarCanceled())
3263 return false; 3273 return false;
3264 if ( incCounter % modulo == 0 ) 3274 if ( incCounter % modulo == 0 )
3265 syncManager->showProgressBar(incCounter); 3275 syncManager->showProgressBar(incCounter);
3266 uid = el[ incCounter ]; 3276 uid = el[ incCounter ];
3267 bool skipIncidence = false; 3277 bool skipIncidence = false;
3268 if ( uid.left(19) == QString("last-syncAddressee-") ) 3278 if ( uid.left(19) == QString("last-syncAddressee-") )
3269 skipIncidence = true; 3279 skipIncidence = true;
3270 if ( !skipIncidence ) { 3280 if ( !skipIncidence ) {
3271 inL = local->findByUid( uid ); 3281 inL = local->findByUid( uid );
3272 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3282 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3273 inR = remote->findByUid( uid ); 3283 inR = remote->findByUid( uid );
3274 if ( inR.isEmpty() ){ 3284 if ( inR.isEmpty() ){
3275 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { 3285 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) {
3276 // no conflict ********** add or delete local 3286 // no conflict ********** add or delete local
3277 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3287 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3278 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 3288 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
3279 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3289 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3280 local->removeAddressee( inL ); 3290 local->removeAddressee( inL );
3281 ++deletedAddresseeL; 3291 ++deletedAddresseeL;
3282 } else { 3292 } else {
3283 if ( ! syncManager->mWriteBackExistingOnly ) { 3293 if ( ! syncManager->mWriteBackExistingOnly ) {
3284 inL.removeID(mCurrentSyncDevice ); 3294 inL.removeID(mCurrentSyncDevice );
3285 ++addedAddresseeR; 3295 ++addedAddresseeR;
3286 inL.setRevision( modifiedCalendar ); 3296 inL.setRevision( modifiedCalendar );
3287 local->insertAddressee( inL, false ); 3297 local->insertAddressee( inL, false );
3288 inR = inL; 3298 inR = inL;
3289 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 3299 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
3290 inR.setResource( 0 ); 3300 inR.setResource( 0 );
3291 remote->insertAddressee( inR, false ); 3301 remote->insertAddressee( inR, false );
3292 } 3302 }
3293 } 3303 }
3294 } else { 3304 } else {
3295 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 3305 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
3296 //qDebug("data %s ", inL.revision().toString().latin1()); 3306 //qDebug("data %s ", inL.revision().toString().latin1());
3297 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3307 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3298 local->removeAddressee( inL ); 3308 local->removeAddressee( inL );
3299 ++deletedAddresseeL; 3309 ++deletedAddresseeL;
3300 } else { 3310 } else {
3301 if ( ! syncManager->mWriteBackExistingOnly ) { 3311 if ( ! syncManager->mWriteBackExistingOnly ) {
3302 ++addedAddresseeR; 3312 ++addedAddresseeR;
3303 inL.setRevision( modifiedCalendar ); 3313 inL.setRevision( modifiedCalendar );
3304 local->insertAddressee( inL, false ); 3314 local->insertAddressee( inL, false );
3305 inR = inL; 3315 inR = inL;
3306 inR.setIDStr( ":" ); 3316 inR.setIDStr( ":" );
3307 inR.setResource( 0 ); 3317 inR.setResource( 0 );
3308 remote->insertAddressee( inR, false ); 3318 remote->insertAddressee( inR, false );
3309 } 3319 }
3310 } 3320 }
3311 } 3321 }
3312 } else { 3322 } else {
3313 ++filteredOUT; 3323 ++filteredOUT;
3314 } 3324 }
3315 } 3325 }
3316 } 3326 }
3317 } 3327 }
3318 ++incCounter; 3328 ++incCounter;
3319 } 3329 }
3320 el.clear(); 3330 el.clear();
3321 syncManager->hideProgressBar(); 3331 syncManager->hideProgressBar();
3322 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3332 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
3323 // get rid of micro seconds 3333 // get rid of micro seconds
3324 QTime t = mLastAddressbookSync.time(); 3334 QTime t = mLastAddressbookSync.time();
3325 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3335 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3326 addresseeLSync.setRevision( mLastAddressbookSync ); 3336 addresseeLSync.setRevision( mLastAddressbookSync );
3327 addresseeRSync.setRevision( mLastAddressbookSync ); 3337 addresseeRSync.setRevision( mLastAddressbookSync );
3328 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 3338 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
3329 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 3339 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
3330 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 3340 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
3331 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 3341 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
3332 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 3342 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
3333 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 3343 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
3334 addresseeRSync.setNote( "" ) ; 3344 addresseeRSync.setNote( "" ) ;
3335 addresseeLSync.setNote( "" ); 3345 addresseeLSync.setNote( "" );
3336 3346
3337 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 3347 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
3338 remote->insertAddressee( addresseeRSync, false ); 3348 remote->insertAddressee( addresseeRSync, false );
3339 local->insertAddressee( addresseeLSync, false ); 3349 local->insertAddressee( addresseeLSync, false );
3340 QString mes; 3350 QString mes;
3341 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); 3351 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT );
3342 qDebug( mes ); 3352 qDebug( mes );
3343 mes = i18n("Local addressbook changed!\n") +mes; 3353 mes = i18n("Local addressbook changed!\n") +mes;
3344 if ( syncManager->mShowSyncSummary ) { 3354 if ( syncManager->mShowSyncSummary ) {
3345 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 3355 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
3346 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 3356 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
3347 qDebug("KA: WB cancelled "); 3357 qDebug("KA: WB cancelled ");
3348 syncManager->mWriteBackFile = false; 3358 syncManager->mWriteBackFile = false;
3349 return syncOK; 3359 return syncOK;
3350 } 3360 }
3351 } 3361 }
3352 return syncOK; 3362 return syncOK;
3353} 3363}
3354 3364
3355 3365
3356//this is a overwritten callbackmethods from the syncinterface 3366//this is a overwritten callbackmethods from the syncinterface
3357bool KABCore::sync(KSyncManager* manager, QString filename, int mode,QString resource) 3367bool KABCore::sync(KSyncManager* manager, QString filename, int mode,QString resource)
3358{ 3368{
3359 3369
3360 //pending prepare addresseeview for output 3370 //pending prepare addresseeview for output
3361 //pending detect, if remote file has REV field. if not switch to external sync 3371 //pending detect, if remote file has REV field. if not switch to external sync
3362 mGlobalSyncMode = SYNC_MODE_NORMAL; 3372 mGlobalSyncMode = SYNC_MODE_NORMAL;
3363 if ( manager != syncManager ) 3373 if ( manager != syncManager )
3364 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3374 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3365 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3375 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3366 3376
3367 AddressBook abLocal(filename,"syncContact"); 3377 AddressBook abLocal(filename,"syncContact");
3368 bool syncOK = false; 3378 bool syncOK = false;
3369 if ( abLocal.load() ) { 3379 if ( abLocal.load() ) {
3370 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); 3380 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode );
3371 bool external = false; 3381 bool external = false;
3372 bool isXML = false; 3382 bool isXML = false;
3373 if ( filename.right(4) == ".xml") { 3383 if ( filename.right(4) == ".xml") {
3374 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3384 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3375 isXML = true; 3385 isXML = true;
3376 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3386 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3377 } else { 3387 } else {
3378 external = !manager->mIsKapiFile; 3388 external = !manager->mIsKapiFile;
3379 if ( external ) { 3389 if ( external ) {
3380 qDebug("KA: Sync::Setting vcf mode to external "); 3390 qDebug("KA: Sync::Setting vcf mode to external ");
3381 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3391 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3382 AddressBook::Iterator it; 3392 AddressBook::Iterator it;
3383 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3393 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3384 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3394 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3385 (*it).computeCsum( mCurrentSyncDevice ); 3395 (*it).computeCsum( mCurrentSyncDevice );
3386 } 3396 }
3387 } 3397 }
3388 } 3398 }
3389 //AddressBook::Iterator it; 3399 //AddressBook::Iterator it;
3390 //QStringList vcards; 3400 //QStringList vcards;
3391 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3401 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3392 // qDebug("Name %s ", (*it).familyName().latin1()); 3402 // qDebug("Name %s ", (*it).familyName().latin1());
3393 //} 3403 //}
3394 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3404 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3395 syncManager->hideProgressBar(); 3405 syncManager->hideProgressBar();
3396 if ( syncOK ) { 3406 if ( syncOK ) {
3397 if ( syncManager->mWriteBackFile ) 3407 if ( syncManager->mWriteBackFile )
3398 { 3408 {
3399 if ( external ) 3409 if ( external )
3400 abLocal.removeSyncAddressees( !isXML); 3410 abLocal.removeSyncAddressees( !isXML);
3401 qDebug("KA: Sync::Saving remote AB "); 3411 qDebug("KA: Sync::Saving remote AB ");
3402 if ( ! abLocal.saveAB()) 3412 if ( ! abLocal.saveAB())
3403 qDebug("KA: sync::Error writing back AB to file "); 3413 qDebug("KA: sync::Error writing back AB to file ");
3404 if ( external ) { 3414 if ( external ) {
3405 // afterwrite processing 3415 // afterwrite processing
3406 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3416 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3407 } 3417 }
3408 } 3418 }
3409 } 3419 }
3410 setModified(); 3420 setModified();
3411 3421
3412 } 3422 }
3413 abLocal.removeResources(); 3423 abLocal.removeResources();
3414 if ( syncOK ) 3424 if ( syncOK )
3415 mViewManager->refreshView(); 3425 mViewManager->refreshView();
3416 return syncOK; 3426 return syncOK;
3417 3427
3418} 3428}
3419void KABCore::removeSyncInfo( QString syncProfile) 3429void KABCore::removeSyncInfo( QString syncProfile)
3420{ 3430{
3421 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3431 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3422 mAddressBook->removeSyncInfo( syncProfile ); 3432 mAddressBook->removeSyncInfo( syncProfile );
3423 setModified(); 3433 setModified();
3424} 3434}
3425 3435
3426bool KABCore::syncOL() 3436bool KABCore::syncOL()
3427{ 3437{
3428 disableBR( true ); 3438 disableBR( true );
3429 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3439 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3430 AddressBook abLocal; 3440 AddressBook abLocal;
3431 if ( ! readOLdata( &abLocal ) ) 3441 if ( ! readOLdata( &abLocal ) )
3432 return false; 3442 return false;
3433 bool syncOK = false; 3443 bool syncOK = false;
3434 message(i18n("Data from OL loaded..."), false); 3444 message(i18n("Data from OL loaded..."), false);
3435 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3445 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3436 message(i18n("Sync preprocessing..."),false); 3446 message(i18n("Sync preprocessing..."),false);
3437 abLocal.preOLSync( mAddressBook ,mCurrentSyncDevice ); 3447 abLocal.preOLSync( mAddressBook ,mCurrentSyncDevice );
3438 message(i18n("Synchronizing..."),false); 3448 message(i18n("Synchronizing..."),false);
3439 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3449 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3440 syncManager->hideProgressBar(); 3450 syncManager->hideProgressBar();
3441 if ( syncOK ) { 3451 if ( syncOK ) {
3442 if ( syncManager->mWriteBackFile ) { 3452 if ( syncManager->mWriteBackFile ) {
3443 abLocal.removeSyncAddressees( false ); 3453 abLocal.removeSyncAddressees( false );
3444 message(i18n("Saving address data to OL..."),false); 3454 message(i18n("Saving address data to OL..."),false);
3445 //abLocal.saveAB(); 3455 //abLocal.saveAB();
3446 writeOLdata( &abLocal ); 3456 writeOLdata( &abLocal );
3447 message(i18n("Sync postprocessing..."),false); 3457 message(i18n("Sync postprocessing..."),false);
3448 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3458 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3449 } 3459 }
3450 } else 3460 } else
3451 message( i18n("Sync cancelled or failed.") ); 3461 message( i18n("Sync cancelled or failed.") );
3452 setModified(); 3462 setModified();
3453 abLocal.removeResources(); 3463 abLocal.removeResources();
3454 if ( syncOK ) { 3464 if ( syncOK ) {
3455 mViewManager->refreshView(); 3465 mViewManager->refreshView();
3456 message(i18n("OL syncing finished.")); 3466 message(i18n("OL syncing finished."));
3457 } 3467 }
3458 disableBR( false ); 3468 disableBR( false );
3459 return syncOK; 3469 return syncOK;
3460} 3470}
3461 3471
3462//this is a overwritten callbackmethods from the syncinterface 3472//this is a overwritten callbackmethods from the syncinterface
3463bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3473bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3464{ 3474{
3465 if ( resource == "phone" ) 3475 if ( resource == "phone" )
3466 return syncPhone(); 3476 return syncPhone();
3467 if ( resource == "ol" ) 3477 if ( resource == "ol" )
3468 return syncOL(); 3478 return syncOL();
3469 disableBR( true ); 3479 disableBR( true );
3470 if ( manager != syncManager ) 3480 if ( manager != syncManager )
3471 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3481 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3472 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3482 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3473 3483
3474 AddressBook abLocal( resource,"syncContact"); 3484 AddressBook abLocal( resource,"syncContact");
3475 bool syncOK = false; 3485 bool syncOK = false;
3476 message(i18n("Loading DTM address data..."), false); 3486 message(i18n("Loading DTM address data..."), false);
3477 if ( abLocal.load() ) { 3487 if ( abLocal.load() ) {
3478 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3488 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3479 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3489 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3480 message(i18n("Sync preprocessing..."),false); 3490 message(i18n("Sync preprocessing..."),false);
3481 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3491 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3482 message(i18n("Synchronizing..."),false); 3492 message(i18n("Synchronizing..."),false);
3483 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3493 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3484 syncManager->hideProgressBar(); 3494 syncManager->hideProgressBar();
3485 if ( syncOK ) { 3495 if ( syncOK ) {
3486 if ( syncManager->mWriteBackFile ) { 3496 if ( syncManager->mWriteBackFile ) {
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index ec6a9ec..4351720 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -1,540 +1,544 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 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#ifndef KABCORE_H 24#ifndef KABCORE_H
25#define KABCORE_H 25#define KABCORE_H
26 26
27#include <kabc/field.h> 27#include <kabc/field.h>
28 28
29#ifndef KAB_EMBEDDED 29#ifndef KAB_EMBEDDED
30#endif //KAB_EMBEDDED 30#endif //KAB_EMBEDDED
31#include <qdict.h> 31#include <q3dict.h>
32#include <qtimer.h> 32#include <qtimer.h>
33 33
34#include <qwidget.h> 34#include <qwidget.h>
35#include <qpopupmenu.h> 35#include <q3popupmenu.h>
36//Added by qt3to4:
37#include <Q3CString>
38#include <QPixmap>
39#include <QResizeEvent>
36#include <ksyncmanager.h> 40#include <ksyncmanager.h>
37#ifndef DESKTOP_VERSION 41#ifndef DESKTOP_VERSION
38#include <qcopchannel_qws.h> 42#include <qcopchannel_qws.h>
39#endif 43#endif
40 44
41namespace KABC { 45namespace KABC {
42class AddressBook; 46class AddressBook;
43} 47}
44 48
45#ifndef KAB_EMBEDDED 49#ifndef KAB_EMBEDDED
46class KAboutData; 50class KAboutData;
47class KConfig; 51class KConfig;
48 52
49class KAddressBookService; 53class KAddressBookService;
50class LDAPSearchDialog; 54class LDAPSearchDialog;
51#else //KAB_EMBEDDED 55#else //KAB_EMBEDDED
52class KAddressBookMain; 56class KAddressBookMain;
53//US class QAction; 57//US class QAction;
54#endif //KAB_EMBEDDED 58#endif //KAB_EMBEDDED
55class KCMultiDialog; 59class KCMultiDialog;
56class KXMLGUIClient; 60class KXMLGUIClient;
57class ExtensionManager; 61class ExtensionManager;
58class XXPortManager; 62class XXPortManager;
59class JumpButtonBar; 63class JumpButtonBar;
60class IncSearchWidget; 64class IncSearchWidget;
61class KDGanttMinimizeSplitter; 65class KDGanttMinimizeSplitter;
62class KAction; 66class KAction;
63class KActionCollection; 67class KActionCollection;
64class KToggleAction; 68class KToggleAction;
65class KSyncProfile; 69class KSyncProfile;
66 70
67class QAction; 71class QAction;
68class QMenuBar; 72class QMenuBar;
69class QSplitter; 73class QSplitter;
70class ViewContainer; 74class ViewContainer;
71class ViewManager; 75class ViewManager;
72class AddresseeEditorDialog; 76class AddresseeEditorDialog;
73class Ir; 77class Ir;
74 78
75class KABCore : public QWidget, public KSyncInterface 79class KABCore : public QWidget, public KSyncInterface
76{ 80{
77 Q_OBJECT 81 Q_OBJECT
78 82
79 public: 83 public:
80 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); 84 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 );
81 85
82 86
83 ~KABCore(); 87 ~KABCore();
84 88
85 89
86#ifdef KAB_EMBEDDED 90#ifdef KAB_EMBEDDED
87 //US added functionality 91 //US added functionality
88 QPopupMenu* getViewMenu() {return viewMenu;} 92 Q3PopupMenu* getViewMenu() {return viewMenu;}
89 QPopupMenu* getFilterMenu() {return filterMenu;} 93 Q3PopupMenu* getFilterMenu() {return filterMenu;}
90 QPopupMenu* getSettingsMenu() {return settingsMenu;} 94 Q3PopupMenu* getSettingsMenu() {return settingsMenu;}
91 void addActionsManually(); 95 void addActionsManually();
92#endif //KAB_EMBEDDED 96#endif //KAB_EMBEDDED
93 /** 97 /**
94 Restores the global settings. 98 Restores the global settings.
95 */ 99 */
96 void restoreSettings(); 100 void restoreSettings();
97 101
98 102
99 103
100 /** 104 /**
101 Returns a pointer to the StdAddressBook of the application. 105 Returns a pointer to the StdAddressBook of the application.
102 */ 106 */
103 KABC::AddressBook *addressBook() const; 107 KABC::AddressBook *addressBook() const;
104 108
105 /** 109 /**
106 Returns a pointer to the KConfig object of the application. 110 Returns a pointer to the KConfig object of the application.
107 */ 111 */
108 static KConfig *config(); 112 static KConfig *config();
109 113
110 /** 114 /**
111 Returns a pointer to the global KActionCollection object. So 115 Returns a pointer to the global KActionCollection object. So
112 other classes can register their actions easily. 116 other classes can register their actions easily.
113 */ 117 */
114 KActionCollection *actionCollection() const; 118 KActionCollection *actionCollection() const;
115 119
116 /** 120 /**
117 Returns the current search field of the Incremental Search Widget. 121 Returns the current search field of the Incremental Search Widget.
118 */ 122 */
119 KABC::Field *currentSearchField() const; 123 KABC::Field *currentSearchField() const;
120 124
121 /** 125 /**
122 Returns the uid list of the currently selected contacts. 126 Returns the uid list of the currently selected contacts.
123 */ 127 */
124 QStringList selectedUIDs() const; 128 QStringList selectedUIDs() const;
125 129
126 /** 130 /**
127 Displays the ResourceSelectDialog and returns the selected 131 Displays the ResourceSelectDialog and returns the selected
128 resource or a null pointer if no resource was selected by 132 resource or a null pointer if no resource was selected by
129 the user. 133 the user.
130 */ 134 */
131 KABC::Resource *requestResource( QWidget *parent ); 135 KABC::Resource *requestResource( QWidget *parent );
132 136
133#ifndef KAB_EMBEDDED 137#ifndef KAB_EMBEDDED
134 static KAboutData *createAboutData(); 138 static KAboutData *createAboutData();
135#endif //KAB_EMBEDDED 139#endif //KAB_EMBEDDED
136 140
137#ifdef KAB_EMBEDDED 141#ifdef KAB_EMBEDDED
138 inline QPopupMenu* getImportMenu() { return ImportMenu;} 142 inline Q3PopupMenu* getImportMenu() { return ImportMenu;}
139 inline QPopupMenu* getExportMenu() { return ExportMenu;} 143 inline Q3PopupMenu* getExportMenu() { return ExportMenu;}
140#endif //KAB_EMBEDDED 144#endif //KAB_EMBEDDED
141 145
142 public slots: 146 public slots:
143#ifdef KAB_EMBEDDED 147#ifdef KAB_EMBEDDED
144 void createAboutData(); 148 void createAboutData();
145#endif //KAB_EMBEDDED 149#endif //KAB_EMBEDDED
146 void setDetailsToggle(); 150 void setDetailsToggle();
147 151
148 void showLicence(); 152 void showLicence();
149 void faq(); 153 void faq();
150 void whatsnew() ; 154 void whatsnew() ;
151 void synchowto() ; 155 void synchowto() ;
152 void storagehowto() ; 156 void storagehowto() ;
153 void multisynchowto() ; 157 void multisynchowto() ;
154 void kdesynchowto() ; 158 void kdesynchowto() ;
155 void writeToPhone(); 159 void writeToPhone();
156 160
157 /** 161 /**
158 Is called whenever a contact is selected in the view. 162 Is called whenever a contact is selected in the view.
159 */ 163 */
160 void setContactSelected( const QString &uid ); 164 void setContactSelected( const QString &uid );
161 165
162 /** 166 /**
163 Opens the preferred mail composer with all selected contacts as 167 Opens the preferred mail composer with all selected contacts as
164 arguments. 168 arguments.
165 */ 169 */
166 void sendMail(); 170 void sendMail();
167 171
168 /** 172 /**
169 Opens the preferred mail composer with the given contacts as 173 Opens the preferred mail composer with the given contacts as
170 arguments. 174 arguments.
171 */ 175 */
172 void sendMail( const QString& email ); 176 void sendMail( const QString& email );
173 177
174 178
175 void mailVCard(); 179 void mailVCard();
176 void mailVCard(const QStringList& uids); 180 void mailVCard(const QStringList& uids);
177 181
178 /** 182 /**
179 Beams the "WhoAmI contact. 183 Beams the "WhoAmI contact.
180 */ 184 */
181 void beamMySelf(); 185 void beamMySelf();
182 186
183 void beamVCard(); 187 void beamVCard();
184 void export2phone(); 188 void export2phone();
185 void beamVCard(const QStringList& uids); 189 void beamVCard(const QStringList& uids);
186 void beamDone( Ir *ir ); 190 void beamDone( Ir *ir );
187 191
188 192
189 /** 193 /**
190 Starts the preferred web browser with the given URL as argument. 194 Starts the preferred web browser with the given URL as argument.
191 */ 195 */
192 void browse( const QString& url ); 196 void browse( const QString& url );
193 197
194 /** 198 /**
195 Select all contacts in the view. 199 Select all contacts in the view.
196 */ 200 */
197 void selectAllContacts(); 201 void selectAllContacts();
198 202
199 /** 203 /**
200 Deletes all selected contacts from the address book. 204 Deletes all selected contacts from the address book.
201 */ 205 */
202 void deleteContacts(); 206 void deleteContacts();
203 207
204 /** 208 /**
205 Deletes given contacts from the address book. 209 Deletes given contacts from the address book.
206 210
207 @param uids The uids of the contacts, which shall be deleted. 211 @param uids The uids of the contacts, which shall be deleted.
208 */ 212 */
209 void deleteContacts( const QStringList &uids ); 213 void deleteContacts( const QStringList &uids );
210 214
211 /** 215 /**
212 Copys the selected contacts into clipboard for later pasting. 216 Copys the selected contacts into clipboard for later pasting.
213 */ 217 */
214 void copyContacts(); 218 void copyContacts();
215 219
216 /** 220 /**
217 Cuts the selected contacts and stores them for later pasting. 221 Cuts the selected contacts and stores them for later pasting.
218 */ 222 */
219 void cutContacts(); 223 void cutContacts();
220 224
221 /** 225 /**
222 Paste contacts from clipboard into the address book. 226 Paste contacts from clipboard into the address book.
223 */ 227 */
224 void pasteContacts(); 228 void pasteContacts();
225 229
226 /** 230 /**
227 Paste given contacts into the address book. 231 Paste given contacts into the address book.
228 232
229 @param list The list of addressee, which shall be pasted. 233 @param list The list of addressee, which shall be pasted.
230 */ 234 */
231 void pasteContacts( KABC::Addressee::List &list ); 235 void pasteContacts( KABC::Addressee::List &list );
232 236
233 /** 237 /**
234 Sets the whoAmI contact, that is used by many other programs to 238 Sets the whoAmI contact, that is used by many other programs to
235 get personal information about the current user. 239 get personal information about the current user.
236 */ 240 */
237 void setWhoAmI(); 241 void setWhoAmI();
238 242
239 /** 243 /**
240 Displays the category dialog and applies the result to all 244 Displays the category dialog and applies the result to all
241 selected contacts. 245 selected contacts.
242 */ 246 */
243 void setCategories(); 247 void setCategories();
244 void manageCategories(); 248 void manageCategories();
245 void editCategories(); 249 void editCategories();
246 250
247 /** 251 /**
248 Sets the field list of the Incremental Search Widget. 252 Sets the field list of the Incremental Search Widget.
249 */ 253 */
250 void setSearchFields( const KABC::Field::List &fields ); 254 void setSearchFields( const KABC::Field::List &fields );
251 255
252 /** 256 /**
253 Search with the current search field for a contact, that matches 257 Search with the current search field for a contact, that matches
254 the given text, and selects it in the view. 258 the given text, and selects it in the view.
255 */ 259 */
256 void incrementalSearch( const QString& text ); 260 void incrementalSearch( const QString& text );
257 void incrementalSearchJump( const QString& text ); 261 void incrementalSearchJump( const QString& text );
258 262
259 /** 263 /**
260 Marks the address book as modified. 264 Marks the address book as modified.
261 */ 265 */
262 void setModified(); 266 void setModified();
263 /** 267 /**
264 Marks the address book as modified without refreshing the view. 268 Marks the address book as modified without refreshing the view.
265 */ 269 */
266 void setModifiedWOrefresh(); 270 void setModifiedWOrefresh();
267 271
268 /** 272 /**
269 Marks the address book as modified concerning the argument. 273 Marks the address book as modified concerning the argument.
270 */ 274 */
271 void setModified( bool modified ); 275 void setModified( bool modified );
272 276
273 /** 277 /**
274 Returns whether the address book is modified. 278 Returns whether the address book is modified.
275 */ 279 */
276 bool modified() const; 280 bool modified() const;
277 281
278 /** 282 /**
279 Called whenever an contact is modified in the contact editor 283 Called whenever an contact is modified in the contact editor
280 dialog or the quick edit. 284 dialog or the quick edit.
281 */ 285 */
282 void contactModified( const KABC::Addressee &addr ); 286 void contactModified( const KABC::Addressee &addr );
283 void addrModified( const KABC::Addressee &addr, bool updateDetails = true ); 287 void addrModified( const KABC::Addressee &addr, bool updateDetails = true );
284 288
285 /** 289 /**
286 DCOP METHODS. 290 DCOP METHODS.
287 */ 291 */
288 void addEmail( QString addr ); 292 void addEmail( QString addr );
289 void importVCard( const KURL& url, bool showPreview ); 293 void importVCard( const KURL& url, bool showPreview );
290 void importVCard( const QString& vCard, bool showPreview ); 294 void importVCard( const QString& vCard, bool showPreview );
291 void newContact(); 295 void newContact();
292 QString getNameByPhone( const QString& phone ); 296 QString getNameByPhone( const QString& phone );
293 /** 297 /**
294 END DCOP METHODS 298 END DCOP METHODS
295 */ 299 */
296 300
297 /** 301 /**
298 Saves the contents of the AddressBook back to disk. 302 Saves the contents of the AddressBook back to disk.
299 */ 303 */
300 void save(); 304 void save();
301 305
302 /** 306 /**
303 Undos the last command using the undo stack. 307 Undos the last command using the undo stack.
304 */ 308 */
305 void undo(); 309 void undo();
306 310
307 /** 311 /**
308 Redos the last command that was undone, using the redo stack. 312 Redos the last command that was undone, using the redo stack.
309 */ 313 */
310 void redo(); 314 void redo();
311 315
312 /** 316 /**
313 Shows the edit dialog for the given uid. If the uid is QString::null, 317 Shows the edit dialog for the given uid. If the uid is QString::null,
314 the method will try to find a selected addressee in the view. 318 the method will try to find a selected addressee in the view.
315 */ 319 */
316 void editContact( const QString &uid /*US = QString::null*/ ); 320 void editContact( const QString &uid /*US = QString::null*/ );
317//US added a second method without defaultparameter 321//US added a second method without defaultparameter
318 void editContact2(); 322 void editContact2();
319 323
320 /** 324 /**
321 Shows or edits the detail view for the given uid. If the uid is QString::null, 325 Shows or edits the detail view for the given uid. If the uid is QString::null,
322 the method will try to find a selected addressee in the view. 326 the method will try to find a selected addressee in the view.
323 */ 327 */
324 void executeContact( const QString &uid /*US = QString::null*/ ); 328 void executeContact( const QString &uid /*US = QString::null*/ );
325 329
326 /** 330 /**
327 Launches the configuration dialog. 331 Launches the configuration dialog.
328 */ 332 */
329 void openConfigDialog(); 333 void openConfigDialog();
330 void openConfigGlobalDialog(); 334 void openConfigGlobalDialog();
331 335
332 /** 336 /**
333 Launches the ldap search dialog. 337 Launches the ldap search dialog.
334 */ 338 */
335 void openLDAPDialog(); 339 void openLDAPDialog();
336 340
337 /** 341 /**
338 Creates a KAddressBookPrinter, which will display the print 342 Creates a KAddressBookPrinter, which will display the print
339 dialog and do the printing. 343 dialog and do the printing.
340 */ 344 */
341 void print(); 345 void print();
342 346
343 /** 347 /**
344 Registers a new GUI client, so plugins can register its actions. 348 Registers a new GUI client, so plugins can register its actions.
345 */ 349 */
346 void addGUIClient( KXMLGUIClient *client ); 350 void addGUIClient( KXMLGUIClient *client );
347 351
348 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); 352 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
349 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); 353 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
350 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); 354 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid);
351 355
352 356
353 signals: 357 signals:
354 void contactSelected( const QString &name ); 358 void contactSelected( const QString &name );
355 void contactSelected( const QPixmap &pixmap ); 359 void contactSelected( const QPixmap &pixmap );
356 public slots: 360 public slots:
357 void loadDataAfterStart(); 361 void loadDataAfterStart();
358 void recieve(QString cmsg ); 362 void recieve(QString cmsg );
359 void getFile( bool success,const QString & ); 363 void getFile( bool success,const QString & );
360 void syncFileRequest(const QString &); 364 void syncFileRequest(const QString &);
361 void setDetailsVisible( bool visible ); 365 void setDetailsVisible( bool visible );
362 void setDetailsToState(); 366 void setDetailsToState();
363 367
364 void saveSettings(); 368 void saveSettings();
365 369
366 private slots: 370 private slots:
367 void updateToolBar(); 371 void updateToolBar();
368 void updateMainWindow(); 372 void updateMainWindow();
369 void receive( const QCString& cmsg, const QByteArray& data ); 373 void receive( const Q3CString& cmsg, const QByteArray& data );
370 void receiveStart( const QCString& cmsg, const QByteArray& data ); 374 void receiveStart( const Q3CString& cmsg, const QByteArray& data );
371 void toggleBeamReceive( ); 375 void toggleBeamReceive( );
372 void disableBR(bool); 376 void disableBR(bool);
373 void setJumpButtonBarVisible( bool visible ); 377 void setJumpButtonBarVisible( bool visible );
374 void setJumpButtonBar( bool visible ); 378 void setJumpButtonBar( bool visible );
375 void setCaptionBack(); 379 void setCaptionBack();
376 void resizeAndCallContactdialog(); 380 void resizeAndCallContactdialog();
377 void callContactdialog(); 381 void callContactdialog();
378 void doRingSync(); 382 void doRingSync();
379 383
380 void importFromOL(); 384 void importFromOL();
381 void extensionModified( const KABC::Addressee::List &list ); 385 void extensionModified( const KABC::Addressee::List &list );
382 void extensionChanged( int id ); 386 void extensionChanged( int id );
383 void clipboardDataChanged(); 387 void clipboardDataChanged();
384 void updateActionMenu(); 388 void updateActionMenu();
385 void configureKeyBindings(); 389 void configureKeyBindings();
386 void removeVoice(); 390 void removeVoice();
387 void setFormattedName(); 391 void setFormattedName();
388#ifdef KAB_EMBEDDED 392#ifdef KAB_EMBEDDED
389 void configureResources(); 393 void configureResources();
390#endif //KAB_EMBEDDED 394#endif //KAB_EMBEDDED
391 395
392 void slotEditorDestroyed( const QString &uid ); 396 void slotEditorDestroyed( const QString &uid );
393 void configurationChanged(); 397 void configurationChanged();
394 void addressBookChanged(); 398 void addressBookChanged();
395 399
396 private: 400 private:
397 QCString mCStringMess; 401 Q3CString mCStringMess;
398 QByteArray mByteData; 402 QByteArray mByteData;
399 QString mEmailSourceChannel; 403 QString mEmailSourceChannel;
400 QString mEmailSourceUID; 404 QString mEmailSourceUID;
401 void resizeEvent(QResizeEvent* e ); 405 void resizeEvent(QResizeEvent* e );
402 bool mBRdisabled; 406 bool mBRdisabled;
403#ifndef DESKTOP_VERSION 407#ifndef DESKTOP_VERSION
404 QCopChannel* infrared; 408 QCopChannel* infrared;
405#endif 409#endif
406 QTimer *mMessageTimer; 410 QTimer *mMessageTimer;
407 void initGUI(); 411 void initGUI();
408 void initActions(); 412 void initActions();
409 QString getPhoneFile(); 413 QString getPhoneFile();
410 414
411 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, 415 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
412 const char *name = 0 ); 416 const char *name = 0 );
413 417
414 KXMLGUIClient *mGUIClient; 418 KXMLGUIClient *mGUIClient;
415 419
416 KABC::AddressBook *mAddressBook; 420 KABC::AddressBook *mAddressBook;
417 421
418 ViewManager *mViewManager; 422 ViewManager *mViewManager;
419 // QSplitter *mDetailsSplitter; 423 // QSplitter *mDetailsSplitter;
420 KDGanttMinimizeSplitter *mExtensionBarSplitter; 424 KDGanttMinimizeSplitter *mExtensionBarSplitter;
421 ViewContainer *mDetails; 425 ViewContainer *mDetails;
422 KDGanttMinimizeSplitter* mMiniSplitter; 426 KDGanttMinimizeSplitter* mMiniSplitter;
423 XXPortManager *mXXPortManager; 427 XXPortManager *mXXPortManager;
424 JumpButtonBar *mJumpButtonBar; 428 JumpButtonBar *mJumpButtonBar;
425 IncSearchWidget *mIncSearchWidget; 429 IncSearchWidget *mIncSearchWidget;
426 ExtensionManager *mExtensionManager; 430 ExtensionManager *mExtensionManager;
427 431
428 KCMultiDialog *mConfigureDialog; 432 KCMultiDialog *mConfigureDialog;
429 433
430#ifndef KAB_EMBEDDED 434#ifndef KAB_EMBEDDED
431 LDAPSearchDialog *mLdapSearchDialog; 435 LDAPSearchDialog *mLdapSearchDialog;
432#endif //KAB_EMBEDDED 436#endif //KAB_EMBEDDED
433 // QDict<AddresseeEditorDialog> mEditorDict; 437 // QDict<AddresseeEditorDialog> mEditorDict;
434 AddresseeEditorDialog *mEditorDialog; 438 AddresseeEditorDialog *mEditorDialog;
435 bool mReadWrite; 439 bool mReadWrite;
436 bool mModified; 440 bool mModified;
437 bool mIsPart; 441 bool mIsPart;
438 bool mMultipleViewsAtOnce; 442 bool mMultipleViewsAtOnce;
439 443
440 444
441 //US file menu 445 //US file menu
442 KAction *mActionMail; 446 KAction *mActionMail;
443 KAction *mActionBeam; 447 KAction *mActionBeam;
444 KToggleAction *mActionBR; 448 KToggleAction *mActionBR;
445 KAction *mActionExport2phone; 449 KAction *mActionExport2phone;
446 KAction* mActionPrint; 450 KAction* mActionPrint;
447 KAction* mActionPrintDetails; 451 KAction* mActionPrintDetails;
448 KAction* mActionNewContact; 452 KAction* mActionNewContact;
449 KAction *mActionSave; 453 KAction *mActionSave;
450 KAction *mActionEditAddressee; 454 KAction *mActionEditAddressee;
451 KAction *mActionMailVCard; 455 KAction *mActionMailVCard;
452 KAction *mActionBeamVCard; 456 KAction *mActionBeamVCard;
453 457
454 KAction *mActionQuit; 458 KAction *mActionQuit;
455 459
456 //US edit menu 460 //US edit menu
457 KAction *mActionCopy; 461 KAction *mActionCopy;
458 KAction *mActionCut; 462 KAction *mActionCut;
459 KAction *mActionPaste; 463 KAction *mActionPaste;
460 KAction *mActionSelectAll; 464 KAction *mActionSelectAll;
461 KAction *mActionUndo; 465 KAction *mActionUndo;
462 KAction *mActionRedo; 466 KAction *mActionRedo;
463 KAction *mActionDelete; 467 KAction *mActionDelete;
464 468
465 //US settings menu 469 //US settings menu
466 KAction *mActionConfigResources; 470 KAction *mActionConfigResources;
467 KAction *mActionConfigGlobal; 471 KAction *mActionConfigGlobal;
468 KAction *mActionConfigKAddressbook; 472 KAction *mActionConfigKAddressbook;
469 KAction *mActionConfigShortcuts; 473 KAction *mActionConfigShortcuts;
470 KAction *mActionConfigureToolbars; 474 KAction *mActionConfigureToolbars;
471 KAction *mActionKeyBindings; 475 KAction *mActionKeyBindings;
472 KToggleAction *mActionJumpBar; 476 KToggleAction *mActionJumpBar;
473 KToggleAction *mActionDetails; 477 KToggleAction *mActionDetails;
474 KAction *mActionWhoAmI; 478 KAction *mActionWhoAmI;
475 KAction *mActionCategories; 479 KAction *mActionCategories;
476 KAction *mActionEditCategories; 480 KAction *mActionEditCategories;
477 KAction *mActionManageCategories; 481 KAction *mActionManageCategories;
478 KAction *mActionAboutKAddressbook; 482 KAction *mActionAboutKAddressbook;
479 KAction *mActionLicence; 483 KAction *mActionLicence;
480 KAction *mActionFaq; 484 KAction *mActionFaq;
481 KAction *mActionWN; 485 KAction *mActionWN;
482 KAction *mActionSyncHowto; 486 KAction *mActionSyncHowto;
483 KAction *mActionStorageHowto; 487 KAction *mActionStorageHowto;
484 KAction *mActionKdeSyncHowto; 488 KAction *mActionKdeSyncHowto;
485 KAction *mActionMultiSyncHowto; 489 KAction *mActionMultiSyncHowto;
486 490
487 KAction *mActionDeleteView; 491 KAction *mActionDeleteView;
488 492
489 QPopupMenu *viewMenu; 493 Q3PopupMenu *viewMenu;
490 QPopupMenu *filterMenu; 494 Q3PopupMenu *filterMenu;
491 QPopupMenu *settingsMenu; 495 Q3PopupMenu *settingsMenu;
492 QPopupMenu *changeMenu; 496 Q3PopupMenu *changeMenu;
493 QPopupMenu *beamMenu; 497 Q3PopupMenu *beamMenu;
494//US QAction *mActionSave; 498//US QAction *mActionSave;
495 QPopupMenu *ImportMenu; 499 Q3PopupMenu *ImportMenu;
496 QPopupMenu *ExportMenu; 500 Q3PopupMenu *ExportMenu;
497 //LR additional methods 501 //LR additional methods
498 KAction *mActionRemoveVoice; 502 KAction *mActionRemoveVoice;
499 KAction *mActionSetFormattedName; 503 KAction *mActionSetFormattedName;
500 KAction * mActionImportOL; 504 KAction * mActionImportOL;
501 505
502#ifndef KAB_EMBEDDED 506#ifndef KAB_EMBEDDED
503 KAddressBookService *mAddressBookService; 507 KAddressBookService *mAddressBookService;
504#endif //KAB_EMBEDDED 508#endif //KAB_EMBEDDED
505 509
506 class KABCorePrivate; 510 class KABCorePrivate;
507 KABCorePrivate *d; 511 KABCorePrivate *d;
508 //US bool mBlockSaveFlag; 512 //US bool mBlockSaveFlag;
509 513
510#ifdef KAB_EMBEDDED 514#ifdef KAB_EMBEDDED
511 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 515 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
512#endif //KAB_EMBEDDED 516#endif //KAB_EMBEDDED
513 517
514 //this are the overwritten callbackmethods from the syncinterface 518 //this are the overwritten callbackmethods from the syncinterface
515 virtual bool sync(KSyncManager* manager, QString filename, int mode,QString resource); 519 virtual bool sync(KSyncManager* manager, QString filename, int mode,QString resource);
516 virtual bool syncExternal(KSyncManager* manager, QString resource); 520 virtual bool syncExternal(KSyncManager* manager, QString resource);
517 virtual void removeSyncInfo( QString syncProfile); 521 virtual void removeSyncInfo( QString syncProfile);
518 bool readOLdata( KABC::AddressBook* local ); 522 bool readOLdata( KABC::AddressBook* local );
519 bool writeOLdata( KABC::AddressBook* local ); 523 bool writeOLdata( KABC::AddressBook* local );
520 bool syncOL(); 524 bool syncOL();
521 bool syncPhone(); 525 bool syncPhone();
522 void message( QString m , bool startTimer = true); 526 void message( QString m , bool startTimer = true);
523 527
524 // LR ******************************* 528 // LR *******************************
525 // sync stuff! 529 // sync stuff!
526 QString sentSyncFile(); 530 QString sentSyncFile();
527 QPopupMenu *syncMenu; 531 Q3PopupMenu *syncMenu;
528 KSyncManager* syncManager; 532 KSyncManager* syncManager;
529 int mGlobalSyncMode; 533 int mGlobalSyncMode;
530 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); 534 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
531 KABC::Addressee getLastSyncAddressee(); 535 KABC::Addressee getLastSyncAddressee();
532 QDateTime mLastAddressbookSync; 536 QDateTime mLastAddressbookSync;
533 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); 537 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
534 // ********************* 538 // *********************
535 //OL sync stuff 539 //OL sync stuff
536 QString mOLsyncFolderID; 540 QString mOLsyncFolderID;
537 541
538}; 542};
539 543
540#endif 544#endif
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp
index 42d541b..6f9c995 100644
--- a/kaddressbook/kabprefs.cpp
+++ b/kaddressbook/kabprefs.cpp
@@ -1,157 +1,157 @@
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//US#ifdef KAB_EMBEDDED 24//US#ifdef KAB_EMBEDDED
25//#include <qstring.h> 25//#include <qstring.h>
26//#endif //KAB_EMBEDDED 26//#endif //KAB_EMBEDDED
27 27
28#include <qtextstream.h> 28#include <q3textstream.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qregexp.h> 30#include <qregexp.h>
31#include <stdlib.h> 31#include <stdlib.h>
32#include <libkdepim/kpimglobalprefs.h> 32#include <libkdepim/kpimglobalprefs.h>
33 33
34#include <kconfig.h> 34#include <kconfig.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kstaticdeleter.h> 36#include <kstaticdeleter.h>
37#include <kglobalsettings.h> 37#include <kglobalsettings.h>
38//US#include <kdebug.h> // defines kdDebug() 38//US#include <kdebug.h> // defines kdDebug()
39 39
40#include "kabprefs.h" 40#include "kabprefs.h"
41 41
42#ifdef DESKTOP_VERSION 42#ifdef DESKTOP_VERSION
43#include <qapplication.h> 43#include <qapplication.h>
44#endif 44#endif
45 45
46KABPrefs *KABPrefs::sInstance = 0; 46KABPrefs *KABPrefs::sInstance = 0;
47static KStaticDeleter<KABPrefs> staticDeleterAB; 47static KStaticDeleter<KABPrefs> staticDeleterAB;
48 48
49KABPrefs::KABPrefs() 49KABPrefs::KABPrefs()
50 : KPimPrefs("kaddressbookrc") 50 : KPimPrefs("kaddressbookrc")
51{ 51{
52 KPrefs::setCurrentGroup( "Views" ); 52 KPrefs::setCurrentGroup( "Views" );
53 addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); 53 addItemBool( "HonorSingleClick", &mHonorSingleClick, false );
54 54
55 KPrefs::setCurrentGroup( "General" ); 55 KPrefs::setCurrentGroup( "General" );
56 addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true ); 56 addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true );
57 addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 ); 57 addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 );
58#ifdef KAB_EMBEDDED 58#ifdef KAB_EMBEDDED
59 addItemBool("AskForDelete",&mAskForDelete,true); 59 addItemBool("AskForDelete",&mAskForDelete,true);
60 addItemBool("AskForQuit",&mAskForQuit,true); 60 addItemBool("AskForQuit",&mAskForQuit,true);
61 addItemBool("ToolBarHor",&mToolBarHor, true ); 61 addItemBool("ToolBarHor",&mToolBarHor, true );
62 addItemBool("ToolBarUp",&mToolBarUp, false ); 62 addItemBool("ToolBarUp",&mToolBarUp, false );
63 addItemBool("SearchWithReturn",&mSearchWithReturn, false ); 63 addItemBool("SearchWithReturn",&mSearchWithReturn, false );
64 addItemBool("AutoSearchWithWildcard",&mAutoSearchWithWildcard, false ); 64 addItemBool("AutoSearchWithWildcard",&mAutoSearchWithWildcard, false );
65 addItemBool("HideSearchOnSwitch",&mHideSearchOnSwitch, false ); 65 addItemBool("HideSearchOnSwitch",&mHideSearchOnSwitch, false );
66 addItemFont("DetailsFont",&mDetailsFont,KGlobalSettings::generalFont()); 66 addItemFont("DetailsFont",&mDetailsFont,KGlobalSettings::generalFont());
67 67
68 68
69#endif //KAB_EMBEDDED 69#endif //KAB_EMBEDDED
70 70
71 KPrefs::setCurrentGroup( "MainWindow" ); 71 KPrefs::setCurrentGroup( "MainWindow" );
72 bool m_visible = false; 72 bool m_visible = false;
73#ifdef DESKTOP_VERSION 73#ifdef DESKTOP_VERSION
74 m_visible = true; 74 m_visible = true;
75#endif 75#endif
76 addItemBool( "FullMenuBarVisible", &mFullMenuBarVisible, m_visible ); 76 addItemBool( "FullMenuBarVisible", &mFullMenuBarVisible, m_visible );
77 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false ); 77 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false );
78 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true ); 78 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true );
79 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter ); 79 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter );
80 addItemIntList( "DetailsSplitter", &mDetailsSplitter ); 80 addItemIntList( "DetailsSplitter", &mDetailsSplitter );
81 addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true ); 81 addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true );
82 82
83 83
84 KPrefs::setCurrentGroup( "Extensions_General" ); 84 KPrefs::setCurrentGroup( "Extensions_General" );
85 QStringList defaultExtensions; 85 QStringList defaultExtensions;
86 defaultExtensions << "merge"; 86 defaultExtensions << "merge";
87 defaultExtensions << "distribution_list_editor"; 87 defaultExtensions << "distribution_list_editor";
88 addItemInt( "CurrentExtension", &mCurrentExtension, 0 ); 88 addItemInt( "CurrentExtension", &mCurrentExtension, 0 );
89 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions ); 89 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions );
90 90
91 KPrefs::setCurrentGroup( "Views" ); 91 KPrefs::setCurrentGroup( "Views" );
92 QString defaultView = i18n( "Default Table View" ); 92 QString defaultView = i18n( "Default Table View" );
93 addItemString( "CurrentView", &mCurrentView, defaultView ); 93 addItemString( "CurrentView", &mCurrentView, defaultView );
94 addItemStringList( "ViewNames", &mViewNames, defaultView ); 94 addItemStringList( "ViewNames", &mViewNames, QStringList(defaultView) );
95 95
96 KPrefs::setCurrentGroup( "Filters" ); 96 KPrefs::setCurrentGroup( "Filters" );
97 addItemInt( "CurrentFilter", &mCurrentFilter, 0 ); 97 addItemInt( "CurrentFilter", &mCurrentFilter, 0 );
98 98
99} 99}
100 100
101KABPrefs::~KABPrefs() 101KABPrefs::~KABPrefs()
102{ 102{
103 //qDebug("KABPrefs::~KABPrefs() "); 103 //qDebug("KABPrefs::~KABPrefs() ");
104 if (sInstance == this) 104 if (sInstance == this)
105 sInstance = staticDeleterAB.setObject(0); 105 sInstance = staticDeleterAB.setObject(0);
106} 106}
107 107
108KABPrefs *KABPrefs::instance() 108KABPrefs *KABPrefs::instance()
109{ 109{
110 if ( !sInstance ) { 110 if ( !sInstance ) {
111#ifdef KAB_EMBEDDED 111#ifdef KAB_EMBEDDED
112 sInstance = staticDeleterAB.setObject( new KABPrefs() ); 112 sInstance = staticDeleterAB.setObject( new KABPrefs() );
113#else //KAB_EMBEDDED 113#else //KAB_EMBEDDED
114 //US the following line has changed ???. Why 114 //US the following line has changed ???. Why
115 staticDeleterAB.setObject( sInstance, new KABPrefs() ); 115 staticDeleterAB.setObject( sInstance, new KABPrefs() );
116#endif //KAB_EMBEDDED 116#endif //KAB_EMBEDDED
117 sInstance->readConfig(); 117 sInstance->readConfig();
118 } 118 }
119 119
120 return sInstance; 120 return sInstance;
121} 121}
122 122
123void KABPrefs::setCategoryDefaults() 123void KABPrefs::setCategoryDefaults()
124{ 124{
125 mCustomCategories.clear(); 125 mCustomCategories.clear();
126 126
127 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" ) 127 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" )
128 << i18n( "Customer" ) << i18n( "Friend" ); 128 << i18n( "Customer" ) << i18n( "Friend" );
129} 129}
130 130
131 // US introduce a nonconst way to return the config object. 131 // US introduce a nonconst way to return the config object.
132KConfig* KABPrefs::getConfig() 132KConfig* KABPrefs::getConfig()
133{ 133{
134 return config(); 134 return config();
135} 135}
136void KABPrefs::usrReadConfig() 136void KABPrefs::usrReadConfig()
137{ 137{
138 KPimPrefs::usrReadConfig(); 138 KPimPrefs::usrReadConfig();
139} 139}
140 140
141 141
142/*US 142/*US
143void KABPrefs::usrSetDefaults() 143void KABPrefs::usrSetDefaults()
144{ 144{
145 KPimPrefs::usrSetDefaults(); 145 KPimPrefs::usrSetDefaults();
146} 146}
147 147
148void KABPrefs::usrReadConfig() 148void KABPrefs::usrReadConfig()
149{ 149{
150 KPimPrefs::usrReadConfig(); 150 KPimPrefs::usrReadConfig();
151} 151}
152 152
153void KABPrefs::usrWriteConfig() 153void KABPrefs::usrWriteConfig()
154{ 154{
155 KPimPrefs::usrWriteConfig(); 155 KPimPrefs::usrWriteConfig();
156} 156}
157*/ 157*/
diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h
index ddbc0c0..aff725e 100644
--- a/kaddressbook/kabprefs.h
+++ b/kaddressbook/kabprefs.h
@@ -1,99 +1,101 @@
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 KABPREFS_H 24#ifndef KABPREFS_H
25#define KABPREFS_H 25#define KABPREFS_H
26 26
27#include <qstringlist.h> 27#include <qstringlist.h>
28#include <qdict.h> 28#include <q3dict.h>
29//Added by qt3to4:
30#include <Q3ValueList>
29 31
30#include <libkdepim/kpimprefs.h> 32#include <libkdepim/kpimprefs.h>
31 33
32class KConfig; 34class KConfig;
33 35
34class KABPrefs : public KPimPrefs 36class KABPrefs : public KPimPrefs
35{ 37{
36 public: 38 public:
37 virtual ~KABPrefs(); 39 virtual ~KABPrefs();
38 40
39 static KABPrefs *instance(); 41 static KABPrefs *instance();
40 42
41 // General 43 // General
42 bool mHonorSingleClick; 44 bool mHonorSingleClick;
43 bool mAutomaticNameParsing; 45 bool mAutomaticNameParsing;
44 int mCurrentIncSearchField; 46 int mCurrentIncSearchField;
45 47
46#ifdef KAB_EMBEDDED 48#ifdef KAB_EMBEDDED
47 // US introduce a nonconst way to return the config object. 49 // US introduce a nonconst way to return the config object.
48 KConfig* getConfig(); 50 KConfig* getConfig();
49 51
50 bool mToolBarHor; 52 bool mToolBarHor;
51 bool mToolBarUp; 53 bool mToolBarUp;
52 bool mAskForQuit; 54 bool mAskForQuit;
53 55
54 56
55 /** Set preferences to default values */ 57 /** Set preferences to default values */
56// void usrSetDefaults(); 58// void usrSetDefaults();
57 59
58 /** Read preferences from config file */ 60 /** Read preferences from config file */
59// void usrReadConfig(); 61// void usrReadConfig();
60 62
61 /** Write preferences to config file */ 63 /** Write preferences to config file */
62// void usrWriteConfig(); 64// void usrWriteConfig();
63#endif //KAB_EMBEDDED 65#endif //KAB_EMBEDDED
64 void usrReadConfig(); 66 void usrReadConfig();
65 67
66 68
67 // GUI 69 // GUI
68 bool mFullMenuBarVisible; 70 bool mFullMenuBarVisible;
69 bool mJumpButtonBarVisible; 71 bool mJumpButtonBarVisible;
70 bool mDetailsPageVisible; 72 bool mDetailsPageVisible;
71 bool mMultipleViewsAtOnce; 73 bool mMultipleViewsAtOnce;
72 bool mSearchWithReturn; 74 bool mSearchWithReturn;
73 bool mAutoSearchWithWildcard; 75 bool mAutoSearchWithWildcard;
74 bool mHideSearchOnSwitch; 76 bool mHideSearchOnSwitch;
75 bool mAskForDelete; 77 bool mAskForDelete;
76 QValueList<int> mExtensionsSplitter; 78 Q3ValueList<int> mExtensionsSplitter;
77 QValueList<int> mDetailsSplitter; 79 Q3ValueList<int> mDetailsSplitter;
78 80
79 // Extensions stuff 81 // Extensions stuff
80 int mCurrentExtension; 82 int mCurrentExtension;
81 QStringList mActiveExtensions; 83 QStringList mActiveExtensions;
82 84
83 // Views stuff 85 // Views stuff
84 QString mCurrentView; 86 QString mCurrentView;
85 QStringList mViewNames; 87 QStringList mViewNames;
86 88
87 // Filter 89 // Filter
88 int mCurrentFilter; 90 int mCurrentFilter;
89 91
90 void setCategoryDefaults(); 92 void setCategoryDefaults();
91 QFont mDetailsFont; 93 QFont mDetailsFont;
92 94
93 private: 95 private:
94 KABPrefs(); 96 KABPrefs();
95 97
96 static KABPrefs *sInstance; 98 static KABPrefs *sInstance;
97}; 99};
98 100
99#endif 101#endif
diff --git a/kaddressbook/kaddressbook.pro b/kaddressbook/kaddressbook.pro
index cd38e5f..4eb1f7f 100644
--- a/kaddressbook/kaddressbook.pro
+++ b/kaddressbook/kaddressbook.pro
@@ -1,206 +1,208 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on 2 CONFIG = qt warn_on
3 TARGET = kapi 3 TARGET = kapi
4DESTDIR= ../bin 4DESTDIR= ../bin
5 5
6include( ../variables.pri ) 6include( ../variables.pri )
7 7
8 8
9INCLUDEPATH += . ./details ./features ./xxport ../libkdepim ../microkde ../microkde/kdecore ../microkde/kutils ../microkde/kio/kfile ../microkde/kio/kio ../microkde/kdeui ../microkde/kresources ../kabc ../ interfaces 9INCLUDEPATH += . ./details ./features ./xxport ../libkdepim ../microkde ../microkde/kdecore ../microkde/kutils ../microkde/kio/kfile ../microkde/kio/kio ../microkde/kdeui ../microkde/kresources ../kabc ../ interfaces
10DEFINES += KAB_EMBEDDED KAB_NOSPLITTER DESKTOP_VERSION 10DEFINES += KAB_EMBEDDED KAB_NOSPLITTER DESKTOP_VERSION
11 11
12unix : { 12unix : {
13 13
14staticlib: { 14staticlib: {
15 TARGET = kapi_linux 15 TARGET = kapi_linux
16LIBS += ../bin/libmicrokabc_qtopia.a 16LIBS += ../bin/libxmicrokabc_qtopia.a
17LIBS += ../bin/libmicrokabc_file.a 17LIBS += ../bin/libxmicrokabc_file.a
18LIBS += ../bin/libmicrokabc_dir.a 18LIBS += ../bin/libxmicrokabc_dir.a
19LIBS += ../bin/libmicrokdepim.a 19LIBS += ../bin/libxmicrokdepim.a
20LIBS += ../bin/libmicrokcal.a 20LIBS += ../bin/libxmicrokcal.a
21LIBS += ../bin/libmicrokabc.a 21LIBS += ../bin/libxmicrokabc.a
22LIBS += ../bin/libmicrokde.a 22LIBS += ../bin/libxmicrokde.a
23LIBS += ../bin/libmicrokabc_qtopia.a 23LIBS += ../bin/libxmicrokabc_qtopia.a
24LIBS += ../bin/libmicrokabc_file.a 24LIBS += ../bin/libxmicrokabc_file.a
25LIBS += ../bin/libmicrokabc_dir.a 25LIBS += ../bin/libxmicrokabc_dir.a
26LIBS += ../bin/libmicrokdepim.a 26LIBS += ../bin/libxmicrokdepim.a
27LIBS += ../bin/libmicrokcal.a 27LIBS += ../bin/libxmicrokcal.a
28LIBS += ../bin/libmicrokabc.a 28LIBS += ../bin/libxmicrokabc.a
29LIBS += ../bin/libmicrokde.a 29LIBS += ../bin/libxmicrokde.a
30LIBS += ../libical/lib/libical.a 30LIBS += ../libical/lib/libical.a
31LIBS += ../libical/lib/libicalss.a 31LIBS += ../libical/lib/libicalss.a
32 32
33} else { 33} else {
34LIBS += ../bin/libmicrokdepim.so 34LIBS += ../bin/libxmicrokdepim.so
35LIBS += ../bin/libmicrokde.so 35LIBS += ../bin/libxmicrokde.so
36LIBS += ../bin/libmicrokabc.so 36LIBS += ../bin/libxmicrokabc.so
37LIBS += ../bin/libmicrokcal.so 37LIBS += ../bin/libxmicrokcal.so
38#LIBS += -lldap 38#LIBS += -lldap
39} 39}
40OBJECTS_DIR = obj/unix 40OBJECTS_DIR = obj/unix
41MOC_DIR = moc/unix 41MOC_DIR = moc/unix
42} 42}
43win32: { 43win32: {
44RC_FILE = winicons.rc 44RC_FILE = winicons.rc
45DEFINES += _WIN32_ 45DEFINES += _WIN32_
46LIBS += ../bin/microkdepim.lib 46LIBS += ../bin/xmicrokdepim.lib
47LIBS += ../bin/microkcal.lib 47LIBS += ../bin/xmicrokcal.lib
48LIBS += ../bin/microkde.lib 48LIBS += ../bin/xmicrokde.lib
49LIBS += ../bin/microkabc.lib 49LIBS += ../bin/xmicrokabc.lib
50QMAKE_LINK += /NODEFAULTLIB:LIBC 50QMAKE_LINK += /NODEFAULTLIB:LIBC
51OBJECTS_DIR = obj/win 51OBJECTS_DIR = obj/win
52MOC_DIR = moc/win 52MOC_DIR = moc/win
53#olimport section 53#olimport section
54importol { 54importol {
55debug: { 55debug: {
56LIBS += mfc71ud.lib 56LIBS += mfc71ud.lib
57} 57}
58release: { 58release: {
59LIBS += mfc71u.lib 59LIBS += mfc71u.lib
60} 60}
61DEFINES += _OL_IMPORT_ 61DEFINES += _OL_IMPORT_
62HEADERS = ../outport/msoutl9.h \ 62HEADERS = ../outport/msoutl9.h \
63 kaimportoldialog.h 63 kaimportoldialog.h
64SOURCES = ../outport/msoutl9.cpp \ 64SOURCES = ../outport/msoutl9.cpp \
65 kaimportoldialog.cpp 65 kaimportoldialog.cpp
66#olimport section end 66#olimport section end
67 TARGET = kapi_xp 67 TARGET = kapi_xp
68} else { 68} else {
69 TARGET = kapi_me 69 TARGET = kapi_me
70} 70}
71} 71}
72 72
73INTERFACES = \ 73INTERFACES = \
74# filteredit_base.ui \ 74# filteredit_base.ui \
75# kofilterview_base.ui \ 75# kofilterview_base.ui \
76 76
77HEADERS += \ 77HEADERS += \
78features/mergewidget.h \ 78features/mergewidget.h \
79features/distributionlistwidget.h \ 79features/distributionlistwidget.h \
80kcmconfigs/addresseewidget.h \ 80kcmconfigs/addresseewidget.h \
81kcmconfigs/extensionconfigdialog.h \ 81kcmconfigs/extensionconfigdialog.h \
82kcmconfigs/kcmkabconfig.h \ 82kcmconfigs/kcmkabconfig.h \
83kcmconfigs/kabconfigwidget.h \ 83kcmconfigs/kabconfigwidget.h \
84addresseeeditordialog.h \ 84addresseeeditordialog.h \
85addresseeeditorwidget.h \ 85addresseeeditorwidget.h \
86addresseditwidget.h \ 86addresseditwidget.h \
87addresseeconfig.h \ 87addresseeconfig.h \
88addresseeutil.h \ 88addresseeutil.h \
89emaileditwidget.h \ 89emaileditwidget.h \
90filtereditdialog.h \ 90filtereditdialog.h \
91kaddressbookmain.h \ 91kaddressbookmain.h \
92kabprefs.h \ 92kabprefs.h \
93kabcore.h \ 93kabcore.h \
94viewmanager.h \ 94viewmanager.h \
95extensionmanager.h \ 95extensionmanager.h \
96extensionwidget.h \ 96extensionwidget.h \
97kaddressbookview.h \ 97kaddressbookview.h \
98geowidget.h \ 98geowidget.h \
99imagewidget.h \ 99imagewidget.h \
100incsearchwidget.h \ 100incsearchwidget.h \
101jumpbuttonbar.h \ 101jumpbuttonbar.h \
102phoneeditwidget.h \ 102phoneeditwidget.h \
103secrecywidget.h \ 103secrecywidget.h \
104keywidget.h \ 104keywidget.h \
105nameeditdialog.h \ 105nameeditdialog.h \
106filter.h \ 106filter.h \
107addviewdialog.h \ 107addviewdialog.h \
108configurewidget.h \ 108configurewidget.h \
109viewconfigurewidget.h \ 109viewconfigurewidget.h \
110viewconfigurefieldspage.h \ 110viewconfigurefieldspage.h \
111viewconfigurefilterpage.h \ 111viewconfigurefilterpage.h \
112typecombo.h \ 112typecombo.h \
113undo.h \ 113undo.h \
114undocmds.h \ 114undocmds.h \
115xxportmanager.h \ 115xxportmanager.h \
116xxportobject.h \ 116xxportobject.h \
117xxportselectdialog.h \ 117xxportselectdialog.h \
118details/detailsviewcontainer.h \ 118details/detailsviewcontainer.h \
119details/look_basic.h \ 119details/look_basic.h \
120details/look_html.h \ 120details/look_html.h \
121views/kaddressbookiconview.h \ 121views/kaddressbookiconview.h \
122views/kaddressbooktableview.h \ 122views/kaddressbooktableview.h \
123views/kaddressbookcardview.h \ 123views/kaddressbookcardview.h \
124views/configuretableviewdialog.h \ 124views/configuretableviewdialog.h \
125views/configurecardviewdialog.h \ 125views/configurecardviewdialog.h \
126views/cardview.h \ 126views/cardview.h \
127views/colorlistbox.h \ 127views/colorlistbox.h \
128views/contactlistview.h \ 128views/contactlistview.h \
129xxport/vcard_xxport.h \ 129xxport/vcard_xxport.h \
130xxport/kde2_xxport.h \ 130xxport/kde2_xxport.h \
131xxport/csv_xxport.h \ 131xxport/csv_xxport.h \
132xxport/csvimportdialog.h \ 132xxport/csvimportdialog.h \
133xxport/opie_xxport.h \ 133xxport/opie_xxport.h \
134xxport/qtopia_xxport.h \ 134xxport/qtopia_xxport.h \
135xxport/sharpdtm_xxport.h \ 135xxport/sharpdtm_xxport.h \
136#details/look_details.h \ 136#details/look_details.h \
137#mainwindoiw.h \ 137#mainwindoiw.h \
138# alarmclient.h \ 138# alarmclient.h \
139# calendarview.h \ 139# calendarview.h \
140# customlistviewitem.h \ 140# customlistviewitem.h \
141# datenavigator.h 141# datenavigator.h
142 142
143SOURCES += \ 143SOURCES += \
144addresseeeditordialog.cpp \ 144addresseeeditordialog.cpp \
145addresseeeditorwidget.cpp \ 145addresseeeditorwidget.cpp \
146addresseditwidget.cpp \ 146addresseditwidget.cpp \
147addresseeconfig.cpp \ 147addresseeconfig.cpp \
148addresseeutil.cpp \ 148addresseeutil.cpp \
149extensionmanager.cpp \ 149extensionmanager.cpp \
150features/mergewidget.cpp \ 150features/mergewidget.cpp \
151features/distributionlistwidget.cpp \ 151features/distributionlistwidget.cpp \
152kcmconfigs/addresseewidget.cpp \ 152kcmconfigs/addresseewidget.cpp \
153kcmconfigs/extensionconfigdialog.cpp \ 153kcmconfigs/extensionconfigdialog.cpp \
154kcmconfigs/kcmkabconfig.cpp \ 154kcmconfigs/kcmkabconfig.cpp \
155kcmconfigs/kabconfigwidget.cpp \ 155kcmconfigs/kabconfigwidget.cpp \
156emaileditwidget.cpp \ 156emaileditwidget.cpp \
157filtereditdialog.cpp \ 157filtereditdialog.cpp \
158mainembedded.cpp \ 158mainembedded.cpp \
159kaddressbookmain.cpp \ 159kaddressbookmain.cpp \
160kabcore.cpp \ 160kabcore.cpp \
161kabprefs.cpp \ 161kabprefs.cpp \
162viewmanager.cpp \ 162viewmanager.cpp \
163kaddressbookview.cpp \ 163kaddressbookview.cpp \
164extensionwidget.cpp \ 164extensionwidget.cpp \
165geowidget.cpp \ 165geowidget.cpp \
166imagewidget.cpp \ 166imagewidget.cpp \
167incsearchwidget.cpp \ 167incsearchwidget.cpp \
168jumpbuttonbar.cpp \ 168jumpbuttonbar.cpp \
169phoneeditwidget.cpp \ 169phoneeditwidget.cpp \
170secrecywidget.cpp \ 170secrecywidget.cpp \
171keywidget.cpp \ 171keywidget.cpp \
172nameeditdialog.cpp \ 172nameeditdialog.cpp \
173filter.cpp \ 173filter.cpp \
174addviewdialog.cpp \ 174addviewdialog.cpp \
175configurewidget.cpp \ 175configurewidget.cpp \
176viewconfigurewidget.cpp \ 176viewconfigurewidget.cpp \
177viewconfigurefieldspage.cpp \ 177viewconfigurefieldspage.cpp \
178viewconfigurefilterpage.cpp \ 178viewconfigurefilterpage.cpp \
179undo.cpp \ 179undo.cpp \
180undocmds.cpp \ 180undocmds.cpp \
181xxportmanager.cpp \ 181xxportmanager.cpp \
182xxportobject.cpp \ 182xxportobject.cpp \
183xxportselectdialog.cpp \ 183xxportselectdialog.cpp \
184details/detailsviewcontainer.cpp \ 184details/detailsviewcontainer.cpp \
185details/look_basic.cpp \ 185details/look_basic.cpp \
186details/look_html.cpp \ 186details/look_html.cpp \
187views/kaddressbookiconview.cpp \ 187views/kaddressbookiconview.cpp \
188views/kaddressbooktableview.cpp \ 188views/kaddressbooktableview.cpp \
189views/kaddressbookcardview.cpp \ 189views/kaddressbookcardview.cpp \
190views/configuretableviewdialog.cpp \ 190views/configuretableviewdialog.cpp \
191views/configurecardviewdialog.cpp \ 191views/configurecardviewdialog.cpp \
192views/cardview.cpp \ 192views/cardview.cpp \
193views/contactlistview.cpp \ 193views/contactlistview.cpp \
194views/colorlistbox.cpp \ 194views/colorlistbox.cpp \
195xxport/vcard_xxport.cpp \ 195xxport/vcard_xxport.cpp \
196xxport/kde2_xxport.cpp \ 196xxport/kde2_xxport.cpp \
197xxport/csv_xxport.cpp \ 197xxport/csv_xxport.cpp \
198xxport/csvimportdialog.cpp \ 198xxport/csvimportdialog.cpp \
199xxport/opie_xxport.cpp \ 199xxport/opie_xxport.cpp \
200xxport/qtopia_xxport.cpp \ 200xxport/qtopia_xxport.cpp \
201xxport/sharpdtm_xxport.cpp \ 201xxport/sharpdtm_xxport.cpp \
202#details/look_details.cpp \ 202#details/look_details.cpp \
203#mainwindow.cpp \ 203#mainwindow.cpp \
204# calendarview.cpp \ 204# calendarview.cpp \
205# timespanview.cpp 205# timespanview.cpp
206 206
207#The following line was inserted by qt3to4
208QT += xml qt3support
diff --git a/kaddressbook/kaddressbookE.pro b/kaddressbook/kaddressbookE.pro
index 64e3a4a..c4b2499 100644
--- a/kaddressbook/kaddressbookE.pro
+++ b/kaddressbook/kaddressbookE.pro
@@ -1,160 +1,160 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG += qt warn_on 2 CONFIG += qt warn_on
3 3
4 4
5 TARGET = kapi 5 TARGET = kapi
6OBJECTS_DIR = obj/$(PLATFORM) 6OBJECTS_DIR = obj/$(PLATFORM)
7MOC_DIR = moc/$(PLATFORM) 7MOC_DIR = moc/$(PLATFORM)
8DESTDIR=$(QPEDIR)/bin 8DESTDIR=$(QPEDIR)/bin
9 9
10INCLUDEPATH += . ./details ./features ./xxport ../libkdepim ../microkde ../microkde/kdecore ../microkde/kutils ../microkde/kio/kfile ../microkde/kio/kio ../microkde/kdeui ../microkde/kresources ../kabc ../qtcompat ../ interfaces $(QPEDIR)/include 10INCLUDEPATH += . ./details ./features ./xxport ../libkdepim ../microkde ../microkde/kdecore ../microkde/kutils ../microkde/kio/kfile ../microkde/kio/kio ../microkde/kdeui ../microkde/kresources ../kabc ../qtcompat ../ interfaces $(QPEDIR)/include
11DEFINES += KAB_EMBEDDED KAB_NOSPLITTER 11DEFINES += KAB_EMBEDDED KAB_NOSPLITTER
12#DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOKABC KORG_NOARCHIVE KORG_NOMAIL 12#DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOKABC KORG_NOARCHIVE KORG_NOMAIL
13#DEFINES += KORG_NOPRINTER KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER 13#DEFINES += KORG_NOPRINTER KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER
14#DEFINES += KORG_NOLVALTERNATION 14#DEFINES += KORG_NOLVALTERNATION
15LIBS += -lmicrokdepim 15LIBS += -lxmicrokdepim
16LIBS += -lmicrokde 16LIBS += -lxmicrokde
17LIBS += -lmicroqtcompat 17LIBS += -lmicroqtcompat
18LIBS += -lmicrokabc 18LIBS += -lxmicrokabc
19LIBS += -lqpe 19LIBS += -lqpe
20LIBS += -ljpeg 20LIBS += -ljpeg
21LIBS += $(QTOPIALIB) 21LIBS += $(QTOPIALIB)
22LIBS += -L$(QPEDIR)/lib 22LIBS += -L$(QPEDIR)/lib
23LIBS += -Wl,-export-dynamic 23LIBS += -Wl,-export-dynamic
24LIBS += $(GCC3EXTRALIB1) 24LIBS += $(GCC3EXTRALIB1)
25LIBS += $(GCC3EXTRALIB2) 25LIBS += $(GCC3EXTRALIB2)
26 26
27INTERFACES = \ 27INTERFACES = \
28# filteredit_base.ui \ 28# filteredit_base.ui \
29# kofilterview_base.ui \ 29# kofilterview_base.ui \
30 30
31HEADERS = \ 31HEADERS = \
32features/mergewidget.h \ 32features/mergewidget.h \
33features/distributionlistwidget.h \ 33features/distributionlistwidget.h \
34kcmconfigs/addresseewidget.h \ 34kcmconfigs/addresseewidget.h \
35kcmconfigs/extensionconfigdialog.h \ 35kcmconfigs/extensionconfigdialog.h \
36kcmconfigs/kcmkabconfig.h \ 36kcmconfigs/kcmkabconfig.h \
37kcmconfigs/kabconfigwidget.h \ 37kcmconfigs/kabconfigwidget.h \
38addresseeeditordialog.h \ 38addresseeeditordialog.h \
39addresseeeditorwidget.h \ 39addresseeeditorwidget.h \
40addresseditwidget.h \ 40addresseditwidget.h \
41addresseeconfig.h \ 41addresseeconfig.h \
42addresseeutil.h \ 42addresseeutil.h \
43emaileditwidget.h \ 43emaileditwidget.h \
44filtereditdialog.h \ 44filtereditdialog.h \
45kaddressbookmain.h \ 45kaddressbookmain.h \
46kabprefs.h \ 46kabprefs.h \
47kabcore.h \ 47kabcore.h \
48viewmanager.h \ 48viewmanager.h \
49extensionmanager.h \ 49extensionmanager.h \
50extensionwidget.h \ 50extensionwidget.h \
51kaddressbookview.h \ 51kaddressbookview.h \
52geowidget.h \ 52geowidget.h \
53imagewidget.h \ 53imagewidget.h \
54incsearchwidget.h \ 54incsearchwidget.h \
55jumpbuttonbar.h \ 55jumpbuttonbar.h \
56phoneeditwidget.h \ 56phoneeditwidget.h \
57secrecywidget.h \ 57secrecywidget.h \
58keywidget.h \ 58keywidget.h \
59nameeditdialog.h \ 59nameeditdialog.h \
60filter.h \ 60filter.h \
61addviewdialog.h \ 61addviewdialog.h \
62configurewidget.h \ 62configurewidget.h \
63viewconfigurewidget.h \ 63viewconfigurewidget.h \
64viewconfigurefieldspage.h \ 64viewconfigurefieldspage.h \
65viewconfigurefilterpage.h \ 65viewconfigurefilterpage.h \
66typecombo.h \ 66typecombo.h \
67undo.h \ 67undo.h \
68undocmds.h \ 68undocmds.h \
69xxportmanager.h \ 69xxportmanager.h \
70xxportobject.h \ 70xxportobject.h \
71xxportselectdialog.h \ 71xxportselectdialog.h \
72details/detailsviewcontainer.h \ 72details/detailsviewcontainer.h \
73details/look_basic.h \ 73details/look_basic.h \
74details/look_html.h \ 74details/look_html.h \
75views/kaddressbookiconview.h \ 75views/kaddressbookiconview.h \
76views/kaddressbooktableview.h \ 76views/kaddressbooktableview.h \
77views/kaddressbookcardview.h \ 77views/kaddressbookcardview.h \
78views/configuretableviewdialog.h \ 78views/configuretableviewdialog.h \
79views/configurecardviewdialog.h \ 79views/configurecardviewdialog.h \
80views/cardview.h \ 80views/cardview.h \
81views/colorlistbox.h \ 81views/colorlistbox.h \
82views/contactlistview.h \ 82views/contactlistview.h \
83xxport/vcard_xxport.h \ 83xxport/vcard_xxport.h \
84xxport/kde2_xxport.h \ 84xxport/kde2_xxport.h \
85xxport/csv_xxport.h \ 85xxport/csv_xxport.h \
86xxport/csvimportdialog.h \ 86xxport/csvimportdialog.h \
87xxport/opie_xxport.h \ 87xxport/opie_xxport.h \
88xxport/qtopia_xxport.h \ 88xxport/qtopia_xxport.h \
89xxport/sharpdtm_xxport.h \ 89xxport/sharpdtm_xxport.h \
90#details/look_details.h \ 90#details/look_details.h \
91#mainwindoiw.h \ 91#mainwindoiw.h \
92# alarmclient.h \ 92# alarmclient.h \
93# calendarview.h \ 93# calendarview.h \
94# customlistviewitem.h \ 94# customlistviewitem.h \
95# datenavigator.h 95# datenavigator.h
96 96
97SOURCES = \ 97SOURCES = \
98addresseeeditordialog.cpp \ 98addresseeeditordialog.cpp \
99addresseeeditorwidget.cpp \ 99addresseeeditorwidget.cpp \
100addresseditwidget.cpp \ 100addresseditwidget.cpp \
101addresseeconfig.cpp \ 101addresseeconfig.cpp \
102addresseeutil.cpp \ 102addresseeutil.cpp \
103extensionmanager.cpp \ 103extensionmanager.cpp \
104features/mergewidget.cpp \ 104features/mergewidget.cpp \
105features/distributionlistwidget.cpp \ 105features/distributionlistwidget.cpp \
106kcmconfigs/addresseewidget.cpp \ 106kcmconfigs/addresseewidget.cpp \
107kcmconfigs/extensionconfigdialog.cpp \ 107kcmconfigs/extensionconfigdialog.cpp \
108kcmconfigs/kcmkabconfig.cpp \ 108kcmconfigs/kcmkabconfig.cpp \
109kcmconfigs/kabconfigwidget.cpp \ 109kcmconfigs/kabconfigwidget.cpp \
110emaileditwidget.cpp \ 110emaileditwidget.cpp \
111filtereditdialog.cpp \ 111filtereditdialog.cpp \
112mainembedded.cpp \ 112mainembedded.cpp \
113kaddressbookmain.cpp \ 113kaddressbookmain.cpp \
114kabcore.cpp \ 114kabcore.cpp \
115kabprefs.cpp \ 115kabprefs.cpp \
116viewmanager.cpp \ 116viewmanager.cpp \
117kaddressbookview.cpp \ 117kaddressbookview.cpp \
118extensionwidget.cpp \ 118extensionwidget.cpp \
119geowidget.cpp \ 119geowidget.cpp \
120imagewidget.cpp \ 120imagewidget.cpp \
121incsearchwidget.cpp \ 121incsearchwidget.cpp \
122jumpbuttonbar.cpp \ 122jumpbuttonbar.cpp \
123phoneeditwidget.cpp \ 123phoneeditwidget.cpp \
124secrecywidget.cpp \ 124secrecywidget.cpp \
125keywidget.cpp \ 125keywidget.cpp \
126nameeditdialog.cpp \ 126nameeditdialog.cpp \
127filter.cpp \ 127filter.cpp \
128addviewdialog.cpp \ 128addviewdialog.cpp \
129configurewidget.cpp \ 129configurewidget.cpp \
130viewconfigurewidget.cpp \ 130viewconfigurewidget.cpp \
131viewconfigurefieldspage.cpp \ 131viewconfigurefieldspage.cpp \
132viewconfigurefilterpage.cpp \ 132viewconfigurefilterpage.cpp \
133undo.cpp \ 133undo.cpp \
134undocmds.cpp \ 134undocmds.cpp \
135xxportmanager.cpp \ 135xxportmanager.cpp \
136xxportobject.cpp \ 136xxportobject.cpp \
137xxportselectdialog.cpp \ 137xxportselectdialog.cpp \
138details/detailsviewcontainer.cpp \ 138details/detailsviewcontainer.cpp \
139details/look_basic.cpp \ 139details/look_basic.cpp \
140details/look_html.cpp \ 140details/look_html.cpp \
141views/kaddressbookiconview.cpp \ 141views/kaddressbookiconview.cpp \
142views/kaddressbooktableview.cpp \ 142views/kaddressbooktableview.cpp \
143views/kaddressbookcardview.cpp \ 143views/kaddressbookcardview.cpp \
144views/configuretableviewdialog.cpp \ 144views/configuretableviewdialog.cpp \
145views/configurecardviewdialog.cpp \ 145views/configurecardviewdialog.cpp \
146views/cardview.cpp \ 146views/cardview.cpp \
147views/contactlistview.cpp \ 147views/contactlistview.cpp \
148views/colorlistbox.cpp \ 148views/colorlistbox.cpp \
149xxport/vcard_xxport.cpp \ 149xxport/vcard_xxport.cpp \
150xxport/kde2_xxport.cpp \ 150xxport/kde2_xxport.cpp \
151xxport/csv_xxport.cpp \ 151xxport/csv_xxport.cpp \
152xxport/csvimportdialog.cpp \ 152xxport/csvimportdialog.cpp \
153xxport/opie_xxport.cpp \ 153xxport/opie_xxport.cpp \
154xxport/qtopia_xxport.cpp \ 154xxport/qtopia_xxport.cpp \
155xxport/sharpdtm_xxport.cpp \ 155xxport/sharpdtm_xxport.cpp \
156#details/look_details.cpp \ 156#details/look_details.cpp \
157#mainwindow.cpp \ 157#mainwindow.cpp \
158# calendarview.cpp \ 158# calendarview.cpp \
159# timespanview.cpp 159# timespanview.cpp
160 160
diff --git a/kaddressbook/kaddressbookmain.cpp b/kaddressbook/kaddressbookmain.cpp
index c417226..b317974 100644
--- a/kaddressbook/kaddressbookmain.cpp
+++ b/kaddressbook/kaddressbookmain.cpp
@@ -1,241 +1,243 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 1999 Don Sanders <dsanders@kde.org> 3 Copyright (c) 1999 Don Sanders <dsanders@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#ifdef KAB_EMBEDDED 24#ifdef KAB_EMBEDDED
25#include "kabprefs.h" 25#include "kabprefs.h"
26#include <kglobal.h> 26#include <kglobal.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28#include <qtoolbar.h> 28#include <q3toolbar.h>
29#include <qapplication.h> 29#include <qapplication.h>
30//Added by qt3to4:
31#include <Q3CString>
32#include <QCloseEvent>
30#else //KAB_EMBEDDED 33#else //KAB_EMBEDDED
31#include <kedittoolbar.h> 34#include <kedittoolbar.h>
32#include <kkeydialog.h> 35#include <kkeydialog.h>
33#include <kmessagebox.h> 36#include <kmessagebox.h>
34#include <kstatusbar.h> 37#include <kstatusbar.h>
35#endif //KAB_EMBEDDED 38#endif //KAB_EMBEDDED
36#include <klocale.h> 39#include <klocale.h>
37 40
38#include "kabcore.h" 41#include "kabcore.h"
39#include "kaddressbookmain.h" 42#include "kaddressbookmain.h"
40#include "kactioncollection.h" 43#include "kactioncollection.h"
41 44
42#ifdef KAB_EMBEDDED 45#ifdef KAB_EMBEDDED
43KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "abmain" ) 46KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "abmain" )
44#else //KAB_EMBEDDED 47#else //KAB_EMBEDDED
45//MOC_SKIP_BEGIN 48#ifndef Q_MOC_RUN
46KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 ) 49KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 )
47//MOC_SKIP_END 50#endif
48#endif //KAB_EMBEDDED 51#endif //KAB_EMBEDDED
49{ 52{
50 setIcon(SmallIcon( "ka24" ) ); 53 setIcon(SmallIcon( "ka24" ) );
51#if 0 54#if 0
52 //US for embedded systems, create the toolbar before we initiate KABCore. 55 //US for embedded systems, create the toolbar before we initiate KABCore.
53 // KABCore will fill the toolbar with menues and icons 56 // KABCore will fill the toolbar with menues and icons
54 QMainWindow::ToolBarDock tbd; 57 Qt::ToolBarDock tbd;
55 tbd = Top; 58 tbd = Qt::DockTop;
56 iconToolBar = new QToolBar( this ); 59 iconToolBar = new Q3ToolBar( this );
57 addToolBar (iconToolBar , tbd ); 60 addToolBar (iconToolBar , tbd );
58 iconToolBar->setHorizontalStretchable(true); 61 iconToolBar->setHorizontalStretchable(true);
59//US iconToolBar->setWidth(300); 62//US iconToolBar->setWidth(300);
60#endif // 0 63#endif // 0
61 64
62 mCore = new KABCore( this, true, this ); 65 mCore = new KABCore( this, true, this );
63 66
64#ifdef KAB_EMBEDDED 67#ifdef KAB_EMBEDDED
65 setCaption( i18n( "KAddressbook/Pi" ) ); 68 setCaption( i18n( "KAddressbook/Pi" ) );
66#else //KAB_EMBEDDED 69#else //KAB_EMBEDDED
67 setCaption( i18n( "Address Book Browser" ) ); 70 setCaption( i18n( "Address Book Browser" ) );
68#endif //KAB_EMBEDDED 71#endif //KAB_EMBEDDED
69 72
70 //mCore->restoreSettings(); 73 //mCore->restoreSettings();
71 74
72 initActions(); 75 initActions();
73 76
74 setCentralWidget( mCore ); 77 setCentralWidget( mCore );
75 78
76//US statusBar()->show(); 79//US statusBar()->show();
77 80
78#ifndef KAB_EMBEDDED 81#ifndef KAB_EMBEDDED
79 setStandardToolBarMenuEnabled(true); 82 setStandardToolBarMenuEnabled(true);
80 83
81 createGUI( "kaddressbookui.rc", false ); 84 createGUI( "kaddressbookui.rc", false );
82 85
83 86
84#endif //KAB_EMBEDDED 87#endif //KAB_EMBEDDED
85 setAutoSaveSettings(); 88 setAutoSaveSettings();
86 mCore->restoreSettings(); 89 mCore->restoreSettings();
87#ifndef DESKTOP_VERSION 90#ifndef DESKTOP_VERSION
88 QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), mCore, SLOT (receiveStart ( const QCString &, const QByteArray & ))); 91 QObject::connect(qApp, SIGNAL (appMessage ( const Q3CString &, const QByteArray & )), mCore, SLOT (receiveStart ( const Q3CString &, const QByteArray & )));
89#endif 92#endif
90} 93}
91 94
92KAddressBookMain::~KAddressBookMain() 95KAddressBookMain::~KAddressBookMain()
93{ 96{
94 // mCore->saveSettings(); 97 // mCore->saveSettings();
95} 98}
96 99
97void KAddressBookMain::showMinimized () 100void KAddressBookMain::showMinimized ()
98{ 101{
99 QWidget::showMinimized () ; 102 QWidget::showMinimized () ;
100} 103}
101void KAddressBookMain::addEmail( QString addr ) 104void KAddressBookMain::addEmail( QString addr )
102{ 105{
103 mCore->addEmail( addr ); 106 mCore->addEmail( addr );
104} 107}
105 108
106#ifndef KAB_EMBEDDED 109#ifndef KAB_EMBEDDED
107ASYNC KAddressBookMain::showContactEditor( QString uid ) 110ASYNC KAddressBookMain::showContactEditor( QString uid )
108{ 111{
109 mCore->editContact( uid ); 112 mCore->editContact( uid );
110} 113}
111#endif //KAB_EMBEDDED 114#endif //KAB_EMBEDDED
112void KAddressBookMain::newContact() 115void KAddressBookMain::newContact()
113{ 116{
114 mCore->newContact(); 117 mCore->newContact();
115} 118}
116 119
117QString KAddressBookMain::getNameByPhone( QString phone ) 120QString KAddressBookMain::getNameByPhone( QString phone )
118{ 121{
119 return mCore->getNameByPhone( phone ); 122 return mCore->getNameByPhone( phone );
120} 123}
121 124
122void KAddressBookMain::save() 125void KAddressBookMain::save()
123{ 126{
124 mCore->save(); 127 mCore->save();
125} 128}
126 129
127void KAddressBookMain::exit() 130void KAddressBookMain::exit()
128{ 131{
129 close( ); 132 close( );
130} 133}
131 134
132void KAddressBookMain::saveProperties( KConfig* ) 135void KAddressBookMain::saveProperties( KConfig* )
133{ 136{
134} 137}
135 138
136void KAddressBookMain::readProperties( KConfig* ) 139void KAddressBookMain::readProperties( KConfig* )
137{ 140{
138} 141}
139 142
140void KAddressBookMain::initActions() 143void KAddressBookMain::initActions()
141{ 144{
142#ifndef KAB_EMBEDDED 145#ifndef KAB_EMBEDDED
143 KStdAction::quit( this, SLOT( close() ), actionCollection() ); 146 KStdAction::quit( this, SLOT( close() ), actionCollection() );
144 KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() ); 147 KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() );
145#else //KAB_EMBEDDED 148#else //KAB_EMBEDDED
146 //US: transfered the setup of the actions into KABCore 149 //US: transfered the setup of the actions into KABCore
147#endif //KAB_EMBEDDED 150#endif //KAB_EMBEDDED
148 151
149 152
150} 153}
151 154
152//US new method to setup menues and toolbars on embedded systems 155//US new method to setup menues and toolbars on embedded systems
153#ifdef KAB_EMBEDDED 156#ifdef KAB_EMBEDDED
154/* 157/*
155QToolBar * KAddressBookMain::getIconToolBar() 158QToolBar * KAddressBookMain::getIconToolBar()
156{ 159{
157 return iconToolBar; 160 return iconToolBar;
158} 161}
159*/ 162*/
160 163
161void KAddressBookMain::createGUI() 164void KAddressBookMain::createGUI()
162{ 165{
163 166
164 167
165 168
166} 169}
167#endif //KAB_EMBEDDED 170#endif //KAB_EMBEDDED
168 171
169void KAddressBookMain::configureToolbars() 172void KAddressBookMain::configureToolbars()
170{ 173{
171#ifndef KAB_EMBEDDED 174#ifndef KAB_EMBEDDED
172 saveMainWindowSettings( KGlobal::config(), "MainWindow" ); 175 saveMainWindowSettings( KGlobal::config(), "MainWindow" );
173 176
174 KEditToolbar dlg( factory() ); 177 KEditToolbar dlg( factory() );
175 connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) ); 178 connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) );
176 179
177 dlg.exec(); 180 dlg.exec();
178#else //KAB_EMBEDDED 181#else //KAB_EMBEDDED
179 qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" ); 182 qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" );
180#endif //KAB_EMBEDDED 183#endif //KAB_EMBEDDED
181} 184}
182 185
183void KAddressBookMain::slotNewToolbarConfig() 186void KAddressBookMain::slotNewToolbarConfig()
184{ 187{
185#ifndef KAB_EMBEDDED 188#ifndef KAB_EMBEDDED
186 applyMainWindowSettings( KGlobal::config(), "MainWindow" ); 189 applyMainWindowSettings( KGlobal::config(), "MainWindow" );
187#else //KAB_EMBEDDED 190#else //KAB_EMBEDDED
188 qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" ); 191 qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" );
189#endif //KAB_EMBEDDED 192#endif //KAB_EMBEDDED
190} 193}
191 194
192void KAddressBookMain::configureKeys() 195void KAddressBookMain::configureKeys()
193{ 196{
194#ifndef KAB_EMBEDDED 197#ifndef KAB_EMBEDDED
195 KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this ); 198 KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this );
196#else //KAB_EMBEDDED 199#else //KAB_EMBEDDED
197 qDebug("KAddressBookMain::configureKeys() not implemented by ulf" ); 200 qDebug("KAddressBookMain::configureKeys() not implemented by ulf" );
198#endif //KAB_EMBEDDED 201#endif //KAB_EMBEDDED
199} 202}
200 203
201void KAddressBookMain::closeEvent( QCloseEvent* ce ) 204void KAddressBookMain::closeEvent( QCloseEvent* ce )
202{ 205{
203 bool mModified = mCore->modified(); 206 bool mModified = mCore->modified();
204 bool mAskForQuit = KABPrefs::instance()->mAskForQuit; 207 bool mAskForQuit = KABPrefs::instance()->mAskForQuit;
205 208
206 QString mess = i18n( "Close KA/Pi?"); 209 QString mess = i18n( "Close KA/Pi?");
207 if ( mModified == true ) 210 if ( mModified == true )
208 mess += i18n( "\nChanges will be saved!"); 211 mess += i18n( "\nChanges will be saved!");
209 else 212 else
210 mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!"); 213 mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!");
211 214
212 bool mQuit = true; 215 bool mQuit = true;
213 216
214 217
215 if (mAskForQuit) 218 if (mAskForQuit)
216 { 219 {
217 220
218 int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 ); 221 int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 );
219 if (res == 0) 222 if (res == 0)
220 mQuit = true; 223 mQuit = true;
221 else 224 else
222 mQuit = false; 225 mQuit = false;
223 } 226 }
224 227
225 if (mQuit == false) 228 if (mQuit == false)
226 return; 229 return;
227 230
228 if (mModified == true) 231 if (mModified == true)
229 { 232 {
230 save(); 233 save();
231 mCore->saveSettings(); 234 mCore->saveSettings();
232 //KABPrefs::instance()->writeConfig(); 235 //KABPrefs::instance()->writeConfig();
233 } 236 }
234 237
235 ce->accept(); 238 ce->accept();
236} 239}
237 240
238#ifndef KAB_EMBEDDED 241#ifndef KAB_EMBEDDED_
239#include "kaddressbookmain.moc" 242#include "moc_kaddressbookmain.cpp"
240#endif //KAB_EMBEDDED 243#endif //KAB_EMBEDDED
241
diff --git a/kaddressbook/kaddressbookmain.h b/kaddressbook/kaddressbookmain.h
index b6d9b4b..d3f5cc7 100644
--- a/kaddressbook/kaddressbookmain.h
+++ b/kaddressbook/kaddressbookmain.h
@@ -1,121 +1,123 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 1999 Don Sanders <dsanders@kde.org> 3 Copyright (c) 1999 Don Sanders <dsanders@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#ifndef KADDRESSBOOKMAIN_H 24#ifndef KADDRESSBOOKMAIN_H
25#define KADDRESSBOOKMAIN_H 25#define KADDRESSBOOKMAIN_H
26 26
27#include <qptrlist.h> 27#include <q3ptrlist.h>
28//Added by qt3to4:
29#include <QCloseEvent>
28 30
29#ifdef KAB_EMBEDDED 31#ifdef KAB_EMBEDDED
30class QToolBar; 32class Q3ToolBar;
31#include <qaction.h> 33#include <qaction.h>
32//#include <qmainwindow.h> 34//#include <qmainwindow.h>
33#include <kmainwindow.h> 35#include <kmainwindow.h>
34#else //KAB_EMBEDDED 36#else //KAB_EMBEDDED
35#include <kaction.h> 37#include <kaction.h>
36#include <kapplication.h> 38#include <kapplication.h>
37#include <kmainwindow.h> 39#include <kmainwindow.h>
38#include "kaddressbookiface.h" 40#include "kaddressbookiface.h"
39#endif //KAB_EMBEDDED 41#endif //KAB_EMBEDDED
40 42
41class KABCore; 43class KABCore;
42class KConfig; 44class KConfig;
43 45
44/** 46/**
45 This class serves as the main window for KAddressBook. It handles the 47 This class serves as the main window for KAddressBook. It handles the
46 menus, toolbars, and status bars. 48 menus, toolbars, and status bars.
47 49
48 @short Main window class 50 @short Main window class
49 @author Don Sanders <dsanders@kde.org> 51 @author Don Sanders <dsanders@kde.org>
50 @version 0.1 52 @version 0.1
51 */ 53 */
52#ifdef KAB_EMBEDDED 54#ifdef KAB_EMBEDDED
53class KAddressBookMain : public KMainWindow 55class KAddressBookMain : public KMainWindow
54#else //KAB_EMBEDDED 56#else //KAB_EMBEDDED
55//MOC_SKIP_BEGIN 57#ifndef Q_MOC_RUN
56class KAddressBookMain : public KMainWindow, virtual public KAddressBookIface 58class KAddressBookMain : public KMainWindow, virtual public KAddressBookIface
57//MOC_SKIP_END 59#endif
58#endif //KAB_EMBEDDED 60#endif //KAB_EMBEDDED
59{ 61{
60 Q_OBJECT 62 Q_OBJECT
61 63
62 public: 64 public:
63 KAddressBookMain(); 65 KAddressBookMain();
64 virtual ~KAddressBookMain(); 66 virtual ~KAddressBookMain();
65 67
66#ifdef KAB_EMBEDDED 68#ifdef KAB_EMBEDDED
67// QPEToolBar * getIconToolBar(); 69// QPEToolBar * getIconToolBar();
68 // QToolBar * getIconToolBar(); 70 // QToolBar * getIconToolBar();
69#endif //KAB_EMBEDDED 71#endif //KAB_EMBEDDED
70 72
71 73
72 public slots: 74 public slots:
73 void showMinimized () ; 75 void showMinimized () ;
74 virtual void addEmail( QString addr ); 76 virtual void addEmail( QString addr );
75#ifndef KAB_EMBEDDED 77#ifndef KAB_EMBEDDED
76//MOC_SKIP_BEGIN 78#ifndef Q_MOC_RUN
77 virtual ASYNC showContactEditor( QString uid ); 79 virtual ASYNC showContactEditor( QString uid );
78//MOC_SKIP_END 80#endif
79#endif //KAB_EMBEDDED 81#endif //KAB_EMBEDDED
80 virtual void newContact(); 82 virtual void newContact();
81 virtual QString getNameByPhone( QString phone ); 83 virtual QString getNameByPhone( QString phone );
82 virtual void save(); 84 virtual void save();
83 virtual void exit(); 85 virtual void exit();
84 protected: 86 protected:
85 void initActions(); 87 void initActions();
86#ifdef KAB_EMBEDDED 88#ifdef KAB_EMBEDDED
87 //US new method to setup menues and toolbars on embedded systems 89 //US new method to setup menues and toolbars on embedded systems
88 void createGUI(); 90 void createGUI();
89#endif //KAB_EMBEDDED 91#endif //KAB_EMBEDDED
90 92
91 /** 93 /**
92 This function is called when it is time for the app to save its 94 This function is called when it is time for the app to save its
93 properties for session management purposes. 95 properties for session management purposes.
94 */ 96 */
95 void saveProperties( KConfig* ); 97 void saveProperties( KConfig* );
96 98
97 /** 99 /**
98 This function is called when this app is restored. The KConfig 100 This function is called when this app is restored. The KConfig
99 object points to the session management config file that was saved 101 object points to the session management config file that was saved
100 with @ref saveProperties 102 with @ref saveProperties
101 */ 103 */
102 void readProperties( KConfig* ); 104 void readProperties( KConfig* );
103 105
104 void closeEvent( QCloseEvent* ce ); 106 void closeEvent( QCloseEvent* ce );
105 107
106 protected slots: 108 protected slots:
107 void configureToolbars(); 109 void configureToolbars();
108 void configureKeys(); 110 void configureKeys();
109 111
110 void slotNewToolbarConfig(); 112 void slotNewToolbarConfig();
111 113
112 private: 114 private:
113 KABCore *mCore; 115 KABCore *mCore;
114 116
115#ifdef KAB_EMBEDDED 117#ifdef KAB_EMBEDDED
116 // QToolBar *iconToolBar; 118 // QToolBar *iconToolBar;
117#endif //KAB_EMBEDDED 119#endif //KAB_EMBEDDED
118 120
119}; 121};
120 122
121#endif 123#endif
diff --git a/kaddressbook/kaddressbookview.cpp b/kaddressbook/kaddressbookview.cpp
index 86898e2..4823b37 100644
--- a/kaddressbook/kaddressbookview.cpp
+++ b/kaddressbook/kaddressbookview.cpp
@@ -1,188 +1,190 @@
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 KAB_EMBEDDED 24#ifndef KAB_EMBEDDED
25#include <qapplication.h> 25#include <qapplication.h>
26 26
27#include <kabc/distributionlistdialog.h> 27#include <kabc/distributionlistdialog.h>
28#include <kconfig.h> 28#include <kconfig.h>
29#include <klocale.h> 29#include <klocale.h>
30 30
31#include "viewmanager.h" 31#include "viewmanager.h"
32 32
33#endif //KAB_EMBEDDED 33#endif //KAB_EMBEDDED
34#include <qlayout.h> 34#include <qlayout.h>
35//Added by qt3to4:
36#include <Q3VBoxLayout>
35 37
36#include <kabc/distributionlistdialog.h> 38#include <kabc/distributionlistdialog.h>
37#include <kabc/addressbook.h> 39#include <kabc/addressbook.h>
38#include <kdebug.h> 40#include <kdebug.h>
39 41
40#include "kaddressbookview.h" 42#include "kaddressbookview.h"
41 43
42KAddressBookView::KAddressBookView( KABC::AddressBook *ab, QWidget *parent, 44KAddressBookView::KAddressBookView( KABC::AddressBook *ab, QWidget *parent,
43 const char *name ) 45 const char *name )
44 : QWidget( parent, name ), mAddressBook( ab ), mFieldList() 46 : QWidget( parent, name ), mAddressBook( ab ), mFieldList()
45{ 47{
46 48
47 initGUI(); 49 initGUI();
48} 50}
49 51
50KAddressBookView::~KAddressBookView() 52KAddressBookView::~KAddressBookView()
51{ 53{
52 54
53} 55}
54 56
55QRegExp KAddressBookView::getRegExp( const QString s ) 57QRegExp KAddressBookView::getRegExp( const QString s )
56{ 58{
57 QRegExp re; 59 QRegExp re;
58 60
59 if ( s.length() == 3 && s.mid(1,1) == "-" ) { 61 if ( s.length() == 3 && s.mid(1,1) == "-" ) {
60 QString pattern = "^[" + s.lower() +"]"; 62 QString pattern = "^[" + s.lower() +"]";
61 re.setCaseSensitive(false); 63 re.setCaseSensitive(false);
62 re.setPattern( pattern ); 64 re.setPattern( pattern );
63 } else { 65 } else {
64 QString pattern = s.lower()+"*"; 66 QString pattern = s.lower()+"*";
65 re.setWildcard(true); // most people understand these better. 67 re.setWildcard(true); // most people understand these better.
66 re.setCaseSensitive(false); 68 re.setCaseSensitive(false);
67 re.setPattern( pattern ); 69 re.setPattern( pattern );
68 } 70 }
69 return re; 71 return re;
70} 72}
71 73
72void KAddressBookView::readConfig( KConfig *config ) 74void KAddressBookView::readConfig( KConfig *config )
73{ 75{
74 mFieldList = KABC::Field::restoreFields( config, "KABCFields" ); 76 mFieldList = KABC::Field::restoreFields( config, "KABCFields" );
75 77
76 if ( mFieldList.isEmpty() ) 78 if ( mFieldList.isEmpty() )
77 mFieldList = KABC::Field::defaultFields(); 79 mFieldList = KABC::Field::defaultFields();
78 80
79 mDefaultFilterType = (DefaultFilterType)config->readNumEntry( "DefaultFilterType", 1 ); 81 mDefaultFilterType = (DefaultFilterType)config->readNumEntry( "DefaultFilterType", 1 );
80 mDefaultFilterName = config->readEntry( "DefaultFilterName", QString::null ); 82 mDefaultFilterName = config->readEntry( "DefaultFilterName", QString::null );
81} 83}
82 84
83void KAddressBookView::writeConfig( KConfig* ) 85void KAddressBookView::writeConfig( KConfig* )
84{ 86{
85 // Most of writing the config is handled by the ConfigureViewDialog 87 // Most of writing the config is handled by the ConfigureViewDialog
86} 88}
87 89
88QString KAddressBookView::selectedEmails() 90QString KAddressBookView::selectedEmails()
89{ 91{
90 bool first = true; 92 bool first = true;
91 QString emailAddrs; 93 QString emailAddrs;
92 QStringList uidList = selectedUids(); 94 QStringList uidList = selectedUids();
93 KABC::Addressee addr; 95 KABC::Addressee addr;
94 QString email; 96 QString email;
95 97
96 QStringList::Iterator it; 98 QStringList::Iterator it;
97 for ( it = uidList.begin(); it != uidList.end(); ++it ) { 99 for ( it = uidList.begin(); it != uidList.end(); ++it ) {
98 addr = mAddressBook->findByUid( *it ); 100 addr = mAddressBook->findByUid( *it );
99 101
100 if ( !addr.isEmpty() ) { 102 if ( !addr.isEmpty() ) {
101 QString m = QString::null; 103 QString m = QString::null;
102 104
103 if ( addr.emails().count() > 1 ) 105 if ( addr.emails().count() > 1 )
104 m = KABC::EmailSelector::getEmail( addr.emails(), addr.preferredEmail(), this ); 106 m = KABC::EmailSelector::getEmail( addr.emails(), addr.preferredEmail(), this );
105 107
106 email = addr.fullEmail( m ); 108 email = addr.fullEmail( m );
107 109
108 if ( !first ) 110 if ( !first )
109 emailAddrs += ", "; 111 emailAddrs += ", ";
110 else 112 else
111 first = false; 113 first = false;
112 114
113 emailAddrs += email; 115 emailAddrs += email;
114 } 116 }
115 } 117 }
116 118
117 return emailAddrs; 119 return emailAddrs;
118} 120}
119 121
120KABC::Addressee::List KAddressBookView::addressees() 122KABC::Addressee::List KAddressBookView::addressees()
121{ 123{
122 KABC::Addressee::List addresseeList; 124 KABC::Addressee::List addresseeList;
123 125
124 KABC::AddressBook::Iterator it; 126 KABC::AddressBook::Iterator it;
125 for (it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 127 for (it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
126 if ( mFilter.filterAddressee( *it ) ) 128 if ( mFilter.filterAddressee( *it ) )
127 addresseeList.append( *it ); 129 addresseeList.append( *it );
128 } 130 }
129 131
130 return addresseeList; 132 return addresseeList;
131} 133}
132 134
133void KAddressBookView::initGUI() 135void KAddressBookView::initGUI()
134{ 136{
135 // Create the layout 137 // Create the layout
136 QVBoxLayout *layout = new QVBoxLayout( this ); 138 Q3VBoxLayout *layout = new Q3VBoxLayout( this );
137 139
138 // Add the view widget 140 // Add the view widget
139 mViewWidget = new QWidget( this ); 141 mViewWidget = new QWidget( this );
140 layout->addWidget( mViewWidget ); 142 layout->addWidget( mViewWidget );
141} 143}
142 144
143KABC::Field::List KAddressBookView::fields() const 145KABC::Field::List KAddressBookView::fields() const
144{ 146{
145 return mFieldList; 147 return mFieldList;
146} 148}
147KABC::Field::List KAddressBookView::allFields() const 149KABC::Field::List KAddressBookView::allFields() const
148{ 150{
149 return KABC::Field::allFields(); 151 return KABC::Field::allFields();
150} 152}
151 153
152void KAddressBookView::setFilter( const Filter &filter ) 154void KAddressBookView::setFilter( const Filter &filter )
153{ 155{
154 mFilter = filter; 156 mFilter = filter;
155} 157}
156 158
157KAddressBookView::DefaultFilterType KAddressBookView::defaultFilterType() const 159KAddressBookView::DefaultFilterType KAddressBookView::defaultFilterType() const
158{ 160{
159 return mDefaultFilterType; 161 return mDefaultFilterType;
160} 162}
161 163
162const QString &KAddressBookView::defaultFilterName() const 164const QString &KAddressBookView::defaultFilterName() const
163{ 165{
164 return mDefaultFilterName; 166 return mDefaultFilterName;
165} 167}
166 168
167KABC::AddressBook *KAddressBookView::addressBook() const 169KABC::AddressBook *KAddressBookView::addressBook() const
168{ 170{
169 return mAddressBook; 171 return mAddressBook;
170} 172}
171 173
172QWidget *KAddressBookView::viewWidget() 174QWidget *KAddressBookView::viewWidget()
173{ 175{
174 return mViewWidget; 176 return mViewWidget;
175} 177}
176 178
177ViewConfigureWidget *ViewFactory::configureWidget( KABC::AddressBook *ab, 179ViewConfigureWidget *ViewFactory::configureWidget( KABC::AddressBook *ab,
178 QWidget *parent, 180 QWidget *parent,
179 const char *name ) 181 const char *name )
180{ 182{
181 return new ViewConfigureWidget( ab, parent, name ); 183 return new ViewConfigureWidget( ab, parent, name );
182} 184}
183 185
184 186
185 187
186#ifndef KAB_EMBEDDED 188#ifndef KAB_EMBEDDED_
187#include "kaddressbookview.moc" 189#include "moc_kaddressbookview.cpp"
188#endif //KAB_EMBEDDED 190#endif //KAB_EMBEDDED
diff --git a/kaddressbook/kaddressbookview.h b/kaddressbook/kaddressbookview.h
index 3a3f71a..e423cd7 100644
--- a/kaddressbook/kaddressbookview.h
+++ b/kaddressbook/kaddressbookview.h
@@ -1,314 +1,316 @@
1//Added by qt3to4:
2#include <QDropEvent>
1/* 3/*
2 This file is part of KAddressBook. 4 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 5 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 6
5 This program is free software; you can redistribute it and/or modify 7 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 8 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 9 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 10 (at your option) any later version.
9 11
10 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 15 GNU General Public License for more details.
14 16
15 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 20
19 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
22*/ 24*/
23 25
24#ifndef KADDRESSBOOKVIEW_H 26#ifndef KADDRESSBOOKVIEW_H
25#define KADDRESSBOOKVIEW_H 27#define KADDRESSBOOKVIEW_H
26 28
27#ifndef KAB_EMBEDDED 29#ifndef KAB_EMBEDDED
28#include <klibloader.h> 30#include <klibloader.h>
29#endif //KAB_EMBEDDED 31#endif //KAB_EMBEDDED
30 32
31class KConfig; 33class KConfig;
32class QDropEvent; 34class QDropEvent;
33 35
34#include <qstringlist.h> 36#include <qstringlist.h>
35#include <kabc/field.h> 37#include <kabc/field.h>
36#include <qwidget.h> 38#include <qwidget.h>
37#include <qregexp.h> 39#include <qregexp.h>
38 40
39#include "viewconfigurewidget.h" 41#include "viewconfigurewidget.h"
40#include "filter.h" 42#include "filter.h"
41 43
42#ifdef DESKTOP_VERSION 44#ifdef DESKTOP_VERSION
43#include <qpaintdevicemetrics.h> 45#include <q3paintdevicemetrics.h>
44#include <qprinter.h> 46#include <qprinter.h>
45#include <qpainter.h> 47#include <qpainter.h>
46#endif 48#endif
47 49
48namespace KABC { class AddressBook; } 50namespace KABC { class AddressBook; }
49 51
50/** 52/**
51 Base class for all views in kaddressbook. This class implements 53 Base class for all views in kaddressbook. This class implements
52 all the common methods needed to provide a view to the user. 54 all the common methods needed to provide a view to the user.
53 55
54 To implement a specific view (table, card, etc), just inherit from 56 To implement a specific view (table, card, etc), just inherit from
55 this class and implement all the pure virtuals. 57 this class and implement all the pure virtuals.
56 58
57 @author Mike Pilone <mpilone@slac.com> 59 @author Mike Pilone <mpilone@slac.com>
58 */ 60 */
59class KAddressBookView : public QWidget 61class KAddressBookView : public QWidget
60{ 62{
61 Q_OBJECT 63 Q_OBJECT
62 64
63 public: 65 public:
64 enum DefaultFilterType { None = 0, Active = 1, Specific = 2 }; 66 enum DefaultFilterType { None = 0, Active = 1, Specific = 2 };
65 67
66 KAddressBookView( KABC::AddressBook *ab, QWidget *parent, const char *name ); 68 KAddressBookView( KABC::AddressBook *ab, QWidget *parent, const char *name );
67 virtual ~KAddressBookView(); 69 virtual ~KAddressBookView();
68 70
69 /** 71 /**
70 Must be overloaded in subclasses. Should return a list of 72 Must be overloaded in subclasses. Should return a list of
71 all the uids of selected contacts. 73 all the uids of selected contacts.
72 */ 74 */
73 virtual QStringList selectedUids() = 0; 75 virtual QStringList selectedUids() = 0;
74 virtual void doSearch( const QString& s ,KABC::Field *field ) = 0; 76 virtual void doSearch( const QString& s ,KABC::Field *field ) = 0;
75 virtual void scrollUP() = 0; 77 virtual void scrollUP() = 0;
76 virtual void scrollDOWN() = 0; 78 virtual void scrollDOWN() = 0;
77 virtual void setFocusAV() = 0; 79 virtual void setFocusAV() = 0;
78 80
79 /** 81 /**
80 Called whenever this view should read the config. This can be used 82 Called whenever this view should read the config. This can be used
81 as a sign that the config has changed, therefore the view should 83 as a sign that the config has changed, therefore the view should
82 assume the worst and rebuild itself if necessary. For example, 84 assume the worst and rebuild itself if necessary. For example,
83 in a table view this method may be called when the user adds or 85 in a table view this method may be called when the user adds or
84 removes columns from the view. 86 removes columns from the view.
85 87
86 If overloaded in the subclass, do not forget to call super class's 88 If overloaded in the subclass, do not forget to call super class's
87 method. 89 method.
88 90
89 @param config The KConfig object to read from. The group will already 91 @param config The KConfig object to read from. The group will already
90 be set, so do not change the group. 92 be set, so do not change the group.
91 */ 93 */
92 virtual void readConfig( KConfig *config ); 94 virtual void readConfig( KConfig *config );
93 95
94 /** 96 /**
95 Called whenever this view should write the config. The view should not 97 Called whenever this view should write the config. The view should not
96 write out information handled by the application, such as which fields 98 write out information handled by the application, such as which fields
97 are visible. The view should only write out information specific 99 are visible. The view should only write out information specific
98 to itself (i.e.: All information in the ViewConfigWidget) 100 to itself (i.e.: All information in the ViewConfigWidget)
99 101
100 If overloaded in the subclass, do not forget to call the super class's 102 If overloaded in the subclass, do not forget to call the super class's
101 method. 103 method.
102 104
103 @param config The KConfig object to read from. The group will already 105 @param config The KConfig object to read from. The group will already
104 be set, so do not change the group. 106 be set, so do not change the group.
105 */ 107 */
106 virtual void writeConfig( KConfig *config ); 108 virtual void writeConfig( KConfig *config );
107 109
108 /** 110 /**
109 Returns a QString with all the selected email addresses concatenated 111 Returns a QString with all the selected email addresses concatenated
110 together with a ',' seperator. 112 together with a ',' seperator.
111 */ 113 */
112 virtual QString selectedEmails(); 114 virtual QString selectedEmails();
113 115
114 /** 116 /**
115 Return the type of the view: Icon, Table, etc. Please make sure that 117 Return the type of the view: Icon, Table, etc. Please make sure that
116 this is the same value that ViewWrapper::type() will return for your 118 this is the same value that ViewWrapper::type() will return for your
117 view. 119 view.
118 */ 120 */
119 virtual QString type() const = 0; 121 virtual QString type() const = 0;
120 122
121 /** 123 /**
122 Returns a list of the fields that should be displayed. The list 124 Returns a list of the fields that should be displayed. The list
123 is composed of the fields proper names (ie: Home Address), so 125 is composed of the fields proper names (ie: Home Address), so
124 the view may need to translate them in order to get the 126 the view may need to translate them in order to get the
125 value from the addressee. 127 value from the addressee.
126 128
127 This list is generated from the config file, so it is advisable to call 129 This list is generated from the config file, so it is advisable to call
128 this method whenever a readConfig() is called in order to get the newest 130 this method whenever a readConfig() is called in order to get the newest
129 list of fields. 131 list of fields.
130 */ 132 */
131 KABC::Field::List fields() const; 133 KABC::Field::List fields() const;
132 134
133 KABC::Field::List allFields() const; 135 KABC::Field::List allFields() const;
134 136
135 /** 137 /**
136 Sets the active filter. This filter will be used for filtering 138 Sets the active filter. This filter will be used for filtering
137 the list of addressees to display. The view will <b>not</b> 139 the list of addressees to display. The view will <b>not</b>
138 automatically refresh itself, so in most cases you will want to call 140 automatically refresh itself, so in most cases you will want to call
139 KAddressBookView::refresh() after this method. 141 KAddressBookView::refresh() after this method.
140 */ 142 */
141 void setFilter( const Filter& ); 143 void setFilter( const Filter& );
142 144
143 /** 145 /**
144 @return The default filter type selection. If the selection 146 @return The default filter type selection. If the selection
145 is SpecificFilter, the name of the filter can be retrieved with 147 is SpecificFilter, the name of the filter can be retrieved with
146 defaultFilterName() 148 defaultFilterName()
147 */ 149 */
148 DefaultFilterType defaultFilterType() const; 150 DefaultFilterType defaultFilterType() const;
149 151
150 /** 152 /**
151 @return The name of the default filter. This string is 153 @return The name of the default filter. This string is
152 only valid if defaultFilterType() is returning SpecificFilter. 154 only valid if defaultFilterType() is returning SpecificFilter.
153 */ 155 */
154 const QString &defaultFilterName() const; 156 const QString &defaultFilterName() const;
155 157
156 /** 158 /**
157 @return The address book. 159 @return The address book.
158 */ 160 */
159 KABC::AddressBook *addressBook() const; 161 KABC::AddressBook *addressBook() const;
160 void printMyView() { emit printView() ;} 162 void printMyView() { emit printView() ;}
161 163
162 public slots: 164 public slots:
163 /** 165 /**
164 Must be overloaded in subclasses to refresh the view. 166 Must be overloaded in subclasses to refresh the view.
165 Refreshing includes updating the view to ensure that only items 167 Refreshing includes updating the view to ensure that only items
166 in the document are visible. If <i>uid</i> is valid, only the 168 in the document are visible. If <i>uid</i> is valid, only the
167 addressee with uid needs to be refreshed. This is an optimization 169 addressee with uid needs to be refreshed. This is an optimization
168 only. 170 only.
169 */ 171 */
170 virtual void refresh( QString uid = QString::null ) = 0; 172 virtual void refresh( QString uid = QString::null ) = 0;
171 173
172 /** 174 /**
173 This method must be overloaded in subclasses. Select (highlight) 175 This method must be overloaded in subclasses. Select (highlight)
174 the addressee matching <i>uid</i>. If uid 176 the addressee matching <i>uid</i>. If uid
175 is equal to QString::null, then all addressees should be selected. 177 is equal to QString::null, then all addressees should be selected.
176 */ 178 */
177#ifndef KAB_EMBEDDED 179#ifndef KAB_EMBEDDED
178//MOC_SKIP_BEGIN 180#ifndef Q_MOC_RUN
179 virtual void setSelected( QString uid = QString::null, bool selected = true ) = 0; 181 virtual void setSelected( QString uid = QString::null, bool selected = true ) = 0;
180//MOC_SKIP_END 182#endif
181#else //KAB_EMBEDDED 183#else //KAB_EMBEDDED
182 //US my moc can not handle the default parameters. Is this a problem ??? 184 //US my moc can not handle the default parameters. Is this a problem ???
183 virtual void setSelected( QString uid, bool selected) = 0; 185 virtual void setSelected( QString uid, bool selected) = 0;
184#endif //KAB_EMBEDDED 186#endif //KAB_EMBEDDED
185 187
186 signals: 188 signals:
187 189
188 void printView(); 190 void printView();
189 /** 191 /**
190 This signal should be emitted by a subclass whenever an addressee 192 This signal should be emitted by a subclass whenever an addressee
191 is modified. 193 is modified.
192 */ 194 */
193 void modified(); 195 void modified();
194 196
195 /** 197 /**
196 This signal should be emitted by a subclass whenever an addressee 198 This signal should be emitted by a subclass whenever an addressee
197 is selected. Selected means that the addressee was given the focus. 199 is selected. Selected means that the addressee was given the focus.
198 Some widgets may call this 'highlighted'. The view is responsible for 200 Some widgets may call this 'highlighted'. The view is responsible for
199 emitting this signal multiple times if multiple items are selected, 201 emitting this signal multiple times if multiple items are selected,
200 with the last item selected being the last emit. 202 with the last item selected being the last emit.
201 203
202 @param uid The uid of the selected addressee. 204 @param uid The uid of the selected addressee.
203 205
204 @see KListView 206 @see KListView
205 */ 207 */
206 void selected( const QString &uid ); 208 void selected( const QString &uid );
207 void deleteRequest(); 209 void deleteRequest();
208 /** 210 /**
209 This signal should be emitted by a subclass whenever an addressee 211 This signal should be emitted by a subclass whenever an addressee
210 is executed. This is defined by the KDE system wide config, but it 212 is executed. This is defined by the KDE system wide config, but it
211 either means single or doubleclicked. 213 either means single or doubleclicked.
212 214
213 @param ui The uid of the selected addressee 215 @param ui The uid of the selected addressee
214 216
215 @see KListView 217 @see KListView
216 */ 218 */
217 void executed( const QString &uid ); 219 void executed( const QString &uid );
218 220
219 /** 221 /**
220 This signal is emitted whenever a user attempts to start a drag 222 This signal is emitted whenever a user attempts to start a drag
221 in the view. The slot connected to this signal would usually want 223 in the view. The slot connected to this signal would usually want
222 to create a QDragObject. 224 to create a QDragObject.
223 */ 225 */
224 void startDrag(); 226 void startDrag();
225 227
226 /** 228 /**
227 This signal is emitted whenever the user drops something on the 229 This signal is emitted whenever the user drops something on the
228 view. The individual view should handle checking if the item is 230 view. The individual view should handle checking if the item is
229 droppable (ie: if it is a vcard). 231 droppable (ie: if it is a vcard).
230 */ 232 */
231 void dropped( QDropEvent* ); 233 void dropped( QDropEvent* );
232 234
233 protected: 235 protected:
234 236
235 /** 237 /**
236 Returns a list of the addressees that should be displayed. This method 238 Returns a list of the addressees that should be displayed. This method
237 should always be used by the subclass to get a list of addressees. This 239 should always be used by the subclass to get a list of addressees. This
238 method internally takes many factors into account, including the current 240 method internally takes many factors into account, including the current
239 filter. 241 filter.
240 */ 242 */
241 KABC::Addressee::List addressees(); 243 KABC::Addressee::List addressees();
242 244
243 /** 245 /**
244 This method returns the widget that should be used as the parent for 246 This method returns the widget that should be used as the parent for
245 all view components. By using this widget as the parent and not 247 all view components. By using this widget as the parent and not
246 'this', the view subclass has the option of placing other widgets 248 'this', the view subclass has the option of placing other widgets
247 around the view (ie: search fields, etc). Do not delete this widget! 249 around the view (ie: search fields, etc). Do not delete this widget!
248 */ 250 */
249 QWidget *viewWidget(); 251 QWidget *viewWidget();
250 QRegExp getRegExp( const QString ); 252 QRegExp getRegExp( const QString );
251 253
252 private: 254 private:
253 void initGUI(); 255 void initGUI();
254 256
255 DefaultFilterType mDefaultFilterType; 257 DefaultFilterType mDefaultFilterType;
256 Filter mFilter; 258 Filter mFilter;
257 QString mDefaultFilterName; 259 QString mDefaultFilterName;
258 KABC::AddressBook *mAddressBook; 260 KABC::AddressBook *mAddressBook;
259 KABC::Field::List mFieldList; 261 KABC::Field::List mFieldList;
260 262
261 QWidget *mViewWidget; 263 QWidget *mViewWidget;
262}; 264};
263 265
264#ifndef KAB_EMBEDDED 266#ifndef KAB_EMBEDDED
265//MOC_SKIP_BEGIN 267#ifndef Q_MOC_RUN
266class ViewFactory : public KLibFactory 268class ViewFactory : public KLibFactory
267//MOC_SKIP_END 269#endif
268#else //KAB_EMBEDDED 270#else //KAB_EMBEDDED
269class ViewFactory 271class ViewFactory
270#endif //KAB_EMBEDDED 272#endif //KAB_EMBEDDED
271{ 273{
272 274
273 public: 275 public:
274 virtual KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, 276 virtual KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent,
275 const char *name = 0 ) = 0; 277 const char *name = 0 ) = 0;
276 278
277 /** 279 /**
278 @return The type of the view. This is normally a small one word 280 @return The type of the view. This is normally a small one word
279 string (ie: Table, Icon, Tree, etc). 281 string (ie: Table, Icon, Tree, etc).
280 */ 282 */
281 virtual QString type() const = 0; 283 virtual QString type() const = 0;
282 284
283 /** 285 /**
284 @return The description of the view. This should be a 3 to 286 @return The description of the view. This should be a 3 to
285 4 line string (don't actually use return characters in the string) 287 4 line string (don't actually use return characters in the string)
286 describing the features offered by the view. 288 describing the features offered by the view.
287 */ 289 */
288 virtual QString description() const = 0; 290 virtual QString description() const = 0;
289 291
290 /** 292 /**
291 Creates a config dialog for the view type. The default 293 Creates a config dialog for the view type. The default
292 implementation will return a ViewConfigDialog. This default 294 implementation will return a ViewConfigDialog. This default
293 dialog will allow the user to set the visible fields only. If 295 dialog will allow the user to set the visible fields only. If
294 you need more config options (as most views will), this method 296 you need more config options (as most views will), this method
295 can be overloaded to return your sublcass of ViewConfigDialog. 297 can be overloaded to return your sublcass of ViewConfigDialog.
296 If this method is over loaded the base classes method should 298 If this method is over loaded the base classes method should
297 <B>not</B> be called. 299 <B>not</B> be called.
298 */ 300 */
299 virtual ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, 301 virtual ViewConfigureWidget *configureWidget( KABC::AddressBook *ab,
300 QWidget *parent, 302 QWidget *parent,
301 const char *name = 0 ); 303 const char *name = 0 );
302 304
303 protected: 305 protected:
304 virtual QObject* createObject( QObject*, const char*, const char*, 306 virtual QObject* createObject( QObject*, const char*, const char*,
305 const QStringList & ) 307 const QStringList & )
306 { 308 {
307 return 0; 309 return 0;
308 } 310 }
309 311
310 312
311}; 313};
312 314
313 315
314#endif 316#endif
diff --git a/kaddressbook/kcmconfigs/addresseewidget.cpp b/kaddressbook/kcmconfigs/addresseewidget.cpp
index 168d39e..8055085 100644
--- a/kaddressbook/kcmconfigs/addresseewidget.cpp
+++ b/kaddressbook/kcmconfigs/addresseewidget.cpp
@@ -1,238 +1,242 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 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 <qgroupbox.h> 24#include <q3groupbox.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlistbox.h> 27#include <q3listbox.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qapplication.h> 29#include <qapplication.h>
30#include <QDesktopWidget>
31//Added by qt3to4:
32#include <Q3GridLayout>
33#include <Q3HBoxLayout>
30 34
31#include <kbuttonbox.h> 35#include <kbuttonbox.h>
32#include <kcombobox.h> 36#include <kcombobox.h>
33#include <kconfig.h> 37#include <kconfig.h>
34#include <kdialog.h> 38#include <kdialog.h>
35#include <klocale.h> 39#include <klocale.h>
36#include <kglobal.h> 40#include <kglobal.h>
37#include <klineedit.h> 41#include <klineedit.h>
38#include <kstandarddirs.h> 42#include <kstandarddirs.h>
39 43
40#include "addresseewidget.h" 44#include "addresseewidget.h"
41 45
42NamePartWidget::NamePartWidget( const QString &title, QWidget *parent, 46NamePartWidget::NamePartWidget( const QString &title, QWidget *parent,
43 const char *name ) 47 const char *name )
44 : QWidget( parent, name ) 48 : QWidget( parent, name )
45{ 49{
46 if (KGlobal::getOrientation() == KGlobal::Portrait) 50 if (KGlobal::getOrientation() == KGlobal::Portrait)
47 { 51 {
48 QGridLayout* layout = new QGridLayout( this, 1, 1, KDialog::marginHintSmall(), 52 Q3GridLayout* layout = new Q3GridLayout( this, 1, 1, KDialog::marginHintSmall(),
49 KDialog::spacingHintSmall() ); 53 KDialog::spacingHintSmall() );
50 54
51 QLabel *label = new QLabel( i18n( title ), this ); 55 QLabel *label = new QLabel( i18n( title ), this );
52 layout->addWidget( label, 0, 1 ); 56 layout->addWidget( label, 0, 1 );
53 57
54 mBox = new QListBox( this ); 58 mBox = new Q3ListBox( this );
55 mBox->setMaximumSize(70, 70); 59 mBox->setMaximumSize(70, 70);
56 layout->addMultiCellWidget( mBox, 0, 1, 0, 0 ); 60 layout->addMultiCellWidget( mBox, 0, 1, 0, 0 );
57 61
58 KButtonBox *bbox = new KButtonBox( this, Qt::Vertical ); 62 KButtonBox *bbox = new KButtonBox( this, Qt::Vertical );
59 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) ); 63 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) );
60 mRemoveButton = bbox->addButton( i18n( "Rem" ), this, SLOT( remove() ) ); 64 mRemoveButton = bbox->addButton( i18n( "Rem" ), this, SLOT( remove() ) );
61 bbox->layout(); 65 bbox->layout();
62 layout->addMultiCellWidget( bbox, 0, 1, 2,2); 66 layout->addMultiCellWidget( bbox, 0, 1, 2,2);
63 67
64 mEdit = new KLineEdit( this ); 68 mEdit = new KLineEdit( this );
65 layout->addWidget( mEdit, 1, 1 ); 69 layout->addWidget( mEdit, 1, 1 );
66 //mEdit->setMinimumWidth(50); 70 //mEdit->setMinimumWidth(50);
67 71
68// layout->addWidget( group ); 72// layout->addWidget( group );
69 73
70 } 74 }
71 else 75 else
72 { 76 {
73 QHBoxLayout *layout = new QHBoxLayout( this ); 77 Q3HBoxLayout *layout = new Q3HBoxLayout( this );
74 78
75 QGroupBox *group = new QGroupBox( 0, Qt::Vertical, title, this ); 79 Q3GroupBox *group = new Q3GroupBox( 0, Qt::Vertical, title, this );
76 QGridLayout *groupLayout = new QGridLayout( group->layout(), 2, 2, 80 Q3GridLayout *groupLayout = new Q3GridLayout( group->layout(), 2, 2,
77 KDialog::spacingHint() ); 81 KDialog::spacingHint() );
78 82
79 mBox = new QListBox( group ); 83 mBox = new Q3ListBox( group );
80 84
81 groupLayout->addWidget( mBox, 0, 0 ); 85 groupLayout->addWidget( mBox, 0, 0 );
82 86
83 KButtonBox *bbox = new KButtonBox( group, Qt::Vertical ); 87 KButtonBox *bbox = new KButtonBox( group, Qt::Vertical );
84 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) ); 88 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) );
85 mRemoveButton = bbox->addButton( i18n( "Remove" ), this, SLOT( remove() ) ); 89 mRemoveButton = bbox->addButton( i18n( "Remove" ), this, SLOT( remove() ) );
86 bbox->layout(); 90 bbox->layout();
87 groupLayout->addWidget( bbox, 0, 1 ); 91 groupLayout->addWidget( bbox, 0, 1 );
88 92
89 mEdit = new KLineEdit( group ); 93 mEdit = new KLineEdit( group );
90 groupLayout->addMultiCellWidget( mEdit, 1, 1, 0, 1 ); 94 groupLayout->addMultiCellWidget( mEdit, 1, 1, 0, 1 );
91 95
92 layout->addWidget( group ); 96 layout->addWidget( group );
93 97
94 } 98 }
95 99
96 mAddButton->setEnabled( false ); 100 mAddButton->setEnabled( false );
97 mRemoveButton->setEnabled( false ); 101 mRemoveButton->setEnabled( false );
98 102
99 103
100 connect( mBox, SIGNAL( selectionChanged( QListBoxItem* ) ), 104 connect( mBox, SIGNAL( selectionChanged( Q3ListBoxItem* ) ),
101 SLOT( selectionChanged( QListBoxItem* ) ) ); 105 SLOT( selectionChanged( Q3ListBoxItem* ) ) );
102 connect( mEdit, SIGNAL( textChanged( const QString& ) ), 106 connect( mEdit, SIGNAL( textChanged( const QString& ) ),
103 SLOT( textChanged( const QString& ) ) ); 107 SLOT( textChanged( const QString& ) ) );
104 connect( mEdit, SIGNAL( returnPressed() ), SLOT( add() ) ); 108 connect( mEdit, SIGNAL( returnPressed() ), SLOT( add() ) );
105 109
106} 110}
107 111
108NamePartWidget::~NamePartWidget() 112NamePartWidget::~NamePartWidget()
109{ 113{
110} 114}
111 115
112void NamePartWidget::setNameParts( const QStringList &list ) 116void NamePartWidget::setNameParts( const QStringList &list )
113{ 117{
114 mBox->clear(); 118 mBox->clear();
115 mBox->insertStringList( list ); 119 mBox->insertStringList( list );
116} 120}
117 121
118QStringList NamePartWidget::nameParts() const 122QStringList NamePartWidget::nameParts() const
119{ 123{
120 QStringList parts; 124 QStringList parts;
121 for ( uint i = 0; i < mBox->count(); ++i ) 125 for ( uint i = 0; i < mBox->count(); ++i )
122 parts.append( mBox->text( i ) ); 126 parts.append( mBox->text( i ) );
123 127
124 return parts; 128 return parts;
125} 129}
126 130
127void NamePartWidget::add() 131void NamePartWidget::add()
128{ 132{
129 if ( !mEdit->text().isEmpty() ) { 133 if ( !mEdit->text().isEmpty() ) {
130 mBox->insertItem( mEdit->text() ); 134 mBox->insertItem( mEdit->text() );
131 emit modified(); 135 emit modified();
132 } 136 }
133 137
134 mEdit->setText( "" ); 138 mEdit->setText( "" );
135} 139}
136 140
137void NamePartWidget::remove() 141void NamePartWidget::remove()
138{ 142{
139 mBox->removeItem( mBox->currentItem() ); 143 mBox->removeItem( mBox->currentItem() );
140 if ( mBox->count() == 0 ) 144 if ( mBox->count() == 0 )
141 selectionChanged( 0 ); 145 selectionChanged( 0 );
142 146
143 emit modified(); 147 emit modified();
144} 148}
145 149
146void NamePartWidget::selectionChanged( QListBoxItem *item ) 150void NamePartWidget::selectionChanged( Q3ListBoxItem *item )
147{ 151{
148 mRemoveButton->setEnabled( item != 0 ); 152 mRemoveButton->setEnabled( item != 0 );
149} 153}
150 154
151void NamePartWidget::textChanged( const QString& text ) 155void NamePartWidget::textChanged( const QString& text )
152{ 156{
153 mAddButton->setEnabled( !text.isEmpty() ); 157 mAddButton->setEnabled( !text.isEmpty() );
154} 158}
155 159
156 160
157AddresseeWidget::AddresseeWidget( QWidget *parent, const char *name ) 161AddresseeWidget::AddresseeWidget( QWidget *parent, const char *name )
158 : QWidget( parent, name ) 162 : QWidget( parent, name )
159{ 163{
160 QGridLayout *layout; 164 Q3GridLayout *layout;
161 165
162 mPrefix = new NamePartWidget( i18n( "Prefixes" ), this ); 166 mPrefix = new NamePartWidget( i18n( "Prefixes" ), this );
163 mInclusion = new NamePartWidget( i18n( "Inclusions" ), this ); 167 mInclusion = new NamePartWidget( i18n( "Inclusions" ), this );
164 mSuffix = new NamePartWidget( i18n( "Suffixes" ), this ); 168 mSuffix = new NamePartWidget( i18n( "Suffixes" ), this );
165 QString dfn; 169 QString dfn;
166 if (QApplication::desktop()->width() > 320 ) 170 if (QApplication::desktop()->width() > 320 )
167 dfn = i18n( "Default formatted name:" ); 171 dfn = i18n( "Default formatted name:" );
168 else 172 else
169 dfn = i18n( "Def. formatted name:" ); 173 dfn = i18n( "Def. formatted name:" );
170 174
171 QLabel *label = new QLabel( dfn, this ); 175 QLabel *label = new QLabel( dfn, this );
172 176
173 mFormattedNameCombo = new KComboBox( this ); 177 mFormattedNameCombo = new KComboBox( this );
174 mFormattedNameCombo->insertItem( i18n( "Empty" ) ); 178 mFormattedNameCombo->insertItem( i18n( "Empty" ) );
175 mFormattedNameCombo->insertItem( i18n( "Simple Name" ) ); 179 mFormattedNameCombo->insertItem( i18n( "Simple Name" ) );
176 mFormattedNameCombo->insertItem( i18n( "Full Name" ) ); 180 mFormattedNameCombo->insertItem( i18n( "Full Name" ) );
177 mFormattedNameCombo->insertItem( i18n( "Reverse Name" ) ); 181 mFormattedNameCombo->insertItem( i18n( "Reverse Name" ) );
178 182
179 if (KGlobal::getOrientation() == KGlobal::Portrait) 183 if (KGlobal::getOrientation() == KGlobal::Portrait)
180 { 184 {
181 layout = new QGridLayout( this, 4, 2, KDialog::marginHintSmall(), 185 layout = new Q3GridLayout( this, 4, 2, KDialog::marginHintSmall(),
182 KDialog::spacingHintSmall() ); 186 KDialog::spacingHintSmall() );
183 187
184 layout->addMultiCellWidget( mPrefix, 0, 0, 0, 1 ); 188 layout->addMultiCellWidget( mPrefix, 0, 0, 0, 1 );
185 layout->addMultiCellWidget( mInclusion, 1, 1, 0, 1 ); 189 layout->addMultiCellWidget( mInclusion, 1, 1, 0, 1 );
186 layout->addMultiCellWidget( mSuffix, 2, 2, 0, 1 ); 190 layout->addMultiCellWidget( mSuffix, 2, 2, 0, 1 );
187 layout->addWidget( label, 3, 0 ); 191 layout->addWidget( label, 3, 0 );
188 layout->addWidget( mFormattedNameCombo, 3, 1 ); 192 layout->addWidget( mFormattedNameCombo, 3, 1 );
189 193
190 } 194 }
191 else 195 else
192 { 196 {
193 layout = new QGridLayout( this, 2, 3, KDialog::marginHint(), 197 layout = new Q3GridLayout( this, 2, 3, KDialog::marginHint(),
194 KDialog::spacingHint() ); 198 KDialog::spacingHint() );
195 199
196 layout->addWidget( mPrefix, 0, 0 ); 200 layout->addWidget( mPrefix, 0, 0 );
197 layout->addWidget( mInclusion, 0, 1 ); 201 layout->addWidget( mInclusion, 0, 1 );
198 layout->addWidget( mSuffix, 0, 2 ); 202 layout->addWidget( mSuffix, 0, 2 );
199 layout->addWidget( label, 1, 0 ); 203 layout->addWidget( label, 1, 0 );
200 layout->addMultiCellWidget( mFormattedNameCombo, 1, 1, 1, 2 ); 204 layout->addMultiCellWidget( mFormattedNameCombo, 1, 1, 1, 2 );
201 } 205 }
202 206
203 connect( mPrefix, SIGNAL( modified() ), SIGNAL( modified() ) ); 207 connect( mPrefix, SIGNAL( modified() ), SIGNAL( modified() ) );
204 connect( mInclusion, SIGNAL( modified() ), SIGNAL( modified() ) ); 208 connect( mInclusion, SIGNAL( modified() ), SIGNAL( modified() ) );
205 connect( mSuffix, SIGNAL( modified() ), SIGNAL( modified() ) ); 209 connect( mSuffix, SIGNAL( modified() ), SIGNAL( modified() ) );
206 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SIGNAL( modified() ) ); 210 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SIGNAL( modified() ) );
207} 211}
208 212
209AddresseeWidget::~AddresseeWidget() 213AddresseeWidget::~AddresseeWidget()
210{ 214{
211} 215}
212 216
213void AddresseeWidget::restoreSettings() 217void AddresseeWidget::restoreSettings()
214{ 218{
215 KConfig config( locateLocal("config", "kabcrc") ); 219 KConfig config( locateLocal("config", "kabcrc") );
216 config.setGroup( "General" ); 220 config.setGroup( "General" );
217 221
218 mPrefix->setNameParts( config.readListEntry( "Prefixes" ) ); 222 mPrefix->setNameParts( config.readListEntry( "Prefixes" ) );
219 mInclusion->setNameParts( config.readListEntry( "Inclusions" ) ); 223 mInclusion->setNameParts( config.readListEntry( "Inclusions" ) );
220 mSuffix->setNameParts( config.readListEntry( "Suffixes" ) ); 224 mSuffix->setNameParts( config.readListEntry( "Suffixes" ) );
221 mFormattedNameCombo->setCurrentItem( config.readNumEntry( "FormattedNameType", 1 ) ); 225 mFormattedNameCombo->setCurrentItem( config.readNumEntry( "FormattedNameType", 1 ) );
222} 226}
223 227
224void AddresseeWidget::saveSettings() 228void AddresseeWidget::saveSettings()
225{ 229{
226 qDebug("AddresseeWidget::saveSettings() "); 230 qDebug("AddresseeWidget::saveSettings() ");
227 KConfig config( locateLocal("config","kabcrc") ); 231 KConfig config( locateLocal("config","kabcrc") );
228 config.setGroup( "General" ); 232 config.setGroup( "General" );
229 233
230 config.writeEntry( "Prefixes", mPrefix->nameParts() ); 234 config.writeEntry( "Prefixes", mPrefix->nameParts() );
231 config.writeEntry( "Inclusions", mInclusion->nameParts() ); 235 config.writeEntry( "Inclusions", mInclusion->nameParts() );
232 config.writeEntry( "Suffixes", mSuffix->nameParts() ); 236 config.writeEntry( "Suffixes", mSuffix->nameParts() );
233 config.writeEntry( "FormattedNameType", mFormattedNameCombo->currentItem() ); 237 config.writeEntry( "FormattedNameType", mFormattedNameCombo->currentItem() );
234} 238}
235 239
236#ifndef KAB_EMBEDDED 240#ifndef KAB_EMBEDDED_
237#include "addresseewidget.moc" 241#include "moc_addresseewidget.cpp"
238#endif //KAB_EMBEDDED 242#endif //KAB_EMBEDDED
diff --git a/kaddressbook/kcmconfigs/addresseewidget.h b/kaddressbook/kcmconfigs/addresseewidget.h
index 09330c8..f2a95a8 100644
--- a/kaddressbook/kcmconfigs/addresseewidget.h
+++ b/kaddressbook/kcmconfigs/addresseewidget.h
@@ -1,87 +1,87 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 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#ifndef ADDRESSEEWIDGET_H 24#ifndef ADDRESSEEWIDGET_H
25#define ADDRESSEEWIDGET_H 25#define ADDRESSEEWIDGET_H
26 26
27#include <qwidget.h> 27#include <qwidget.h>
28 28
29class KComboBox; 29class KComboBox;
30class KLineEdit; 30class KLineEdit;
31 31
32class QListBox; 32class Q3ListBox;
33class QListBoxItem; 33class Q3ListBoxItem;
34class QPushButton; 34class QPushButton;
35 35
36class NamePartWidget : public QWidget 36class NamePartWidget : public QWidget
37{ 37{
38 Q_OBJECT 38 Q_OBJECT
39 39
40 public: 40 public:
41 NamePartWidget( const QString &title, QWidget *parent, 41 NamePartWidget( const QString &title, QWidget *parent,
42 const char *name = 0 ); 42 const char *name = 0 );
43 ~NamePartWidget(); 43 ~NamePartWidget();
44 44
45 void setNameParts( const QStringList &list ); 45 void setNameParts( const QStringList &list );
46 QStringList nameParts() const; 46 QStringList nameParts() const;
47 47
48 signals: 48 signals:
49 void modified(); 49 void modified();
50 50
51 private slots: 51 private slots:
52 void add(); 52 void add();
53 void remove(); 53 void remove();
54 54
55 void selectionChanged( QListBoxItem* ); 55 void selectionChanged( Q3ListBoxItem* );
56 void textChanged( const QString& ); 56 void textChanged( const QString& );
57 57
58 private: 58 private:
59 KLineEdit *mEdit; 59 KLineEdit *mEdit;
60 60
61 QListBox *mBox; 61 Q3ListBox *mBox;
62 QPushButton *mAddButton; 62 QPushButton *mAddButton;
63 QPushButton *mRemoveButton; 63 QPushButton *mRemoveButton;
64}; 64};
65 65
66class AddresseeWidget : public QWidget 66class AddresseeWidget : public QWidget
67{ 67{
68 Q_OBJECT 68 Q_OBJECT
69 69
70 public: 70 public:
71 AddresseeWidget( QWidget *parent, const char *name = 0 ); 71 AddresseeWidget( QWidget *parent, const char *name = 0 );
72 ~AddresseeWidget(); 72 ~AddresseeWidget();
73 73
74 void restoreSettings(); 74 void restoreSettings();
75 void saveSettings(); 75 void saveSettings();
76 76
77 signals: 77 signals:
78 void modified(); 78 void modified();
79 79
80 private: 80 private:
81 KComboBox *mFormattedNameCombo; 81 KComboBox *mFormattedNameCombo;
82 NamePartWidget *mPrefix; 82 NamePartWidget *mPrefix;
83 NamePartWidget *mInclusion; 83 NamePartWidget *mInclusion;
84 NamePartWidget *mSuffix; 84 NamePartWidget *mSuffix;
85}; 85};
86 86
87#endif 87#endif
diff --git a/kaddressbook/kcmconfigs/extensionconfigdialog.cpp b/kaddressbook/kcmconfigs/extensionconfigdialog.cpp
index e87b000..33b66ad 100644
--- a/kaddressbook/kcmconfigs/extensionconfigdialog.cpp
+++ b/kaddressbook/kcmconfigs/extensionconfigdialog.cpp
@@ -1,59 +1,62 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 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 <qlayout.h> 24#include <qlayout.h>
25//Added by qt3to4:
26#include <Q3GridLayout>
27#include <Q3Frame>
25 28
26#include <klocale.h> 29#include <klocale.h>
27 30
28#include "configurewidget.h" 31#include "configurewidget.h"
29 32
30#include "extensionconfigdialog.h" 33#include "extensionconfigdialog.h"
31 34
32ExtensionConfigDialog::ExtensionConfigDialog( ExtensionFactory *factory, KConfig *config, 35ExtensionConfigDialog::ExtensionConfigDialog( ExtensionFactory *factory, KConfig *config,
33 QWidget *parent, const char *name ) 36 QWidget *parent, const char *name )
34 : KDialogBase( Plain, i18n( "Extension Settings" ), Ok | Cancel, Ok, parent, 37 : KDialogBase( Plain, i18n( "Extension Settings" ), Ok | Cancel, Ok, parent,
35 name, true, true ), mWidget( 0 ), mConfig( config ) 38 name, true, true ), mWidget( 0 ), mConfig( config )
36{ 39{
37 QFrame *page = plainPage(); 40 Q3Frame *page = plainPage();
38 QGridLayout *layout = new QGridLayout( page, 1, 1, marginHint(), spacingHint() ); 41 Q3GridLayout *layout = new Q3GridLayout( page, 1, 1, marginHint(), spacingHint() );
39 42
40 mWidget = factory->configureWidget( page, "ExtensionConfigWidget" ); 43 mWidget = factory->configureWidget( page, "ExtensionConfigWidget" );
41 layout->addWidget( mWidget, 0, 0 ); 44 layout->addWidget( mWidget, 0, 0 );
42 45
43 mWidget->restoreSettings( mConfig ); 46 mWidget->restoreSettings( mConfig );
44} 47}
45 48
46ExtensionConfigDialog::~ExtensionConfigDialog() 49ExtensionConfigDialog::~ExtensionConfigDialog()
47{ 50{
48} 51}
49 52
50void ExtensionConfigDialog::slotOk() 53void ExtensionConfigDialog::slotOk()
51{ 54{
52 mWidget->saveSettings( mConfig ); 55 mWidget->saveSettings( mConfig );
53 56
54 KDialogBase::slotOk(); 57 KDialogBase::slotOk();
55} 58}
56 59
57#ifndef KAB_EMBEDDED 60#ifndef KAB_EMBEDDED_
58#include "extensionconfigdialog.moc" 61#include "moc_extensionconfigdialog.cpp"
59#endif //KAB_EMBEDDED 62#endif //KAB_EMBEDDED
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.cpp b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
index 9e4db74..d2b7ef1 100644
--- a/kaddressbook/kcmconfigs/kabconfigwidget.cpp
+++ b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
@@ -1,424 +1,427 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 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 <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qframe.h> 25#include <q3frame.h>
26#include <qgroupbox.h> 26#include <q3groupbox.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qtabwidget.h> 29#include <qtabwidget.h>
30#include <qcombobox.h> 30#include <qcombobox.h>
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qlabel.h> 32#include <qlabel.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qvbox.h> 34#include <q3vbox.h>
35//Added by qt3to4:
36#include <Q3HBoxLayout>
37#include <Q3PtrList>
38#include <Q3VBoxLayout>
35 39
36#include <kconfig.h> 40#include <kconfig.h>
37#include <kdebug.h> 41#include <kdebug.h>
38#include <kdialog.h> 42#include <kdialog.h>
39#include <klistview.h> 43#include <klistview.h>
40#include <klocale.h> 44#include <klocale.h>
41#include <kglobal.h> 45#include <kglobal.h>
42#include <kmessagebox.h> 46#include <kmessagebox.h>
43#include <kstandarddirs.h> 47#include <kstandarddirs.h>
44 48
45#ifndef KAB_EMBEDDED 49#ifndef KAB_EMBEDDED
46#include <ktrader.h> 50#include <ktrader.h>
47#else // KAB_EMBEDDED 51#else // KAB_EMBEDDED
48#include <mergewidget.h> 52#include <mergewidget.h>
49#include <distributionlistwidget.h> 53#include <distributionlistwidget.h>
50#endif // KAB_EMBEDDED 54#endif // KAB_EMBEDDED
51 55
52#include "addresseewidget.h" 56#include "addresseewidget.h"
53#include "extensionconfigdialog.h" 57#include "extensionconfigdialog.h"
54#include "extensionwidget.h" 58#include "extensionwidget.h"
55#include "kabprefs.h" 59#include "kabprefs.h"
56 60
57#include "kabconfigwidget.h" 61#include "kabconfigwidget.h"
58#include <kglobalsettings.h> 62#include <kglobalsettings.h>
59 63
60class ExtensionItem : public QCheckListItem 64class ExtensionItem : public Q3CheckListItem
61{ 65{
62 public: 66 public:
63 67
64#ifndef KAB_EMBEDDED 68#ifndef KAB_EMBEDDED
65 ExtensionItem( QListView *parent, const QString &text ); 69 ExtensionItem( Q3ListView *parent, const QString &text );
66 void setService( const KService::Ptr &ptr ); 70 void setService( const KService::Ptr &ptr );
67#else //KAB_EMBEDDED 71#else //KAB_EMBEDDED
68 ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ); 72 ExtensionItem( Q3ListView *parent, const QString &text, const QString &name, const QString &comment );
69 void setFactory( ExtensionFactory* fac ); 73 void setFactory( ExtensionFactory* fac );
70#endif //KAB_EMBEDDED 74#endif //KAB_EMBEDDED
71 75
72 bool configWidgetAvailable() const; 76 bool configWidgetAvailable() const;
73 ExtensionFactory *factory() const; 77 ExtensionFactory *factory() const;
74 78
75 virtual QString text( int column ) const; 79 virtual QString text( int column ) const;
76 80
77 private: 81 private:
78#ifndef KAB_EMBEDDED 82#ifndef KAB_EMBEDDED
79 KService::Ptr mPtr; 83 KService::Ptr mPtr;
80#else //KAB_EMBEDDED 84#else //KAB_EMBEDDED
81 ExtensionFactory* mFactory; 85 ExtensionFactory* mFactory;
82 QString mName; 86 QString mName;
83 QString mComment; 87 QString mComment;
84 88
85#endif //KAB_EMBEDDED 89#endif //KAB_EMBEDDED
86 90
87}; 91};
88 92
89KABConfigWidget::KABConfigWidget( KABPrefs* prefs, QWidget *parent, const char *name ) 93KABConfigWidget::KABConfigWidget( KABPrefs* prefs, QWidget *parent, const char *name )
90 : KPrefsWidget( prefs, parent, name ) 94 : KPrefsWidget( prefs, parent, name )
91{ 95{
92 96
93 QVBoxLayout *topLayout = new QVBoxLayout( this, 0, 97 Q3VBoxLayout *topLayout = new Q3VBoxLayout( this, 0,
94 KDialog::spacingHintSmall() ); 98 KDialog::spacingHintSmall() );
95 99
96 QTabWidget *tabWidget = new QTabWidget( this ); 100 QTabWidget *tabWidget = new QTabWidget( this );
97 topLayout->addWidget( tabWidget ); 101 topLayout->addWidget( tabWidget );
98 102
99 // General page 103 // General page
100 QWidget *generalPage = new QWidget( this ); 104 QWidget *generalPage = new QWidget( this );
101 QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(), 105 Q3VBoxLayout *layout = new Q3VBoxLayout( generalPage, KDialog::marginHintSmall(),
102 KDialog::spacingHintSmall() ); 106 KDialog::spacingHintSmall() );
103 107
104 108
105 QWidget *hBox = new QWidget( generalPage, "qhbox" ); 109 QWidget *hBox = new QWidget( generalPage, "qhbox" );
106 QHBoxLayout *hboxLayout = new QHBoxLayout( hBox); 110 Q3HBoxLayout *hboxLayout = new Q3HBoxLayout( hBox);
107 KPrefsWidFont *detailsFont = 111 KPrefsWidFont *detailsFont =
108 addWidFont(i18n("phone:123"),i18n("Details view font"), 112 addWidFont(i18n("phone:123"),i18n("Details view font"),
109 &(KABPrefs::instance()->mDetailsFont),hBox); 113 &(KABPrefs::instance()->mDetailsFont),hBox);
110 hboxLayout->addWidget(detailsFont->label()); 114 hboxLayout->addWidget(detailsFont->label());
111 hboxLayout->addWidget(detailsFont->preview()); 115 hboxLayout->addWidget(detailsFont->preview());
112 hboxLayout->addWidget(detailsFont->button()); 116 hboxLayout->addWidget(detailsFont->button());
113 hboxLayout->setMargin(KDialog::marginHintSmall() ); 117 hboxLayout->setMargin(KDialog::marginHintSmall() );
114 hboxLayout->setSpacing(KDialog::spacingHintSmall()); 118 hboxLayout->setSpacing(KDialog::spacingHintSmall());
115 //hBox->setBackgroundColor( black); 119 //hBox->setBackgroundColor( black);
116 layout->addWidget( hBox ); 120 layout->addWidget( hBox );
117 121
118 //general groupbox 122 //general groupbox
119 QWidget *vBox = new QWidget( generalPage, "qvbox" ); 123 QWidget *vBox = new QWidget( generalPage, "qvbox" );
120 QVBoxLayout *boxLayout = new QVBoxLayout( vBox ); 124 Q3VBoxLayout *boxLayout = new Q3VBoxLayout( vBox );
121 boxLayout->setAlignment( Qt::AlignTop ); 125 boxLayout->setAlignment( Qt::AlignTop );
122 boxLayout->setMargin(KDialog::marginHintSmall() ); 126 boxLayout->setMargin(KDialog::marginHintSmall() );
123 boxLayout->setSpacing( KDialog::spacingHintSmall() ); 127 boxLayout->setSpacing( KDialog::spacingHintSmall() );
124 mMenuBarBox = new QCheckBox( i18n( "Full Menu bar (restart)" ), vBox, "mremenuturn" ); 128 mMenuBarBox = new QCheckBox( i18n( "Full Menu bar (restart)" ), vBox, "mremenuturn" );
125 boxLayout->addWidget( mMenuBarBox ); 129 boxLayout->addWidget( mMenuBarBox );
126 mSearchReturnBox = new QCheckBox( i18n( "Search only after <return> key pressed" ), vBox, "mreturn" ); 130 mSearchReturnBox = new QCheckBox( i18n( "Search only after <return> key pressed" ), vBox, "mreturn" );
127 boxLayout->addWidget( mSearchReturnBox ); 131 boxLayout->addWidget( mSearchReturnBox );
128 mAutoSearchWithWildcardBox = new QCheckBox( i18n( "Search with '*' prefix (wildcard)" ), vBox, "mwildcard" ); 132 mAutoSearchWithWildcardBox = new QCheckBox( i18n( "Search with '*' prefix (wildcard)" ), vBox, "mwildcard" );
129 boxLayout->addWidget( mAutoSearchWithWildcardBox); 133 boxLayout->addWidget( mAutoSearchWithWildcardBox);
130 mHideSearchOnSwitchBox = new QCheckBox( i18n( "Shrink searchfield in portrait view" ), vBox, "mswitch" ); 134 mHideSearchOnSwitchBox = new QCheckBox( i18n( "Shrink searchfield in portrait view" ), vBox, "mswitch" );
131 boxLayout->addWidget( mHideSearchOnSwitchBox ); 135 boxLayout->addWidget( mHideSearchOnSwitchBox );
132 136
133#ifdef DESKTOP_VERSION 137#ifdef DESKTOP_VERSION
134 mHideSearchOnSwitchBox->hide(); 138 mHideSearchOnSwitchBox->hide();
135#endif 139#endif
136 mViewsSingleClickBox = new QCheckBox( i18n( "Show edit dialog on single click" ), vBox, "msingle" ); 140 mViewsSingleClickBox = new QCheckBox( i18n( "Show edit dialog on single click" ), vBox, "msingle" );
137 boxLayout->addWidget( mViewsSingleClickBox ); 141 boxLayout->addWidget( mViewsSingleClickBox );
138 142
139 mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new contacts" ), vBox, "mparse" ); 143 mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new contacts" ), vBox, "mparse" );
140 boxLayout->addWidget( mNameParsing ); 144 boxLayout->addWidget( mNameParsing );
141 145
142 mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), vBox, "mdisplay" ); 146 mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), vBox, "mdisplay" );
143 boxLayout->addWidget( mMultipleViewsAtOnce ); 147 boxLayout->addWidget( mMultipleViewsAtOnce );
144 148
145 mAskForDelete = new QCheckBox( i18n( "Ask before delete contact" ), vBox, "mdel" ); 149 mAskForDelete = new QCheckBox( i18n( "Ask before delete contact" ), vBox, "mdel" );
146 boxLayout->addWidget( mAskForDelete ); 150 boxLayout->addWidget( mAskForDelete );
147 151
148 mAskForQuit = new QCheckBox( i18n( "Show exit confirmation" ), vBox, "mquit" ); 152 mAskForQuit = new QCheckBox( i18n( "Show exit confirmation" ), vBox, "mquit" );
149 boxLayout->addWidget( mAskForQuit ); 153 boxLayout->addWidget( mAskForQuit );
150 154
151 layout->addWidget( vBox ); 155 layout->addWidget( vBox );
152 156
153 tabWidget->addTab( generalPage, i18n( "General" ) ); 157 tabWidget->addTab( generalPage, i18n( "General" ) );
154 158
155 // Extension page 159 // Extension page
156 QWidget *extensionPage = new QWidget( this ); 160 QWidget *extensionPage = new QWidget( this );
157 QVBoxLayout *extensionLayout = new QVBoxLayout( extensionPage, KDialog::marginHintSmall(), 161 Q3VBoxLayout *extensionLayout = new Q3VBoxLayout( extensionPage, KDialog::marginHintSmall(),
158 KDialog::spacingHintSmall() ); 162 KDialog::spacingHintSmall() );
159 163
160 //extensions groupbox 164 //extensions groupbox
161 165
162 QGroupBox* groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), extensionPage ); 166 Q3GroupBox* groupBox = new Q3GroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), extensionPage );
163 boxLayout = new QVBoxLayout( groupBox->layout() ); 167 boxLayout = new Q3VBoxLayout( groupBox->layout() );
164 boxLayout->setAlignment( Qt::AlignTop ); 168 boxLayout->setAlignment( Qt::AlignTop );
165 boxLayout->setMargin(KDialog::marginHintSmall()); 169 boxLayout->setMargin(KDialog::marginHintSmall());
166 boxLayout->setSpacing(KDialog::spacingHintSmall()); 170 boxLayout->setSpacing(KDialog::spacingHintSmall());
167 groupBox->layout()->setMargin(1) ; 171 groupBox->layout()->setMargin(1) ;
168 groupBox->layout()->setSpacing(0); 172 groupBox->layout()->setSpacing(0);
169 mExtensionView = new KListView( groupBox ); 173 mExtensionView = new KListView( groupBox );
170 mExtensionView->setAllColumnsShowFocus( true ); 174 mExtensionView->setAllColumnsShowFocus( true );
171 mExtensionView->addColumn( i18n( "Name" ) ); 175 mExtensionView->addColumn( i18n( "Name" ) );
172 mExtensionView->addColumn( i18n( "Description" ) ); 176 mExtensionView->addColumn( i18n( "Description" ) );
173 //mExtensionView->setMaximumHeight(80); 177 //mExtensionView->setMaximumHeight(80);
174 178
175 boxLayout->addWidget( mExtensionView ); 179 boxLayout->addWidget( mExtensionView );
176 180
177 mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); 181 mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox );
178 mConfigureButton->setEnabled( false ); 182 mConfigureButton->setEnabled( false );
179 boxLayout->addWidget( mConfigureButton ); 183 boxLayout->addWidget( mConfigureButton );
180 184
181 extensionLayout->addWidget( groupBox ); 185 extensionLayout->addWidget( groupBox );
182 186
183 connect( mMenuBarBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 187 connect( mMenuBarBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
184 connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 188 connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
185 connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 189 connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
186 connect( mSearchReturnBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 190 connect( mSearchReturnBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
187 connect( mAutoSearchWithWildcardBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 191 connect( mAutoSearchWithWildcardBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
188 connect( mHideSearchOnSwitchBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 192 connect( mHideSearchOnSwitchBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
189 connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 193 connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
190 connect( mAskForQuit, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 194 connect( mAskForQuit, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
191 connect( mAskForDelete, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 195 connect( mAskForDelete, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
192 connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), 196 connect( mExtensionView, SIGNAL( selectionChanged( Q3ListViewItem* ) ),
193 SLOT( selectionChanged( QListViewItem* ) ) ); 197 SLOT( selectionChanged( Q3ListViewItem* ) ) );
194 connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), 198 connect( mExtensionView, SIGNAL( clicked( Q3ListViewItem* ) ),
195 SLOT( itemClicked( QListViewItem* ) ) ); 199 SLOT( itemClicked( Q3ListViewItem* ) ) );
196 connect( mConfigureButton, SIGNAL( clicked() ), 200 connect( mConfigureButton, SIGNAL( clicked() ),
197 SLOT( configureExtension() ) ); 201 SLOT( configureExtension() ) );
198 202
199 tabWidget->addTab( extensionPage, i18n( "Extensions" ) ); 203 tabWidget->addTab( extensionPage, i18n( "Extensions" ) );
200 204
201 // Addressee page 205 // Addressee page
202 mAddresseeWidget = new AddresseeWidget( this ); 206 mAddresseeWidget = new AddresseeWidget( this );
203 tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); 207 tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) );
204 connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); 208 connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) );
205 209
206} 210}
207 211
208void KABConfigWidget::usrReadConfig() 212void KABConfigWidget::usrReadConfig()
209{ 213{
210 KABPrefs* prefs = KABPrefs::instance(); 214 KABPrefs* prefs = KABPrefs::instance();
211 215
212 bool blocked = signalsBlocked(); 216 bool blocked = signalsBlocked();
213 blockSignals( true ); 217 blockSignals( true );
214 mMenuBarBox->setChecked( prefs->mFullMenuBarVisible); 218 mMenuBarBox->setChecked( prefs->mFullMenuBarVisible);
215 mNameParsing->setChecked( prefs->mAutomaticNameParsing ); 219 mNameParsing->setChecked( prefs->mAutomaticNameParsing );
216 mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick ); 220 mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick );
217 mSearchReturnBox->setChecked( prefs->mSearchWithReturn ); 221 mSearchReturnBox->setChecked( prefs->mSearchWithReturn );
218 mAutoSearchWithWildcardBox->setChecked( prefs->mAutoSearchWithWildcard ); 222 mAutoSearchWithWildcardBox->setChecked( prefs->mAutoSearchWithWildcard );
219 mHideSearchOnSwitchBox->setChecked( prefs->mHideSearchOnSwitch ); 223 mHideSearchOnSwitchBox->setChecked( prefs->mHideSearchOnSwitch );
220 mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce ); 224 mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce );
221 mAskForQuit->setChecked( prefs->mAskForQuit ); 225 mAskForQuit->setChecked( prefs->mAskForQuit );
222 mAskForDelete->setChecked( prefs->mAskForDelete ); 226 mAskForDelete->setChecked( prefs->mAskForDelete );
223 227
224 mAddresseeWidget->restoreSettings(); 228 mAddresseeWidget->restoreSettings();
225 229
226 restoreExtensionSettings(); 230 restoreExtensionSettings();
227 231
228 blockSignals( blocked ); 232 blockSignals( blocked );
229 233
230} 234}
231 235
232void KABConfigWidget::usrWriteConfig() 236void KABConfigWidget::usrWriteConfig()
233{ 237{
234 KABPrefs* prefs = KABPrefs::instance(); 238 KABPrefs* prefs = KABPrefs::instance();
235 prefs->mFullMenuBarVisible = mMenuBarBox->isChecked(); 239 prefs->mFullMenuBarVisible = mMenuBarBox->isChecked();
236 prefs->mAutomaticNameParsing = mNameParsing->isChecked(); 240 prefs->mAutomaticNameParsing = mNameParsing->isChecked();
237 prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked(); 241 prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked();
238 prefs->mSearchWithReturn = mSearchReturnBox->isChecked(); 242 prefs->mSearchWithReturn = mSearchReturnBox->isChecked();
239 prefs->mAutoSearchWithWildcard = mAutoSearchWithWildcardBox->isChecked(); 243 prefs->mAutoSearchWithWildcard = mAutoSearchWithWildcardBox->isChecked();
240 prefs->mHideSearchOnSwitch = mHideSearchOnSwitchBox->isChecked(); 244 prefs->mHideSearchOnSwitch = mHideSearchOnSwitchBox->isChecked();
241 245
242 prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked(); 246 prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked();
243 prefs->mAskForQuit = mAskForQuit->isChecked(); 247 prefs->mAskForQuit = mAskForQuit->isChecked();
244 prefs->mAskForDelete = mAskForDelete->isChecked(); 248 prefs->mAskForDelete = mAskForDelete->isChecked();
245 249
246 mAddresseeWidget->saveSettings(); 250 mAddresseeWidget->saveSettings();
247 251
248 saveExtensionSettings(); 252 saveExtensionSettings();
249 253
250} 254}
251 255
252void KABConfigWidget::restoreExtensionSettings() 256void KABConfigWidget::restoreExtensionSettings()
253{ 257{
254 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; 258 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions;
255 259
256 mExtensionView->clear(); 260 mExtensionView->clear();
257 261
258#ifndef KAB_EMBEDDED 262#ifndef KAB_EMBEDDED
259 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); 263 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" );
260 KTrader::OfferList::ConstIterator it; 264 KTrader::OfferList::ConstIterator it;
261 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 265 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
262 if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) 266 if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) )
263 continue; 267 continue;
264 268
265 ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); 269 ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() );
266 item->setService( *it ); 270 item->setService( *it );
267 if ( activeExtensions.contains( item->factory()->identifier() ) ) 271 if ( activeExtensions.contains( item->factory()->identifier() ) )
268 item->setOn( true ); 272 item->setOn( true );
269 } 273 }
270#else //KAB_EMBEDDED 274#else //KAB_EMBEDDED
271 ExtensionFactory *extensionFactory = new MergeFactory(); 275 ExtensionFactory *extensionFactory = new MergeFactory();
272 276
273 ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); 277 ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts");
274 278
275 item->setFactory( extensionFactory ); 279 item->setFactory( extensionFactory );
276 if ( activeExtensions.contains( extensionFactory->identifier() ) ) 280 if ( activeExtensions.contains( extensionFactory->identifier() ) )
277 item->setOn( true ); 281 item->setOn( true );
278 282
279 283
280 284
281 extensionFactory = new DistributionListFactory(); 285 extensionFactory = new DistributionListFactory();
282 286
283 item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); 287 item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists");
284 288
285 item->setFactory( extensionFactory ); 289 item->setFactory( extensionFactory );
286 if ( activeExtensions.contains( extensionFactory->identifier() ) ) 290 if ( activeExtensions.contains( extensionFactory->identifier() ) )
287 item->setOn( true ); 291 item->setOn( true );
288 292
289 293
290#endif //KAB_EMBEDDED 294#endif //KAB_EMBEDDED
291 295
292} 296}
293 297
294void KABConfigWidget::saveExtensionSettings() 298void KABConfigWidget::saveExtensionSettings()
295{ 299{
296 QStringList activeExtensions; 300 QStringList activeExtensions;
297 301
298 QPtrList<QListViewItem> list; 302 Q3PtrList<Q3ListViewItem> list;
299 QListViewItemIterator it( mExtensionView ); 303 Q3ListViewItemIterator it( mExtensionView );
300 while ( it.current() ) { 304 while ( it.current() ) {
301 ExtensionItem *item = static_cast<ExtensionItem*>( it.current() ); 305 ExtensionItem *item = static_cast<ExtensionItem*>( it.current() );
302 if ( item ) { 306 if ( item ) {
303 if ( item->isOn() ) 307 if ( item->isOn() )
304 activeExtensions.append( item->factory()->identifier() ); 308 activeExtensions.append( item->factory()->identifier() );
305 } 309 }
306 ++it; 310 ++it;
307 } 311 }
308 312
309 KABPrefs::instance()->mActiveExtensions = activeExtensions; 313 KABPrefs::instance()->mActiveExtensions = activeExtensions;
310} 314}
311 315
312void KABConfigWidget::configureExtension() 316void KABConfigWidget::configureExtension()
313{ 317{
314 ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() ); 318 ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() );
315 if ( !item ) 319 if ( !item )
316 return; 320 return;
317 321
318#ifndef KAB_EMBEDDED 322#ifndef KAB_EMBEDDED
319 KConfig config( "kaddressbookrc" ); 323 KConfig config( "kaddressbookrc" );
320#else //KAB_EMBEDDED 324#else //KAB_EMBEDDED
321 KConfig config( locateLocal("config", "kaddressbookrc") ); 325 KConfig config( locateLocal("config", "kaddressbookrc") );
322#endif //KAB_EMBEDDED 326#endif //KAB_EMBEDDED
323 config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) ); 327 config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) );
324 328
325 ExtensionConfigDialog dlg( item->factory(), &config, this ); 329 ExtensionConfigDialog dlg( item->factory(), &config, this );
326 dlg.exec(); 330 dlg.exec();
327 331
328 config.sync(); 332 config.sync();
329} 333}
330 334
331void KABConfigWidget::selectionChanged( QListViewItem *i ) 335void KABConfigWidget::selectionChanged( Q3ListViewItem *i )
332{ 336{
333 ExtensionItem *item = static_cast<ExtensionItem*>( i ); 337 ExtensionItem *item = static_cast<ExtensionItem*>( i );
334 if ( !item ) 338 if ( !item )
335 return; 339 return;
336 340
337 mConfigureButton->setEnabled( item->configWidgetAvailable() ); 341 mConfigureButton->setEnabled( item->configWidgetAvailable() );
338} 342}
339 343
340void KABConfigWidget::itemClicked( QListViewItem *item ) 344void KABConfigWidget::itemClicked( Q3ListViewItem *item )
341{ 345{
342 if ( item != 0 ) 346 if ( item != 0 )
343 modified(); 347 modified();
344} 348}
345 349
346#ifndef KAB_EMBEDDED 350#ifndef KAB_EMBEDDED
347ExtensionItem::ExtensionItem( QListView *parent, const QString &text ) 351ExtensionItem::ExtensionItem( Q3ListView *parent, const QString &text )
348 : QCheckListItem( parent, text, CheckBox ) 352 : Q3CheckListItem( parent, text, CheckBox )
349{ 353{
350} 354}
351 355
352void ExtensionItem::setService( const KService::Ptr &ptr ) 356void ExtensionItem::setService( const KService::Ptr &ptr )
353{ 357{
354 mPtr = ptr; 358 mPtr = ptr;
355} 359}
356#else //KAB_EMBEDDED 360#else //KAB_EMBEDDED
357ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ) 361ExtensionItem::ExtensionItem( Q3ListView *parent, const QString &text, const QString &name, const QString &comment )
358 : QCheckListItem( parent, text, CheckBox ) 362 : Q3CheckListItem( parent, text, CheckBox )
359{ 363{
360 mName = name; 364 mName = name;
361 mComment = comment; 365 mComment = comment;
362} 366}
363 367
364 368
365void ExtensionItem::setFactory( ExtensionFactory* fac ) 369void ExtensionItem::setFactory( ExtensionFactory* fac )
366{ 370{
367 mFactory = fac; 371 mFactory = fac;
368} 372}
369#endif //KAB_EMBEDDED 373#endif //KAB_EMBEDDED
370 374
371bool ExtensionItem::configWidgetAvailable() const 375bool ExtensionItem::configWidgetAvailable() const
372{ 376{
373#ifndef KAB_EMBEDDED 377#ifndef KAB_EMBEDDED
374 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); 378 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() );
375 if ( !factory ) 379 if ( !factory )
376 return false; 380 return false;
377 381
378 ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory ); 382 ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory );
379 if ( !extensionFactory ) 383 if ( !extensionFactory )
380 return false; 384 return false;
381 385
382 return extensionFactory->configureWidgetAvailable(); 386 return extensionFactory->configureWidgetAvailable();
383#else //KAB_EMBEDDED 387#else //KAB_EMBEDDED
384 return mFactory->configureWidgetAvailable(); 388 return mFactory->configureWidgetAvailable();
385#endif //KAB_EMBEDDED 389#endif //KAB_EMBEDDED
386 390
387} 391}
388 392
389ExtensionFactory *ExtensionItem::factory() const 393ExtensionFactory *ExtensionItem::factory() const
390{ 394{
391#ifndef KAB_EMBEDDED 395#ifndef KAB_EMBEDDED
392 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); 396 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() );
393 if ( !factory ) 397 if ( !factory )
394 return 0; 398 return 0;
395 399
396 return static_cast<ExtensionFactory*>( factory ); 400 return static_cast<ExtensionFactory*>( factory );
397#else //KAB_EMBEDDED 401#else //KAB_EMBEDDED
398 return mFactory; 402 return mFactory;
399#endif //KAB_EMBEDDED 403#endif //KAB_EMBEDDED
400} 404}
401 405
402QString ExtensionItem::text( int column ) const 406QString ExtensionItem::text( int column ) const
403{ 407{
404#ifndef KAB_EMBEDDED 408#ifndef KAB_EMBEDDED
405 if ( column == 0 ) 409 if ( column == 0 )
406 return mPtr->name(); 410 return mPtr->name();
407 else if ( column == 1 ) 411 else if ( column == 1 )
408 return mPtr->comment(); 412 return mPtr->comment();
409 else 413 else
410 return QString::null; 414 return QString::null;
411#else //KAB_EMBEDDED 415#else //KAB_EMBEDDED
412 if ( column == 0 ) 416 if ( column == 0 )
413 return mName; 417 return mName;
414 else if ( column == 1 ) 418 else if ( column == 1 )
415 return mComment; 419 return mComment;
416 else 420 else
417 return QString::null; 421 return QString::null;
418#endif //KAB_EMBEDDED 422#endif //KAB_EMBEDDED
419} 423}
420 424
421#ifndef KAB_EMBEDDED 425#ifndef KAB_EMBEDDED_
422#include "kabconfigwidget.moc" 426#include "moc_kabconfigwidget.cpp"
423#endif //KAB_EMBEDDED 427#endif //KAB_EMBEDDED
424
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.h b/kaddressbook/kcmconfigs/kabconfigwidget.h
index f2a6b1b..4b6e58c 100644
--- a/kaddressbook/kcmconfigs/kabconfigwidget.h
+++ b/kaddressbook/kcmconfigs/kabconfigwidget.h
@@ -1,78 +1,78 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 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#ifndef KABCONFIGWIDGET_H 24#ifndef KABCONFIGWIDGET_H
25#define KABCONFIGWIDGET_H 25#define KABCONFIGWIDGET_H
26 26
27#include <kprefswidget.h> 27#include <kprefswidget.h>
28 28
29class QCheckBox; 29class QCheckBox;
30class QListViewItem; 30class Q3ListViewItem;
31class QPushButton; 31class QPushButton;
32class QComboBox; 32class QComboBox;
33class QLineEdit; 33class QLineEdit;
34class KListView; 34class KListView;
35class KABPrefs; 35class KABPrefs;
36 36
37class AddresseeWidget; 37class AddresseeWidget;
38 38
39class KABConfigWidget : public KPrefsWidget 39class KABConfigWidget : public KPrefsWidget
40{ 40{
41 Q_OBJECT 41 Q_OBJECT
42 42
43 public: 43 public:
44 KABConfigWidget(KABPrefs *prefs, QWidget *parent, const char *name = 0 ); 44 KABConfigWidget(KABPrefs *prefs, QWidget *parent, const char *name = 0 );
45 45
46 protected: 46 protected:
47 /** Implement this to read custom configuration widgets. */ 47 /** Implement this to read custom configuration widgets. */
48 virtual void usrReadConfig(); 48 virtual void usrReadConfig();
49 /** Implement this to write custom configuration widgets. */ 49 /** Implement this to write custom configuration widgets. */
50 virtual void usrWriteConfig(); 50 virtual void usrWriteConfig();
51 51
52 52
53 53
54 private slots: 54 private slots:
55 void configureExtension(); 55 void configureExtension();
56 void selectionChanged( QListViewItem* ); 56 void selectionChanged( Q3ListViewItem* );
57 void itemClicked( QListViewItem* ); 57 void itemClicked( Q3ListViewItem* );
58 58
59 private: 59 private:
60 void restoreExtensionSettings(); 60 void restoreExtensionSettings();
61 void saveExtensionSettings(); 61 void saveExtensionSettings();
62 62
63 KListView *mExtensionView; 63 KListView *mExtensionView;
64 QCheckBox *mSearchReturnBox; 64 QCheckBox *mSearchReturnBox;
65 QCheckBox *mNameParsing; 65 QCheckBox *mNameParsing;
66 QCheckBox *mViewsSingleClickBox; 66 QCheckBox *mViewsSingleClickBox;
67 QCheckBox *mAutoSearchWithWildcardBox; 67 QCheckBox *mAutoSearchWithWildcardBox;
68 QCheckBox *mHideSearchOnSwitchBox; 68 QCheckBox *mHideSearchOnSwitchBox;
69 QCheckBox *mMultipleViewsAtOnce; 69 QCheckBox *mMultipleViewsAtOnce;
70 QCheckBox *mAskForQuit; 70 QCheckBox *mAskForQuit;
71 QCheckBox *mMenuBarBox; 71 QCheckBox *mMenuBarBox;
72 QCheckBox *mAskForDelete; 72 QCheckBox *mAskForDelete;
73 QPushButton *mConfigureButton; 73 QPushButton *mConfigureButton;
74 74
75 AddresseeWidget *mAddresseeWidget; 75 AddresseeWidget *mAddresseeWidget;
76}; 76};
77 77
78#endif 78#endif
diff --git a/kaddressbook/kcmconfigs/kcmkabconfig.cpp b/kaddressbook/kcmconfigs/kcmkabconfig.cpp
index cbfedbd..55ffcd8 100644
--- a/kaddressbook/kcmconfigs/kcmkabconfig.cpp
+++ b/kaddressbook/kcmconfigs/kcmkabconfig.cpp
@@ -1,92 +1,94 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 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 <qlayout.h> 24#include <qlayout.h>
25//Added by qt3to4:
26#include <Q3VBoxLayout>
25 27
26#ifndef KAB_EMBEDDED 28#ifndef KAB_EMBEDDED
27#include <kaboutdata.h> 29#include <kaboutdata.h>
28#endif //KAB_EMBEDDED 30#endif //KAB_EMBEDDED
29#include <kdebug.h> 31#include <kdebug.h>
30//#include <klocale.h> 32//#include <klocale.h>
31//#include <stdlib.h> 33//#include <stdlib.h>
32 34
33#include "kabconfigwidget.h" 35#include "kabconfigwidget.h"
34 36
35#include "kcmkabconfig.h" 37#include "kcmkabconfig.h"
36 38
37#include "kabprefs.h" 39#include "kabprefs.h"
38#include "kprefs.h" 40#include "kprefs.h"
39 41
40extern "C" 42extern "C"
41{ 43{
42 KCModule *create_kabconfig( QWidget *parent, const char * ) { 44 KCModule *create_kabconfig( QWidget *parent, const char * ) {
43 return new KCMKabConfig( parent, "kcmkabconfig" ); 45 return new KCMKabConfig( parent, "kcmkabconfig" );
44 } 46 }
45} 47}
46 48
47KCMKabConfig::KCMKabConfig( QWidget *parent, const char *name ) 49KCMKabConfig::KCMKabConfig( QWidget *parent, const char *name )
48 : KCModule( KABPrefs::instance(), parent, name ) 50 : KCModule( KABPrefs::instance(), parent, name )
49{ 51{
50 //abort(); 52 //abort();
51 QVBoxLayout *layout = new QVBoxLayout( this ); 53 Q3VBoxLayout *layout = new Q3VBoxLayout( this );
52 mConfigWidget = new KABConfigWidget( (KABPrefs*)getPreferences(), this, "KABConfigWidget" ); 54 mConfigWidget = new KABConfigWidget( (KABPrefs*)getPreferences(), this, "KABConfigWidget" );
53 layout->addWidget( mConfigWidget ); 55 layout->addWidget( mConfigWidget );
54 layout->setSpacing( 0 ); 56 layout->setSpacing( 0 );
55 layout->setMargin( 0 ); 57 layout->setMargin( 0 );
56 58
57 connect( mConfigWidget, SIGNAL( changed( bool ) ), SIGNAL( changed( bool ) ) ); 59 connect( mConfigWidget, SIGNAL( changed( bool ) ), SIGNAL( changed( bool ) ) );
58} 60}
59 61
60void KCMKabConfig::load() 62void KCMKabConfig::load()
61{ 63{
62 mConfigWidget->readConfig(); 64 mConfigWidget->readConfig();
63} 65}
64 66
65void KCMKabConfig::save() 67void KCMKabConfig::save()
66{ 68{
67 mConfigWidget->writeConfig(); 69 mConfigWidget->writeConfig();
68} 70}
69 71
70void KCMKabConfig::defaults() 72void KCMKabConfig::defaults()
71{ 73{
72 mConfigWidget->setDefaults(); 74 mConfigWidget->setDefaults();
73} 75}
74 76
75#ifndef KAB_EMBEDDED 77#ifndef KAB_EMBEDDED
76const KAboutData* KCMKabConfig::aboutData() const 78const KAboutData* KCMKabConfig::aboutData() const
77{ 79{
78 KAboutData *about = new KAboutData( I18N_NOOP( "kcmkabconfig" ), 80 KAboutData *about = new KAboutData( I18N_NOOP( "kcmkabconfig" ),
79 I18N_NOOP( "KAddressBook Configure Dialog" ), 81 I18N_NOOP( "KAddressBook Configure Dialog" ),
80 0, 0, KAboutData::License_GPL, 82 0, 0, KAboutData::License_GPL,
81 I18N_NOOP( "(c), 2003 Tobias Koenig" ) ); 83 I18N_NOOP( "(c), 2003 Tobias Koenig" ) );
82 84
83 about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" ); 85 about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" );
84 86
85 return about; 87 return about;
86 88
87} 89}
88#endif //KAB_EMBEDDED 90#endif //KAB_EMBEDDED
89 91
90#ifndef KAB_EMBEDDED 92#ifndef KAB_EMBEDDED_
91#include "kcmkabconfig.moc" 93#include "moc_kcmkabconfig.cpp"
92#endif //KAB_EMBEDDED 94#endif //KAB_EMBEDDED
diff --git a/kaddressbook/keywidget.cpp b/kaddressbook/keywidget.cpp
index c117d34..8ebee19 100644
--- a/kaddressbook/keywidget.cpp
+++ b/kaddressbook/keywidget.cpp
@@ -1,277 +1,279 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 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 <qfile.h> 24#include <qfile.h>
25 25
26#include <qinputdialog.h> 26#include <qinputdialog.h>
27 27
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31//Added by qt3to4:
32#include <Q3GridLayout>
31 33
32#ifndef KAB_EMBEDDED 34#ifndef KAB_EMBEDDED
33#include <kaccelmanager.h> 35#include <kaccelmanager.h>
34#include <kio/netaccess.h> 36#include <kio/netaccess.h>
35#include <kmessagebox.h> 37#include <kmessagebox.h>
36#else //KAB_EMBEDDED 38#else //KAB_EMBEDDED
37#include <qmap.h> 39#include <qmap.h>
38#include <qmessagebox.h> 40#include <qmessagebox.h>
39#include <qtextstream.h> 41#include <q3textstream.h>
40#include <kurl.h> 42#include <kurl.h>
41#endif //KAB_EMBEDDED 43#endif //KAB_EMBEDDED
42 44
43#include <kapplication.h> 45#include <kapplication.h>
44#include <kcombobox.h> 46#include <kcombobox.h>
45#include <kdialog.h> 47#include <kdialog.h>
46#include <kfiledialog.h> 48#include <kfiledialog.h>
47#include <klocale.h> 49#include <klocale.h>
48#include <ktempfile.h> 50#include <ktempfile.h>
49 51
50#include "keywidget.h" 52#include "keywidget.h"
51 53
52KeyWidget::KeyWidget( QWidget *parent, const char *name ) 54KeyWidget::KeyWidget( QWidget *parent, const char *name )
53 : QWidget( parent, name ) 55 : QWidget( parent, name )
54{ 56{
55 QGridLayout *layout = new QGridLayout( this, 2, 2, KDialog::marginHint(), 57 Q3GridLayout *layout = new Q3GridLayout( this, 2, 2, KDialog::marginHint(),
56 KDialog::spacingHint() ); 58 KDialog::spacingHint() );
57 59
58 QLabel *label = new QLabel( i18n( "Keys:" ), this ); 60 QLabel *label = new QLabel( i18n( "Keys:" ), this );
59 layout->addWidget( label, 0, 0 ); 61 layout->addWidget( label, 0, 0 );
60 62
61 mKeyCombo = new KComboBox( this ); 63 mKeyCombo = new KComboBox( this );
62 layout->addWidget( mKeyCombo, 0, 1 ); 64 layout->addWidget( mKeyCombo, 0, 1 );
63 65
64 mAddButton = new QPushButton( i18n( "Add" ), this ); 66 mAddButton = new QPushButton( i18n( "Add" ), this );
65 layout->addWidget( mAddButton, 1, 0 ); 67 layout->addWidget( mAddButton, 1, 0 );
66 68
67 mRemoveButton = new QPushButton( i18n( "Remove" ), this ); 69 mRemoveButton = new QPushButton( i18n( "Remove" ), this );
68 mRemoveButton->setEnabled( false ); 70 mRemoveButton->setEnabled( false );
69 layout->addWidget( mRemoveButton, 1, 1 ); 71 layout->addWidget( mRemoveButton, 1, 1 );
70 72
71 mExportButton = new QPushButton( i18n( "Export" ), this ); 73 mExportButton = new QPushButton( i18n( "Export" ), this );
72 mExportButton->setEnabled( false ); 74 mExportButton->setEnabled( false );
73 layout->addMultiCellWidget( mExportButton, 2, 2, 0, 1 ); 75 layout->addMultiCellWidget( mExportButton, 2, 2, 0, 1 );
74 76
75 connect( mAddButton, SIGNAL( clicked() ), SLOT( addKey() ) ); 77 connect( mAddButton, SIGNAL( clicked() ), SLOT( addKey() ) );
76 connect( mRemoveButton, SIGNAL( clicked() ), SLOT( removeKey() ) ); 78 connect( mRemoveButton, SIGNAL( clicked() ), SLOT( removeKey() ) );
77 connect( mExportButton, SIGNAL( clicked() ), SLOT( exportKey() ) ); 79 connect( mExportButton, SIGNAL( clicked() ), SLOT( exportKey() ) );
78} 80}
79 81
80KeyWidget::~KeyWidget() 82KeyWidget::~KeyWidget()
81{ 83{
82} 84}
83 85
84void KeyWidget::setKeys( const KABC::Key::List &list ) 86void KeyWidget::setKeys( const KABC::Key::List &list )
85{ 87{
86 mKeyList = list; 88 mKeyList = list;
87 89
88 updateKeyCombo(); 90 updateKeyCombo();
89} 91}
90 92
91KABC::Key::List KeyWidget::keys() const 93KABC::Key::List KeyWidget::keys() const
92{ 94{
93 return mKeyList; 95 return mKeyList;
94} 96}
95 97
96void KeyWidget::addKey() 98void KeyWidget::addKey()
97{ 99{
98 QMap<QString, int> keyMap; 100 QMap<QString, int> keyMap;
99 QStringList keyTypeNames; 101 QStringList keyTypeNames;
100 QStringList existingKeyTypes; 102 QStringList existingKeyTypes;
101 103
102 KABC::Key::List::Iterator listIt; 104 KABC::Key::List::Iterator listIt;
103 for ( listIt = mKeyList.begin(); listIt != mKeyList.end(); ++listIt ) { 105 for ( listIt = mKeyList.begin(); listIt != mKeyList.end(); ++listIt ) {
104 if ( (*listIt).type() != KABC::Key::Custom ) 106 if ( (*listIt).type() != KABC::Key::Custom )
105 existingKeyTypes.append( KABC::Key::typeLabel( (*listIt).type() ) ); 107 existingKeyTypes.append( KABC::Key::typeLabel( (*listIt).type() ) );
106 } 108 }
107 109
108 KABC::Key::TypeList typeList = KABC::Key::typeList(); 110 KABC::Key::TypeList typeList = KABC::Key::typeList();
109 KABC::Key::TypeList::Iterator it; 111 KABC::Key::TypeList::Iterator it;
110 for ( it = typeList.begin(); it != typeList.end(); ++it ) { 112 for ( it = typeList.begin(); it != typeList.end(); ++it ) {
111 if ( (*it) != KABC::Key::Custom && 113 if ( (*it) != KABC::Key::Custom &&
112 !existingKeyTypes.contains( KABC::Key::typeLabel( *it ) ) ) { 114 !existingKeyTypes.contains( KABC::Key::typeLabel( *it ) ) ) {
113 keyMap.insert( KABC::Key::typeLabel( *it ), *it ); 115 keyMap.insert( KABC::Key::typeLabel( *it ), *it );
114 keyTypeNames.append( KABC::Key::typeLabel( *it ) ); 116 keyTypeNames.append( KABC::Key::typeLabel( *it ) );
115 } 117 }
116 } 118 }
117 119
118 bool ok; 120 bool ok;
119 QString name = QInputDialog::getItem( i18n( "Key type" ), i18n( "Select the key type." ), keyTypeNames, 0, true, &ok ); 121 QString name = QInputDialog::getItem( i18n( "Key type" ), i18n( "Select the key type." ), keyTypeNames, 0, true, &ok );
120 122
121 123
122 124
123 if ( !ok || name.isEmpty() ) 125 if ( !ok || name.isEmpty() )
124 return; 126 return;
125 127
126 int type = keyMap[ name ]; 128 int type = keyMap[ name ];
127 if ( !keyTypeNames.contains( name ) ) 129 if ( !keyTypeNames.contains( name ) )
128 type = KABC::Key::Custom; 130 type = KABC::Key::Custom;
129 131
130#ifndef KAB_EMBEDDED 132#ifndef KAB_EMBEDDED
131 KURL url = KFileDialog::getOpenURL(); 133 KURL url = KFileDialog::getOpenURL();
132 134
133 if ( url.isEmpty() ) 135 if ( url.isEmpty() )
134 return; 136 return;
135 137
136 QString tmpFile; 138 QString tmpFile;
137 if ( KIO::NetAccess::download( url, tmpFile ) ) { 139 if ( KIO::NetAccess::download( url, tmpFile ) ) {
138 QFile file( tmpFile ); 140 QFile file( tmpFile );
139 if ( !file.open( IO_ReadOnly ) ) { 141 if ( !file.open( QIODevice::ReadOnly ) ) {
140 QString text( i18n( "<qt>Unable to open file <b>%1</b>.</qt>" ) ); 142 QString text( i18n( "<qt>Unable to open file <b>%1</b>.</qt>" ) );
141 KMessageBox::error( this, text.arg( url.url() ) ); 143 KMessageBox::error( this, text.arg( url.url() ) );
142 return; 144 return;
143 } 145 }
144 146
145 147
146#else //KAB_EMBEDDED 148#else //KAB_EMBEDDED
147 QString keyfile = KFileDialog::getOpenFileName( "huhu", 149 QString keyfile = KFileDialog::getOpenFileName( "huhu",
148 "Select Key", this ); 150 "Select Key", this );
149 151
150 if ( keyfile.isEmpty() ) 152 if ( keyfile.isEmpty() )
151 return; 153 return;
152 154
153 { 155 {
154 QFile file( keyfile ); 156 QFile file( keyfile );
155 if ( !file.open( IO_ReadOnly ) ) { 157 if ( !file.open( QIODevice::ReadOnly ) ) {
156 QString text( i18n( "<qt>Unable to open file <b>%1</b>.</qt>" ) ); 158 QString text( i18n( "<qt>Unable to open file <b>%1</b>.</qt>" ) );
157 QString caption( i18n( "Error" ) ); 159 QString caption( i18n( "Error" ) );
158 QMessageBox::critical( this, caption, text.arg( keyfile ) ); 160 QMessageBox::critical( this, caption, text.arg( keyfile ) );
159 return; 161 return;
160 } 162 }
161 163
162#endif //KAB_EMBEDDED 164#endif //KAB_EMBEDDED
163 165
164 166
165 167
166 QTextStream s( &file ); 168 Q3TextStream s( &file );
167 QString data; 169 QString data;
168 170
169 s.setEncoding( QTextStream::UnicodeUTF8 ); 171 s.setEncoding( Q3TextStream::UnicodeUTF8 );
170 s >> data; 172 s >> data;
171 file.close(); 173 file.close();
172 174
173 KABC::Key key( data, type ); 175 KABC::Key key( data, type );
174 if ( type == KABC::Key::Custom ) 176 if ( type == KABC::Key::Custom )
175 key.setCustomTypeString( name ); 177 key.setCustomTypeString( name );
176 mKeyList.append( key ); 178 mKeyList.append( key );
177 179
178 emit changed(); 180 emit changed();
179 181
180#ifndef KAB_EMBEDDED 182#ifndef KAB_EMBEDDED
181 KIO::NetAccess::removeTempFile( tmpFile ); 183 KIO::NetAccess::removeTempFile( tmpFile );
182#endif //KAB_EMBEDDED 184#endif //KAB_EMBEDDED
183 185
184 } 186 }
185 187
186 updateKeyCombo(); 188 updateKeyCombo();
187} 189}
188 190
189void KeyWidget::removeKey() 191void KeyWidget::removeKey()
190{ 192{
191 int pos = mKeyCombo->currentItem(); 193 int pos = mKeyCombo->currentItem();
192 if ( pos == -1 ) 194 if ( pos == -1 )
193 return; 195 return;
194 196
195 QString type = mKeyCombo->currentText(); 197 QString type = mKeyCombo->currentText();
196 QString text = i18n( "<qt>Do you really want to remove the key <b>%1</b>?</qt>" ); 198 QString text = i18n( "<qt>Do you really want to remove the key <b>%1</b>?</qt>" );
197 199
198 200
199#ifndef KAB_EMBEDDED 201#ifndef KAB_EMBEDDED
200 if ( KMessageBox::questionYesNo( this, text.arg( type ) ) == KMessageBox::No ) 202 if ( KMessageBox::questionYesNo( this, text.arg( type ) ) == KMessageBox::No )
201 return; 203 return;
202#else //KAB_EMBEDDED 204#else //KAB_EMBEDDED
203 QString caption = i18n( "Confirm Delete" ); 205 QString caption = i18n( "Confirm Delete" );
204 if (QMessageBox::information( this, caption, 206 if (QMessageBox::information( this, caption,
205 text.arg( type ), 207 text.arg( type ),
206 i18n("Yes!"), i18n("No"), 0, 0 ) == 1) 208 i18n("Yes!"), i18n("No"), 0, 0 ) == 1)
207 return; 209 return;
208#endif //KAB_EMBEDDED 210#endif //KAB_EMBEDDED
209 211
210 mKeyList.remove( mKeyList.at( pos ) ); 212 mKeyList.remove( mKeyList.at( pos ) );
211 emit changed(); 213 emit changed();
212 214
213 updateKeyCombo(); 215 updateKeyCombo();
214} 216}
215 217
216void KeyWidget::exportKey() 218void KeyWidget::exportKey()
217{ 219{
218 KABC::Key key = (*mKeyList.at( mKeyCombo->currentItem() ) ); 220 KABC::Key key = (*mKeyList.at( mKeyCombo->currentItem() ) );
219 221
220#ifndef KAB_EMBEDDED 222#ifndef KAB_EMBEDDED
221 KURL url = KFileDialog::getSaveURL(); 223 KURL url = KFileDialog::getSaveURL();
222 224
223 KTempFile tempFile; 225 KTempFile tempFile;
224 QTextStream *s = tempFile.textStream(); 226 Q3TextStream *s = tempFile.textStream();
225 s->setEncoding( QTextStream::UnicodeUTF8 ); 227 s->setEncoding( Q3TextStream::UnicodeUTF8 );
226 (*s) << key.textData(); 228 (*s) << key.textData();
227 tempFile.close(); 229 tempFile.close();
228 230
229 KIO::NetAccess::upload( tempFile.name(), url, kapp->mainWidget() ); 231 KIO::NetAccess::upload( tempFile.name(), url, kapp->mainWidget() );
230#else //KAB_EMBEDDED 232#else //KAB_EMBEDDED
231 QString keyfile = KFileDialog::getSaveFileName( "huhu", 233 QString keyfile = KFileDialog::getSaveFileName( "huhu",
232 "Save Key", this ); 234 "Save Key", this );
233 235
234 if ( keyfile.isEmpty() ) 236 if ( keyfile.isEmpty() )
235 return; 237 return;
236 238
237 QFile file( keyfile ); 239 QFile file( keyfile );
238 if ( !file.open( IO_ReadWrite ) ) { 240 if ( !file.open( QIODevice::ReadWrite ) ) {
239 QString text( i18n( "<qt>Unable to open file <b>%1</b>.</qt>" ) ); 241 QString text( i18n( "<qt>Unable to open file <b>%1</b>.</qt>" ) );
240 QString caption( i18n( "Error" ) ); 242 QString caption( i18n( "Error" ) );
241 QMessageBox::critical( this, caption, text.arg( keyfile ) ); 243 QMessageBox::critical( this, caption, text.arg( keyfile ) );
242 return; 244 return;
243 } 245 }
244 246
245 QTextStream s( &file ); 247 Q3TextStream s( &file );
246 s.setEncoding( QTextStream::UnicodeUTF8 ); 248 s.setEncoding( Q3TextStream::UnicodeUTF8 );
247 s << key.textData(); 249 s << key.textData();
248 file.close(); 250 file.close();
249 251
250 252
251#endif //KAB_EMBEDDED 253#endif //KAB_EMBEDDED
252 254
253} 255}
254 256
255void KeyWidget::updateKeyCombo() 257void KeyWidget::updateKeyCombo()
256{ 258{
257 int pos = mKeyCombo->currentItem(); 259 int pos = mKeyCombo->currentItem();
258 mKeyCombo->clear(); 260 mKeyCombo->clear();
259 261
260 KABC::Key::List::Iterator it; 262 KABC::Key::List::Iterator it;
261 for ( it = mKeyList.begin(); it != mKeyList.end(); ++it ) { 263 for ( it = mKeyList.begin(); it != mKeyList.end(); ++it ) {
262 if ( (*it).type() == KABC::Key::Custom ) 264 if ( (*it).type() == KABC::Key::Custom )
263 mKeyCombo->insertItem( (*it).customTypeString() ); 265 mKeyCombo->insertItem( (*it).customTypeString() );
264 else 266 else
265 mKeyCombo->insertItem( KABC::Key::typeLabel( (*it).type() ) ); 267 mKeyCombo->insertItem( KABC::Key::typeLabel( (*it).type() ) );
266 } 268 }
267 269
268 mKeyCombo->setCurrentItem( pos ); 270 mKeyCombo->setCurrentItem( pos );
269 271
270 bool state = ( mKeyList.count() != 0 ); 272 bool state = ( mKeyList.count() != 0 );
271 mRemoveButton->setEnabled( state ); 273 mRemoveButton->setEnabled( state );
272 mExportButton->setEnabled( state ); 274 mExportButton->setEnabled( state );
273} 275}
274 276
275#ifndef KAB_EMBEDDED 277#ifndef KAB_EMBEDDED_
276#include "keywidget.moc" 278#include "moc_keywidget.cpp"
277#endif //KAB_EMBEDDED 279#endif //KAB_EMBEDDED
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp
index 2f3531d..e373105 100644
--- a/kaddressbook/mainembedded.cpp
+++ b/kaddressbook/mainembedded.cpp
@@ -1,119 +1,118 @@
1#ifndef DESKTOP_VERSION 1#ifndef DESKTOP_VERSION
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include <qcopchannel_qws.h> 3#include <qcopchannel_qws.h>
4#include <stdlib.h> 4#include <stdlib.h>
5#else 5#else
6#include <qapplication.h> 6#include <qapplication.h>
7#include <qwindowsstyle.h> 7#include <qwindowsstyle.h>
8#include <qplatinumstyle.h> 8#include <q3mainwindow.h>
9#include <qmainwindow.h>
10#include <qmessagebox.h> 9#include <qmessagebox.h>
11#include <stdlib.h> 10#include <stdlib.h>
12#endif 11#endif
13 12
14#include <qtextcodec.h> 13#include <qtextcodec.h>
15#include <kstandarddirs.h> 14#include <kstandarddirs.h>
16#include <qregexp.h> 15#include <qregexp.h>
17#include <kglobal.h> 16#include <kglobal.h>
18#include <stdio.h> 17#include <stdio.h>
19#include <qdir.h> 18#include <qdir.h>
20#include "kabprefs.h" 19#include "kabprefs.h"
21#include "kaddressbookmain.h" 20#include "kaddressbookmain.h"
22#include "externalapphandler.h" 21#include "externalapphandler.h"
23#include <libkdepim/kpimglobalprefs.h> 22#include <libkdepim/kpimglobalprefs.h>
24void dumpMissing(); 23void dumpMissing();
25int main( int argc, char **argv ) 24int main( int argc, char **argv )
26{ 25{
26 if(!getenv("QPEDIR")) putenv("QPEDIR=/usr/lib/kdepimpi");
27#ifndef DESKTOP_VERSION 27#ifndef DESKTOP_VERSION
28 QPEApplication a( argc, argv ); 28 QPEApplication a( argc, argv );
29 a.setKeepRunning (); 29 a.setKeepRunning ();
30#else 30#else
31 QApplication a( argc, argv ); 31 QApplication a( argc, argv );
32 QApplication::setStyle( new QPlatinumStyle ());
33#ifdef _WIN32_ 32#ifdef _WIN32_
34 QString hdir ( getenv( "HOME") ); 33 QString hdir ( getenv( "HOME") );
35 if ( hdir.isEmpty() ) { 34 if ( hdir.isEmpty() ) {
36 QString hd ("C:/" ); 35 QString hd ("C:/" );
37 //QMessageBox::information(0,"hh",QDir::homeDirPath()+" xx" +hd ); 36 //QMessageBox::information(0,"hh",QDir::homeDirPath()+" xx" +hd );
38 if ( QDir::homeDirPath().lower() == hd.lower() ) { 37 if ( QDir::homeDirPath().lower() == hd.lower() ) {
39 _putenv( "HOME=C:"); 38 _putenv( "HOME=C:");
40 //QMessageBox::information(0,"hh",QString ( getenv( "HOME") ) ); 39 //QMessageBox::information(0,"hh",QString ( getenv( "HOME") ) );
41 } 40 }
42 } else { 41 } else {
43 QDir app_dir; 42 QDir app_dir;
44 if ( !app_dir.exists(hdir) ) 43 if ( !app_dir.exists(hdir) )
45 app_dir.mkdir (hdir); 44 app_dir.mkdir (hdir);
46 } 45 }
47#endif 46#endif
48#endif 47#endif
49 48
50 bool exitHelp = false; 49 bool exitHelp = false;
51 if ( argc > 1 ) { 50 if ( argc > 1 ) {
52 QString command = argv[1]; 51 QString command = argv[1];
53 if ( command == "-help" ){ 52 if ( command == "-help" ){
54 printf("KA/E command line commands:\n"); 53 printf("KA/E command line commands:\n");
55 printf(" no command: Start KA/E in usual way\n"); 54 printf(" no command: Start KA/E in usual way\n");
56 printf(" -help: This output\n"); 55 printf(" -help: This output\n");
57 printf(" KA/E is exiting now. Bye!\n"); 56 printf(" KA/E is exiting now. Bye!\n");
58 exitHelp = true; 57 exitHelp = true;
59 } 58 }
60 } 59 }
61 if ( ! exitHelp ) { 60 if ( ! exitHelp ) {
62 61
63 KGlobal::setAppName( "kaddressbook" ); 62 KGlobal::setAppName( "kaddressbook" );
64#ifndef DESKTOP_VERSION 63#ifndef DESKTOP_VERSION
65 if ( QApplication::desktop()->width() > 320 ) 64 if ( QApplication::desktop()->width() > 320 )
66 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); 65 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/");
67 else 66 else
68 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); 67 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/");
69#else 68#else
70 QString fileName ; 69 QString fileName ;
71 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; 70 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/";
72 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 71 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
73 QApplication::addLibraryPath ( qApp->applicationDirPath () ); 72 QApplication::addLibraryPath ( qApp->applicationDirPath () );
74 73
75#endif 74#endif
76 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); 75 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook")));
77 // init language 76 // init language
78 KPimGlobalPrefs::instance()->setGlobalConfig(); 77 KPimGlobalPrefs::instance()->setGlobalConfig();
79 QApplication::setFont( KPimGlobalPrefs::instance()->mApplicationFont ); 78 QApplication::setFont( KPimGlobalPrefs::instance()->mApplicationFont );
80 KAddressBookMain m ; 79 KAddressBookMain m ;
81//US MainWindow m; 80//US MainWindow m;
82 81
83 82
84 83
85#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
86 a.showMainWidget( &m ); 85 a.showMainWidget( &m );
87 86
88#else 87#else
89 a.setMainWidget( &m ); 88 a.setMainWidget( &m );
90 m.show(); 89 m.show();
91#endif 90#endif
92 m.setCaption(i18n("Loading addressbook data ... please wait" )); 91 m.setCaption(i18n("Loading addressbook data ... please wait" ));
93 a.exec(); 92 a.exec();
94#ifdef DESKTOP_VERSION 93#ifdef DESKTOP_VERSION
95 KConfig *config = KABPrefs::instance()->getConfig(); 94 KConfig *config = KABPrefs::instance()->getConfig();
96 config->setGroup("WidgetLayout"); 95 config->setGroup("WidgetLayout");
97 QStringList list ;//= config->readListEntry("MainLayout"); 96 QStringList list ;//= config->readListEntry("MainLayout");
98 int x,y,w,h; 97 int x,y,w,h;
99 QWidget* wid; 98 QWidget* wid;
100 wid = &m; 99 wid = &m;
101 x = wid->geometry().x(); 100 x = wid->geometry().x();
102 y = wid->geometry().y(); 101 y = wid->geometry().y();
103 w = wid->width(); 102 w = wid->width();
104 h = wid->height(); 103 h = wid->height();
105 list.clear(); 104 list.clear();
106 list << QString::number( x ); 105 list << QString::number( x );
107 list << QString::number( y ); 106 list << QString::number( y );
108 list << QString::number( w ); 107 list << QString::number( w );
109 list << QString::number( h ); 108 list << QString::number( h );
110 config->writeEntry("MainLayout",list ); 109 config->writeEntry("MainLayout",list );
111 config->sync(); 110 config->sync();
112#endif 111#endif
113 dumpMissing(); 112 dumpMissing();
114 113
115 KPimGlobalPrefs::instance()->writeConfig(); 114 KPimGlobalPrefs::instance()->writeConfig();
116 } 115 }
117 qDebug("KA: Bye! "); 116 qDebug("KA: Bye! ");
118} 117}
119 118
diff --git a/kaddressbook/nameeditdialog.cpp b/kaddressbook/nameeditdialog.cpp
index 199f3d6..96822d8 100644
--- a/kaddressbook/nameeditdialog.cpp
+++ b/kaddressbook/nameeditdialog.cpp
@@ -1,300 +1,302 @@
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#include <qlayout.h> 24#include <qlayout.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qlistbox.h> 26#include <q3listbox.h>
27#include <qlistview.h> 27#include <q3listview.h>
28#include <qtooltip.h> 28#include <qtooltip.h>
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30#include <qcheckbox.h> 30#include <qcheckbox.h>
31#include <qstring.h> 31#include <qstring.h>
32//Added by qt3to4:
33#include <Q3GridLayout>
32 34
33#ifndef KAB_EMBEDDED 35#ifndef KAB_EMBEDDED
34#include <kaccelmanager.h> 36#include <kaccelmanager.h>
35#else //KAB_EMBEDDED 37#else //KAB_EMBEDDED
36#include <kstandarddirs.h> 38#include <kstandarddirs.h>
37#endif //KAB_EMBEDDED 39#endif //KAB_EMBEDDED
38 40
39#include <kapplication.h> 41#include <kapplication.h>
40#include <kbuttonbox.h> 42#include <kbuttonbox.h>
41#include <kconfig.h> 43#include <kconfig.h>
42#include <klineedit.h> 44#include <klineedit.h>
43#include <klistview.h> 45#include <klistview.h>
44#include <kcombobox.h> 46#include <kcombobox.h>
45#include <klocale.h> 47#include <klocale.h>
46#include <kglobal.h> 48#include <kglobal.h>
47#include <kdebug.h> 49#include <kdebug.h>
48#include <kiconloader.h> 50#include <kiconloader.h>
49#include <kmessagebox.h> 51#include <kmessagebox.h>
50 52
51#include "nameeditdialog.h" 53#include "nameeditdialog.h"
52 54
53NameEditDialog::NameEditDialog( const KABC::Addressee &addr, int type, 55NameEditDialog::NameEditDialog( const KABC::Addressee &addr, int type,
54 QWidget *parent, const char *name ) 56 QWidget *parent, const char *name )
55 : KDialogBase( Plain, i18n( "Edit Contact Name" ), Help | Ok | Cancel, 57 : KDialogBase( Plain, i18n( "Edit Contact Name" ), Help | Ok | Cancel,
56 Ok, parent, name, true ) 58 Ok, parent, name, true )
57{ 59{
58 60
59 QWidget *page = plainPage(); 61 QWidget *page = plainPage();
60 QGridLayout *layout = new QGridLayout( page, 5, 3 ); 62 Q3GridLayout *layout = new Q3GridLayout( page, 5, 3 );
61 layout->setSpacing( spacingHint() ); 63 layout->setSpacing( spacingHint() );
62 layout->addColSpacing( 2, 100 ); 64 layout->addColSpacing( 2, 100 );
63 QLabel *label; 65 QLabel *label;
64 66
65 label = new QLabel( i18n( "Honorific prefixes:" ), page ); 67 label = new QLabel( i18n( "Honorific prefixes:" ), page );
66 layout->addWidget( label, 0, 0 ); 68 layout->addWidget( label, 0, 0 );
67 mPrefixCombo = new KComboBox( page ); 69 mPrefixCombo = new KComboBox( page );
68 mPrefixCombo->setDuplicatesEnabled( false ); 70 mPrefixCombo->setDuplicatesEnabled( false );
69 mPrefixCombo->setEditable( true ); 71 mPrefixCombo->setEditable( true );
70 label->setBuddy( mPrefixCombo ); 72 label->setBuddy( mPrefixCombo );
71 layout->addMultiCellWidget( mPrefixCombo, 0, 0, 1, 2 ); 73 layout->addMultiCellWidget( mPrefixCombo, 0, 0, 1, 2 );
72 74
73 label = new QLabel( i18n( "Given name:" ), page ); 75 label = new QLabel( i18n( "Given name:" ), page );
74 layout->addWidget( label, 1, 0 ); 76 layout->addWidget( label, 1, 0 );
75 mGivenNameEdit = new KLineEdit( page ); 77 mGivenNameEdit = new KLineEdit( page );
76 label->setBuddy( mGivenNameEdit ); 78 label->setBuddy( mGivenNameEdit );
77 layout->addMultiCellWidget( mGivenNameEdit, 1, 1, 1, 2 ); 79 layout->addMultiCellWidget( mGivenNameEdit, 1, 1, 1, 2 );
78 80
79 label = new QLabel( i18n( "Additional names:" ), page ); 81 label = new QLabel( i18n( "Additional names:" ), page );
80 layout->addWidget( label, 2, 0 ); 82 layout->addWidget( label, 2, 0 );
81 mAdditionalNameEdit = new KLineEdit( page ); 83 mAdditionalNameEdit = new KLineEdit( page );
82 label->setBuddy( mAdditionalNameEdit ); 84 label->setBuddy( mAdditionalNameEdit );
83 layout->addMultiCellWidget( mAdditionalNameEdit, 2, 2, 1, 2 ); 85 layout->addMultiCellWidget( mAdditionalNameEdit, 2, 2, 1, 2 );
84 86
85 label = new QLabel( i18n( "Family names:" ), page ); 87 label = new QLabel( i18n( "Family names:" ), page );
86 layout->addWidget( label, 3, 0 ); 88 layout->addWidget( label, 3, 0 );
87 mFamilyNameEdit = new KLineEdit( page ); 89 mFamilyNameEdit = new KLineEdit( page );
88 label->setBuddy( mFamilyNameEdit ); 90 label->setBuddy( mFamilyNameEdit );
89 layout->addMultiCellWidget( mFamilyNameEdit, 3, 3, 1, 2 ); 91 layout->addMultiCellWidget( mFamilyNameEdit, 3, 3, 1, 2 );
90 92
91 label = new QLabel( i18n( "Honorific suffixes:" ), page ); 93 label = new QLabel( i18n( "Honorific suffixes:" ), page );
92 layout->addWidget( label, 4, 0 ); 94 layout->addWidget( label, 4, 0 );
93 mSuffixCombo = new KComboBox( page ); 95 mSuffixCombo = new KComboBox( page );
94 mSuffixCombo->setDuplicatesEnabled( false ); 96 mSuffixCombo->setDuplicatesEnabled( false );
95 mSuffixCombo->setEditable( true ); 97 mSuffixCombo->setEditable( true );
96 label->setBuddy( mSuffixCombo ); 98 label->setBuddy( mSuffixCombo );
97 layout->addMultiCellWidget( mSuffixCombo, 4, 4, 1, 2 ); 99 layout->addMultiCellWidget( mSuffixCombo, 4, 4, 1, 2 );
98 100
99 mFormattedNameCombo = new KComboBox( page ); 101 mFormattedNameCombo = new KComboBox( page );
100 mFormattedNameCombo->setMaximumWidth(100); 102 mFormattedNameCombo->setMaximumWidth(100);
101 103
102 layout->addMultiCellWidget( mFormattedNameCombo, 5, 5, 0, 0 ); 104 layout->addMultiCellWidget( mFormattedNameCombo, 5, 5, 0, 0 );
103 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( typeChanged( int ) ) ); 105 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( typeChanged( int ) ) );
104 106
105 mFormattedNameEdit = new KLineEdit( page ); 107 mFormattedNameEdit = new KLineEdit( page );
106 mFormattedNameEdit->setEnabled( type == CustomName ); 108 mFormattedNameEdit->setEnabled( type == CustomName );
107 layout->addMultiCellWidget( mFormattedNameEdit, 5, 5, 1, 2 ); 109 layout->addMultiCellWidget( mFormattedNameEdit, 5, 5, 1, 2 );
108 110
109 mParseBox = new QCheckBox( i18n( "Parse name automatically" ), page ); 111 mParseBox = new QCheckBox( i18n( "Parse name automatically" ), page );
110 connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( parseBoxChanged(bool) ) ); 112 connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( parseBoxChanged(bool) ) );
111 connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( modified() ) ); 113 connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( modified() ) );
112 layout->addMultiCellWidget( mParseBox, 6, 6, 0, 2 ); 114 layout->addMultiCellWidget( mParseBox, 6, 6, 0, 2 );
113 115
114 // Fill in the values 116 // Fill in the values
115 mFamilyNameEdit->setText( addr.familyName() ); 117 mFamilyNameEdit->setText( addr.familyName() );
116 mGivenNameEdit->setText( addr.givenName() ); 118 mGivenNameEdit->setText( addr.givenName() );
117 mAdditionalNameEdit->setText( addr.additionalName() ); 119 mAdditionalNameEdit->setText( addr.additionalName() );
118 mFormattedNameEdit->setText( addr.formattedName() ); 120 mFormattedNameEdit->setText( addr.formattedName() );
119 121
120 // Prefix and suffix combos 122 // Prefix and suffix combos
121//US KConfig config( "kabcrc" ); 123//US KConfig config( "kabcrc" );
122 KConfig config( locateLocal("config", "kabcrc") ); 124 KConfig config( locateLocal("config", "kabcrc") );
123 config.setGroup( "General" ); 125 config.setGroup( "General" );
124 126
125 QStringList sTitle; 127 QStringList sTitle;
126 sTitle += i18n( "Dr." ); 128 sTitle += i18n( "Dr." );
127 sTitle += i18n( "Miss" ); 129 sTitle += i18n( "Miss" );
128 sTitle += i18n( "Mr." ); 130 sTitle += i18n( "Mr." );
129 sTitle += i18n( "Mrs." ); 131 sTitle += i18n( "Mrs." );
130 sTitle += i18n( "Ms." ); 132 sTitle += i18n( "Ms." );
131 sTitle += i18n( "Prof." ); 133 sTitle += i18n( "Prof." );
132 sTitle += config.readListEntry( "Prefixes" ); 134 sTitle += config.readListEntry( "Prefixes" );
133 sTitle.sort(); 135 sTitle.sort();
134 136
135 QStringList sSuffix; 137 QStringList sSuffix;
136 sSuffix += i18n( "I" ); 138 sSuffix += i18n( "I" );
137 sSuffix += i18n( "II" ); 139 sSuffix += i18n( "II" );
138 sSuffix += i18n( "III" ); 140 sSuffix += i18n( "III" );
139 sSuffix += i18n( "Jr." ); 141 sSuffix += i18n( "Jr." );
140 sSuffix += i18n( "Sr." ); 142 sSuffix += i18n( "Sr." );
141 sSuffix += config.readListEntry( "Suffixes" ); 143 sSuffix += config.readListEntry( "Suffixes" );
142 sSuffix.sort(); 144 sSuffix.sort();
143 145
144 mPrefixCombo->insertStringList( sTitle ); 146 mPrefixCombo->insertStringList( sTitle );
145 mSuffixCombo->insertStringList( sSuffix ); 147 mSuffixCombo->insertStringList( sSuffix );
146 148
147#ifndef KAB_EMBEDDED 149#ifndef KAB_EMBEDDED
148 mPrefixCombo->setCurrentText( addr.prefix() ); 150 mPrefixCombo->setCurrentText( addr.prefix() );
149 mSuffixCombo->setCurrentText( addr.suffix() ); 151 mSuffixCombo->setCurrentText( addr.suffix() );
150#else //KAB_EMBEDDED 152#else //KAB_EMBEDDED
151 mPrefixCombo->setEditText( addr.prefix() ); 153 mPrefixCombo->setEditText( addr.prefix() );
152 mSuffixCombo->setEditText( addr.suffix() ); 154 mSuffixCombo->setEditText( addr.suffix() );
153#endif //KAB_EMBEDDED 155#endif //KAB_EMBEDDED
154 156
155 AddresseeConfig::instance()->setUid( addr.uid() ); 157 AddresseeConfig::instance()->setUid( addr.uid() );
156 mParseBox->setChecked( AddresseeConfig::instance()->automaticNameParsing() ); 158 mParseBox->setChecked( AddresseeConfig::instance()->automaticNameParsing() );
157 159
158#ifndef KAB_EMBEDDED 160#ifndef KAB_EMBEDDED
159 KAcceleratorManager::manage( this ); 161 KAcceleratorManager::manage( this );
160#endif //KAB_EMBEDDED 162#endif //KAB_EMBEDDED
161 163
162 connect( mPrefixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 164 connect( mPrefixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
163 connect( mPrefixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); 165 connect( mPrefixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) );
164 connect( mGivenNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 166 connect( mGivenNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
165 connect( mGivenNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); 167 connect( mGivenNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) );
166 connect( mAdditionalNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 168 connect( mAdditionalNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
167 connect( mAdditionalNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); 169 connect( mAdditionalNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) );
168 connect( mFamilyNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 170 connect( mFamilyNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
169 connect( mFamilyNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); 171 connect( mFamilyNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) );
170 connect( mSuffixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 172 connect( mSuffixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
171 connect( mSuffixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); 173 connect( mSuffixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) );
172 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( modified() ) ); 174 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( modified() ) );
173 connect( mFormattedNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 175 connect( mFormattedNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
174 176
175 updateTypeCombo(); 177 updateTypeCombo();
176 mFormattedNameCombo->setCurrentItem( type ); 178 mFormattedNameCombo->setCurrentItem( type );
177 179
178 180
179 mChanged = false; 181 mChanged = false;
180} 182}
181 183
182NameEditDialog::~NameEditDialog() 184NameEditDialog::~NameEditDialog()
183{ 185{
184} 186}
185 187
186QString NameEditDialog::familyName() const 188QString NameEditDialog::familyName() const
187{ 189{
188 return mFamilyNameEdit->text(); 190 return mFamilyNameEdit->text();
189} 191}
190 192
191QString NameEditDialog::givenName() const 193QString NameEditDialog::givenName() const
192{ 194{
193 return mGivenNameEdit->text(); 195 return mGivenNameEdit->text();
194} 196}
195 197
196QString NameEditDialog::prefix() const 198QString NameEditDialog::prefix() const
197{ 199{
198 return mPrefixCombo->currentText(); 200 return mPrefixCombo->currentText();
199} 201}
200 202
201QString NameEditDialog::suffix() const 203QString NameEditDialog::suffix() const
202{ 204{
203 return mSuffixCombo->currentText(); 205 return mSuffixCombo->currentText();
204} 206}
205 207
206QString NameEditDialog::additionalName() const 208QString NameEditDialog::additionalName() const
207{ 209{
208 return mAdditionalNameEdit->text(); 210 return mAdditionalNameEdit->text();
209} 211}
210 212
211QString NameEditDialog::customFormattedName() const 213QString NameEditDialog::customFormattedName() const
212{ 214{
213 return mFormattedNameEdit->text(); 215 return mFormattedNameEdit->text();
214} 216}
215 217
216int NameEditDialog::formattedNameType() const 218int NameEditDialog::formattedNameType() const
217{ 219{
218 return mFormattedNameCombo->currentItem(); 220 return mFormattedNameCombo->currentItem();
219} 221}
220 222
221bool NameEditDialog::changed() const 223bool NameEditDialog::changed() const
222{ 224{
223 return mChanged; 225 return mChanged;
224} 226}
225 227
226QString NameEditDialog::formattedName( const KABC::Addressee &addr, int type ) 228QString NameEditDialog::formattedName( const KABC::Addressee &addr, int type )
227{ 229{
228 QString retval; 230 QString retval;
229 switch ( type ) { 231 switch ( type ) {
230 case SimpleName: 232 case SimpleName:
231 retval = addr.givenName() + " " + addr.familyName(); 233 retval = addr.givenName() + " " + addr.familyName();
232 break; 234 break;
233 case FullName: 235 case FullName:
234 retval =addr.prefix() + " " + addr.givenName() + " " + 236 retval =addr.prefix() + " " + addr.givenName() + " " +
235 addr.additionalName() + " " + addr.familyName() + " " + 237 addr.additionalName() + " " + addr.familyName() + " " +
236 addr.suffix(); 238 addr.suffix();
237 break; 239 break;
238 case ReverseName: 240 case ReverseName:
239 if ( !addr.familyName().isEmpty() ) { 241 if ( !addr.familyName().isEmpty() ) {
240 retval = addr.familyName(); 242 retval = addr.familyName();
241 if ( !addr.givenName().isEmpty() ) 243 if ( !addr.givenName().isEmpty() )
242 retval += ", " + addr.givenName(); 244 retval += ", " + addr.givenName();
243 } else 245 } else
244 retval = addr.givenName(); 246 retval = addr.givenName();
245 break; 247 break;
246 default: 248 default:
247 return ""; 249 return "";
248 break; 250 break;
249 } 251 }
250 return retval.stripWhiteSpace (); 252 return retval.stripWhiteSpace ();
251} 253}
252 254
253void NameEditDialog::parseBoxChanged( bool value ) 255void NameEditDialog::parseBoxChanged( bool value )
254{ 256{
255 //AddresseeConfig::instance()->setUid( addr.uid() ); 257 //AddresseeConfig::instance()->setUid( addr.uid() );
256 AddresseeConfig::instance()->setAutomaticNameParsing( value ); 258 AddresseeConfig::instance()->setAutomaticNameParsing( value );
257} 259}
258 260
259void NameEditDialog::typeChanged( int pos ) 261void NameEditDialog::typeChanged( int pos )
260{ 262{
261 mFormattedNameEdit->setEnabled( pos == 0 ); 263 mFormattedNameEdit->setEnabled( pos == 0 );
262} 264}
263 265
264void NameEditDialog::modified() 266void NameEditDialog::modified()
265{ 267{
266 mChanged = true; 268 mChanged = true;
267} 269}
268 270
269void NameEditDialog::updateTypeCombo() 271void NameEditDialog::updateTypeCombo()
270{ 272{
271 KABC::Addressee addr; 273 KABC::Addressee addr;
272 addr.setPrefix( mPrefixCombo->currentText() ); 274 addr.setPrefix( mPrefixCombo->currentText() );
273 addr.setGivenName( mGivenNameEdit->text() ); 275 addr.setGivenName( mGivenNameEdit->text() );
274 addr.setAdditionalName( mAdditionalNameEdit->text() ); 276 addr.setAdditionalName( mAdditionalNameEdit->text() );
275 addr.setFamilyName( mFamilyNameEdit->text() ); 277 addr.setFamilyName( mFamilyNameEdit->text() );
276 addr.setSuffix( mSuffixCombo->currentText() ); 278 addr.setSuffix( mSuffixCombo->currentText() );
277 279
278 int pos = mFormattedNameCombo->currentItem(); 280 int pos = mFormattedNameCombo->currentItem();
279 281
280 mFormattedNameCombo->clear(); 282 mFormattedNameCombo->clear();
281 mFormattedNameCombo->insertItem( i18n( "Custom" ) ); 283 mFormattedNameCombo->insertItem( i18n( "Custom" ) );
282 mFormattedNameCombo->insertItem( formattedName( addr, SimpleName ) ); 284 mFormattedNameCombo->insertItem( formattedName( addr, SimpleName ) );
283 mFormattedNameCombo->insertItem( formattedName( addr, FullName ) ); 285 mFormattedNameCombo->insertItem( formattedName( addr, FullName ) );
284 mFormattedNameCombo->insertItem( formattedName( addr, ReverseName ) ); 286 mFormattedNameCombo->insertItem( formattedName( addr, ReverseName ) );
285 287
286 mFormattedNameCombo->setCurrentItem( pos ); 288 mFormattedNameCombo->setCurrentItem( pos );
287} 289}
288 290
289void NameEditDialog::slotHelp() 291void NameEditDialog::slotHelp()
290{ 292{
291#ifndef KAB_EMBEDDED 293#ifndef KAB_EMBEDDED
292 kapp->invokeHelp( "managing-contacts-automatic-nameparsing" ); 294 kapp->invokeHelp( "managing-contacts-automatic-nameparsing" );
293#else //KAB_EMBEDDED 295#else //KAB_EMBEDDED
294qDebug("NameEditDialog::slotHelp Help is not supported yet"); 296qDebug("NameEditDialog::slotHelp Help is not supported yet");
295#endif //KAB_EMBEDDED 297#endif //KAB_EMBEDDED
296} 298}
297 299
298#ifndef KAB_EMBEDDED 300#ifndef KAB_EMBEDDED_
299#include "nameeditdialog.moc" 301#include "moc_nameeditdialog.cpp"
300#endif //KAB_EMBEDDED 302#endif //KAB_EMBEDDED
diff --git a/kaddressbook/old_mainwindow.cpp b/kaddressbook/old_mainwindow.cpp
index 0e886d9..7a445c7 100644
--- a/kaddressbook/old_mainwindow.cpp
+++ b/kaddressbook/old_mainwindow.cpp
@@ -1,709 +1,709 @@
1#include <qlabel.h> 1#include <qlabel.h>
2#include <qapp.h> 2#include <qapp.h>
3#include <qmessagebox.h> 3#include <qmessagebox.h>
4#include <qaction.h> 4#include <qaction.h>
5 5
6 #include <kdebug.h>// defined kdDebug() 6 #include <kdebug.h>// defined kdDebug()
7 #include <klocale.h>// defines i18n (microkde) 7 #include <klocale.h>// defines i18n (microkde)
8 8
9#include "kabprefs.h" 9#include "kabprefs.h"
10 10
11#ifndef DESKTOP_VERSION 11#ifndef DESKTOP_VERSION
12#include <qpe/qpetoolbar.h> 12#include <qpe/qpetoolbar.h>
13#include <qpe/qpemenubar.h> 13#include <qpe/qpemenubar.h>
14#include <qpe/resource.h> 14#include <qpe/resource.h>
15#else 15#else
16#include <qtoolbar.h> 16#include <qtoolbar.h>
17#include <qmenubar.h> 17#include <qmenubar.h>
18#include <resource.h> 18#include <resource.h>
19#endif 19#endif
20 20
21/* 21/*
22#include <stdlib.h> 22#include <stdlib.h>
23 23
24#include <qaction.h> 24#include <qaction.h>
25#include <qpainter.h> 25#include <qpainter.h>
26#include <qwhatsthis.h> 26#include <qwhatsthis.h>
27#include <qpopupmenu.h> 27#include <qpopupmenu.h>
28#include <qmessagebox.h> 28#include <qmessagebox.h>
29#include <qlineedit.h> 29#include <qlineedit.h>
30#include <qfile.h> 30#include <qfile.h>
31#include <qfileinfo.h> 31#include <qfileinfo.h>
32#include <qwmatrix.h> 32#include <qwmatrix.h>
33#ifndef DESKTOP_VERSION 33#ifndef DESKTOP_VERSION
34#include <qpe/global.h> 34#include <qpe/global.h>
35#include <qpe/qpemenubar.h> 35#include <qpe/qpemenubar.h>
36#include <qpe/qpetoolbar.h> 36#include <qpe/qpetoolbar.h>
37#include <qpe/resource.h> 37#include <qpe/resource.h>
38#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
39#include <qtopia/alarmserver.h> 39#include <qtopia/alarmserver.h>
40#include <qtopia/qcopenvelope_qws.h> 40#include <qtopia/qcopenvelope_qws.h>
41#else 41#else
42#include <qtoolbar.h> 42#include <qtoolbar.h>
43#include <qdir.h> 43#include <qdir.h>
44#include <qapplication.h> 44#include <qapplication.h>
45//#include <resource.h> 45//#include <resource.h>
46#endif 46#endif
47 47
48#include <libkcal/calendarlocal.h> 48#include <libkcal/calendarlocal.h>
49#include <libkcal/todo.h> 49#include <libkcal/todo.h>
50 50
51//#include "calendarview.h" 51//#include "calendarview.h"
52//#include "koviewmanager.h" 52//#include "koviewmanager.h"
53//#include "koagendaview.h" 53//#include "koagendaview.h"
54//#include "kodialogmanager.h" 54//#include "kodialogmanager.h"
55//#include "kdialogbase.h" 55//#include "kdialogbase.h"
56//#include "koprefs.h" 56//#include "koprefs.h"
57//#include "kfiledialog.h" 57//#include "kfiledialog.h"
58//#include "koglobals.h" 58//#include "koglobals.h"
59 59
60//#include "kconfig.h" 60//#include "kconfig.h"
61//#include "simplealarmclient.h" 61//#include "simplealarmclient.h"
62*/ 62*/
63//US using namespace KACore; 63//US using namespace KACore;
64 64
65 65
66#include "mainwindow.h" 66#include "mainwindow.h"
67 67
68MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 68MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
69 QMainWindow( parent, name ) 69 QMainWindow( parent, name )
70{ 70{
71 71
72#ifdef DESKTOP_VERSION 72#ifdef DESKTOP_VERSION
73 setFont( QFont("Arial"), 14 ); 73 setFont( QFont("Arial"), 14 );
74#endif 74#endif
75// mBlockAtStartup = true; 75// mBlockAtStartup = true;
76 kdDebug() << "MainWindow()::MainWindow()" << endl; 76 kdDebug() << "MainWindow()::MainWindow()" << endl;
77// mFlagKeyPressed = false; 77// mFlagKeyPressed = false;
78 setCaption("KAddressbook/Pi"); 78 setCaption("KAddressbook/Pi");
79 79
80 KABPrefs *p = KABPrefs::instance(); 80 KABPrefs *p = KABPrefs::instance();
81 if ( QApplication::desktop()->height() > 480 ) { 81 if ( QApplication::desktop()->height() > 480 ) {
82//US if ( p->mHourSize == 4 ) 82//US if ( p->mHourSize == 4 )
83//US p->mHourSize = 6; 83//US p->mHourSize = 6;
84 } 84 }
85 85
86 QMainWindow::ToolBarDock tbd; 86 QMainWindow::ToolBarDock tbd;
87 if ( p->mToolBarHor ) { 87 if ( p->mToolBarHor ) {
88 if ( p->mToolBarUp ) 88 if ( p->mToolBarUp )
89 tbd = Bottom; 89 tbd = Bottom;
90 else 90 else
91 tbd = Top; 91 tbd = Top;
92 } 92 }
93 else { 93 else {
94 if ( p->mToolBarUp ) 94 if ( p->mToolBarUp )
95 tbd = Right; 95 tbd = Right;
96 else 96 else
97 tbd = Left; 97 tbd = Left;
98 } 98 }
99 99
100 iconToolBar = new QPEToolBar( this ); 100 iconToolBar = new QPEToolBar( this );
101 addToolBar (iconToolBar , tbd ); 101 addToolBar (iconToolBar , tbd );
102 102
103/*US 103/*US
104 mBlockSaveFlag = false; 104 mBlockSaveFlag = false;
105 mCalendarModifiedFlag = false; 105 mCalendarModifiedFlag = false;
106*/ 106*/
107 QLabel* splash = new QLabel(i18n("KA/Pi is starting ... "), this ); 107 QLabel* splash = new QLabel(i18n("KA/Pi is starting ... "), this );
108 splash->setAlignment ( AlignCenter ); 108 splash->setAlignment ( AlignCenter );
109 setCentralWidget( splash ); 109 setCentralWidget( splash );
110#ifndef DESKTOP_VERSION 110#ifndef DESKTOP_VERSION
111 showMaximized(); 111 showMaximized();
112#endif 112#endif
113 qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 113 qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
114// setDefaultPreferences(); 114// setDefaultPreferences();
115/* mCalendar = new CalendarLocal(); 115/* mCalendar = new CalendarLocal();
116 mView = new CalendarView( mCalendar, this,"mCalendar " ); 116 mView = new CalendarView( mCalendar, this,"mCalendar " );
117 mView->hide(); 117 mView->hide();
118 //mView->resize(splash->size() ); 118 //mView->resize(splash->size() );
119*/ 119*/
120 initActions(); 120 initActions();
121 121
122#ifndef DESKTOP_VERSION 122#ifndef DESKTOP_VERSION
123//US iconToolBar->show(); 123//US iconToolBar->show();
124 qApp->processEvents(); 124 qApp->processEvents();
125#endif 125#endif
126 qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 126 qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
127 127
128 int vh = height() ; 128 int vh = height() ;
129 int vw = width(); 129 int vw = width();
130 qDebug("Toolbar hei %d ",iconToolBar->height() ); 130 qDebug("Toolbar hei %d ",iconToolBar->height() );
131/*US if ( iconToolBar->orientation () == Qt:: Horizontal ) { 131/*US if ( iconToolBar->orientation () == Qt:: Horizontal ) {
132 vh -= iconToolBar->height(); 132 vh -= iconToolBar->height();
133 } else { 133 } else {
134 vw -= iconToolBar->height(); 134 vw -= iconToolBar->height();
135 } 135 }
136*/ 136*/
137 //mView->setMaximumSize( splash->size() ); 137 //mView->setMaximumSize( splash->size() );
138 //mView->resize( splash->size() ); 138 //mView->resize( splash->size() );
139 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 139 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
140/* mView->readSettings(); 140/* mView->readSettings();
141 if( !QFile::exists( defaultFileName() ) ) { 141 if( !QFile::exists( defaultFileName() ) ) {
142 mView->saveCalendar( defaultFileName() ); 142 mView->saveCalendar( defaultFileName() );
143 } 143 }
144 mView->openCalendar( defaultFileName() ); 144 mView->openCalendar( defaultFileName() );
145 processIncidenceSelection( 0 ); 145 processIncidenceSelection( 0 );
146 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 146 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
147 SLOT( processIncidenceSelection( Incidence * ) ) ); 147 SLOT( processIncidenceSelection( Incidence * ) ) );
148 connect( mView, SIGNAL( modifiedChanged( bool ) ), 148 connect( mView, SIGNAL( modifiedChanged( bool ) ),
149 SLOT( slotModifiedChanged( bool ) ) ); 149 SLOT( slotModifiedChanged( bool ) ) );
150 connect( mView, SIGNAL( signalmodified() ), 150 connect( mView, SIGNAL( signalmodified() ),
151 SLOT( checkAlarms( ) ) ); 151 SLOT( checkAlarms( ) ) );
152 152
153 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 153 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
154 connect( &alarmTimer, SIGNAL( timeout() ), SLOT( writeAlarm() ) ); 154 connect( &alarmTimer, SIGNAL( timeout() ), SLOT( writeAlarm() ) );
155 mView->setModified( false ); 155 mView->setModified( false );
156 mBlockAtStartup = false; 156 mBlockAtStartup = false;
157 mView->setModified( false ); 157 mView->setModified( false );
158 setCentralWidget( mView ); 158 setCentralWidget( mView );
159 mView->show(); 159 mView->show();
160*/ 160*/
161 delete splash; 161 delete splash;
162 162
163 qApp->processEvents(); 163 qApp->processEvents();
164//US qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 164//US qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
165 165
166} 166}
167MainWindow::~MainWindow() 167MainWindow::~MainWindow()
168{ 168{
169 qDebug("MainWindow::~MainWindow() "); 169 qDebug("MainWindow::~MainWindow() ");
170 kdDebug() << "MainWindow()::~MainWindow()" << endl; 170 kdDebug() << "MainWindow()::~MainWindow()" << endl;
171 //save toolbar location 171 //save toolbar location
172/* 172/*
173 KOPrefs *p = KOPrefs::instance(); 173 KOPrefs *p = KOPrefs::instance();
174 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 174 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
175 p->mToolBarUp = iconToolBar->x() > width()/2 || 175 p->mToolBarUp = iconToolBar->x() > width()/2 ||
176 iconToolBar->y() > height()/2; 176 iconToolBar->y() > height()/2;
177 alarmTimer.stop(); 177 alarmTimer.stop();
178 mView->writeSettings(); 178 mView->writeSettings();
179 writeAlarm(); 179 writeAlarm();
180 if ( mCalendarModifiedFlag ) 180 if ( mCalendarModifiedFlag )
181 save(); 181 save();
182 delete mCalendar; 182 delete mCalendar;
183*/ 183*/
184} 184}
185 185
186 186
187void MainWindow::closeEvent( QCloseEvent* ce ) 187void MainWindow::closeEvent( QCloseEvent* ce )
188{ 188{
189 189
190 if ( ! KABPrefs::instance()->mAskForQuit ) { 190 if ( ! KABPrefs::instance()->mAskForQuit ) {
191 191
192 ce->accept(); 192 ce->accept();
193 return; 193 return;
194 194
195 } 195 }
196 196
197 switch( QMessageBox::information( this, "KA/Pi", 197 switch( QMessageBox::information( this, "KA/Pi",
198 i18n("Do you really want\nto close KA/Pi?"), 198 i18n("Do you really want\nto close KA/Pi?"),
199 i18n("Close!"), i18n("No"), 199 i18n("Close!"), i18n("No"),
200 0, 0 ) ) { 200 0, 0 ) ) {
201 case 0: 201 case 0:
202 ce->accept(); 202 ce->accept();
203 break; 203 break;
204 case 1: 204 case 1:
205 ce->ignore(); 205 ce->ignore();
206 break; 206 break;
207 case 2: 207 case 2:
208 208
209 default: 209 default:
210 break; 210 break;
211 } 211 }
212 212
213 213
214} 214}
215 215
216 216
217void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 217void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
218{ 218{
219/* 219/*
220 QDataStream stream( data, IO_ReadOnly ); 220 QDataStream stream( data, IO_ReadOnly );
221 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 221 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
222 222
223 223
224 if ( cmsg == "-writeFile" ) { 224 if ( cmsg == "-writeFile" ) {
225 mView->viewManager()->showWhatsNextView(); 225 mView->viewManager()->showWhatsNextView();
226 save(); 226 save();
227 setCaption( i18n("File written on AD request")); 227 setCaption( i18n("File written on AD request"));
228 showMaximized(); 228 showMaximized();
229 raise(); 229 raise();
230#ifndef DESKTOP_VERSION 230#ifndef DESKTOP_VERSION
231 QCopEnvelope e3("kosaved", "blabla"); 231 QCopEnvelope e3("kosaved", "blabla");
232#endif 232#endif
233 return; 233 return;
234 234
235 } 235 }
236 if ( cmsg == "-newCountdown" ) { 236 if ( cmsg == "-newCountdown" ) {
237 qDebug("newCountdown "); 237 qDebug("newCountdown ");
238 238
239 } 239 }
240 QString msg ;; 240 QString msg ;;
241 QString allmsg = cmsg; 241 QString allmsg = cmsg;
242 while ( allmsg.length() > 0 ) { 242 while ( allmsg.length() > 0 ) {
243 int nextC = allmsg.find( "-", 1 ); 243 int nextC = allmsg.find( "-", 1 );
244 if ( nextC == -1 ) { 244 if ( nextC == -1 ) {
245 msg = allmsg; 245 msg = allmsg;
246 allmsg = ""; 246 allmsg = "";
247 } else{ 247 } else{
248 msg = allmsg.left( nextC ); 248 msg = allmsg.left( nextC );
249 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 249 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
250 } 250 }
251 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 251 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
252 if ( msg == "-newEvent" ) { 252 if ( msg == "-newEvent" ) {
253 mView->newEvent(); 253 mView->newEvent();
254 } 254 }
255 if ( msg == "-newTodo" ) { 255 if ( msg == "-newTodo" ) {
256 mView->newTodo(); 256 mView->newTodo();
257 257
258 } 258 }
259 if ( msg == "-showWN" ) { 259 if ( msg == "-showWN" ) {
260 mView->viewManager()->showWhatsNextView(); 260 mView->viewManager()->showWhatsNextView();
261 } 261 }
262 if ( msg == "-showTodo" ) { 262 if ( msg == "-showTodo" ) {
263 mView->viewManager()->showTodoView(); 263 mView->viewManager()->showTodoView();
264 } 264 }
265 if ( msg == "-showList" ) { 265 if ( msg == "-showList" ) {
266 mView->viewManager()->showListView(); 266 mView->viewManager()->showListView();
267 } 267 }
268 else if ( msg == "-showDay" ) { 268 else if ( msg == "-showDay" ) {
269 mView->viewManager()->showDayView(); 269 mView->viewManager()->showDayView();
270 } 270 }
271 else if ( msg == "-showWWeek" ) { 271 else if ( msg == "-showWWeek" ) {
272 mView->viewManager()->showWorkWeekView(); 272 mView->viewManager()->showWorkWeekView();
273 } 273 }
274 else if ( msg == "-showWeek" ) { 274 else if ( msg == "-showWeek" ) {
275 mView->viewManager()->showWeekView(); 275 mView->viewManager()->showWeekView();
276 } 276 }
277 else if ( msg == "-showTodo" ) { 277 else if ( msg == "-showTodo" ) {
278 mView->viewManager()->showTodoView(); 278 mView->viewManager()->showTodoView();
279 } 279 }
280 else if ( msg == "-showJournal" ) { 280 else if ( msg == "-showJournal" ) {
281 mView->viewManager()->showJournalView(); 281 mView->viewManager()->showJournalView();
282 } 282 }
283 else if ( msg == "-showKO" ) { 283 else if ( msg == "-showKO" ) {
284 mView->viewManager()->showNextXView(); 284 mView->viewManager()->showNextXView();
285 } 285 }
286 else if ( msg == "-showWNext" ) { 286 else if ( msg == "-showWNext" ) {
287 mView->viewManager()->showWhatsNextView(); 287 mView->viewManager()->showWhatsNextView();
288 } 288 }
289 } 289 }
290 290
291 showMaximized(); 291 showMaximized();
292 raise(); 292 raise();
293*/ 293*/
294} 294}
295 295
296 296
297QPixmap MainWindow::loadPixmap( QString name ) 297QPixmap MainWindow::loadPixmap( QString name )
298{ 298{
299 return KGlobal::iconLoader().loadPixmap( name ); 299 return KGlobal::iconLoader().loadPixmap( name );
300/*US use the advanced version of the iconloader 300/*US use the advanced version of the iconloader
301#ifdef DESKTOP_VERSION 301#ifdef DESKTOP_VERSION
302 QPixmap pixmapLoader; 302 QPixmap pixmapLoader;
303 QString file; 303 QString file;
304 file = QDir::homeDirPath()+"/kaddressbook/pics/" + name+".png"; 304 file = QDir::homeDirPath()+"/kaddressbook/pics/" + name+".png";
305 //qDebug("pixmap name %s ", file.latin1()); 305 //qDebug("pixmap name %s ", file.latin1());
306 pixmapLoader.load( file ); 306 pixmapLoader.load( file );
307 return pixmapLoader; 307 return pixmapLoader;
308#else 308#else
309 return Resource::loadPixmap( name ); 309 return Resource::loadPixmap( name );
310#endif 310#endif
311*/ 311*/
312} 312}
313 313
314void MainWindow::initActions() 314void MainWindow::initActions()
315{ 315{
316 iconToolBar->clear(); 316 iconToolBar->clear();
317 KABPrefs *p = KABPrefs::instance(); 317 KABPrefs *p = KABPrefs::instance();
318 QPEMenuBar *menuBar1 = new QPEMenuBar( iconToolBar ); 318 QPEMenuBar *menuBar1 = new QPEMenuBar( iconToolBar );
319 QPopupMenu *menuBar = new QPopupMenu( this ); 319 Q3PopupMenu *menuBar = new Q3PopupMenu( this );
320 menuBar1->insertItem( "ME", menuBar); 320 menuBar1->insertItem( "ME", menuBar);
321 QPopupMenu *fileMenu = new QPopupMenu( this ); 321 Q3PopupMenu *fileMenu = new Q3PopupMenu( this );
322 QPopupMenu *editMenu = new QPopupMenu( this ); 322 Q3PopupMenu *editMenu = new Q3PopupMenu( this );
323 QPopupMenu *viewMenu = new QPopupMenu( this ); 323 Q3PopupMenu *viewMenu = new Q3PopupMenu( this );
324 QPopupMenu *settingsMenu = new QPopupMenu( this ); 324 Q3PopupMenu *settingsMenu = new Q3PopupMenu( this );
325 QPopupMenu *importMenu = new QPopupMenu( this ); 325 Q3PopupMenu *importMenu = new Q3PopupMenu( this );
326 326
327 menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 327 menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
328 328
329 QIconSet icon; 329 QIconSet icon;
330 330
331 331
332 icon = loadPixmap( pathString + "newtodo" ); 332 icon = loadPixmap( pathString + "newtodo" );
333 configureToolBarMenu->insertItem(icon, "New todo", 20 ); 333 configureToolBarMenu->insertItem(icon, "New todo", 20 );
334 QAction* nt_action = new QAction( "New Todo", icon, "New Todo...", 0, this ); 334 QAction* nt_action = new QAction( "New Todo", icon, "New Todo...", 0, this );
335 nt_action->addTo( actionMenu ); 335 nt_action->addTo( actionMenu );
336 connect( nt_action, SIGNAL( activated() ), 336 connect( nt_action, SIGNAL( activated() ),
337 mView, SLOT( newTodo() ) ); 337 mView, SLOT( newTodo() ) );
338 338
339/* 339/*
340 QAction *action; 340 QAction *action;
341 QIconSet icon; 341 QIconSet icon;
342 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 342 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
343 configureToolBarMenu = new QPopupMenu( this ); 343 configureToolBarMenu = new QPopupMenu( this );
344 configureToolBarMenu->setCheckable( true ); 344 configureToolBarMenu->setCheckable( true );
345#ifdef DESKTOP_VERSION 345#ifdef DESKTOP_VERSION
346 QString pathString = ""; 346 QString pathString = "";
347#else 347#else
348 QString pathString = "kaddressbook/"; 348 QString pathString = "kaddressbook/";
349#endif 349#endif
350 if ( QApplication::desktop()->width() < 480 ) 350 if ( QApplication::desktop()->width() < 480 )
351 pathString += "icons16/"; 351 pathString += "icons16/";
352 configureAgendaMenu = new QPopupMenu( menuBar ); 352 configureAgendaMenu = new QPopupMenu( menuBar );
353 configureAgendaMenu->setCheckable( true ); 353 configureAgendaMenu->setCheckable( true );
354 configureAgendaMenu->insertItem("Toggle Allday", 1 ); 354 configureAgendaMenu->insertItem("Toggle Allday", 1 );
355 configureAgendaMenu->insertSeparator(); 355 configureAgendaMenu->insertSeparator();
356 configureAgendaMenu->insertItem("Tiny", 4 ); 356 configureAgendaMenu->insertItem("Tiny", 4 );
357 configureAgendaMenu->insertItem("Small", 6 ); 357 configureAgendaMenu->insertItem("Small", 6 );
358 configureAgendaMenu->insertItem("Medium", 8 ); 358 configureAgendaMenu->insertItem("Medium", 8 );
359 configureAgendaMenu->insertItem("Normal", 10 ); 359 configureAgendaMenu->insertItem("Normal", 10 );
360 configureAgendaMenu->insertItem("Large", 12 ); 360 configureAgendaMenu->insertItem("Large", 12 );
361 configureAgendaMenu->insertItem("Big", 14 ); 361 configureAgendaMenu->insertItem("Big", 14 );
362 configureAgendaMenu->insertItem("Bigger", 16 ); 362 configureAgendaMenu->insertItem("Bigger", 16 );
363 configureAgendaMenu->insertItem("Biggest", 18 ); 363 configureAgendaMenu->insertItem("Biggest", 18 );
364 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 364 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
365 icon = loadPixmap( pathString + "newevent" ); 365 icon = loadPixmap( pathString + "newevent" );
366 icon = loadPixmap( pathString + "newevent" ); 366 icon = loadPixmap( pathString + "newevent" );
367 configureToolBarMenu->insertItem("Stretched TB", 5 ); 367 configureToolBarMenu->insertItem("Stretched TB", 5 );
368 configureToolBarMenu->insertSeparator(); 368 configureToolBarMenu->insertSeparator();
369 configureToolBarMenu->insertItem(icon, "New event", 10 ); 369 configureToolBarMenu->insertItem(icon, "New event", 10 );
370 QAction* ne_action = new QAction( "New Event", icon, "New Event...", 0, this ); 370 QAction* ne_action = new QAction( "New Event", icon, "New Event...", 0, this );
371 ne_action->addTo( actionMenu ); 371 ne_action->addTo( actionMenu );
372*/ 372*/
373/* 373/*
374 connect( ne_action, SIGNAL( activated() ), 374 connect( ne_action, SIGNAL( activated() ),
375 mView, SLOT( newEvent() ) ); 375 mView, SLOT( newEvent() ) );
376 icon = loadPixmap( pathString + "newtodo" ); 376 icon = loadPixmap( pathString + "newtodo" );
377 configureToolBarMenu->insertItem(icon, "New todo", 20 ); 377 configureToolBarMenu->insertItem(icon, "New todo", 20 );
378 QAction* nt_action = new QAction( "New Todo", icon, "New Todo...", 0, this ); 378 QAction* nt_action = new QAction( "New Todo", icon, "New Todo...", 0, this );
379 nt_action->addTo( actionMenu ); 379 nt_action->addTo( actionMenu );
380 connect( nt_action, SIGNAL( activated() ), 380 connect( nt_action, SIGNAL( activated() ),
381 mView, SLOT( newTodo() ) ); 381 mView, SLOT( newTodo() ) );
382 382
383 action = new QAction( "Toggle FilterView", QPixmap(), "Toggle FilterView", 0, this ); 383 action = new QAction( "Toggle FilterView", QPixmap(), "Toggle FilterView", 0, this );
384 action->addTo( viewMenu ); 384 action->addTo( viewMenu );
385 connect( action, SIGNAL( activated() ), 385 connect( action, SIGNAL( activated() ),
386 mView, SLOT( toggleFilter() ) ); 386 mView, SLOT( toggleFilter() ) );
387 387
388 viewMenu->insertSeparator(); 388 viewMenu->insertSeparator();
389 icon = loadPixmap( pathString + "picker" ); 389 icon = loadPixmap( pathString + "picker" );
390 action = new QAction( "Date Picker", icon, "Date Picker", 0, this ); 390 action = new QAction( "Date Picker", icon, "Date Picker", 0, this );
391 action->addTo( viewMenu ); 391 action->addTo( viewMenu );
392 connect( action, SIGNAL( activated() ), 392 connect( action, SIGNAL( activated() ),
393 mView, SLOT( showDatePicker() ) ); 393 mView, SLOT( showDatePicker() ) );
394 action->addTo( iconToolBar ); 394 action->addTo( iconToolBar );
395 viewMenu->insertSeparator(); 395 viewMenu->insertSeparator();
396 icon = loadPixmap( pathString + "list" ); 396 icon = loadPixmap( pathString + "list" );
397 configureToolBarMenu->insertItem(icon, "Event list", 30 ); 397 configureToolBarMenu->insertItem(icon, "Event list", 30 );
398 QAction* showlist_action = new QAction( "List", icon, "List", 0, this ); 398 QAction* showlist_action = new QAction( "List", icon, "List", 0, this );
399 showlist_action->addTo( viewMenu ); 399 showlist_action->addTo( viewMenu );
400 connect( showlist_action, SIGNAL( activated() ), 400 connect( showlist_action, SIGNAL( activated() ),
401 mView->viewManager(), SLOT( showListView() ) ); 401 mView->viewManager(), SLOT( showListView() ) );
402 402
403 403
404 icon = loadPixmap( pathString + "day" ); 404 icon = loadPixmap( pathString + "day" );
405 configureToolBarMenu->insertItem(icon, "One day", 40 ); 405 configureToolBarMenu->insertItem(icon, "One day", 40 );
406 QAction* day1_action = new QAction( "Day", icon, "Day", 0, this ); 406 QAction* day1_action = new QAction( "Day", icon, "Day", 0, this );
407 day1_action->addTo( viewMenu ); 407 day1_action->addTo( viewMenu );
408 // action->addTo( toolBar ); 408 // action->addTo( toolBar );
409 connect( day1_action, SIGNAL( activated() ), 409 connect( day1_action, SIGNAL( activated() ),
410 mView->viewManager(), SLOT( showDayView() ) ); 410 mView->viewManager(), SLOT( showDayView() ) );
411 411
412 icon = loadPixmap( pathString + "workweek" ); 412 icon = loadPixmap( pathString + "workweek" );
413 configureToolBarMenu->insertItem(icon, "Work week", 50 ); 413 configureToolBarMenu->insertItem(icon, "Work week", 50 );
414 QAction* day5_action = new QAction( "Work Week", icon, "Work Week", 0, this ); 414 QAction* day5_action = new QAction( "Work Week", icon, "Work Week", 0, this );
415 day5_action->addTo( viewMenu ); 415 day5_action->addTo( viewMenu );
416 connect( day5_action, SIGNAL( activated() ), 416 connect( day5_action, SIGNAL( activated() ),
417 mView->viewManager(), SLOT( showWorkWeekView() ) ); 417 mView->viewManager(), SLOT( showWorkWeekView() ) );
418 418
419 icon = loadPixmap( pathString + "week" ); 419 icon = loadPixmap( pathString + "week" );
420 configureToolBarMenu->insertItem(icon, "Week", 60 ); 420 configureToolBarMenu->insertItem(icon, "Week", 60 );
421 QAction* day7_action = new QAction( "Week", icon, "Week", 0, this ); 421 QAction* day7_action = new QAction( "Week", icon, "Week", 0, this );
422 day7_action->addTo( viewMenu ); 422 day7_action->addTo( viewMenu );
423 connect( day7_action, SIGNAL( activated() ), 423 connect( day7_action, SIGNAL( activated() ),
424 mView->viewManager(), SLOT( showWeekView() ) ); 424 mView->viewManager(), SLOT( showWeekView() ) );
425 425
426 icon = loadPixmap( pathString + "month" ); 426 icon = loadPixmap( pathString + "month" );
427 configureToolBarMenu->insertItem(icon, "Month", 70 ); 427 configureToolBarMenu->insertItem(icon, "Month", 70 );
428 QAction* month_action = new QAction( "Month", icon, "Month", 0, this ); 428 QAction* month_action = new QAction( "Month", icon, "Month", 0, this );
429 month_action->addTo( viewMenu ); 429 month_action->addTo( viewMenu );
430 connect( month_action, SIGNAL( activated() ), 430 connect( month_action, SIGNAL( activated() ),
431 mView->viewManager(), SLOT( showMonthView() ) ); 431 mView->viewManager(), SLOT( showMonthView() ) );
432 432
433 icon = loadPixmap( pathString + "todo" ); 433 icon = loadPixmap( pathString + "todo" );
434 configureToolBarMenu->insertItem(icon, "Todo list", 80 ); 434 configureToolBarMenu->insertItem(icon, "Todo list", 80 );
435 QAction* todoview_action = new QAction( "Todo", icon, "Todo", 0, this ); 435 QAction* todoview_action = new QAction( "Todo", icon, "Todo", 0, this );
436 todoview_action->addTo( viewMenu ); 436 todoview_action->addTo( viewMenu );
437 connect( todoview_action, SIGNAL( activated() ), 437 connect( todoview_action, SIGNAL( activated() ),
438 mView->viewManager(), SLOT( showTodoView() ) ); 438 mView->viewManager(), SLOT( showTodoView() ) );
439 439
440 icon = loadPixmap( pathString + "journal" ); 440 icon = loadPixmap( pathString + "journal" );
441 configureToolBarMenu->insertItem(icon, "Journal", 90 ); 441 configureToolBarMenu->insertItem(icon, "Journal", 90 );
442 QAction* viewjournal_action = new QAction( "Journal", icon, "Journal", 0, this ); 442 QAction* viewjournal_action = new QAction( "Journal", icon, "Journal", 0, this );
443 viewjournal_action->addTo( viewMenu ); 443 viewjournal_action->addTo( viewMenu );
444 connect( viewjournal_action, SIGNAL( activated() ), 444 connect( viewjournal_action, SIGNAL( activated() ),
445 mView->viewManager(), SLOT( showJournalView() ) ); 445 mView->viewManager(), SLOT( showJournalView() ) );
446 446
447 icon = loadPixmap( pathString + "xdays" ); 447 icon = loadPixmap( pathString + "xdays" );
448 configureToolBarMenu->insertItem(icon, "Next days", 100,4 ); 448 configureToolBarMenu->insertItem(icon, "Next days", 100,4 );
449 QAction* xdays_action = new QAction( "Next days", icon, "Next Days", 0, this ); 449 QAction* xdays_action = new QAction( "Next days", icon, "Next Days", 0, this );
450 xdays_action->addTo( viewMenu ); 450 xdays_action->addTo( viewMenu );
451 connect( xdays_action, SIGNAL( activated() ), 451 connect( xdays_action, SIGNAL( activated() ),
452 mView->viewManager(), SLOT( showNextXView() ) ); 452 mView->viewManager(), SLOT( showNextXView() ) );
453 453
454 icon = loadPixmap( pathString + "whatsnext" ); 454 icon = loadPixmap( pathString + "whatsnext" );
455 configureToolBarMenu->insertItem(icon, "Whats next", 110, 4 ); 455 configureToolBarMenu->insertItem(icon, "Whats next", 110, 4 );
456 QAction* whatsnext_action = new QAction( "What's Next", icon, "What's Next", 0, this ); 456 QAction* whatsnext_action = new QAction( "What's Next", icon, "What's Next", 0, this );
457 whatsnext_action->addTo( viewMenu ); 457 whatsnext_action->addTo( viewMenu );
458 connect( whatsnext_action, SIGNAL( activated() ), 458 connect( whatsnext_action, SIGNAL( activated() ),
459 mView->viewManager(), SLOT( showWhatsNextView() ) ); 459 mView->viewManager(), SLOT( showWhatsNextView() ) );
460 460
461#if 0 461#if 0
462 action = new QAction( "view_timespan", "Time Span", 0, this ); 462 action = new QAction( "view_timespan", "Time Span", 0, this );
463 action->addTo( viewMenu ); 463 action->addTo( viewMenu );
464 connect( action, SIGNAL( activated() ), 464 connect( action, SIGNAL( activated() ),
465 mView->viewManager(), SLOT( showTimeSpanView() ) ); 465 mView->viewManager(), SLOT( showTimeSpanView() ) );
466#endif 466#endif
467 467
468 menuBar->insertItem( "View", viewMenu ); 468 menuBar->insertItem( "View", viewMenu );
469 469
470 470
471#if 0 471#if 0
472 QPopupMenu *navigationMenu = new QPopupMenu( menuBar ); 472 QPopupMenu *navigationMenu = new QPopupMenu( menuBar );
473 473
474 action = new QAction( "Go backward", "Go Backward", 0, navigationMenu ); 474 action = new QAction( "Go backward", "Go Backward", 0, navigationMenu );
475 action->addTo( navigationMenu ); 475 action->addTo( navigationMenu );
476 connect( action, SIGNAL( activated() ), 476 connect( action, SIGNAL( activated() ),
477 mView, SLOT( goPrevious() ) ); 477 mView, SLOT( goPrevious() ) );
478 478
479 action = new QAction( "Go forward", "Go Forward", 0, navigationMenu ); 479 action = new QAction( "Go forward", "Go Forward", 0, navigationMenu );
480 action->addTo( navigationMenu ); 480 action->addTo( navigationMenu );
481 connect( action, SIGNAL( activated() ), 481 connect( action, SIGNAL( activated() ),
482 mView, SLOT( goNext() ) ); 482 mView, SLOT( goNext() ) );
483 483
484 menuBar->insertItem( "Go", navigationMenu ); 484 menuBar->insertItem( "Go", navigationMenu );
485#endif 485#endif
486 486
487 487
488 488
489 489
490 490
491 491
492 mNewSubTodoAction = new QAction( "new_subtodo", "New Sub-Todo...", 0, 492 mNewSubTodoAction = new QAction( "new_subtodo", "New Sub-Todo...", 0,
493 this ); 493 this );
494 mNewSubTodoAction->addTo( actionMenu ); 494 mNewSubTodoAction->addTo( actionMenu );
495 connect( mNewSubTodoAction, SIGNAL( activated() ), 495 connect( mNewSubTodoAction, SIGNAL( activated() ),
496 mView, SLOT( newSubTodo() ) ); 496 mView, SLOT( newSubTodo() ) );
497 497
498 actionMenu->insertSeparator(); 498 actionMenu->insertSeparator();
499 499
500 mShowAction = new QAction( "show_incidence", "Show...", 0, this ); 500 mShowAction = new QAction( "show_incidence", "Show...", 0, this );
501 mShowAction->addTo( actionMenu ); 501 mShowAction->addTo( actionMenu );
502 connect( mShowAction, SIGNAL( activated() ), 502 connect( mShowAction, SIGNAL( activated() ),
503 mView, SLOT( showIncidence() ) ); 503 mView, SLOT( showIncidence() ) );
504 504
505 mEditAction = new QAction( "edit_incidence", "Edit...", 0, this ); 505 mEditAction = new QAction( "edit_incidence", "Edit...", 0, this );
506 mEditAction->addTo( actionMenu ); 506 mEditAction->addTo( actionMenu );
507 connect( mEditAction, SIGNAL( activated() ), 507 connect( mEditAction, SIGNAL( activated() ),
508 mView, SLOT( editIncidence() ) ); 508 mView, SLOT( editIncidence() ) );
509 509
510 mDeleteAction = new QAction( "delete_incidence", "Delete...", 0, this ); 510 mDeleteAction = new QAction( "delete_incidence", "Delete...", 0, this );
511 mDeleteAction->addTo( actionMenu ); 511 mDeleteAction->addTo( actionMenu );
512 connect( mDeleteAction, SIGNAL( activated() ), 512 connect( mDeleteAction, SIGNAL( activated() ),
513 mView, SLOT( deleteIncidence() ) ); 513 mView, SLOT( deleteIncidence() ) );
514 514
515 actionMenu->insertSeparator(); 515 actionMenu->insertSeparator();
516 516
517 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 517 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
518 this ); 518 this );
519 action->addTo( actionMenu ); 519 action->addTo( actionMenu );
520 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 520 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
521 521
522 icon = loadPixmap( pathString + "search" ); 522 icon = loadPixmap( pathString + "search" );
523 QAction* search_action = new QAction( "search", icon, "Search...", 0, this ); 523 QAction* search_action = new QAction( "search", icon, "Search...", 0, this );
524 configureToolBarMenu->insertItem(icon, "Search", 120 , 4); 524 configureToolBarMenu->insertItem(icon, "Search", 120 , 4);
525 search_action->addTo( actionMenu ); 525 search_action->addTo( actionMenu );
526 connect( search_action, SIGNAL( activated() ), 526 connect( search_action, SIGNAL( activated() ),
527 mView->dialogManager(), SLOT( showSearchDialog() ) ); 527 mView->dialogManager(), SLOT( showSearchDialog() ) );
528 528
529 icon = loadPixmap( pathString + "today" ); 529 icon = loadPixmap( pathString + "today" );
530 configureToolBarMenu->insertItem(icon, "Today", 130); 530 configureToolBarMenu->insertItem(icon, "Today", 130);
531 QAction* today_action = new QAction( "Today", icon, "Go to Today", 0, this ); 531 QAction* today_action = new QAction( "Today", icon, "Go to Today", 0, this );
532 today_action->addTo( actionMenu ); 532 today_action->addTo( actionMenu );
533 connect( today_action, SIGNAL( activated() ), 533 connect( today_action, SIGNAL( activated() ),
534 mView, SLOT( goToday() ) ); 534 mView, SLOT( goToday() ) );
535 535
536 //#if 0 536 //#if 0
537 actionMenu->insertSeparator(); 537 actionMenu->insertSeparator();
538 538
539 action = new QAction( "configure", "Configure...", 0, this ); 539 action = new QAction( "configure", "Configure...", 0, this );
540 action->addTo( actionMenu ); 540 action->addTo( actionMenu );
541 connect( action, SIGNAL( activated() ), 541 connect( action, SIGNAL( activated() ),
542 mView, SLOT( edit_options() ) ); 542 mView, SLOT( edit_options() ) );
543 //#endif 543 //#endif
544 544
545 // actionMenu->insertSeparator(); 545 // actionMenu->insertSeparator();
546 action = new QAction( "import_qtopia", "Import (*.ics/*.vcs) file", 0, 546 action = new QAction( "import_qtopia", "Import (*.ics/*.vcs) file", 0,
547 this ); 547 this );
548 action->addTo( importMenu ); 548 action->addTo( importMenu );
549 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 549 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
550 action = new QAction( "import_quick", "Import last file", 0, 550 action = new QAction( "import_quick", "Import last file", 0,
551 this ); 551 this );
552 action->addTo( importMenu ); 552 action->addTo( importMenu );
553 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 553 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
554 importMenu->insertSeparator(); 554 importMenu->insertSeparator();
555 action = new QAction( "import_qtopia", "Import Opie/Qtopia Cal.", 0, 555 action = new QAction( "import_qtopia", "Import Opie/Qtopia Cal.", 0,
556 this ); 556 this );
557 action->addTo( importMenu ); 557 action->addTo( importMenu );
558 importMenu->insertSeparator(); 558 importMenu->insertSeparator();
559 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 559 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
560 560
561 action = new QAction( "load_cal", "Load Calendar Backup", 0, 561 action = new QAction( "load_cal", "Load Calendar Backup", 0,
562 this ); 562 this );
563 action->addTo( importMenu ); 563 action->addTo( importMenu );
564 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 564 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
565 565
566 action = new QAction( "save_cal", "Save Calendar Backup", 0, 566 action = new QAction( "save_cal", "Save Calendar Backup", 0,
567 this ); 567 this );
568 action->addTo( importMenu ); 568 action->addTo( importMenu );
569 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 569 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
570 570
571 importMenu->insertSeparator(); 571 importMenu->insertSeparator();
572 action = new QAction( "import_qtopia", "Export VCalendar", 0, 572 action = new QAction( "import_qtopia", "Export VCalendar", 0,
573 this ); 573 this );
574 action->addTo( importMenu ); 574 action->addTo( importMenu );
575 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 575 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
576 576
577 577
578 QPopupMenu *syncMenu = new QPopupMenu( this ); 578 QPopupMenu *syncMenu = new QPopupMenu( this );
579 action = new QAction( "syncssh", "Remote via ssh/scp(not implemented)", 0, 579 action = new QAction( "syncssh", "Remote via ssh/scp(not implemented)", 0,
580 this ); 580 this );
581 action->addTo( syncMenu ); 581 action->addTo( syncMenu );
582 connect( action, SIGNAL( activated() ), SLOT( syncSSH() ) ); 582 connect( action, SIGNAL( activated() ), SLOT( syncSSH() ) );
583 action = new QAction( "synclocal", "With local file(not implemented)", 0, 583 action = new QAction( "synclocal", "With local file(not implemented)", 0,
584 this ); 584 this );
585 action->addTo( syncMenu ); 585 action->addTo( syncMenu );
586 connect( action, SIGNAL( activated() ), SLOT( syncLocalFile() ) ); 586 connect( action, SIGNAL( activated() ), SLOT( syncLocalFile() ) );
587 action = new QAction( "quicksynclocal", "With last file(not implemented)", 0, 587 action = new QAction( "quicksynclocal", "With last file(not implemented)", 0,
588 this ); 588 this );
589 action->addTo( syncMenu ); 589 action->addTo( syncMenu );
590 connect( action, SIGNAL( activated() ), SLOT( quickSyncLocalFile() ) ); 590 connect( action, SIGNAL( activated() ), SLOT( quickSyncLocalFile() ) );
591 591
592 menuBar->insertItem( "Actions", actionMenu ); 592 menuBar->insertItem( "Actions", actionMenu );
593 menuBar->insertItem( "Load/Save", importMenu ); 593 menuBar->insertItem( "Load/Save", importMenu );
594 menuBar->insertItem( "Synchronize", syncMenu ); 594 menuBar->insertItem( "Synchronize", syncMenu );
595 //menuBar->insertItem( "Configure",configureMenu ); 595 //menuBar->insertItem( "Configure",configureMenu );
596 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 596 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
597 menuBar->insertItem( "AgendaSize",configureAgendaMenu ); 597 menuBar->insertItem( "AgendaSize",configureAgendaMenu );
598 menuBar->insertItem( "Toolbar",configureToolBarMenu ); 598 menuBar->insertItem( "Toolbar",configureToolBarMenu );
599 QPopupMenu *helpMenu = new QPopupMenu( menuBar ); 599 QPopupMenu *helpMenu = new QPopupMenu( menuBar );
600 icon = loadPixmap( "korganizer/korganizer" ); 600 icon = loadPixmap( "korganizer/korganizer" );
601 action = new QAction( "Key bindings", "Key Bindings...", 0, this ); 601 action = new QAction( "Key bindings", "Key Bindings...", 0, this );
602 action->addTo( helpMenu ); 602 action->addTo( helpMenu );
603 connect( action, SIGNAL( activated() ), 603 connect( action, SIGNAL( activated() ),
604 SLOT( keyBindings() ) ); 604 SLOT( keyBindings() ) );
605 action = new QAction( "Auto saving", "Auto saving...", 0, this ); 605 action = new QAction( "Auto saving", "Auto saving...", 0, this );
606 action->addTo( helpMenu ); 606 action->addTo( helpMenu );
607 connect( action, SIGNAL( activated() ), 607 connect( action, SIGNAL( activated() ),
608 SLOT( aboutAutoSaving() ) ); 608 SLOT( aboutAutoSaving() ) );
609 action = new QAction( "Problemd", "Known Problems...", 0,this ); 609 action = new QAction( "Problemd", "Known Problems...", 0,this );
610 action->addTo( helpMenu ); 610 action->addTo( helpMenu );
611 connect( action, SIGNAL( activated() ), 611 connect( action, SIGNAL( activated() ),
612 SLOT( aboutKnownBugs() ) ); 612 SLOT( aboutKnownBugs() ) );
613 action = new QAction( "about", "About...", 0, this ); 613 action = new QAction( "about", "About...", 0, this );
614 action->addTo( helpMenu ); 614 action->addTo( helpMenu );
615 connect( action, SIGNAL( activated() ), 615 connect( action, SIGNAL( activated() ),
616 SLOT( about() ) ); 616 SLOT( about() ) );
617 menuBar->insertItem( "Help", helpMenu ); 617 menuBar->insertItem( "Help", helpMenu );
618*/ 618*/
619 //menuBar->insertSeparator(); 619 //menuBar->insertSeparator();
620 620
621 // ****************************************************** 621 // ******************************************************
622 // menubar icons 622 // menubar icons
623 623
624 624
625 iconToolBar->setHorizontalStretchable (true ); 625 iconToolBar->setHorizontalStretchable (true );
626 //menuBar->insertItem( iconToolBar ); 626 //menuBar->insertItem( iconToolBar );
627 //xdays_action 627 //xdays_action
628/* 628/*
629 if (p-> mShowIconNewEvent) 629 if (p-> mShowIconNewEvent)
630 ne_action->addTo( iconToolBar ); 630 ne_action->addTo( iconToolBar );
631 if (p->mShowIconNewTodo ) 631 if (p->mShowIconNewTodo )
632 nt_action->addTo( iconToolBar ); 632 nt_action->addTo( iconToolBar );
633 if (p-> mShowIconSearch) 633 if (p-> mShowIconSearch)
634 search_action->addTo( iconToolBar ); 634 search_action->addTo( iconToolBar );
635 if (p-> mShowIconNext) 635 if (p-> mShowIconNext)
636 whatsnext_action->addTo( iconToolBar ); 636 whatsnext_action->addTo( iconToolBar );
637 if (p-> mShowIconNextDays) 637 if (p-> mShowIconNextDays)
638 xdays_action->addTo( iconToolBar ); 638 xdays_action->addTo( iconToolBar );
639 if (p-> mShowIconList) 639 if (p-> mShowIconList)
640 showlist_action->addTo( iconToolBar ); 640 showlist_action->addTo( iconToolBar );
641 if (p-> mShowIconDay1) 641 if (p-> mShowIconDay1)
642 day1_action->addTo( iconToolBar ); 642 day1_action->addTo( iconToolBar );
643 if (p-> mShowIconDay5) 643 if (p-> mShowIconDay5)
644 day5_action->addTo( iconToolBar ); 644 day5_action->addTo( iconToolBar );
645 if (p-> mShowIconDay7) 645 if (p-> mShowIconDay7)
646 day7_action->addTo( iconToolBar ); 646 day7_action->addTo( iconToolBar );
647 if (p-> mShowIconMonth) 647 if (p-> mShowIconMonth)
648 month_action->addTo( iconToolBar ); 648 month_action->addTo( iconToolBar );
649 if (p-> mShowIconTodoview) 649 if (p-> mShowIconTodoview)
650 todoview_action->addTo( iconToolBar ); 650 todoview_action->addTo( iconToolBar );
651 if (p-> mShowIconJournal) 651 if (p-> mShowIconJournal)
652 viewjournal_action->addTo( iconToolBar ); 652 viewjournal_action->addTo( iconToolBar );
653 icon = loadPixmap( pathString + "2leftarrowB" ); 653 icon = loadPixmap( pathString + "2leftarrowB" );
654 configureToolBarMenu->insertItem(icon, "Prev. month", 200, 14); 654 configureToolBarMenu->insertItem(icon, "Prev. month", 200, 14);
655 if (p-> mShowIconBackFast) { 655 if (p-> mShowIconBackFast) {
656 action = new QAction( "Prev month", icon, "Go Backward",0 , this ); 656 action = new QAction( "Prev month", icon, "Go Backward",0 , this );
657 connect( action, SIGNAL( activated() ), 657 connect( action, SIGNAL( activated() ),
658 mView, SLOT( goPreviousMonth() ) ); 658 mView, SLOT( goPreviousMonth() ) );
659 action->addTo( iconToolBar ); 659 action->addTo( iconToolBar );
660 } 660 }
661 icon = loadPixmap( pathString + "1leftarrowB" ); 661 icon = loadPixmap( pathString + "1leftarrowB" );
662 configureToolBarMenu->insertItem(icon, "Go previous", 210,15); 662 configureToolBarMenu->insertItem(icon, "Go previous", 210,15);
663 if (p-> mShowIconBack) { 663 if (p-> mShowIconBack) {
664 action = new QAction( "Go previous", icon, "Go Backward",0 , this ); 664 action = new QAction( "Go previous", icon, "Go Backward",0 , this );
665 connect( action, SIGNAL( activated() ), 665 connect( action, SIGNAL( activated() ),
666 mView, SLOT( goPrevious() ) ); 666 mView, SLOT( goPrevious() ) );
667 action->addTo( iconToolBar ); 667 action->addTo( iconToolBar );
668 } 668 }
669 if (p-> mShowIconToday) 669 if (p-> mShowIconToday)
670 today_action->addTo( iconToolBar ); 670 today_action->addTo( iconToolBar );
671 icon = loadPixmap( pathString + "1rightarrowB" ); 671 icon = loadPixmap( pathString + "1rightarrowB" );
672 configureToolBarMenu->insertItem(icon, "Go next", 220); 672 configureToolBarMenu->insertItem(icon, "Go next", 220);
673 if (p-> mShowIconForward) { 673 if (p-> mShowIconForward) {
674 action = new QAction( "Go next", icon, "Go Backward",0 , this ); 674 action = new QAction( "Go next", icon, "Go Backward",0 , this );
675 connect( action, SIGNAL( activated() ), 675 connect( action, SIGNAL( activated() ),
676 mView, SLOT( goNext() ) ); 676 mView, SLOT( goNext() ) );
677 action->addTo( iconToolBar ); 677 action->addTo( iconToolBar );
678 } 678 }
679 icon = loadPixmap( pathString + "2rightarrowB" ); 679 icon = loadPixmap( pathString + "2rightarrowB" );
680 configureToolBarMenu->insertItem(icon, "Next month", 230); 680 configureToolBarMenu->insertItem(icon, "Next month", 230);
681 if (p-> mShowIconForwardFast) { 681 if (p-> mShowIconForwardFast) {
682 action = new QAction( "Next month", icon, "Go Backward",0 , this ); 682 action = new QAction( "Next month", icon, "Go Backward",0 , this );
683 connect( action, SIGNAL( activated() ), 683 connect( action, SIGNAL( activated() ),
684 mView, SLOT( goNextMonth() ) ); 684 mView, SLOT( goNextMonth() ) );
685 action->addTo( iconToolBar ); 685 action->addTo( iconToolBar );
686 } 686 }
687*/ 687*/
688 688
689 configureToolBarMenu->insertItem("WhatsThis", 300); 689 configureToolBarMenu->insertItem("WhatsThis", 300);
690/* 690/*
691 if (p-> mShowIconNewEvent) 691 if (p-> mShowIconNewEvent)
692 configureToolBarMenu->setItemChecked( 10, true ); 692 configureToolBarMenu->setItemChecked( 10, true );
693 if (p->mShowIconNewTodo ) 693 if (p->mShowIconNewTodo )
694 configureToolBarMenu->setItemChecked( 20, true ); 694 configureToolBarMenu->setItemChecked( 20, true );
695 if (p-> mShowIconSearch) 695 if (p-> mShowIconSearch)
696 configureToolBarMenu->setItemChecked( 120, true ); 696 configureToolBarMenu->setItemChecked( 120, true );
697 if (p-> mShowIconList) 697 if (p-> mShowIconList)
698 configureToolBarMenu->setItemChecked( 30, true ); 698 configureToolBarMenu->setItemChecked( 30, true );
699 if (p-> mShowIconDay1) 699 if (p-> mShowIconDay1)
700 configureToolBarMenu->setItemChecked( 40, true ); 700 configureToolBarMenu->setItemChecked( 40, true );
701 if (p-> mShowIconDay5) 701 if (p-> mShowIconDay5)
702 configureToolBarMenu->setItemChecked( 50, true ); 702 configureToolBarMenu->setItemChecked( 50, true );
703 if (p-> mShowIconDay7) 703 if (p-> mShowIconDay7)
704 configureToolBarMenu->setItemChecked( 60, true ); 704 configureToolBarMenu->setItemChecked( 60, true );
705 if (p-> mShowIconMonth) 705 if (p-> mShowIconMonth)
706 configureToolBarMenu->setItemChecked( 70, true ); 706 configureToolBarMenu->setItemChecked( 70, true );
707 if (p-> mShowIconTodoview) 707 if (p-> mShowIconTodoview)
708 configureToolBarMenu->setItemChecked( 80, true ); 708 configureToolBarMenu->setItemChecked( 80, true );
709 if (p-> mShowIconBackFast) 709 if (p-> mShowIconBackFast)
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp
index df3b551..3661677 100644
--- a/kaddressbook/phoneeditwidget.cpp
+++ b/kaddressbook/phoneeditwidget.cpp
@@ -1,731 +1,737 @@
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#include <qlayout.h> 24#include <qlayout.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qtooltip.h> 26#include <qtooltip.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qcheckbox.h> 28#include <qcheckbox.h>
29#include <qstring.h> 29#include <qstring.h>
30#include <qlistbox.h> 30#include <q3listbox.h>
31#include <qlistview.h> 31#include <q3listview.h>
32#include <qbuttongroup.h> 32#include <q3buttongroup.h>
33#include <qhbox.h> 33#include <q3hbox.h>
34#include <qcursor.h> 34#include <qcursor.h>
35#include <qtimer.h> 35#include <qtimer.h>
36#include <qapplication.h> 36#include <qapplication.h>
37//Added by qt3to4:
38#include <Q3ValueList>
39#include <Q3GridLayout>
40#include <Q3Frame>
41#include <Q3PopupMenu>
42#include <Q3VBoxLayout>
37 43
38#include <kbuttonbox.h> 44#include <kbuttonbox.h>
39#include <klistview.h> 45#include <klistview.h>
40#include <kapplication.h> 46#include <kapplication.h>
41#include <qapplication.h> 47#include <qapplication.h>
42#include <kconfig.h> 48#include <kconfig.h>
43#include <kmessagebox.h> 49#include <kmessagebox.h>
44#include <klineedit.h> 50#include <klineedit.h>
45#include <kcombobox.h> 51#include <kcombobox.h>
46#include <klocale.h> 52#include <klocale.h>
47#include <kdebug.h> 53#include <kdebug.h>
48#include <kglobal.h> 54#include <kglobal.h>
49#include <kiconloader.h> 55#include <kiconloader.h>
50 56
51#include <kabc/phonenumber.h> 57#include <kabc/phonenumber.h>
52 58
53#include "typecombo.h" 59#include "typecombo.h"
54 60
55#include "phoneeditwidget.h" 61#include "phoneeditwidget.h"
56 62
57PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name ) 63PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name )
58 : QWidget(parent,name) 64 : QWidget(parent,name)
59{ 65{
60 QGridLayout* gridLayout = new QGridLayout ( this, 2,2 ); 66 Q3GridLayout* gridLayout = new Q3GridLayout ( this, 2,2 );
61 67
62 QLabel *temp = new QLabel( "", this ); 68 QLabel *temp = new QLabel( "", this );
63 temp->setAlignment( Qt::AlignCenter ); 69 temp->setAlignment( Qt::AlignCenter );
64 temp->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); 70 temp->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) );
65 QPushButton *addBut = new QPushButton ( "add", this ); 71 QPushButton *addBut = new QPushButton ( "add", this );
66 addBut->setPixmap ( SmallIcon("plus")); 72 addBut->setPixmap ( SmallIcon("plus"));
67 addBut->setMaximumSize( addBut->sizeHint().height(),addBut->sizeHint().height() ); 73 addBut->setMaximumSize( addBut->sizeHint().height(),addBut->sizeHint().height() );
68 connect(addBut,SIGNAL(clicked ()),SLOT(addNumber())); 74 connect(addBut,SIGNAL(clicked ()),SLOT(addNumber()));
69 75
70 sv = new QScrollView( this ); 76 sv = new Q3ScrollView( this );
71 sv->setFrameStyle ( QFrame::Plain ); 77 sv->setFrameStyle ( Q3Frame::Plain );
72 sv->setLineWidth ( 0 ); 78 sv->setLineWidth ( 0 );
73 sv->setMidLineWidth ( 0 ); 79 sv->setMidLineWidth ( 0 );
74 mw = new QWidget ( sv->viewport() ); 80 mw = new QWidget ( sv->viewport() );
75 sv->addChild(mw); 81 sv->addChild(mw);
76 sv->setResizePolicy( QScrollView::AutoOneFit ); 82 sv->setResizePolicy( Q3ScrollView::AutoOneFit );
77 mainLayout = new QVBoxLayout ( mw ); 83 mainLayout = new Q3VBoxLayout ( mw );
78 mainLayout->setMargin( 0 ); 84 mainLayout->setMargin( 0 );
79 mainLayout->setSpacing( 0 ); 85 mainLayout->setSpacing( 0 );
80 gridLayout->setMargin( 2 ); 86 gridLayout->setMargin( 2 );
81 gridLayout->setSpacing( 4 ); 87 gridLayout->setSpacing( 4 );
82 if ( QApplication::desktop()->width() == 240 || QApplication::desktop()->width() == 480 ) { 88 if ( QApplication::desktop()->width() == 240 || QApplication::desktop()->width() == 480 ) {
83 gridLayout->addWidget( addBut, 0, 0 ); 89 gridLayout->addWidget( addBut, 0, 0 );
84 gridLayout->addWidget( temp, 0, 1 ); 90 gridLayout->addWidget( temp, 0, 1 );
85 gridLayout->addMultiCellWidget( sv, 1,1 , 0,1 ); 91 gridLayout->addMultiCellWidget( sv, 1,1 , 0,1 );
86 } else { 92 } else {
87 gridLayout->addWidget( temp, 1, 0 ); 93 gridLayout->addWidget( temp, 1, 0 );
88 gridLayout->addWidget( addBut, 0, 0 ); 94 gridLayout->addWidget( addBut, 0, 0 );
89 gridLayout->addMultiCellWidget( sv, 0, 1, 1,1 ); 95 gridLayout->addMultiCellWidget( sv, 0, 1, 1,1 );
90 } 96 }
91 setDefaults(); 97 setDefaults();
92 mTypeNumberEditList.setAutoDelete( true ); 98 mTypeNumberEditList.setAutoDelete( true );
93 mPopup = new QPopupMenu( this ); 99 mPopup = new Q3PopupMenu( this );
94 QStringList list = PhoneNumber::supportedTypeListNames(); 100 QStringList list = PhoneNumber::supportedTypeListNames();
95 mPopupCount = list.count(); 101 mPopupCount = list.count();
96 int i = 0; 102 int i = 0;
97 while ( i < mPopupCount ) { 103 while ( i < mPopupCount ) {
98 mPopup->insertItem( list[ i ], i ); 104 mPopup->insertItem( list[ i ], i );
99 ++i; 105 ++i;
100 } 106 }
101 connect(mPopup,SIGNAL(activated(int)),this,SLOT(addNumberInt( int))); 107 connect(mPopup,SIGNAL(activated(int)),this,SLOT(addNumberInt( int)));
102 108
103} 109}
104 110
105PhoneEditWidget::~PhoneEditWidget() 111PhoneEditWidget::~PhoneEditWidget()
106{ 112{
107} 113}
108void PhoneEditWidget::setDefaults() 114void PhoneEditWidget::setDefaults()
109{ 115{
110 mTypeNumberEditList.clear(); 116 mTypeNumberEditList.clear();
111 PhoneTypeNumberEdit* edit = appendEditCombo(); 117 PhoneTypeNumberEdit* edit = appendEditCombo();
112 KABC::PhoneNumber phoneNumber; 118 KABC::PhoneNumber phoneNumber;
113 phoneNumber.setType( KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref ); 119 phoneNumber.setType( KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref );
114 edit->setPhoneNumber( phoneNumber ); 120 edit->setPhoneNumber( phoneNumber );
115 edit = appendEditCombo(); 121 edit = appendEditCombo();
116 KABC::PhoneNumber phoneNumber2; 122 KABC::PhoneNumber phoneNumber2;
117 phoneNumber2.setType( KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref ); 123 phoneNumber2.setType( KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref );
118 edit->setPhoneNumber( phoneNumber2 ); 124 edit->setPhoneNumber( phoneNumber2 );
119 edit = appendEditCombo(); 125 edit = appendEditCombo();
120 KABC::PhoneNumber phoneNumber3; 126 KABC::PhoneNumber phoneNumber3;
121 phoneNumber3.setType( KABC::PhoneNumber::Cell ); 127 phoneNumber3.setType( KABC::PhoneNumber::Cell );
122 edit->setPhoneNumber( phoneNumber3 ); 128 edit->setPhoneNumber( phoneNumber3 );
123 129
124} 130}
125void PhoneEditWidget::addNumberInt( int index ) 131void PhoneEditWidget::addNumberInt( int index )
126{ 132{
127 PhoneTypeNumberEdit* edit = appendEditCombo(); 133 PhoneTypeNumberEdit* edit = appendEditCombo();
128 KABC::PhoneNumber phoneNumber; 134 KABC::PhoneNumber phoneNumber;
129 phoneNumber.setType( PhoneNumber::supportedTypeList()[index] ); 135 phoneNumber.setType( PhoneNumber::supportedTypeList()[index] );
130 edit->setPhoneNumber( phoneNumber ); 136 edit->setPhoneNumber( phoneNumber );
131 //verticalScrollBar()->setValue( 1024); 137 //verticalScrollBar()->setValue( 1024);
132 QTimer::singleShot( 0, this, SLOT ( bottomVisible() ) ); 138 QTimer::singleShot( 0, this, SLOT ( bottomVisible() ) );
133} 139}
134void PhoneEditWidget::bottomVisible() 140void PhoneEditWidget::bottomVisible()
135{ 141{
136 sv->setContentsPos ( 0, 1024 ); 142 sv->setContentsPos ( 0, 1024 );
137} 143}
138void PhoneEditWidget::addNumber() 144void PhoneEditWidget::addNumber()
139{ 145{
140 int i = 0; 146 int i = 0;
141 while ( i < mPopupCount ) { 147 while ( i < mPopupCount ) {
142 mPopup->setItemEnabled( i, true ); 148 mPopup->setItemEnabled( i, true );
143 ++i; 149 ++i;
144 } 150 }
145 PhoneTypeNumberEdit* edit = mTypeNumberEditList.first(); 151 PhoneTypeNumberEdit* edit = mTypeNumberEditList.first();
146 while ( edit ) { 152 while ( edit ) {
147 if ( edit->currentType() < mPopupCount -1 ) 153 if ( edit->currentType() < mPopupCount -1 )
148 mPopup->setItemEnabled( edit->currentType(), false ); 154 mPopup->setItemEnabled( edit->currentType(), false );
149 edit = mTypeNumberEditList.next(); 155 edit = mTypeNumberEditList.next();
150 } 156 }
151 mPopup->popup( QCursor::pos() ); 157 mPopup->popup( QCursor::pos() );
152} 158}
153PhoneTypeNumberEdit* PhoneEditWidget::appendEditCombo() 159PhoneTypeNumberEdit* PhoneEditWidget::appendEditCombo()
154{ 160{
155 PhoneTypeNumberEdit* edit = new PhoneTypeNumberEdit( mw ); 161 PhoneTypeNumberEdit* edit = new PhoneTypeNumberEdit( mw );
156 connect ( edit, SIGNAL ( typeChange( int , int) ), this, SIGNAL ( typeChange( int , int)) ); 162 connect ( edit, SIGNAL ( typeChange( int , int) ), this, SIGNAL ( typeChange( int , int)) );
157 connect ( edit, SIGNAL ( modified() ), this, SIGNAL ( modified() ) ); 163 connect ( edit, SIGNAL ( modified() ), this, SIGNAL ( modified() ) );
158 connect ( edit, SIGNAL ( deleteMe( PhoneTypeNumberEdit* ) ), this, SLOT ( deleteEdit( PhoneTypeNumberEdit*) ) ); 164 connect ( edit, SIGNAL ( deleteMe( PhoneTypeNumberEdit* ) ), this, SLOT ( deleteEdit( PhoneTypeNumberEdit*) ) );
159 connect ( this, SIGNAL ( typeChange( int , int)), edit, SLOT ( typeExternalChanged( int, int)) ); 165 connect ( this, SIGNAL ( typeChange( int , int)), edit, SLOT ( typeExternalChanged( int, int)) );
160 166
161 mainLayout->add( edit ); 167 mainLayout->add( edit );
162 mTypeNumberEditList.append( edit ); 168 mTypeNumberEditList.append( edit );
163 return edit; 169 return edit;
164} 170}
165 171
166void PhoneEditWidget::deleteEdit( PhoneTypeNumberEdit* ew ) 172void PhoneEditWidget::deleteEdit( PhoneTypeNumberEdit* ew )
167{ 173{
168 mPendingDelete = ew; 174 mPendingDelete = ew;
169 QTimer::singleShot( 0, this, SLOT ( pendingDelete() ) ); 175 QTimer::singleShot( 0, this, SLOT ( pendingDelete() ) );
170} 176}
171void PhoneEditWidget::pendingDelete() 177void PhoneEditWidget::pendingDelete()
172{ 178{
173 mTypeNumberEditList.removeRef( mPendingDelete ); 179 mTypeNumberEditList.removeRef( mPendingDelete );
174 emit modified(); 180 emit modified();
175} 181}
176 182
177void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &li ) 183void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &li )
178{ 184{
179 if ( li.isEmpty() ) { 185 if ( li.isEmpty() ) {
180 setDefaults(); 186 setDefaults();
181 return; 187 return;
182 } 188 }
183 mTypeNumberEditList.clear(); 189 mTypeNumberEditList.clear();
184 KABC::PhoneNumber::List::Iterator it; 190 KABC::PhoneNumber::List::Iterator it;
185 KABC::PhoneNumber::List list2 = li; 191 KABC::PhoneNumber::List list2 = li;
186 KABC::PhoneNumber::List list ; 192 KABC::PhoneNumber::List list ;
187 193
188 PhoneNumber::TypeList tList = PhoneNumber::supportedTypeList(); 194 PhoneNumber::TypeList tList = PhoneNumber::supportedTypeList();
189 int i = 0; 195 int i = 0;
190 int max = tList.count(); 196 int max = tList.count();
191 while ( i < max-1 ) { 197 while ( i < max-1 ) {
192 for ( it = list2.begin(); it != list2.end(); ++it ) { 198 for ( it = list2.begin(); it != list2.end(); ++it ) {
193 if ( (*it).type() == tList[i] ) { 199 if ( (*it).type() == tList[i] ) {
194 list.append( (*it ) ); 200 list.append( (*it ) );
195 break; 201 break;
196 } 202 }
197 } 203 }
198 ++i; 204 ++i;
199 } 205 }
200 for ( it = list2.begin(); it != list2.end(); ++it ) { 206 for ( it = list2.begin(); it != list2.end(); ++it ) {
201 if ( (*it).type() == tList[ max-1 ] ) 207 if ( (*it).type() == tList[ max-1 ] )
202 list.append( (*it ) ); 208 list.append( (*it ) );
203 } 209 }
204 for ( it = list.begin(); it != list.end(); ++it ) { 210 for ( it = list.begin(); it != list.end(); ++it ) {
205 PhoneTypeNumberEdit* editNew = appendEditCombo(); 211 PhoneTypeNumberEdit* editNew = appendEditCombo();
206 editNew->setPhoneNumber( (*it ) ); 212 editNew->setPhoneNumber( (*it ) );
207 } 213 }
208 214
209} 215}
210KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() 216KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers()
211{ 217{
212 KABC::PhoneNumber::List retList; 218 KABC::PhoneNumber::List retList;
213 219
214 PhoneTypeNumberEdit* edit = mTypeNumberEditList.first(); 220 PhoneTypeNumberEdit* edit = mTypeNumberEditList.first();
215 while ( edit ) { 221 while ( edit ) {
216 if ( edit->isValid() ) { 222 if ( edit->isValid() ) {
217 retList.append( edit->phoneNumber()); 223 retList.append( edit->phoneNumber());
218 } 224 }
219 edit = mTypeNumberEditList.next(); 225 edit = mTypeNumberEditList.next();
220 226
221 } 227 }
222 return retList; 228 return retList;
223} 229}
224 230
225#if 0 231#if 0
226PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name ) 232PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name )
227 : QWidget( parent, name ) 233 : QWidget( parent, name )
228{ 234{
229 QGridLayout *layout = new QGridLayout( this, 4, 1 ); 235 Q3GridLayout *layout = new Q3GridLayout( this, 4, 1 );
230//US layout->setSpacing( KDialog::spacingHint() ); 236//US layout->setSpacing( KDialog::spacingHint() );
231 layout->setSpacing( KDialogBase::spacingHintSmall() ); 237 layout->setSpacing( KDialogBase::spacingHintSmall() );
232 238
233 239
234 240
235 QLabel* label = new QLabel( this ); 241 QLabel* label = new QLabel( this );
236//US loadIcon call is ambiguous. Add one more parameter 242//US loadIcon call is ambiguous. Add one more parameter
237//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); 243//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) );
238 label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); 244 label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) );
239 label->setAlignment( AlignCenter ); 245 label->setAlignment( Qt::AlignCenter );
240//US layout->addMultiCellWidget( label, 0, 1, 3, 3 ); 246//US layout->addMultiCellWidget( label, 0, 1, 3, 3 );
241 layout->addWidget( label, 0, 0 ); 247 layout->addWidget( label, 0, 0 );
242 248
243 QPushButton *editButton = new QPushButton( i18n( "Edit Phone Numbers..." ), 249 QPushButton *editButton = new QPushButton( i18n( "Edit Phone Numbers..." ),
244 this ); 250 this );
245 if ( QApplication::desktop()->width() < 640 ) 251 if ( QApplication::desktop()->width() < 640 )
246 layout->addWidget( editButton, 0, 1 ); 252 layout->addWidget( editButton, 0, 1 );
247 else 253 else
248 layout->addMultiCellWidget( editButton, 0, 0, 1, 3); 254 layout->addMultiCellWidget( editButton, 0, 0, 1, 3);
249 255
250 mPrefCombo = new PhoneTypeCombo( mPhoneList, this ); 256 mPrefCombo = new PhoneTypeCombo( mPhoneList, this );
251 mPrefEdit = new KLineEdit( this ); 257 mPrefEdit = new KLineEdit( this );
252 //mPrefEdit->setMinimumWidth( int(mPrefEdit->sizeHint().width() * 1.5) ); 258 //mPrefEdit->setMinimumWidth( int(mPrefEdit->sizeHint().width() * 1.5) );
253 mPrefCombo->setLineEdit( mPrefEdit ); 259 mPrefCombo->setLineEdit( mPrefEdit );
254 layout->addWidget( mPrefCombo, 1, 0 ); 260 layout->addWidget( mPrefCombo, 1, 0 );
255 layout->addWidget( mPrefEdit, 1, 1 ); 261 layout->addWidget( mPrefEdit, 1, 1 );
256 int x = 1, y = 2; 262 int x = 1, y = 2;
257 if ( QApplication::desktop()->width() < 640 ) { 263 if ( QApplication::desktop()->width() < 640 ) {
258 ++x; 264 ++x;
259 y = 0; 265 y = 0;
260 } 266 }
261 mSecondCombo = new PhoneTypeCombo( mPhoneList, this ); 267 mSecondCombo = new PhoneTypeCombo( mPhoneList, this );
262 mSecondEdit = new KLineEdit( this ); 268 mSecondEdit = new KLineEdit( this );
263 mSecondCombo->setLineEdit( mSecondEdit ); 269 mSecondCombo->setLineEdit( mSecondEdit );
264 layout->addWidget( mSecondCombo, x, y++ ); 270 layout->addWidget( mSecondCombo, x, y++ );
265 layout->addWidget( mSecondEdit, x, y++ ); 271 layout->addWidget( mSecondEdit, x, y++ );
266 272
267 y = 0; 273 y = 0;
268 ++x; 274 ++x;
269 mThirdCombo = new PhoneTypeCombo( mPhoneList, this ); 275 mThirdCombo = new PhoneTypeCombo( mPhoneList, this );
270 mThirdEdit = new KLineEdit( this ); 276 mThirdEdit = new KLineEdit( this );
271 mThirdCombo->setLineEdit( mThirdEdit ); 277 mThirdCombo->setLineEdit( mThirdEdit );
272 layout->addWidget( mThirdCombo, x, y++ ); 278 layout->addWidget( mThirdCombo, x, y++ );
273 layout->addWidget( mThirdEdit, x, y++ ); 279 layout->addWidget( mThirdEdit, x, y++ );
274 if ( QApplication::desktop()->width() < 640 ) { 280 if ( QApplication::desktop()->width() < 640 ) {
275 ++x; 281 ++x;
276 y = 0; 282 y = 0;
277 } 283 }
278 mFourthCombo = new PhoneTypeCombo( mPhoneList, this ); 284 mFourthCombo = new PhoneTypeCombo( mPhoneList, this );
279 mFourthEdit = new KLineEdit( this ); 285 mFourthEdit = new KLineEdit( this );
280 mFourthCombo->setLineEdit( mFourthEdit ); 286 mFourthCombo->setLineEdit( mFourthEdit );
281 layout->addWidget( mFourthCombo, x, y++ ); 287 layout->addWidget( mFourthCombo, x, y++ );
282 layout->addWidget( mFourthEdit, x, y++ ); 288 layout->addWidget( mFourthEdit, x, y++ );
283 289
284 // Four numbers don't fit in the current dialog 290 // Four numbers don't fit in the current dialog
285 if ( QApplication::desktop()->width() < 640 ) { 291 if ( QApplication::desktop()->width() < 640 ) {
286 mFourthCombo->hide(); 292 mFourthCombo->hide();
287 mFourthEdit->hide(); 293 mFourthEdit->hide();
288 } else { 294 } else {
289 QFontMetrics fm ( font () ) ; 295 QFontMetrics fm ( font () ) ;
290 int wid = fm.width( "Messenger" ) +60; 296 int wid = fm.width( "Messenger" ) +60;
291 mPrefCombo->setMaximumWidth( wid ); 297 mPrefCombo->setMaximumWidth( wid );
292 mSecondCombo->setMaximumWidth( wid ); 298 mSecondCombo->setMaximumWidth( wid );
293 mThirdCombo->setMaximumWidth( wid ); 299 mThirdCombo->setMaximumWidth( wid );
294 mFourthCombo->setMaximumWidth( wid ); 300 mFourthCombo->setMaximumWidth( wid );
295 } 301 }
296 302
297 303
298 connect( mPrefEdit, SIGNAL( textChanged( const QString& ) ), 304 connect( mPrefEdit, SIGNAL( textChanged( const QString& ) ),
299 SLOT( slotPrefEditChanged() ) ); 305 SLOT( slotPrefEditChanged() ) );
300 connect( mSecondEdit, SIGNAL( textChanged( const QString& ) ), 306 connect( mSecondEdit, SIGNAL( textChanged( const QString& ) ),
301 SLOT( slotSecondEditChanged() ) ); 307 SLOT( slotSecondEditChanged() ) );
302 connect( mThirdEdit, SIGNAL( textChanged( const QString& ) ), 308 connect( mThirdEdit, SIGNAL( textChanged( const QString& ) ),
303 SLOT( slotThirdEditChanged() ) ); 309 SLOT( slotThirdEditChanged() ) );
304 connect( mFourthEdit, SIGNAL( textChanged( const QString& ) ), 310 connect( mFourthEdit, SIGNAL( textChanged( const QString& ) ),
305 SLOT( slotFourthEditChanged() ) ); 311 SLOT( slotFourthEditChanged() ) );
306 312
307 connect( editButton, SIGNAL( clicked() ), SLOT( edit() ) ); 313 connect( editButton, SIGNAL( clicked() ), SLOT( edit() ) );
308 314
309 connect( mPrefCombo, SIGNAL( activated( int ) ), 315 connect( mPrefCombo, SIGNAL( activated( int ) ),
310 SLOT( updatePrefEdit() ) ); 316 SLOT( updatePrefEdit() ) );
311 connect( mSecondCombo, SIGNAL( activated( int ) ), 317 connect( mSecondCombo, SIGNAL( activated( int ) ),
312 SLOT( updateSecondEdit() ) ); 318 SLOT( updateSecondEdit() ) );
313 connect( mThirdCombo, SIGNAL( activated( int ) ), 319 connect( mThirdCombo, SIGNAL( activated( int ) ),
314 SLOT( updateThirdEdit() ) ); 320 SLOT( updateThirdEdit() ) );
315 connect( mFourthCombo, SIGNAL( activated( int ) ), 321 connect( mFourthCombo, SIGNAL( activated( int ) ),
316 SLOT( updateFourthEdit() ) ); 322 SLOT( updateFourthEdit() ) );
317} 323}
318 324
319PhoneEditWidget::~PhoneEditWidget() 325PhoneEditWidget::~PhoneEditWidget()
320{ 326{
321} 327}
322 328
323void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &list ) 329void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &list )
324{ 330{
325 mPhoneList.clear(); 331 mPhoneList.clear();
326 332
327 // Insert types for existing numbers. 333 // Insert types for existing numbers.
328 mPrefCombo->insertTypeList( list ); 334 mPrefCombo->insertTypeList( list );
329 335
330 QValueList<int> defaultTypes; 336 Q3ValueList<int> defaultTypes;
331 defaultTypes << KABC::PhoneNumber::Home; 337 defaultTypes << KABC::PhoneNumber::Home;
332 defaultTypes << KABC::PhoneNumber::Work; 338 defaultTypes << KABC::PhoneNumber::Work;
333 defaultTypes << KABC::PhoneNumber::Cell; 339 defaultTypes << KABC::PhoneNumber::Cell;
334 defaultTypes << ( KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax ); 340 defaultTypes << ( KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax );
335 defaultTypes << ( KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax ); 341 defaultTypes << ( KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax );
336 342
337 // Insert default types. 343 // Insert default types.
338 // Doing this for mPrefCombo is enough because the list is shared by all 344 // Doing this for mPrefCombo is enough because the list is shared by all
339 // combos. 345 // combos.
340 QValueList<int>::ConstIterator it; 346 Q3ValueList<int>::ConstIterator it;
341 for( it = defaultTypes.begin(); it != defaultTypes.end(); ++it ) { 347 for( it = defaultTypes.begin(); it != defaultTypes.end(); ++it ) {
342 if ( !mPrefCombo->hasType( *it ) ) 348 if ( !mPrefCombo->hasType( *it ) )
343 mPrefCombo->insertType( list, *it, PhoneNumber( "", *it ) ); 349 mPrefCombo->insertType( list, *it, PhoneNumber( "", *it ) );
344 } 350 }
345 351
346 updateCombos(); 352 updateCombos();
347 353
348 mPrefCombo->selectType( defaultTypes[ 0 ] ); 354 mPrefCombo->selectType( defaultTypes[ 0 ] );
349 mSecondCombo->selectType( defaultTypes[ 1 ] ); 355 mSecondCombo->selectType( defaultTypes[ 1 ] );
350 mThirdCombo->selectType( defaultTypes[ 2 ] ); 356 mThirdCombo->selectType( defaultTypes[ 2 ] );
351 mFourthCombo->selectType( defaultTypes[ 3 ] ); 357 mFourthCombo->selectType( defaultTypes[ 3 ] );
352 358
353 updateLineEdits(); 359 updateLineEdits();
354} 360}
355 361
356void PhoneEditWidget::updateLineEdits() 362void PhoneEditWidget::updateLineEdits()
357{ 363{
358 updatePrefEdit(); 364 updatePrefEdit();
359 updateSecondEdit(); 365 updateSecondEdit();
360 updateThirdEdit(); 366 updateThirdEdit();
361 updateFourthEdit(); 367 updateFourthEdit();
362} 368}
363 369
364void PhoneEditWidget::updateCombos() 370void PhoneEditWidget::updateCombos()
365{ 371{
366 mPrefCombo->updateTypes(); 372 mPrefCombo->updateTypes();
367 mSecondCombo->updateTypes(); 373 mSecondCombo->updateTypes();
368 mThirdCombo->updateTypes(); 374 mThirdCombo->updateTypes();
369 mFourthCombo->updateTypes(); 375 mFourthCombo->updateTypes();
370} 376}
371 377
372KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() 378KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers()
373{ 379{
374 KABC::PhoneNumber::List retList; 380 KABC::PhoneNumber::List retList;
375 381
376 KABC::PhoneNumber::List::Iterator it; 382 KABC::PhoneNumber::List::Iterator it;
377 for ( it = mPhoneList.begin(); it != mPhoneList.end(); ++it ) 383 for ( it = mPhoneList.begin(); it != mPhoneList.end(); ++it )
378 if ( !(*it).number().isEmpty() ) 384 if ( !(*it).number().isEmpty() )
379 retList.append( *it ); 385 retList.append( *it );
380 386
381 return retList; 387 return retList;
382} 388}
383 389
384void PhoneEditWidget::edit() 390void PhoneEditWidget::edit()
385{ 391{
386 PhoneEditDialog dlg( mPhoneList, this ); 392 PhoneEditDialog dlg( mPhoneList, this );
387 393
388 if ( dlg.exec() ) { 394 if ( dlg.exec() ) {
389 if ( dlg.changed() ) { 395 if ( dlg.changed() ) {
390 KABC::PhoneNumber::List list = dlg.phoneNumbers(); 396 KABC::PhoneNumber::List list = dlg.phoneNumbers();
391 setPhoneNumbers( list ); 397 setPhoneNumbers( list );
392 updateCombos(); 398 updateCombos();
393 updateLineEdits(); 399 updateLineEdits();
394 emit modified(); 400 emit modified();
395 } 401 }
396 } 402 }
397} 403}
398 404
399void PhoneEditWidget::updatePrefEdit() 405void PhoneEditWidget::updatePrefEdit()
400{ 406{
401 updateEdit( mPrefCombo ); 407 updateEdit( mPrefCombo );
402} 408}
403 409
404void PhoneEditWidget::updateSecondEdit() 410void PhoneEditWidget::updateSecondEdit()
405{ 411{
406 updateEdit( mSecondCombo ); 412 updateEdit( mSecondCombo );
407} 413}
408 414
409void PhoneEditWidget::updateThirdEdit() 415void PhoneEditWidget::updateThirdEdit()
410{ 416{
411 updateEdit( mThirdCombo ); 417 updateEdit( mThirdCombo );
412} 418}
413 419
414void PhoneEditWidget::updateFourthEdit() 420void PhoneEditWidget::updateFourthEdit()
415{ 421{
416 updateEdit( mFourthCombo ); 422 updateEdit( mFourthCombo );
417} 423}
418 424
419void PhoneEditWidget::updateEdit( PhoneTypeCombo *combo ) 425void PhoneEditWidget::updateEdit( PhoneTypeCombo *combo )
420{ 426{
421 QLineEdit *edit = combo->lineEdit(); 427 QLineEdit *edit = combo->lineEdit();
422 if ( !edit ) 428 if ( !edit )
423 return; 429 return;
424 430
425#if 0 431#if 0
426 if ( edit == mPrefEdit ) kdDebug(5720) << " prefEdit" << endl; 432 if ( edit == mPrefEdit ) kdDebug(5720) << " prefEdit" << endl;
427 if ( edit == mSecondEdit ) kdDebug(5720) << " secondEdit" << endl; 433 if ( edit == mSecondEdit ) kdDebug(5720) << " secondEdit" << endl;
428 if ( edit == mThirdEdit ) kdDebug(5720) << " thirdEdit" << endl; 434 if ( edit == mThirdEdit ) kdDebug(5720) << " thirdEdit" << endl;
429 if ( edit == mFourthEdit ) kdDebug(5720) << " fourthEdit" << endl; 435 if ( edit == mFourthEdit ) kdDebug(5720) << " fourthEdit" << endl;
430#endif 436#endif
431 437
432 PhoneNumber::List::Iterator it = combo->selectedElement(); 438 PhoneNumber::List::Iterator it = combo->selectedElement();
433 if ( it != mPhoneList.end() ) { 439 if ( it != mPhoneList.end() ) {
434 edit->setText( (*it).number() ); 440 edit->setText( (*it).number() );
435 } else { 441 } else {
436 kdDebug(5720) << "PhoneEditWidget::updateEdit(): no selected element" << endl; 442 kdDebug(5720) << "PhoneEditWidget::updateEdit(): no selected element" << endl;
437 } 443 }
438} 444}
439 445
440void PhoneEditWidget::slotPrefEditChanged() 446void PhoneEditWidget::slotPrefEditChanged()
441{ 447{
442 updatePhoneNumber( mPrefCombo ); 448 updatePhoneNumber( mPrefCombo );
443} 449}
444 450
445void PhoneEditWidget::slotSecondEditChanged() 451void PhoneEditWidget::slotSecondEditChanged()
446{ 452{
447 updatePhoneNumber( mSecondCombo ); 453 updatePhoneNumber( mSecondCombo );
448} 454}
449 455
450void PhoneEditWidget::slotThirdEditChanged() 456void PhoneEditWidget::slotThirdEditChanged()
451{ 457{
452 updatePhoneNumber( mThirdCombo ); 458 updatePhoneNumber( mThirdCombo );
453} 459}
454 460
455void PhoneEditWidget::slotFourthEditChanged() 461void PhoneEditWidget::slotFourthEditChanged()
456{ 462{
457 updatePhoneNumber( mFourthCombo ); 463 updatePhoneNumber( mFourthCombo );
458} 464}
459 465
460void PhoneEditWidget::updatePhoneNumber( PhoneTypeCombo *combo ) 466void PhoneEditWidget::updatePhoneNumber( PhoneTypeCombo *combo )
461{ 467{
462 QLineEdit *edit = combo->lineEdit(); 468 QLineEdit *edit = combo->lineEdit();
463 if ( !edit ) return; 469 if ( !edit ) return;
464 470
465 PhoneNumber::List::Iterator it = combo->selectedElement(); 471 PhoneNumber::List::Iterator it = combo->selectedElement();
466 if ( it != mPhoneList.end() ) { 472 if ( it != mPhoneList.end() ) {
467 (*it).setNumber( edit->text() ); 473 (*it).setNumber( edit->text() );
468 } 474 }
469 475
470 updateOtherEdit( combo, mPrefCombo ); 476 updateOtherEdit( combo, mPrefCombo );
471 updateOtherEdit( combo, mSecondCombo ); 477 updateOtherEdit( combo, mSecondCombo );
472 updateOtherEdit( combo, mThirdCombo ); 478 updateOtherEdit( combo, mThirdCombo );
473 updateOtherEdit( combo, mFourthCombo ); 479 updateOtherEdit( combo, mFourthCombo );
474 480
475 emit modified(); 481 emit modified();
476} 482}
477 483
478void PhoneEditWidget::updateOtherEdit( PhoneTypeCombo *combo, PhoneTypeCombo *otherCombo ) 484void PhoneEditWidget::updateOtherEdit( PhoneTypeCombo *combo, PhoneTypeCombo *otherCombo )
479{ 485{
480 if ( combo == otherCombo ) return; 486 if ( combo == otherCombo ) return;
481 487
482 if ( combo->currentItem() == otherCombo->currentItem() ) { 488 if ( combo->currentItem() == otherCombo->currentItem() ) {
483 updateEdit( otherCombo ); 489 updateEdit( otherCombo );
484 } 490 }
485} 491}
486 492
487/////////////////////////////////////////// 493///////////////////////////////////////////
488// PhoneEditDialog 494// PhoneEditDialog
489 495
490class PhoneViewItem : public QListViewItem 496class PhoneViewItem : public Q3ListViewItem
491{ 497{
492public: 498public:
493 PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number ); 499 PhoneViewItem( Q3ListView *parent, const KABC::PhoneNumber &number );
494 500
495 void setPhoneNumber( const KABC::PhoneNumber &number ) 501 void setPhoneNumber( const KABC::PhoneNumber &number )
496 { 502 {
497 mPhoneNumber = number; 503 mPhoneNumber = number;
498 makeText(); 504 makeText();
499 } 505 }
500 506
501 QString key() { return mPhoneNumber.id(); } 507 QString key() { return mPhoneNumber.id(); }
502 QString country() { return ""; } 508 QString country() { return ""; }
503 QString region() { return ""; } 509 QString region() { return ""; }
504 QString number() { return ""; } 510 QString number() { return ""; }
505 511
506 KABC::PhoneNumber phoneNumber() { return mPhoneNumber; } 512 KABC::PhoneNumber phoneNumber() { return mPhoneNumber; }
507 513
508private: 514private:
509 void makeText(); 515 void makeText();
510 516
511 KABC::PhoneNumber mPhoneNumber; 517 KABC::PhoneNumber mPhoneNumber;
512}; 518};
513 519
514PhoneViewItem::PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number ) 520PhoneViewItem::PhoneViewItem( Q3ListView *parent, const KABC::PhoneNumber &number )
515 : QListViewItem( parent ), mPhoneNumber( number ) 521 : Q3ListViewItem( parent ), mPhoneNumber( number )
516{ 522{
517#ifdef DESKTOP_VERSION 523#ifdef DESKTOP_VERSION
518 setRenameEnabled ( 0, true ); 524 setRenameEnabled ( 0, true );
519#endif 525#endif
520 makeText(); 526 makeText();
521} 527}
522 528
523void PhoneViewItem::makeText() 529void PhoneViewItem::makeText()
524{ 530{
525 /** 531 /**
526 * Will be used in future versions of kaddressbook/libkabc 532 * Will be used in future versions of kaddressbook/libkabc
527 533
528 setText( 0, mPhoneNumber.country() ); 534 setText( 0, mPhoneNumber.country() );
529 setText( 1, mPhoneNumber.region() ); 535 setText( 1, mPhoneNumber.region() );
530 setText( 2, mPhoneNumber.number() ); 536 setText( 2, mPhoneNumber.number() );
531 setText( 3, mPhoneNumber.typeLabel() ); 537 setText( 3, mPhoneNumber.typeLabel() );
532 */ 538 */
533 539
534 setText( 0, mPhoneNumber.number() ); 540 setText( 0, mPhoneNumber.number() );
535 setText( 1, mPhoneNumber.typeLabel() ); 541 setText( 1, mPhoneNumber.typeLabel() );
536} 542}
537 543
538PhoneEditDialog::PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget *parent, const char *name ) 544PhoneEditDialog::PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget *parent, const char *name )
539 : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Numbers" ), 545 : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Numbers" ),
540 KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, 546 KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok,
541 parent, name, true) 547 parent, name, true)
542{ 548{
543 mPhoneNumberList = list; 549 mPhoneNumberList = list;
544 550
545 QWidget *page = plainPage(); 551 QWidget *page = plainPage();
546 552
547 QGridLayout *layout = new QGridLayout( page, 1, 2 ); 553 Q3GridLayout *layout = new Q3GridLayout( page, 1, 2 );
548 layout->setSpacing( spacingHint() ); 554 layout->setSpacing( spacingHint() );
549 555
550 mListView = new KListView( page ); 556 mListView = new KListView( page );
551 mListView->setAllColumnsShowFocus( true ); 557 mListView->setAllColumnsShowFocus( true );
552 mListView->addColumn( i18n( "Number" ) ); 558 mListView->addColumn( i18n( "Number" ) );
553 mListView->addColumn( i18n( "Type" ) ); 559 mListView->addColumn( i18n( "Type" ) );
554 560
555 KButtonBox *buttonBox = new KButtonBox( page, Vertical ); 561 KButtonBox *buttonBox = new KButtonBox( page, Qt::Vertical );
556 562
557 buttonBox->addButton( i18n( "&Add..." ), this, SLOT( slotAddPhoneNumber() ) ); 563 buttonBox->addButton( i18n( "&Add..." ), this, SLOT( slotAddPhoneNumber() ) );
558 mEditButton = buttonBox->addButton( i18n( "&Edit..." ), this, SLOT( slotEditPhoneNumber() ) ); 564 mEditButton = buttonBox->addButton( i18n( "&Edit..." ), this, SLOT( slotEditPhoneNumber() ) );
559 mEditButton->setEnabled( false ); 565 mEditButton->setEnabled( false );
560 mRemoveButton = buttonBox->addButton( i18n( "&Remove" ), this, SLOT( slotRemovePhoneNumber() ) ); 566 mRemoveButton = buttonBox->addButton( i18n( "&Remove" ), this, SLOT( slotRemovePhoneNumber() ) );
561 mRemoveButton->setEnabled( false ); 567 mRemoveButton->setEnabled( false );
562 buttonBox->layout(); 568 buttonBox->layout();
563 569
564 layout->addWidget( mListView, 0, 0 ); 570 layout->addWidget( mListView, 0, 0 );
565 layout->addWidget( buttonBox, 0, 1 ); 571 layout->addWidget( buttonBox, 0, 1 );
566 572
567 connect( mListView, SIGNAL(selectionChanged()), SLOT(slotSelectionChanged()) ); 573 connect( mListView, SIGNAL(selectionChanged()), SLOT(slotSelectionChanged()) );
568 connect( mListView, SIGNAL(doubleClicked( QListViewItem *, const QPoint &, int )), this, SLOT( slotEditPhoneNumber())); 574 connect( mListView, SIGNAL(doubleClicked( Q3ListViewItem *, const QPoint &, int )), this, SLOT( slotEditPhoneNumber()));
569 575
570 KABC::PhoneNumber::List::Iterator it; 576 KABC::PhoneNumber::List::Iterator it;
571 for ( it = mPhoneNumberList.begin(); it != mPhoneNumberList.end(); ++it ) 577 for ( it = mPhoneNumberList.begin(); it != mPhoneNumberList.end(); ++it )
572 new PhoneViewItem( mListView, *it ); 578 new PhoneViewItem( mListView, *it );
573 if (QApplication::desktop()->width() < 480 ) 579 if (QApplication::desktop()->width() < 480 )
574 showMaximized(); 580 showMaximized();
575 else 581 else
576 resize( 400, 400 ); 582 resize( 400, 400 );
577 mChanged = false; 583 mChanged = false;
578} 584}
579 585
580PhoneEditDialog::~PhoneEditDialog() 586PhoneEditDialog::~PhoneEditDialog()
581{ 587{
582 qDebug("PhoneEditDialog::~PhoneEditDialog() "); 588 qDebug("PhoneEditDialog::~PhoneEditDialog() ");
583} 589}
584 590
585void PhoneEditDialog::slotAddPhoneNumber() 591void PhoneEditDialog::slotAddPhoneNumber()
586{ 592{
587 KABC::PhoneNumber tmp( "", 0 ); 593 KABC::PhoneNumber tmp( "", 0 );
588 PhoneTypeDialog dlg( tmp, this ); 594 PhoneTypeDialog dlg( tmp, this );
589 595
590 if ( dlg.exec() ) { 596 if ( dlg.exec() ) {
591 QListViewItem* i = mListView->firstChild(); 597 Q3ListViewItem* i = mListView->firstChild();
592 KABC::PhoneNumber phoneNumber = dlg.phoneNumber(); 598 KABC::PhoneNumber phoneNumber = dlg.phoneNumber();
593 bool insert = true; 599 bool insert = true;
594 while ( i ) { 600 while ( i ) {
595 PhoneViewItem* p = ( PhoneViewItem* ) i; 601 PhoneViewItem* p = ( PhoneViewItem* ) i;
596 KABC::PhoneNumber pn = p->phoneNumber(); 602 KABC::PhoneNumber pn = p->phoneNumber();
597 if ( (pn.type() | KABC::PhoneNumber::Pref) == (phoneNumber.type() | KABC::PhoneNumber::Pref) ) { 603 if ( (pn.type() | KABC::PhoneNumber::Pref) == (phoneNumber.type() | KABC::PhoneNumber::Pref) ) {
598 if ( p->text(0).isEmpty()) { 604 if ( p->text(0).isEmpty()) {
599 p->setPhoneNumber( phoneNumber ); 605 p->setPhoneNumber( phoneNumber );
600 mPhoneNumberList.remove( pn ); 606 mPhoneNumberList.remove( pn );
601 mPhoneNumberList.append( phoneNumber ); 607 mPhoneNumberList.append( phoneNumber );
602 insert = false; 608 insert = false;
603 break; 609 break;
604 } 610 }
605 } 611 }
606 i = i->nextSibling(); 612 i = i->nextSibling();
607 } 613 }
608 if ( insert ) { 614 if ( insert ) {
609 mPhoneNumberList.append( phoneNumber ); 615 mPhoneNumberList.append( phoneNumber );
610 new PhoneViewItem( mListView, phoneNumber ); 616 new PhoneViewItem( mListView, phoneNumber );
611 } 617 }
612 mChanged = true; 618 mChanged = true;
613 } 619 }
614} 620}
615 621
616void PhoneEditDialog::slotRemovePhoneNumber() 622void PhoneEditDialog::slotRemovePhoneNumber()
617{ 623{
618 PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() ); 624 PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() );
619 if ( !item ) 625 if ( !item )
620 return; 626 return;
621 627
622 mPhoneNumberList.remove( item->phoneNumber() ); 628 mPhoneNumberList.remove( item->phoneNumber() );
623 QListViewItem *currItem = mListView->currentItem(); 629 Q3ListViewItem *currItem = mListView->currentItem();
624 mListView->takeItem( currItem ); 630 mListView->takeItem( currItem );
625 delete currItem; 631 delete currItem;
626 632
627 mChanged = true; 633 mChanged = true;
628} 634}
629 635
630void PhoneEditDialog::slotEditPhoneNumber() 636void PhoneEditDialog::slotEditPhoneNumber()
631{ 637{
632 PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() ); 638 PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() );
633 if ( !item ) 639 if ( !item )
634 return; 640 return;
635 641
636 PhoneTypeDialog dlg( item->phoneNumber(), this ); 642 PhoneTypeDialog dlg( item->phoneNumber(), this );
637 643
638 if ( dlg.exec() ) { 644 if ( dlg.exec() ) {
639 slotRemovePhoneNumber(); 645 slotRemovePhoneNumber();
640 KABC::PhoneNumber phoneNumber = dlg.phoneNumber(); 646 KABC::PhoneNumber phoneNumber = dlg.phoneNumber();
641 mPhoneNumberList.append( phoneNumber ); 647 mPhoneNumberList.append( phoneNumber );
642 new PhoneViewItem( mListView, phoneNumber ); 648 new PhoneViewItem( mListView, phoneNumber );
643 649
644 mChanged = true; 650 mChanged = true;
645 } 651 }
646} 652}
647 653
648void PhoneEditDialog::slotSelectionChanged() 654void PhoneEditDialog::slotSelectionChanged()
649{ 655{
650 bool state = ( mListView->currentItem() != 0 ); 656 bool state = ( mListView->currentItem() != 0 );
651 657
652 mRemoveButton->setEnabled( state ); 658 mRemoveButton->setEnabled( state );
653 mEditButton->setEnabled( state ); 659 mEditButton->setEnabled( state );
654} 660}
655 661
656const KABC::PhoneNumber::List &PhoneEditDialog::phoneNumbers() 662const KABC::PhoneNumber::List &PhoneEditDialog::phoneNumbers()
657{ 663{
658 return mPhoneNumberList; 664 return mPhoneNumberList;
659} 665}
660 666
661bool PhoneEditDialog::changed() const 667bool PhoneEditDialog::changed() const
662{ 668{
663 return mChanged; 669 return mChanged;
664} 670}
665 671
666/////////////////////////////////////////// 672///////////////////////////////////////////
667// PhoneTypeDialog 673// PhoneTypeDialog
668PhoneTypeDialog::PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber, 674PhoneTypeDialog::PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber,
669 QWidget *parent, const char *name) 675 QWidget *parent, const char *name)
670 : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Number" ), 676 : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Number" ),
671 KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, 677 KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok,
672 parent, name, true), mPhoneNumber( phoneNumber ) 678 parent, name, true), mPhoneNumber( phoneNumber )
673{ 679{
674 QWidget *page = plainPage(); 680 QWidget *page = plainPage();
675 QLabel *label = 0; 681 QLabel *label = 0;
676 QGridLayout *layout = new QGridLayout( page, 3, 2, marginHint(), spacingHint() ); 682 Q3GridLayout *layout = new Q3GridLayout( page, 3, 2, marginHint(), spacingHint() );
677 683
678 label = new QLabel( i18n( "Number:" ), page ); 684 label = new QLabel( i18n( "Number:" ), page );
679 layout->addWidget( label, 0, 0 ); 685 layout->addWidget( label, 0, 0 );
680 mNumber = new KLineEdit( page ); 686 mNumber = new KLineEdit( page );
681 layout->addWidget( mNumber, 0, 1 ); 687 layout->addWidget( mNumber, 0, 1 );
682 688
683 mPreferredBox = new QCheckBox( i18n( "This is the preferred phone number" ), page ); 689 mPreferredBox = new QCheckBox( i18n( "This is the preferred phone number" ), page );
684 layout->addMultiCellWidget( mPreferredBox, 1, 1, 0, 1 ); 690 layout->addMultiCellWidget( mPreferredBox, 1, 1, 0, 1 );
685 691
686 mGroup = new QButtonGroup( 2, Horizontal, i18n( "Types" ), page ); 692 mGroup = new Q3ButtonGroup( 2, Qt::Horizontal, i18n( "Types" ), page );
687 layout->addMultiCellWidget( mGroup, 2, 2, 0, 1 ); 693 layout->addMultiCellWidget( mGroup, 2, 2, 0, 1 );
688 694
689 // fill widgets 695 // fill widgets
690 mNumber->setText( mPhoneNumber.number() ); 696 mNumber->setText( mPhoneNumber.number() );
691 697
692 mTypeList = KABC::PhoneNumber::typeList(); 698 mTypeList = KABC::PhoneNumber::typeList();
693 mTypeList.remove( KABC::PhoneNumber::Pref ); 699 mTypeList.remove( KABC::PhoneNumber::Pref );
694 700
695 KABC::PhoneNumber::TypeList::Iterator it; 701 KABC::PhoneNumber::TypeList::Iterator it;
696 for ( it = mTypeList.begin(); it != mTypeList.end(); ++it ) 702 for ( it = mTypeList.begin(); it != mTypeList.end(); ++it )
697 new QCheckBox( KABC::PhoneNumber::typeLabel( *it ), mGroup ); 703 new QCheckBox( KABC::PhoneNumber::typeLabel( *it ), mGroup );
698 704
699 for ( int i = 0; i < mGroup->count(); ++i ) { 705 for ( int i = 0; i < mGroup->count(); ++i ) {
700 int type = mPhoneNumber.type(); 706 int type = mPhoneNumber.type();
701 QCheckBox *box = (QCheckBox*)mGroup->find( i ); 707 QCheckBox *box = (QCheckBox*)mGroup->find( i );
702 box->setChecked( type & mTypeList[ i ] ); 708 box->setChecked( type & mTypeList[ i ] );
703 } 709 }
704 710
705 mPreferredBox->setChecked( mPhoneNumber.type() & KABC::PhoneNumber::Pref ); 711 mPreferredBox->setChecked( mPhoneNumber.type() & KABC::PhoneNumber::Pref );
706 mNumber->setFocus(); 712 mNumber->setFocus();
707 mNumber->setSelection( 0, 1024); 713 mNumber->setSelection( 0, 1024);
708} 714}
709 715
710KABC::PhoneNumber PhoneTypeDialog::phoneNumber() 716KABC::PhoneNumber PhoneTypeDialog::phoneNumber()
711{ 717{
712 mPhoneNumber.setNumber( mNumber->text() ); 718 mPhoneNumber.setNumber( mNumber->text() );
713 719
714 int type = 0; 720 int type = 0;
715 for ( int i = 0; i < mGroup->count(); ++i ) { 721 for ( int i = 0; i < mGroup->count(); ++i ) {
716 QCheckBox *box = (QCheckBox*)mGroup->find( i ); 722 QCheckBox *box = (QCheckBox*)mGroup->find( i );
717 if ( box->isChecked() ) 723 if ( box->isChecked() )
718 type += mTypeList[ i ]; 724 type += mTypeList[ i ];
719 } 725 }
720 726
721 if ( mPreferredBox->isChecked() ) 727 if ( mPreferredBox->isChecked() )
722 mPhoneNumber.setType( type | KABC::PhoneNumber::Pref ); 728 mPhoneNumber.setType( type | KABC::PhoneNumber::Pref );
723 else 729 else
724 mPhoneNumber.setType( type & ~KABC::PhoneNumber::Pref ); 730 mPhoneNumber.setType( type & ~KABC::PhoneNumber::Pref );
725 731
726 return mPhoneNumber; 732 return mPhoneNumber;
727} 733}
728#endif 734#endif
729#ifndef KAB_EMBEDDED 735#ifndef KAB_EMBEDDED_
730#include "phoneeditwidget.moc" 736#include "moc_phoneeditwidget.cpp"
731#endif //KAB_EMBEDDED 737#endif //KAB_EMBEDDED
diff --git a/kaddressbook/phoneeditwidget.h b/kaddressbook/phoneeditwidget.h
index 5bb4226..2be3e2b 100644
--- a/kaddressbook/phoneeditwidget.h
+++ b/kaddressbook/phoneeditwidget.h
@@ -1,186 +1,190 @@
1#ifndef PHONEEDITWIDGET_H 1#ifndef PHONEEDITWIDGET_H
2#define PHONEEDITWIDGET_H 2#define PHONEEDITWIDGET_H
3/* 3/*
4 This file is part of KAddressBook. 4 This file is part of KAddressBook.
5 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 5 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 20
21 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
24*/ 24*/
25 25
26#include <kdialogbase.h> 26#include <kdialogbase.h>
27#include <kiconloader.h> 27#include <kiconloader.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qpopupmenu.h> 30#include <q3popupmenu.h>
31#include <qapplication.h> 31#include <qapplication.h>
32#include <QDesktopWidget>
32 33
33#include <qptrlist.h> 34#include <q3ptrlist.h>
34#include <qscrollview.h> 35#include <q3scrollview.h>
36//Added by qt3to4:
37#include <Q3HBoxLayout>
38#include <Q3VBoxLayout>
35 39
36#include "addresseeconfig.h" 40#include "addresseeconfig.h"
37#include "typecombo.h" 41#include "typecombo.h"
38 42
39class QButtonGroup; 43class Q3ButtonGroup;
40class QCheckBox; 44class QCheckBox;
41class PhoneTypeNumberEdit; 45class PhoneTypeNumberEdit;
42 46
43#include <klineedit.h> 47#include <klineedit.h>
44#include <kcombobox.h> 48#include <kcombobox.h>
45#include <kabc/phonenumber.h> 49#include <kabc/phonenumber.h>
46 50
47typedef TypeCombo<KABC::PhoneNumber> PhoneTypeCombo; 51typedef TypeCombo<KABC::PhoneNumber> PhoneTypeCombo;
48 52
49/** 53/**
50 Widget for editing phone numbers. 54 Widget for editing phone numbers.
51*/ 55*/
52class PhoneEditWidget : public QWidget 56class PhoneEditWidget : public QWidget
53{ 57{
54 Q_OBJECT 58 Q_OBJECT
55 59
56 public: 60 public:
57 PhoneEditWidget( QWidget *parent, const char *name = 0 ); 61 PhoneEditWidget( QWidget *parent, const char *name = 0 );
58 ~PhoneEditWidget(); 62 ~PhoneEditWidget();
59 63
60 void setPhoneNumbers( const KABC::PhoneNumber::List &list ); 64 void setPhoneNumbers( const KABC::PhoneNumber::List &list );
61 KABC::PhoneNumber::List phoneNumbers(); 65 KABC::PhoneNumber::List phoneNumbers();
62 66
63 // void updateTypeCombo( const KABC::PhoneNumber::List&, KComboBox* ); 67 // void updateTypeCombo( const KABC::PhoneNumber::List&, KComboBox* );
64 //KABC::PhoneNumber currentPhoneNumber( KComboBox*, int ); 68 //KABC::PhoneNumber currentPhoneNumber( KComboBox*, int );
65 69
66 signals: 70 signals:
67 void modified(); 71 void modified();
68 void typeChange( int oldType, int newType ); 72 void typeChange( int oldType, int newType );
69 73
70 private slots: 74 private slots:
71 void bottomVisible(); 75 void bottomVisible();
72 void addNumberInt( int ); 76 void addNumberInt( int );
73 void deleteEdit( PhoneTypeNumberEdit* ew ); 77 void deleteEdit( PhoneTypeNumberEdit* ew );
74 void addNumber(); 78 void addNumber();
75 void pendingDelete(); 79 void pendingDelete();
76 protected: 80 protected:
77 81
78 private: 82 private:
79 QScrollView* sv; 83 Q3ScrollView* sv;
80 QPopupMenu *mPopup; 84 Q3PopupMenu *mPopup;
81 int mPopupCount; 85 int mPopupCount;
82 PhoneTypeNumberEdit* mPendingDelete; 86 PhoneTypeNumberEdit* mPendingDelete;
83 void setDefaults(); 87 void setDefaults();
84 PhoneTypeNumberEdit* appendEditCombo(); 88 PhoneTypeNumberEdit* appendEditCombo();
85 QWidget* mw; 89 QWidget* mw;
86 QVBoxLayout* mainLayout; 90 Q3VBoxLayout* mainLayout;
87 QPtrList <PhoneTypeNumberEdit> mTypeNumberEditList; 91 Q3PtrList <PhoneTypeNumberEdit> mTypeNumberEditList;
88 92
89}; 93};
90 94
91 95
92class PhoneTypeNumberEdit : public QWidget 96class PhoneTypeNumberEdit : public QWidget
93{ 97{
94 Q_OBJECT 98 Q_OBJECT
95public: 99public:
96 PhoneTypeNumberEdit( QWidget *parent, const char *name = 0 ) :QWidget( parent ) 100 PhoneTypeNumberEdit( QWidget *parent, const char *name = 0 ) :QWidget( parent )
97 { 101 {
98 QHBoxLayout * lay = new QHBoxLayout( this ); 102 Q3HBoxLayout * lay = new Q3HBoxLayout( this );
99 lay->setSpacing( 2 ); 103 lay->setSpacing( 2 );
100 lay->setMargin( 0 ); 104 lay->setMargin( 0 );
101 mMinusButton = new QPushButton ( this ); 105 mMinusButton = new QPushButton ( this );
102 mMinusButton->setPixmap ( SmallIcon("minus")); 106 mMinusButton->setPixmap ( SmallIcon("minus"));
103 mCombo = new KComboBox( this ); 107 mCombo = new KComboBox( this );
104 if ( QApplication::desktop()->width() <= 640 ) 108 if ( QApplication::desktop()->width() <= 640 )
105 mCombo->setSizeLimit ( 6 ); 109 mCombo->setMaxVisibleItems ( 6 );
106 mNumber = new KLineEdit( this ); 110 mNumber = new KLineEdit( this );
107 mMinusButton->setMaximumHeight( mNumber->sizeHint().height() + 6); 111 mMinusButton->setMaximumHeight( mNumber->sizeHint().height() + 6);
108 lay->addWidget( mMinusButton ); 112 lay->addWidget( mMinusButton );
109 lay->addWidget( mCombo ); 113 lay->addWidget( mCombo );
110 lay->addWidget( mNumber ); 114 lay->addWidget( mNumber );
111 connect( mMinusButton , SIGNAL ( clicked() ), this, SLOT ( deleteNumber() ) ); 115 connect( mMinusButton , SIGNAL ( clicked() ), this, SLOT ( deleteNumber() ) );
112 connect( mCombo , SIGNAL ( activated ( int ) ), this, SLOT ( comboTypeChange( int ) ) ); 116 connect( mCombo , SIGNAL ( activated ( int ) ), this, SLOT ( comboTypeChange( int ) ) );
113 connect( mNumber , SIGNAL ( textChanged ( const QString & ) ), 117 connect( mNumber , SIGNAL ( textChanged ( const QString & ) ),
114 this, SLOT ( textChanged ( const QString & ) ) ); 118 this, SLOT ( textChanged ( const QString & ) ) );
115 mCombo->insertStringList( PhoneNumber::supportedTypeListNames() ); 119 mCombo->insertStringList( PhoneNumber::supportedTypeListNames() );
116 } 120 }
117 ~PhoneTypeNumberEdit() { 121 ~PhoneTypeNumberEdit() {
118 // qDebug("~PhoneTypeNumberEdit() "); 122 // qDebug("~PhoneTypeNumberEdit() ");
119 } 123 }
120 void setPhoneNumber( const KABC::PhoneNumber &phoneNumber ) 124 void setPhoneNumber( const KABC::PhoneNumber &phoneNumber )
121 { 125 {
122 mPhoneNumber = phoneNumber; 126 mPhoneNumber = phoneNumber;
123 int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); 127 int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() );
124 mCombo->setCurrentItem( index ); 128 mCombo->setCurrentItem( index );
125 mNumber->setText( mPhoneNumber.number() ); 129 mNumber->setText( mPhoneNumber.number() );
126 show(); 130 show();
127 mNumber->setFocus(); 131 mNumber->setFocus();
128 } 132 }
129 KABC::PhoneNumber phoneNumber() 133 KABC::PhoneNumber phoneNumber()
130 { 134 {
131 mPhoneNumber.setNumber( mNumber->text() ); 135 mPhoneNumber.setNumber( mNumber->text() );
132 int index = mCombo->currentItem(); 136 int index = mCombo->currentItem();
133 mPhoneNumber.setType( PhoneNumber::supportedTypeList()[index] ); 137 mPhoneNumber.setType( PhoneNumber::supportedTypeList()[index] );
134 return mPhoneNumber; 138 return mPhoneNumber;
135 } 139 }
136 bool isValid() 140 bool isValid()
137 { 141 {
138 if ( mNumber->text().isEmpty() )return false; 142 if ( mNumber->text().isEmpty() )return false;
139 return true; 143 return true;
140 } 144 }
141 int currentType() 145 int currentType()
142 { 146 {
143 return mCombo->currentItem(); 147 return mCombo->currentItem();
144 } 148 }
145 private slots: 149 private slots:
146 void typeExternalChanged( int oldType, int newType ) 150 void typeExternalChanged( int oldType, int newType )
147 { 151 {
148 if ( mPhoneNumber.type() == newType ) { 152 if ( mPhoneNumber.type() == newType ) {
149 mPhoneNumber.setType(oldType); 153 mPhoneNumber.setType(oldType);
150 int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); 154 int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() );
151 mCombo->setCurrentItem( index ); 155 mCombo->setCurrentItem( index );
152 } 156 }
153 } 157 }
154 void deleteNumber() 158 void deleteNumber()
155 { 159 {
156 emit deleteMe( this ); 160 emit deleteMe( this );
157 } 161 }
158 void comboTypeChange( int index ) 162 void comboTypeChange( int index )
159 { 163 {
160 int old = mPhoneNumber.type(); 164 int old = mPhoneNumber.type();
161 int newT = PhoneNumber::supportedTypeList()[index]; 165 int newT = PhoneNumber::supportedTypeList()[index];
162 if ( old != newT ) { 166 if ( old != newT ) {
163 emit modified(); 167 emit modified();
164 if ( newT != PhoneNumber::Voice ) 168 if ( newT != PhoneNumber::Voice )
165 emit typeChange ( old, newT ); 169 emit typeChange ( old, newT );
166 mPhoneNumber.setType(newT ); 170 mPhoneNumber.setType(newT );
167 } 171 }
168 172
169 } 173 }
170 void textChanged ( const QString & ) 174 void textChanged ( const QString & )
171 { 175 {
172 emit modified(); 176 emit modified();
173 } 177 }
174 signals: 178 signals:
175void typeChange( int oldType, int newType ); 179void typeChange( int oldType, int newType );
176 void modified(); 180 void modified();
177 void deleteMe( PhoneTypeNumberEdit* ); 181 void deleteMe( PhoneTypeNumberEdit* );
178 182
179private: 183private:
180 KABC::PhoneNumber mPhoneNumber; 184 KABC::PhoneNumber mPhoneNumber;
181 QPushButton* mMinusButton; 185 QPushButton* mMinusButton;
182 KComboBox *mCombo; 186 KComboBox *mCombo;
183 KLineEdit *mNumber; 187 KLineEdit *mNumber;
184}; 188};
185 189
186#endif 190#endif
diff --git a/kaddressbook/secrecywidget.cpp b/kaddressbook/secrecywidget.cpp
index 4a2acc8..1c237c0 100644
--- a/kaddressbook/secrecywidget.cpp
+++ b/kaddressbook/secrecywidget.cpp
@@ -1,70 +1,72 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 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 <qlayout.h> 24#include <qlayout.h>
25//Added by qt3to4:
26#include <Q3VBoxLayout>
25 27
26#include <kabc/secrecy.h> 28#include <kabc/secrecy.h>
27#include <kcombobox.h> 29#include <kcombobox.h>
28#include <kdialog.h> 30#include <kdialog.h>
29 31
30#include "secrecywidget.h" 32#include "secrecywidget.h"
31 33
32SecrecyWidget::SecrecyWidget( QWidget *parent, const char *name ) 34SecrecyWidget::SecrecyWidget( QWidget *parent, const char *name )
33 : QWidget( parent, name ) 35 : QWidget( parent, name )
34{ 36{
35 QVBoxLayout *layout = new QVBoxLayout( this, KDialog::marginHint(), 37 Q3VBoxLayout *layout = new Q3VBoxLayout( this, KDialog::marginHint(),
36 KDialog::spacingHint() ); 38 KDialog::spacingHint() );
37 mSecrecyCombo = new KComboBox( this ); 39 mSecrecyCombo = new KComboBox( this );
38 layout->addWidget( mSecrecyCombo ); 40 layout->addWidget( mSecrecyCombo );
39 41
40 KABC::Secrecy::TypeList list = KABC::Secrecy::typeList(); 42 KABC::Secrecy::TypeList list = KABC::Secrecy::typeList();
41 KABC::Secrecy::TypeList::Iterator it; 43 KABC::Secrecy::TypeList::Iterator it;
42 for ( it = list.begin(); it != list.end(); ++it ) 44 for ( it = list.begin(); it != list.end(); ++it )
43 mSecrecyCombo->insertItem( KABC::Secrecy::typeLabel( *it ), *it ); 45 mSecrecyCombo->insertItem( KABC::Secrecy::typeLabel( *it ), *it );
44 46
45 connect( mSecrecyCombo, SIGNAL( activated( const QString& ) ), 47 connect( mSecrecyCombo, SIGNAL( activated( const QString& ) ),
46 SIGNAL( changed() ) ); 48 SIGNAL( changed() ) );
47} 49}
48 50
49SecrecyWidget::~SecrecyWidget() 51SecrecyWidget::~SecrecyWidget()
50{ 52{
51} 53}
52 54
53void SecrecyWidget::setSecrecy( const KABC::Secrecy &secrecy ) 55void SecrecyWidget::setSecrecy( const KABC::Secrecy &secrecy )
54{ 56{
55//US to avoid an indexoutofbounds error if value is invalid 57//US to avoid an indexoutofbounds error if value is invalid
56 if (secrecy.isValid()) 58 if (secrecy.isValid())
57 mSecrecyCombo->setCurrentItem( secrecy.type() ); 59 mSecrecyCombo->setCurrentItem( secrecy.type() );
58} 60}
59 61
60KABC::Secrecy SecrecyWidget::secrecy() const 62KABC::Secrecy SecrecyWidget::secrecy() const
61{ 63{
62 KABC::Secrecy secrecy; 64 KABC::Secrecy secrecy;
63 secrecy.setType( mSecrecyCombo->currentItem() ); 65 secrecy.setType( mSecrecyCombo->currentItem() );
64 66
65 return secrecy; 67 return secrecy;
66} 68}
67 69
68#ifndef KAB_EMBEDDED 70#ifndef KAB_EMBEDDED_
69#include "secrecywidget.moc" 71#include "moc_secrecywidget.cpp"
70#endif //KAB_EMBEDDED 72#endif //KAB_EMBEDDED
diff --git a/kaddressbook/undo.cpp b/kaddressbook/undo.cpp
index 4442087..a6c1580 100644
--- a/kaddressbook/undo.cpp
+++ b/kaddressbook/undo.cpp
@@ -1,119 +1,119 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (C) 1999 Don Sanders <sanders@kde.org> 3 Copyright (C) 1999 Don Sanders <sanders@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 "undo.h" 24#include "undo.h"
25 25
26/////////////////////////////// 26///////////////////////////////
27// StackBase 27// StackBase
28 28
29void StackBase::push(Command *c) 29void StackBase::push(Command *c)
30{ 30{
31 mCommandStack.push(c); 31 mCommandStack.push(c);
32 emit changed(); 32 emit changed();
33} 33}
34 34
35bool StackBase::isEmpty() 35bool StackBase::isEmpty()
36{ 36{
37 return mCommandStack.isEmpty(); 37 return mCommandStack.isEmpty();
38} 38}
39 39
40Command *StackBase::top() 40Command *StackBase::top()
41{ 41{
42 return mCommandStack.top(); 42 return mCommandStack.top();
43} 43}
44 44
45void StackBase::clear() 45void StackBase::clear()
46{ 46{
47 mCommandStack.clear(); 47 mCommandStack.clear();
48 emit changed(); 48 emit changed();
49} 49}
50 50
51Command *StackBase::pop() 51Command *StackBase::pop()
52{ 52{
53 Command *c = mCommandStack.pop(); 53 Command *c = mCommandStack.pop();
54 if (c) 54 if (c)
55 emit changed(); 55 emit changed();
56 56
57 return c; 57 return c;
58} 58}
59 59
60/////////////////////////////// 60///////////////////////////////
61// UndoStack 61// UndoStack
62 62
63UndoStack* UndoStack::instance_ = 0; 63UndoStack* UndoStack::instance_ = 0;
64 64
65UndoStack::UndoStack() 65UndoStack::UndoStack()
66 : StackBase() 66 : StackBase()
67{ 67{
68 // setAutoDelete( true ); 68 // setAutoDelete( true );
69} 69}
70 70
71UndoStack* UndoStack::instance() 71UndoStack* UndoStack::instance()
72{ 72{
73 if (!instance_) 73 if (!instance_)
74 instance_ = new UndoStack(); 74 instance_ = new UndoStack();
75 return instance_; 75 return instance_;
76} 76}
77 77
78void UndoStack::undo() 78void UndoStack::undo()
79{ 79{
80 if (isEmpty()) 80 if (isEmpty())
81 return; 81 return;
82 82
83 Command *command = pop(); 83 Command *command = pop();
84 command->undo(); 84 command->undo();
85 85
86 RedoStack::instance()->push( command ); 86 RedoStack::instance()->push( command );
87} 87}
88 88
89//////////////////// 89////////////////////
90// RedoStack 90// RedoStack
91 91
92RedoStack* RedoStack::instance_ = 0; 92RedoStack* RedoStack::instance_ = 0;
93 93
94RedoStack::RedoStack() 94RedoStack::RedoStack()
95{ 95{
96 mCommandStack.setAutoDelete( true ); 96 mCommandStack.setAutoDelete( true );
97} 97}
98 98
99RedoStack* RedoStack::instance() 99RedoStack* RedoStack::instance()
100{ 100{
101 if (!instance_) 101 if (!instance_)
102 instance_ = new RedoStack(); 102 instance_ = new RedoStack();
103 return instance_; 103 return instance_;
104} 104}
105 105
106void RedoStack::redo() 106void RedoStack::redo()
107{ 107{
108 Command *command; 108 Command *command;
109 if (isEmpty()) 109 if (isEmpty())
110 return; 110 return;
111 111
112 command = pop(); 112 command = pop();
113 command->redo(); 113 command->redo();
114 UndoStack::instance()->push( command ); 114 UndoStack::instance()->push( command );
115} 115}
116 116
117#ifndef KAB_EMBEDDED 117#ifndef KAB_EMBEDDED_
118#include "undo.moc" 118#include "moc_undo.cpp"
119#endif //KAB_EMBEDDED 119#endif //KAB_EMBEDDED
diff --git a/kaddressbook/undo.h b/kaddressbook/undo.h
index 843bc26..a8ba2ee 100644
--- a/kaddressbook/undo.h
+++ b/kaddressbook/undo.h
@@ -1,95 +1,95 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (C) 1999 Don Sanders <sanders@kde.org> 3 Copyright (C) 1999 Don Sanders <sanders@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#ifndef UNDO_H 24#ifndef UNDO_H
25#define UNDO_H 25#define UNDO_H
26 26
27#include <qobject.h> 27#include <qobject.h>
28#include <qptrstack.h> 28#include <q3ptrstack.h>
29#include <qstring.h> 29#include <qstring.h>
30 30
31class Command 31class Command
32{ 32{
33public: 33public:
34 Command() {} 34 Command() {}
35 virtual ~Command() {}; 35 virtual ~Command() {};
36 virtual QString name() = 0; 36 virtual QString name() = 0;
37 virtual void redo() = 0; // egcs requires these methods to have 37 virtual void redo() = 0; // egcs requires these methods to have
38 virtual void undo() = 0; // implementations (Seems like a bug) 38 virtual void undo() = 0; // implementations (Seems like a bug)
39 // pure virtual may not work 39 // pure virtual may not work
40}; 40};
41 41
42/** The Undo and Redo stacks now no longer inherit directly from a stack. 42/** The Undo and Redo stacks now no longer inherit directly from a stack.
43* They now contain a stack internally and inherit from StackBase, which 43* They now contain a stack internally and inherit from StackBase, which
44* has a signal for when the stack is modified. This is need to keep 44* has a signal for when the stack is modified. This is need to keep
45* the edit menu and toolbar up to date. 45* the edit menu and toolbar up to date.
46* 46*
47* Really this is a simple observable stack. 47* Really this is a simple observable stack.
48*/ 48*/
49class StackBase : public QObject 49class StackBase : public QObject
50{ 50{
51 Q_OBJECT 51 Q_OBJECT
52 52
53 public: 53 public:
54 StackBase() : QObject() {} 54 StackBase() : QObject() {}
55 55
56 void push(Command *c); 56 void push(Command *c);
57 bool isEmpty(); 57 bool isEmpty();
58 Command *top(); 58 Command *top();
59 void clear(); 59 void clear();
60 60
61 signals: 61 signals:
62 void changed(); 62 void changed();
63 63
64 protected: 64 protected:
65 /** Protect the pop method so users must call undo/redo to properly 65 /** Protect the pop method so users must call undo/redo to properly
66 * use the stack, however the subclasses need it to modify the stack. 66 * use the stack, however the subclasses need it to modify the stack.
67 */ 67 */
68 Command *pop(); 68 Command *pop();
69 69
70 QPtrStack<Command> mCommandStack; 70 Q3PtrStack<Command> mCommandStack;
71}; 71};
72 72
73class UndoStack : public StackBase 73class UndoStack : public StackBase
74{ 74{
75public: 75public:
76 static UndoStack *instance(); 76 static UndoStack *instance();
77 void undo(); 77 void undo();
78 78
79protected: 79protected:
80 UndoStack(); 80 UndoStack();
81 static UndoStack* instance_; 81 static UndoStack* instance_;
82}; 82};
83 83
84class RedoStack : public StackBase 84class RedoStack : public StackBase
85{ 85{
86public: 86public:
87 static RedoStack *instance(); 87 static RedoStack *instance();
88 void redo(); 88 void redo();
89 89
90protected: 90protected:
91 RedoStack(); 91 RedoStack();
92 static RedoStack* instance_; 92 static RedoStack* instance_;
93}; 93};
94 94
95#endif 95#endif
diff --git a/kaddressbook/undocmds.cpp b/kaddressbook/undocmds.cpp
index 5807dc0..e900b00 100644
--- a/kaddressbook/undocmds.cpp
+++ b/kaddressbook/undocmds.cpp
@@ -1,242 +1,242 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (C) 1999 Don Sanders <sanders@kde.org> 3 Copyright (C) 1999 Don Sanders <sanders@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 <qtextstream.h> 24#include <q3textstream.h>
25 25
26#include <qapplication.h> 26#include <qapplication.h>
27#include <qclipboard.h> 27#include <qclipboard.h>
28 28
29#include <klocale.h> 29#include <klocale.h>
30#include <kdebug.h> 30#include <kdebug.h>
31#include <kapplication.h> 31#include <kapplication.h>
32#include <kabc/addressbook.h> 32#include <kabc/addressbook.h>
33 33
34#include "addresseeutil.h" 34#include "addresseeutil.h"
35#include "addresseeconfig.h" 35#include "addresseeconfig.h"
36#include "kabcore.h" 36#include "kabcore.h"
37 37
38#include "undocmds.h" 38#include "undocmds.h"
39extern bool pasteWithNewUid; 39extern bool pasteWithNewUid;
40///////////////////////////////// 40/////////////////////////////////
41// PwDelete Methods 41// PwDelete Methods
42 42
43PwDeleteCommand::PwDeleteCommand(KABC::AddressBook *doc, 43PwDeleteCommand::PwDeleteCommand(KABC::AddressBook *doc,
44 const QStringList &uidList) 44 const QStringList &uidList)
45 : Command(), mDocument(doc), mAddresseeList(), mUidList(uidList) 45 : Command(), mDocument(doc), mAddresseeList(), mUidList(uidList)
46{ 46{
47 redo(); 47 redo();
48} 48}
49 49
50PwDeleteCommand::~PwDeleteCommand() 50PwDeleteCommand::~PwDeleteCommand()
51{ 51{
52} 52}
53 53
54QString PwDeleteCommand::name() 54QString PwDeleteCommand::name()
55{ 55{
56 return i18n( "Delete" ); 56 return i18n( "Delete" );
57} 57}
58 58
59void PwDeleteCommand::undo() 59void PwDeleteCommand::undo()
60{ 60{
61 // Put it back in the document 61 // Put it back in the document
62 KABC::Addressee::List::Iterator iter; 62 KABC::Addressee::List::Iterator iter;
63 for (iter = mAddresseeList.begin(); iter != mAddresseeList.end(); ++iter) 63 for (iter = mAddresseeList.begin(); iter != mAddresseeList.end(); ++iter)
64 { 64 {
65 mDocument->insertAddressee(*iter); 65 mDocument->insertAddressee(*iter);
66 } 66 }
67 67
68 mAddresseeList.clear(); 68 mAddresseeList.clear();
69} 69}
70 70
71void PwDeleteCommand::redo() 71void PwDeleteCommand::redo()
72{ 72{
73 // Just remove it from the document. This is enough to make the user 73 // Just remove it from the document. This is enough to make the user
74 // Think the item has been deleted 74 // Think the item has been deleted
75 KABC::Addressee a; 75 KABC::Addressee a;
76 QStringList::Iterator iter; 76 QStringList::Iterator iter;
77 for (iter = mUidList.begin(); iter != mUidList.end(); ++iter) 77 for (iter = mUidList.begin(); iter != mUidList.end(); ++iter)
78 { 78 {
79 a = mDocument->findByUid(*iter); 79 a = mDocument->findByUid(*iter);
80 mDocument->removeAddressee(a); 80 mDocument->removeAddressee(a);
81 mAddresseeList.append(a); 81 mAddresseeList.append(a);
82 AddresseeConfig::instance()->remove(a.uid()); 82 AddresseeConfig::instance()->remove(a.uid());
83 } 83 }
84} 84}
85 85
86///////////////////////////////// 86/////////////////////////////////
87// PwPaste Methods 87// PwPaste Methods
88 88
89PwPasteCommand::PwPasteCommand( KABCore *core, const KABC::Addressee::List &list ) 89PwPasteCommand::PwPasteCommand( KABCore *core, const KABC::Addressee::List &list )
90 : Command(), mCore( core ), mAddresseeList( list ) 90 : Command(), mCore( core ), mAddresseeList( list )
91{ 91{
92 redo(); 92 redo();
93} 93}
94 94
95QString PwPasteCommand::name() 95QString PwPasteCommand::name()
96{ 96{
97 return i18n( "Paste" ); 97 return i18n( "Paste" );
98} 98}
99 99
100void PwPasteCommand::undo() 100void PwPasteCommand::undo()
101{ 101{
102 KABC::Addressee::List::Iterator it; 102 KABC::Addressee::List::Iterator it;
103 for ( it = mAddresseeList.begin(); it != mAddresseeList.end(); ++it ) 103 for ( it = mAddresseeList.begin(); it != mAddresseeList.end(); ++it )
104 mCore->addressBook()->removeAddressee( *it ); 104 mCore->addressBook()->removeAddressee( *it );
105} 105}
106 106
107void PwPasteCommand::redo() 107void PwPasteCommand::redo()
108{ 108{
109 QStringList uids; 109 QStringList uids;
110 KABC::Addressee::List::Iterator it; 110 KABC::Addressee::List::Iterator it;
111 for ( it = mAddresseeList.begin(); it != mAddresseeList.end(); ++it ) { 111 for ( it = mAddresseeList.begin(); it != mAddresseeList.end(); ++it ) {
112 /* we have to set a new uid for the contact, otherwise insertAddressee() 112 /* we have to set a new uid for the contact, otherwise insertAddressee()
113 ignore it. 113 ignore it.
114 */ 114 */
115 if ( pasteWithNewUid ) 115 if ( pasteWithNewUid )
116 (*it).setUid( KApplication::randomString( 10 ) ); 116 (*it).setUid( KApplication::randomString( 10 ) );
117 uids.append( (*it).uid() ); 117 uids.append( (*it).uid() );
118 mCore->addressBook()->insertAddressee( *it ); 118 mCore->addressBook()->insertAddressee( *it );
119 } 119 }
120 if ( uids.count() < 4 ) { 120 if ( uids.count() < 4 ) {
121 QStringList::Iterator uidIt; 121 QStringList::Iterator uidIt;
122 for ( uidIt = uids.begin(); uidIt != uids.end(); ++uidIt ) 122 for ( uidIt = uids.begin(); uidIt != uids.end(); ++uidIt )
123 mCore->editContact( *uidIt ); 123 mCore->editContact( *uidIt );
124 } 124 }
125} 125}
126 126
127///////////////////////////////// 127/////////////////////////////////
128// PwNew Methods 128// PwNew Methods
129 129
130PwNewCommand::PwNewCommand( KABC::AddressBook *doc, const KABC::Addressee &a ) 130PwNewCommand::PwNewCommand( KABC::AddressBook *doc, const KABC::Addressee &a )
131 : Command(), mDocument( doc ), mA( a ) 131 : Command(), mDocument( doc ), mA( a )
132{ 132{
133 mDocument->insertAddressee(mA); 133 mDocument->insertAddressee(mA);
134} 134}
135 135
136PwNewCommand::~PwNewCommand() 136PwNewCommand::~PwNewCommand()
137{ 137{
138} 138}
139 139
140QString PwNewCommand::name() 140QString PwNewCommand::name()
141{ 141{
142 return i18n( "New Contact" ); 142 return i18n( "New Contact" );
143} 143}
144 144
145void PwNewCommand::undo() 145void PwNewCommand::undo()
146{ 146{
147 mDocument->removeAddressee( mA ); 147 mDocument->removeAddressee( mA );
148} 148}
149 149
150void PwNewCommand::redo() 150void PwNewCommand::redo()
151{ 151{
152 mDocument->insertAddressee( mA ); 152 mDocument->insertAddressee( mA );
153} 153}
154 154
155///////////////////////////////// 155/////////////////////////////////
156// PwEdit Methods 156// PwEdit Methods
157 157
158PwEditCommand::PwEditCommand(KABC::AddressBook *doc, 158PwEditCommand::PwEditCommand(KABC::AddressBook *doc,
159 const KABC::Addressee &oldA, 159 const KABC::Addressee &oldA,
160 const KABC::Addressee &newA ) 160 const KABC::Addressee &newA )
161 : Command(), mDocument(doc), mOldA(oldA), mNewA(newA) 161 : Command(), mDocument(doc), mOldA(oldA), mNewA(newA)
162{ 162{
163 redo(); 163 redo();
164} 164}
165 165
166PwEditCommand::~PwEditCommand() 166PwEditCommand::~PwEditCommand()
167{ 167{
168} 168}
169 169
170QString PwEditCommand::name() 170QString PwEditCommand::name()
171{ 171{
172 return i18n( "Entry Edit" ); 172 return i18n( "Entry Edit" );
173} 173}
174 174
175void PwEditCommand::undo() 175void PwEditCommand::undo()
176{ 176{
177 mDocument->insertAddressee(mOldA); 177 mDocument->insertAddressee(mOldA);
178} 178}
179 179
180void PwEditCommand::redo() 180void PwEditCommand::redo()
181{ 181{
182 mDocument->insertAddressee(mNewA); 182 mDocument->insertAddressee(mNewA);
183} 183}
184 184
185///////////////////////////////// 185/////////////////////////////////
186// PwCut Methods 186// PwCut Methods
187 187
188PwCutCommand::PwCutCommand(KABC::AddressBook *doc, const QStringList &uidList) 188PwCutCommand::PwCutCommand(KABC::AddressBook *doc, const QStringList &uidList)
189 : Command(), mDocument(doc), mAddresseeList(), mUidList(uidList), 189 : Command(), mDocument(doc), mAddresseeList(), mUidList(uidList),
190 mClipText(), mOldText() 190 mClipText(), mOldText()
191{ 191{
192 redo(); 192 redo();
193} 193}
194 194
195QString PwCutCommand::name() 195QString PwCutCommand::name()
196{ 196{
197 return i18n( "Cut" ); 197 return i18n( "Cut" );
198} 198}
199 199
200void PwCutCommand::undo() 200void PwCutCommand::undo()
201{ 201{
202 KABC::Addressee::List::Iterator iter; 202 KABC::Addressee::List::Iterator iter;
203 for (iter = mAddresseeList.begin(); iter != mAddresseeList.end(); ++iter) 203 for (iter = mAddresseeList.begin(); iter != mAddresseeList.end(); ++iter)
204 { 204 {
205 mDocument->insertAddressee(*iter); 205 mDocument->insertAddressee(*iter);
206 } 206 }
207 mAddresseeList.clear(); 207 mAddresseeList.clear();
208 208
209 QClipboard *cb = QApplication::clipboard(); 209 QClipboard *cb = QApplication::clipboard();
210//US 210//US
211#ifndef KAB_EMBEDDED 211#ifndef KAB_EMBEDDED
212 kapp->processEvents(); 212 kapp->processEvents();
213#else //KAB_EMBEDDED 213#else //KAB_EMBEDDED
214 qApp->processEvents(); 214 qApp->processEvents();
215#endif //KAB_EMBEDDED 215#endif //KAB_EMBEDDED
216 cb->setText( mOldText ); 216 cb->setText( mOldText );
217} 217}
218 218
219void PwCutCommand::redo() 219void PwCutCommand::redo()
220{ 220{
221 KABC::Addressee a; 221 KABC::Addressee a;
222 QStringList::Iterator iter; 222 QStringList::Iterator iter;
223 for (iter = mUidList.begin(); iter != mUidList.end(); ++iter) 223 for (iter = mUidList.begin(); iter != mUidList.end(); ++iter)
224 { 224 {
225 a = mDocument->findByUid(*iter); 225 a = mDocument->findByUid(*iter);
226 mDocument->removeAddressee(a); 226 mDocument->removeAddressee(a);
227 mAddresseeList.append(a); 227 mAddresseeList.append(a);
228 } 228 }
229 229
230 // Convert to clipboard 230 // Convert to clipboard
231 mClipText = AddresseeUtil::addresseesToClipboard(mAddresseeList); 231 mClipText = AddresseeUtil::addresseesToClipboard(mAddresseeList);
232 232
233 QClipboard *cb = QApplication::clipboard(); 233 QClipboard *cb = QApplication::clipboard();
234 mOldText = cb->text(); 234 mOldText = cb->text();
235//US 235//US
236#ifndef KAB_EMBEDDED 236#ifndef KAB_EMBEDDED
237 kapp->processEvents(); 237 kapp->processEvents();
238#else //KAB_EMBEDDED 238#else //KAB_EMBEDDED
239 qApp->processEvents(); 239 qApp->processEvents();
240#endif //KAB_EMBEDDED 240#endif //KAB_EMBEDDED
241 cb->setText( mClipText ); 241 cb->setText( mClipText );
242} 242}
diff --git a/kaddressbook/viewconfigurefieldspage.cpp b/kaddressbook/viewconfigurefieldspage.cpp
index 5daae1a..7366a0b 100644
--- a/kaddressbook/viewconfigurefieldspage.cpp
+++ b/kaddressbook/viewconfigurefieldspage.cpp
@@ -1,351 +1,355 @@
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#ifndef KAB_EMBEDDED 24#ifndef KAB_EMBEDDED
25#include <kcombobox.h> 25#include <kcombobox.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <kdebug.h> 27#include <kdebug.h>
28 28
29#else //KAB_EMBEDDED 29#else //KAB_EMBEDDED
30#include <qcombobox.h> 30#include <qcombobox.h>
31#endif //KAB_EMBEDDED 31#endif //KAB_EMBEDDED
32 32
33#include <kiconloader.h> 33#include <kiconloader.h>
34#include <kdialog.h> 34#include <kdialog.h>
35#include <klocale.h> 35#include <klocale.h>
36 36
37#include <qtoolbutton.h> 37#include <qtoolbutton.h>
38#include <qapplication.h> 38#include <qapplication.h>
39#include <QDesktopWidget>
39#include <qlabel.h> 40#include <qlabel.h>
40#include <qlistbox.h> 41#include <q3listbox.h>
41#include <qlayout.h> 42#include <qlayout.h>
43//Added by qt3to4:
44#include <Q3GridLayout>
45#include <Q3BoxLayout>
42 46
43#include "viewconfigurefieldspage.h" 47#include "viewconfigurefieldspage.h"
44 48
45class FieldItem : public QListBoxText 49class FieldItem : public Q3ListBoxText
46{ 50{
47 public: 51 public:
48 FieldItem( QListBox *parent, KABC::Field *field ) 52 FieldItem( Q3ListBox *parent, KABC::Field *field )
49 : QListBoxText( parent, field->label() ), mField( field ) {} 53 : Q3ListBoxText( parent, field->label() ), mField( field ) {}
50 54
51 FieldItem( QListBox *parent, KABC::Field *field, int index ) 55 FieldItem( Q3ListBox *parent, KABC::Field *field, int index )
52 : QListBoxText( parent, field->label(), parent->item( index ) ), 56 : Q3ListBoxText( parent, field->label(), parent->item( index ) ),
53 mField( field ) {} 57 mField( field ) {}
54 58
55 KABC::Field *field() { return mField; } 59 KABC::Field *field() { return mField; }
56 60
57 private: 61 private:
58 KABC::Field *mField; 62 KABC::Field *mField;
59}; 63};
60 64
61 65
62ViewConfigureFieldsPage::ViewConfigureFieldsPage( KABC::AddressBook *ab, 66ViewConfigureFieldsPage::ViewConfigureFieldsPage( KABC::AddressBook *ab,
63 QWidget *parent, 67 QWidget *parent,
64 const char *name ) 68 const char *name )
65 : QWidget( parent, name ), mAddressBook( ab ) 69 : QWidget( parent, name ), mAddressBook( ab )
66{ 70{
67 initGUI(); 71 initGUI();
68} 72}
69 73
70void ViewConfigureFieldsPage::restoreSettings( KConfig *config ) 74void ViewConfigureFieldsPage::restoreSettings( KConfig *config )
71{ 75{
72 KABC::Field::List fields = KABC::Field::restoreFields( config, "KABCFields" ); 76 KABC::Field::List fields = KABC::Field::restoreFields( config, "KABCFields" );
73 77
74 if ( fields.isEmpty() ) 78 if ( fields.isEmpty() )
75 fields = KABC::Field::defaultFields(); 79 fields = KABC::Field::defaultFields();
76 80
77 KABC::Field::List::ConstIterator it; 81 KABC::Field::List::ConstIterator it;
78 for( it = fields.begin(); it != fields.end(); ++it ) 82 for( it = fields.begin(); it != fields.end(); ++it )
79 new FieldItem( mSelectedBox, *it ); 83 new FieldItem( mSelectedBox, *it );
80 84
81 slotShowFields( mCategoryCombo->currentItem() ); 85 slotShowFields( mCategoryCombo->currentItem() );
82} 86}
83 87
84void ViewConfigureFieldsPage::saveSettings( KConfig *config ) 88void ViewConfigureFieldsPage::saveSettings( KConfig *config )
85{ 89{
86 KABC::Field::List fields; 90 KABC::Field::List fields;
87 91
88 for( uint i = 0; i < mSelectedBox->count(); ++i ) { 92 for( uint i = 0; i < mSelectedBox->count(); ++i ) {
89 FieldItem *fieldItem = static_cast<FieldItem *>( mSelectedBox->item( i ) ); 93 FieldItem *fieldItem = static_cast<FieldItem *>( mSelectedBox->item( i ) );
90 fields.append( fieldItem->field() ); 94 fields.append( fieldItem->field() );
91 } 95 }
92 96
93 KABC::Field::saveFields( config, "KABCFields", fields ); 97 KABC::Field::saveFields( config, "KABCFields", fields );
94} 98}
95 99
96void ViewConfigureFieldsPage::slotShowFields( int index ) 100void ViewConfigureFieldsPage::slotShowFields( int index )
97{ 101{
98 int currentPos = mUnSelectedBox->currentItem(); 102 int currentPos = mUnSelectedBox->currentItem();
99 mUnSelectedBox->clear(); 103 mUnSelectedBox->clear();
100 104
101 int category; 105 int category;
102 if ( index == 0 ) category = KABC::Field::All; 106 if ( index == 0 ) category = KABC::Field::All;
103 else category = 1 << ( index - 1 ); 107 else category = 1 << ( index - 1 );
104 108
105 KABC::Field::List allFields = mAddressBook->fields( category ); 109 KABC::Field::List allFields = mAddressBook->fields( category );
106 110
107 KABC::Field::List::ConstIterator it; 111 KABC::Field::List::ConstIterator it;
108 for ( it = allFields.begin(); it != allFields.end(); ++it ) { 112 for ( it = allFields.begin(); it != allFields.end(); ++it ) {
109 QListBoxItem *item = mSelectedBox->firstItem(); 113 Q3ListBoxItem *item = mSelectedBox->firstItem();
110 while( item ) { 114 while( item ) {
111 FieldItem *fieldItem = static_cast<FieldItem *>( item ); 115 FieldItem *fieldItem = static_cast<FieldItem *>( item );
112 if ( (*it)->equals( fieldItem->field() ) ) 116 if ( (*it)->equals( fieldItem->field() ) )
113 break; 117 break;
114 item = item->next(); 118 item = item->next();
115 } 119 }
116 120
117 if ( !item ) 121 if ( !item )
118 new FieldItem( mUnSelectedBox, *it ); 122 new FieldItem( mUnSelectedBox, *it );
119 } 123 }
120 124
121 mUnSelectedBox->sort(); 125 mUnSelectedBox->sort();
122 mUnSelectedBox->setCurrentItem( currentPos ); 126 mUnSelectedBox->setCurrentItem( currentPos );
123} 127}
124 128
125void ViewConfigureFieldsPage::slotSelect() 129void ViewConfigureFieldsPage::slotSelect()
126{ 130{
127 // insert selected items in the unselected list to the selected list, 131 // insert selected items in the unselected list to the selected list,
128 // directoy under the current item if selected, or at the bottonm if 132 // directoy under the current item if selected, or at the bottonm if
129 // nothing is selected in the selected list 133 // nothing is selected in the selected list
130 int where = mSelectedBox->currentItem(); 134 int where = mSelectedBox->currentItem();
131//US QListBoxItem::isSelected()) is not available in QT 2.x. Use selected instead. 135//US QListBoxItem::isSelected()) is not available in QT 2.x. Use selected instead.
132 if ( !(where > -1 && mSelectedBox->item( where )->selected()) ) 136 if ( !(where > -1 && mSelectedBox->item( where )->selected()) )
133 where = mSelectedBox->count() - 1; 137 where = mSelectedBox->count() - 1;
134 138
135 for ( uint i = 0; i < mUnSelectedBox->count(); ++i ) 139 for ( uint i = 0; i < mUnSelectedBox->count(); ++i )
136 if ( mUnSelectedBox->isSelected( mUnSelectedBox->item( i ) ) ) { 140 if ( mUnSelectedBox->isSelected( mUnSelectedBox->item( i ) ) ) {
137 FieldItem *fieldItem = static_cast<FieldItem *>( mUnSelectedBox->item( i ) ); 141 FieldItem *fieldItem = static_cast<FieldItem *>( mUnSelectedBox->item( i ) );
138 new FieldItem( mSelectedBox, fieldItem->field(), where ); 142 new FieldItem( mSelectedBox, fieldItem->field(), where );
139 where++; 143 where++;
140 } 144 }
141 145
142 slotShowFields( mCategoryCombo->currentItem() ); 146 slotShowFields( mCategoryCombo->currentItem() );
143} 147}
144 148
145void ViewConfigureFieldsPage::slotUnSelect() 149void ViewConfigureFieldsPage::slotUnSelect()
146{ 150{
147 for ( uint i = 0; i < mSelectedBox->count(); ++i ) 151 for ( uint i = 0; i < mSelectedBox->count(); ++i )
148 if ( mSelectedBox->isSelected( mSelectedBox->item( i ) ) ) { 152 if ( mSelectedBox->isSelected( mSelectedBox->item( i ) ) ) {
149 mSelectedBox->removeItem( i ); 153 mSelectedBox->removeItem( i );
150 --i; 154 --i;
151 } 155 }
152 156
153 slotShowFields( mCategoryCombo->currentItem() ); 157 slotShowFields( mCategoryCombo->currentItem() );
154} 158}
155 159
156void ViewConfigureFieldsPage::slotButtonsEnabled() 160void ViewConfigureFieldsPage::slotButtonsEnabled()
157{ 161{
158 bool state = false; 162 bool state = false;
159 // add button: enabled if any items are selected in the unselected list 163 // add button: enabled if any items are selected in the unselected list
160 for( uint i = 0; i < mUnSelectedBox->count(); ++i ) 164 for( uint i = 0; i < mUnSelectedBox->count(); ++i )
161//US QListBoxItem::isSelected()) is not available in QT 2.x. Use selected instead. 165//US QListBoxItem::isSelected()) is not available in QT 2.x. Use selected instead.
162 if ( mUnSelectedBox->item( i )->selected() ) { 166 if ( mUnSelectedBox->item( i )->selected() ) {
163 state = true; 167 state = true;
164 break; 168 break;
165 } 169 }
166 mAddButton->setEnabled( state ); 170 mAddButton->setEnabled( state );
167 171
168 int j = mSelectedBox->currentItem(); 172 int j = mSelectedBox->currentItem();
169 state = ( j > -1 && mSelectedBox->isSelected( j ) ); 173 state = ( j > -1 && mSelectedBox->isSelected( j ) );
170 174
171 // up button: enabled if there is a current item > 0 and that is selected 175 // up button: enabled if there is a current item > 0 and that is selected
172 mUpButton->setEnabled( ( j > 0 && state ) ); 176 mUpButton->setEnabled( ( j > 0 && state ) );
173 177
174 // down button: enabled if there is a current item < count - 2 and that is selected 178 // down button: enabled if there is a current item < count - 2 and that is selected
175 mDownButton->setEnabled( ( j > -1 && j < (int)mSelectedBox->count() - 1 && state ) ); 179 mDownButton->setEnabled( ( j > -1 && j < (int)mSelectedBox->count() - 1 && state ) );
176 180
177 // remove button: enabled if any items are selected in the selected list 181 // remove button: enabled if any items are selected in the selected list
178 state = false; 182 state = false;
179 for ( uint i = 0; i < mSelectedBox->count(); ++i ) 183 for ( uint i = 0; i < mSelectedBox->count(); ++i )
180//US QListBoxItem::isSelected()) is not available in QT 2.x. Use selected instead. 184//US QListBoxItem::isSelected()) is not available in QT 2.x. Use selected instead.
181 if ( mSelectedBox->item( i )->selected() ) { 185 if ( mSelectedBox->item( i )->selected() ) {
182 state = true; 186 state = true;
183 break; 187 break;
184 } 188 }
185 mRemoveButton->setEnabled( state ); 189 mRemoveButton->setEnabled( state );
186} 190}
187 191
188void ViewConfigureFieldsPage::slotMoveUp() 192void ViewConfigureFieldsPage::slotMoveUp()
189{ 193{
190 int i = mSelectedBox->currentItem(); 194 int i = mSelectedBox->currentItem();
191 if ( i > 0 ) { 195 if ( i > 0 ) {
192 QListBoxItem *item = mSelectedBox->item( i ); 196 Q3ListBoxItem *item = mSelectedBox->item( i );
193 mSelectedBox->takeItem( item ); 197 mSelectedBox->takeItem( item );
194 mSelectedBox->insertItem( item, i - 1 ); 198 mSelectedBox->insertItem( item, i - 1 );
195 mSelectedBox->setCurrentItem( item ); 199 mSelectedBox->setCurrentItem( item );
196 mSelectedBox->setSelected( i - 1, true ); 200 mSelectedBox->setSelected( i - 1, true );
197 } 201 }
198} 202}
199 203
200void ViewConfigureFieldsPage::slotMoveDown() 204void ViewConfigureFieldsPage::slotMoveDown()
201{ 205{
202 int i = mSelectedBox->currentItem(); 206 int i = mSelectedBox->currentItem();
203 if ( i > -1 && i < (int)mSelectedBox->count() - 1 ) { 207 if ( i > -1 && i < (int)mSelectedBox->count() - 1 ) {
204 QListBoxItem *item = mSelectedBox->item( i ); 208 Q3ListBoxItem *item = mSelectedBox->item( i );
205 mSelectedBox->takeItem( item ); 209 mSelectedBox->takeItem( item );
206 mSelectedBox->insertItem( item, i + 1 ); 210 mSelectedBox->insertItem( item, i + 1 );
207 mSelectedBox->setCurrentItem( item ); 211 mSelectedBox->setCurrentItem( item );
208 mSelectedBox->setSelected( i + 1, true ); 212 mSelectedBox->setSelected( i + 1, true );
209 } 213 }
210} 214}
211 215
212void ViewConfigureFieldsPage::initGUI() 216void ViewConfigureFieldsPage::initGUI()
213{ 217{
214 //US change the orientation dependent on the following flag 218 //US change the orientation dependent on the following flag
215 // right the flag is set only staticly. 219 // right the flag is set only staticly.
216 // 0 = 640x480 ; 1 = 240x320 220 // 0 = 640x480 ; 1 = 240x320
217 bool orientation = 1; 221 bool orientation = 1;
218 222
219 223
220 setCaption( i18n("Select Fields to Display") ); 224 setCaption( i18n("Select Fields to Display") );
221 225
222 QGridLayout *gl = 0; 226 Q3GridLayout *gl = 0;
223 if (orientation == 0) 227 if (orientation == 0)
224 gl = new QGridLayout( this , 6, 4, 0, KDialog::spacingHint() ); 228 gl = new Q3GridLayout( this , 6, 4, 0, KDialog::spacingHint() );
225 else 229 else
226 gl = new QGridLayout( this , 4, 6, 0, KDialog::spacingHint() ); 230 gl = new Q3GridLayout( this , 4, 6, 0, KDialog::spacingHint() );
227 231
228 #ifndef KAB_EMBEDDED 232 #ifndef KAB_EMBEDDED
229 mCategoryCombo = new KComboBox( false, this ); 233 mCategoryCombo = new KComboBox( false, this );
230 #else //KAB_EMBEDDED 234 #else //KAB_EMBEDDED
231 mCategoryCombo = new QComboBox( false, this ); 235 mCategoryCombo = new QComboBox( false, this );
232 #endif //KAB_EMBEDDED 236 #endif //KAB_EMBEDDED
233 if ( QApplication::desktop()->width() < 320 ) 237 if ( QApplication::desktop()->width() < 320 )
234 mCategoryCombo->setMaximumWidth( 70 ); 238 mCategoryCombo->setMaximumWidth( 70 );
235 mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::All ) ); 239 mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::All ) );
236 mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Frequent ) ); 240 mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Frequent ) );
237 mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Address ) ); 241 mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Address ) );
238 mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Email ) ); 242 mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Email ) );
239 mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Personal ) ); 243 mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Personal ) );
240 mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Organization ) ); 244 mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Organization ) );
241 mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::CustomCategory ) ); 245 mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::CustomCategory ) );
242 connect( mCategoryCombo, SIGNAL( activated(int) ), SLOT( slotShowFields(int) ) ); 246 connect( mCategoryCombo, SIGNAL( activated(int) ), SLOT( slotShowFields(int) ) );
243 gl->addWidget( mCategoryCombo, 0, 0 ); 247 gl->addWidget( mCategoryCombo, 0, 0 );
244 248
245 QLabel *label = new QLabel( i18n( "&Selected\nfields:" ), this ); 249 QLabel *label = new QLabel( i18n( "&Selected\nfields:" ), this );
246 if (orientation == 0) 250 if (orientation == 0)
247 gl->addWidget( label, 0, 2 ); 251 gl->addWidget( label, 0, 2 );
248 else 252 else
249 gl->addWidget( label, 2, 0 ); 253 gl->addWidget( label, 2, 0 );
250 254
251 255
252 mUnSelectedBox = new QListBox( this ); 256 mUnSelectedBox = new Q3ListBox( this );
253 mUnSelectedBox->setSelectionMode( QListBox::Extended ); 257 mUnSelectedBox->setSelectionMode( Q3ListBox::Extended );
254 mUnSelectedBox->setMinimumHeight( 80 ); 258 mUnSelectedBox->setMinimumHeight( 80 );
255 if (orientation == 0) 259 if (orientation == 0)
256 gl->addWidget( mUnSelectedBox, 1, 0 ); 260 gl->addWidget( mUnSelectedBox, 1, 0 );
257 else 261 else
258 gl->addWidget( mUnSelectedBox, 0, 1 ); 262 gl->addWidget( mUnSelectedBox, 0, 1 );
259 263
260 mSelectedBox = new QListBox( this ); 264 mSelectedBox = new Q3ListBox( this );
261 //if ( QApplication::desktop()->width() < 320 ) { 265 //if ( QApplication::desktop()->width() < 320 ) {
262 // mUnSelectedBox->setMaximumWidth( 134 ); 266 // mUnSelectedBox->setMaximumWidth( 134 );
263 // mSelectedBox->setMaximumWidth( 134 ); 267 // mSelectedBox->setMaximumWidth( 134 );
264 //} 268 //}
265 mSelectedBox->setSelectionMode( QListBox::Extended ); 269 mSelectedBox->setSelectionMode( Q3ListBox::Extended );
266 mSelectedBox->setMinimumHeight( 80 ); 270 mSelectedBox->setMinimumHeight( 80 );
267 label->setBuddy( mSelectedBox ); 271 label->setBuddy( mSelectedBox );
268 if (orientation == 0) 272 if (orientation == 0)
269 gl->addWidget( mSelectedBox, 1, 2 ); 273 gl->addWidget( mSelectedBox, 1, 2 );
270 else 274 else
271 gl->addWidget( mSelectedBox, 2, 1 ); 275 gl->addWidget( mSelectedBox, 2, 1 );
272 276
273 QBoxLayout *vb1 = 0; 277 Q3BoxLayout *vb1 = 0;
274 if (orientation == 0) 278 if (orientation == 0)
275 vb1 = new QBoxLayout( QBoxLayout::TopToBottom, KDialog::spacingHint() ); 279 vb1 = new Q3BoxLayout( Q3BoxLayout::TopToBottom, KDialog::spacingHint() );
276 else 280 else
277 vb1 = new QBoxLayout( QBoxLayout::LeftToRight, KDialog::spacingHint() ); 281 vb1 = new Q3BoxLayout( Q3BoxLayout::LeftToRight, KDialog::spacingHint() );
278 282
279 vb1->addStretch(); 283 vb1->addStretch();
280 284
281 mAddButton = new QToolButton( this ); 285 mAddButton = new QToolButton( this );
282 if (orientation == 0) 286 if (orientation == 0)
283 mAddButton->setIconSet( SmallIconSet( "1rightarrow" ) ); 287 mAddButton->setIconSet( SmallIconSet( "1rightarrow" ) );
284 else 288 else
285 mAddButton->setIconSet( SmallIconSet( "1downarrow" ) ); 289 mAddButton->setIconSet( SmallIconSet( "1downarrow" ) );
286 connect( mAddButton, SIGNAL( clicked() ), SLOT( slotSelect() ) ); 290 connect( mAddButton, SIGNAL( clicked() ), SLOT( slotSelect() ) );
287 vb1->addWidget( mAddButton ); 291 vb1->addWidget( mAddButton );
288 292
289 mRemoveButton = new QToolButton( this ); 293 mRemoveButton = new QToolButton( this );
290 if (orientation == 0) 294 if (orientation == 0)
291 mRemoveButton->setIconSet( SmallIconSet( "1leftarrow" ) ); 295 mRemoveButton->setIconSet( SmallIconSet( "1leftarrow" ) );
292 else 296 else
293 mRemoveButton->setIconSet( SmallIconSet( "1uparrow" ) ); 297 mRemoveButton->setIconSet( SmallIconSet( "1uparrow" ) );
294 298
295 connect( mRemoveButton, SIGNAL( clicked() ), SLOT( slotUnSelect() ) ); 299 connect( mRemoveButton, SIGNAL( clicked() ), SLOT( slotUnSelect() ) );
296 vb1->addWidget( mRemoveButton ); 300 vb1->addWidget( mRemoveButton );
297 301
298 vb1->addStretch(); 302 vb1->addStretch();
299 if (orientation == 0) 303 if (orientation == 0)
300 gl->addLayout( vb1, 1, 1 ); 304 gl->addLayout( vb1, 1, 1 );
301 else 305 else
302 gl->addLayout( vb1, 1, 1 ); 306 gl->addLayout( vb1, 1, 1 );
303 307
304 QBoxLayout *vb2 = 0; 308 Q3BoxLayout *vb2 = 0;
305 if (orientation == 0) 309 if (orientation == 0)
306 vb2 = new QBoxLayout( QBoxLayout::TopToBottom, KDialog::spacingHint() ); 310 vb2 = new Q3BoxLayout( Q3BoxLayout::TopToBottom, KDialog::spacingHint() );
307 else 311 else
308 vb2 = new QBoxLayout( QBoxLayout::LeftToRight, KDialog::spacingHint() ); 312 vb2 = new Q3BoxLayout( Q3BoxLayout::LeftToRight, KDialog::spacingHint() );
309 313
310 vb2->addStretch(); 314 vb2->addStretch();
311 315
312 mUpButton = new QToolButton( this ); 316 mUpButton = new QToolButton( this );
313 mUpButton->setIconSet( SmallIconSet( "1uparrow" ) ); 317 mUpButton->setIconSet( SmallIconSet( "1uparrow" ) );
314 connect( mUpButton, SIGNAL( clicked() ), SLOT( slotMoveUp() ) ); 318 connect( mUpButton, SIGNAL( clicked() ), SLOT( slotMoveUp() ) );
315 vb2->addWidget( mUpButton ); 319 vb2->addWidget( mUpButton );
316 320
317 mDownButton = new QToolButton( this ); 321 mDownButton = new QToolButton( this );
318 mDownButton->setIconSet( SmallIconSet( "1downarrow" ) ); 322 mDownButton->setIconSet( SmallIconSet( "1downarrow" ) );
319 connect( mDownButton, SIGNAL( clicked() ), SLOT( slotMoveDown() ) ); 323 connect( mDownButton, SIGNAL( clicked() ), SLOT( slotMoveDown() ) );
320 vb2->addWidget( mDownButton ); 324 vb2->addWidget( mDownButton );
321 325
322 vb2->addStretch(); 326 vb2->addStretch();
323 if (orientation == 0) 327 if (orientation == 0)
324 gl->addLayout( vb2, 1, 3 ); 328 gl->addLayout( vb2, 1, 3 );
325 else 329 else
326 gl->addLayout( vb2, 3, 1 ); 330 gl->addLayout( vb2, 3, 1 );
327 331
328 QSize sizeHint = mUnSelectedBox->sizeHint(); 332 QSize sizeHint = mUnSelectedBox->sizeHint();
329 333
330 // make sure we fill the list with all items, so that we can 334 // make sure we fill the list with all items, so that we can
331 // get the maxItemWidth we need to not truncate the view 335 // get the maxItemWidth we need to not truncate the view
332 slotShowFields( 0 ); 336 slotShowFields( 0 );
333 337
334 //sizeHint = sizeHint.expandedTo( mSelectedBox->sizeHint() ); 338 //sizeHint = sizeHint.expandedTo( mSelectedBox->sizeHint() );
335 //sizeHint.setWidth( mUnSelectedBox->maxItemWidth() ); 339 //sizeHint.setWidth( mUnSelectedBox->maxItemWidth() );
336 // mUnSelectedBox->setMinimumSize( sizeHint ); 340 // mUnSelectedBox->setMinimumSize( sizeHint );
337 //mSelectedBox->setMinimumSize( sizeHint ); 341 //mSelectedBox->setMinimumSize( sizeHint );
338 342
339 gl->activate(); 343 gl->activate();
340 344
341 connect( mUnSelectedBox, SIGNAL( selectionChanged() ), SLOT( slotButtonsEnabled() ) ); 345 connect( mUnSelectedBox, SIGNAL( selectionChanged() ), SLOT( slotButtonsEnabled() ) );
342 connect( mSelectedBox, SIGNAL( selectionChanged() ), SLOT( slotButtonsEnabled() ) ); 346 connect( mSelectedBox, SIGNAL( selectionChanged() ), SLOT( slotButtonsEnabled() ) );
343 connect( mSelectedBox, SIGNAL( currentChanged( QListBoxItem * ) ), SLOT( slotButtonsEnabled() ) ); 347 connect( mSelectedBox, SIGNAL( currentChanged( Q3ListBoxItem * ) ), SLOT( slotButtonsEnabled() ) );
344 348
345 slotButtonsEnabled(); 349 slotButtonsEnabled();
346} 350}
347 351
348 352
349#ifndef KAB_EMBEDDED 353#ifndef KAB_EMBEDDED_
350#include "viewconfigurefieldspage.moc" 354#include "moc_viewconfigurefieldspage.cpp"
351#endif //KAB_EMBEDDED 355#endif //KAB_EMBEDDED
diff --git a/kaddressbook/viewconfigurefieldspage.h b/kaddressbook/viewconfigurefieldspage.h
index b27668c..42d132f 100644
--- a/kaddressbook/viewconfigurefieldspage.h
+++ b/kaddressbook/viewconfigurefieldspage.h
@@ -1,81 +1,81 @@
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#ifndef VIEWCONFIGUREFIELDSPAGE_H 24#ifndef VIEWCONFIGUREFIELDSPAGE_H
25#define VIEWCONFIGUREFIELDSPAGE_H 25#define VIEWCONFIGUREFIELDSPAGE_H
26 26
27#include <qwidget.h> 27#include <qwidget.h>
28 28
29#include <kabc/field.h> 29#include <kabc/field.h>
30#include <kabc/addressbook.h> 30#include <kabc/addressbook.h>
31 31
32#ifndef KAB_EMBEDDED 32#ifndef KAB_EMBEDDED
33class KComboBox; 33class KComboBox;
34#else //KAB_EMBEDDED 34#else //KAB_EMBEDDED
35class QComboBox; 35class QComboBox;
36#endif //KAB_EMBEDDED 36#endif //KAB_EMBEDDED
37 37
38class QListBox; 38class Q3ListBox;
39class QListBoxItem; 39class Q3ListBoxItem;
40class QPushButton; 40class QPushButton;
41class QToolButton; 41class QToolButton;
42 42
43class ViewConfigureFieldsPage : public QWidget 43class ViewConfigureFieldsPage : public QWidget
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46 46
47 public: 47 public:
48 ViewConfigureFieldsPage( KABC::AddressBook *ab, QWidget *parent = 0, 48 ViewConfigureFieldsPage( KABC::AddressBook *ab, QWidget *parent = 0,
49 const char *name = 0 ); 49 const char *name = 0 );
50 50
51 void restoreSettings( KConfig* ); 51 void restoreSettings( KConfig* );
52 void saveSettings( KConfig* ); 52 void saveSettings( KConfig* );
53 53
54 public slots: 54 public slots:
55 void slotSelect(); 55 void slotSelect();
56 void slotUnSelect(); 56 void slotUnSelect();
57 void slotMoveUp(); 57 void slotMoveUp();
58 void slotMoveDown(); 58 void slotMoveDown();
59 59
60 void slotShowFields( int ); 60 void slotShowFields( int );
61 void slotButtonsEnabled(); 61 void slotButtonsEnabled();
62 62
63 private: 63 private:
64 void initGUI(); 64 void initGUI();
65 65
66#ifndef KAB_EMBEDDED 66#ifndef KAB_EMBEDDED
67 KComboBox *mCategoryCombo; 67 KComboBox *mCategoryCombo;
68#else //KAB_EMBEDDED 68#else //KAB_EMBEDDED
69 QComboBox *mCategoryCombo; 69 QComboBox *mCategoryCombo;
70#endif //KAB_EMBEDDED 70#endif //KAB_EMBEDDED
71 QListBox *mSelectedBox; 71 Q3ListBox *mSelectedBox;
72 QListBox *mUnSelectedBox; 72 Q3ListBox *mUnSelectedBox;
73 QToolButton *mAddButton; 73 QToolButton *mAddButton;
74 QToolButton *mRemoveButton; 74 QToolButton *mRemoveButton;
75 QToolButton *mUpButton; 75 QToolButton *mUpButton;
76 QToolButton *mDownButton; 76 QToolButton *mDownButton;
77 77
78 KABC::AddressBook *mAddressBook; 78 KABC::AddressBook *mAddressBook;
79}; 79};
80 80
81#endif 81#endif
diff --git a/kaddressbook/viewconfigurefilterpage.cpp b/kaddressbook/viewconfigurefilterpage.cpp
index b085a5e..cdb778b 100644
--- a/kaddressbook/viewconfigurefilterpage.cpp
+++ b/kaddressbook/viewconfigurefilterpage.cpp
@@ -1,137 +1,140 @@
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 KAB_EMBEDDED 24#ifndef KAB_EMBEDDED
25#include <kcombobox.h> 25#include <kcombobox.h>
26#else //KAB_EMBEDDED 26#else //KAB_EMBEDDED
27#include <qcombobox.h> 27#include <qcombobox.h>
28#endif //KAB_EMBEDDED 28#endif //KAB_EMBEDDED
29 29
30#include <qbuttongroup.h> 30#include <q3buttongroup.h>
31#include <qlabel.h> 31#include <qlabel.h>
32#include <qlayout.h> 32#include <qlayout.h>
33#include <qradiobutton.h> 33#include <qradiobutton.h>
34//Added by qt3to4:
35#include <Q3HBoxLayout>
36#include <Q3VBoxLayout>
34 37
35#include <kconfig.h> 38#include <kconfig.h>
36#include <kdialog.h> 39#include <kdialog.h>
37#include <klocale.h> 40#include <klocale.h>
38 41
39#include "filter.h" 42#include "filter.h"
40 43
41#include "viewconfigurefilterpage.h" 44#include "viewconfigurefilterpage.h"
42 45
43ViewConfigureFilterPage::ViewConfigureFilterPage( QWidget *parent, 46ViewConfigureFilterPage::ViewConfigureFilterPage( QWidget *parent,
44 const char *name ) 47 const char *name )
45 : QWidget( parent, name ) 48 : QWidget( parent, name )
46{ 49{
47 QBoxLayout *topLayout = new QVBoxLayout( this, 0, KDialog::spacingHint() ); 50 Q3BoxLayout *topLayout = new Q3VBoxLayout( this, 0, KDialog::spacingHint() );
48 51
49 mFilterGroup = new QButtonGroup(); 52 mFilterGroup = new Q3ButtonGroup();
50 connect( mFilterGroup, SIGNAL( clicked( int ) ), SLOT( buttonClicked( int ) ) ); 53 connect( mFilterGroup, SIGNAL( clicked( int ) ), SLOT( buttonClicked( int ) ) );
51 54
52 QLabel *label = new QLabel( i18n( "The default filter will be activated whenever" 55 QLabel *label = new QLabel( i18n( "The default filter will be activated whenever"
53 " this view is displayed. This feature allows you to configure views that only" 56 " this view is displayed. This feature allows you to configure views that only"
54 " interact with certain types of information based on the filter. Once the view" 57 " interact with certain types of information based on the filter. Once the view"
55 " is activated, the filter can be changed at anytime." ), this ); 58 " is activated, the filter can be changed at anytime." ), this );
56 label->setAlignment( Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak ); 59 label->setAlignment( Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak );
57 topLayout->addWidget( label ); 60 topLayout->addWidget( label );
58 61
59 QWidget *spacer = new QWidget( this ); 62 QWidget *spacer = new QWidget( this );
60 spacer->setMinimumHeight( 5 ); 63 spacer->setMinimumHeight( 5 );
61 topLayout->addWidget( spacer ); 64 topLayout->addWidget( spacer );
62 65
63 QRadioButton *button = new QRadioButton( i18n( "No default filter" ), this ); 66 QRadioButton *button = new QRadioButton( i18n( "No default filter" ), this );
64 mFilterGroup->insert( button ); 67 mFilterGroup->insert( button );
65 topLayout->addWidget( button ); 68 topLayout->addWidget( button );
66 69
67 button = new QRadioButton( i18n( "Use last active filter" ), this ); 70 button = new QRadioButton( i18n( "Use last active filter" ), this );
68 mFilterGroup->insert( button ); 71 mFilterGroup->insert( button );
69 topLayout->addWidget( button ); 72 topLayout->addWidget( button );
70 73
71 QBoxLayout *comboLayout = new QHBoxLayout(); 74 Q3BoxLayout *comboLayout = new Q3HBoxLayout();
72 topLayout->addLayout( comboLayout ); 75 topLayout->addLayout( comboLayout );
73 button = new QRadioButton( i18n( "Use filter:" ), this ); 76 button = new QRadioButton( i18n( "Use filter:" ), this );
74 mFilterGroup->insert( button ); 77 mFilterGroup->insert( button );
75 comboLayout->addWidget( button ); 78 comboLayout->addWidget( button );
76 79
77#ifndef KAB_EMBEDDED 80#ifndef KAB_EMBEDDED
78 mFilterCombo = new KComboBox( this ); 81 mFilterCombo = new KComboBox( this );
79#else //KAB_EMBEDDED 82#else //KAB_EMBEDDED
80 mFilterCombo = new QComboBox( this ); 83 mFilterCombo = new QComboBox( this );
81#endif //KAB_EMBEDDED 84#endif //KAB_EMBEDDED
82 85
83 comboLayout->addWidget( mFilterCombo ); 86 comboLayout->addWidget( mFilterCombo );
84} 87}
85 88
86ViewConfigureFilterPage::~ViewConfigureFilterPage() 89ViewConfigureFilterPage::~ViewConfigureFilterPage()
87{ 90{
88 delete mFilterGroup; 91 delete mFilterGroup;
89} 92}
90 93
91void ViewConfigureFilterPage::restoreSettings( KConfig *config ) 94void ViewConfigureFilterPage::restoreSettings( KConfig *config )
92{ 95{
93 mFilterCombo->clear(); 96 mFilterCombo->clear();
94 97
95//US I had to adjust the whole method in order to work with QComboBoxes 98//US I had to adjust the whole method in order to work with QComboBoxes
96// in case of the Platformindependent version 99// in case of the Platformindependent version
97 QString defaultfiltername = config->readEntry( "DefaultFilterName" ); 100 QString defaultfiltername = config->readEntry( "DefaultFilterName" );
98 101
99 int id = config->readNumEntry( "DefaultFilterType", 1 ); 102 int id = config->readNumEntry( "DefaultFilterType", 1 );
100 mFilterGroup->setButton( id ); 103 mFilterGroup->setButton( id );
101 buttonClicked( id ); 104 buttonClicked( id );
102 105
103 // Load the filter combo 106 // Load the filter combo
104 Filter::List list = Filter::restore( config, "Filter" ); 107 Filter::List list = Filter::restore( config, "Filter" );
105 Filter::List::Iterator it; 108 Filter::List::Iterator it;
106 for ( it = list.begin(); it != list.end(); ++it ) 109 for ( it = list.begin(); it != list.end(); ++it )
107 { 110 {
108 mFilterCombo->insertItem( (*it).name() ); 111 mFilterCombo->insertItem( (*it).name() );
109 112
110 if ( id == 2 && (*it).name() == defaultfiltername) // has default filter 113 if ( id == 2 && (*it).name() == defaultfiltername) // has default filter
111 { 114 {
112 mFilterCombo->insertItem( (*it).name(), 0); 115 mFilterCombo->insertItem( (*it).name(), 0);
113 } 116 }
114 else 117 else
115 { 118 {
116 mFilterCombo->insertItem( (*it).name() ); 119 mFilterCombo->insertItem( (*it).name() );
117 } 120 }
118 121
119 } 122 }
120 123
121 124
122} 125}
123 126
124void ViewConfigureFilterPage::saveSettings( KConfig *config ) 127void ViewConfigureFilterPage::saveSettings( KConfig *config )
125{ 128{
126 config->writeEntry( "DefaultFilterName", mFilterCombo->currentText() ); 129 config->writeEntry( "DefaultFilterName", mFilterCombo->currentText() );
127 config->writeEntry( "DefaultFilterType", mFilterGroup->id( mFilterGroup->selected() ) ); 130 config->writeEntry( "DefaultFilterType", mFilterGroup->id( mFilterGroup->selected() ) );
128} 131}
129 132
130void ViewConfigureFilterPage::buttonClicked( int id ) 133void ViewConfigureFilterPage::buttonClicked( int id )
131{ 134{
132 mFilterCombo->setEnabled( id == 2 ); 135 mFilterCombo->setEnabled( id == 2 );
133} 136}
134 137
135#ifndef KAB_EMBEDDED 138#ifndef KAB_EMBEDDED_
136#include "viewconfigurefilterpage.moc" 139#include "moc_viewconfigurefilterpage.cpp"
137#endif //KAB_EMBEDDED 140#endif //KAB_EMBEDDED
diff --git a/kaddressbook/viewconfigurefilterpage.h b/kaddressbook/viewconfigurefilterpage.h
index 3be9564..fb39a61 100644
--- a/kaddressbook/viewconfigurefilterpage.h
+++ b/kaddressbook/viewconfigurefilterpage.h
@@ -1,63 +1,63 @@
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 VIEWCONFIGUREFILTERPAGE 24#ifndef VIEWCONFIGUREFILTERPAGE
25#define VIEWCONFIGUREFILTERPAGE 25#define VIEWCONFIGUREFILTERPAGE
26 26
27#include <qwidget.h> 27#include <qwidget.h>
28 28
29class QButtonGroup; 29class Q3ButtonGroup;
30 30
31#ifndef KAB_EMBEDDED 31#ifndef KAB_EMBEDDED
32class KComboBox; 32class KComboBox;
33#else //KAB_EMBEDDED 33#else //KAB_EMBEDDED
34class QComboBox; 34class QComboBox;
35#endif //KAB_EMBEDDED 35#endif //KAB_EMBEDDED
36 36
37class KConfig; 37class KConfig;
38 38
39class ViewConfigureFilterPage : public QWidget 39class ViewConfigureFilterPage : public QWidget
40{ 40{
41 Q_OBJECT 41 Q_OBJECT
42 42
43 public: 43 public:
44 ViewConfigureFilterPage( QWidget *parent, const char *name = 0 ); 44 ViewConfigureFilterPage( QWidget *parent, const char *name = 0 );
45 ~ViewConfigureFilterPage(); 45 ~ViewConfigureFilterPage();
46 46
47 void restoreSettings( KConfig* ); 47 void restoreSettings( KConfig* );
48 void saveSettings( KConfig* ); 48 void saveSettings( KConfig* );
49 49
50 protected slots: 50 protected slots:
51 void buttonClicked( int id ); 51 void buttonClicked( int id );
52 52
53 private: 53 private:
54#ifndef KAB_EMBEDDED 54#ifndef KAB_EMBEDDED
55 KComboBox *mFilterCombo; 55 KComboBox *mFilterCombo;
56#else //KAB_EMBEDDED 56#else //KAB_EMBEDDED
57 QComboBox *mFilterCombo; 57 QComboBox *mFilterCombo;
58#endif //KAB_EMBEDDED 58#endif //KAB_EMBEDDED
59 59
60 QButtonGroup *mFilterGroup; 60 Q3ButtonGroup *mFilterGroup;
61}; 61};
62 62
63#endif 63#endif
diff --git a/kaddressbook/viewconfigurewidget.cpp b/kaddressbook/viewconfigurewidget.cpp
index 666e188..047df8c 100644
--- a/kaddressbook/viewconfigurewidget.cpp
+++ b/kaddressbook/viewconfigurewidget.cpp
@@ -1,159 +1,160 @@
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#ifndef KAB_EMBEDDED 25#ifndef KAB_EMBEDDED
26 26
27#include <qvbox.h> 27#include <q3vbox.h>
28 28
29#include <kapplication.h> 29#include <kapplication.h>
30#include <kconfig.h> 30#include <kconfig.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kiconloader.h> 32#include <kiconloader.h>
33 33
34#include "viewmanager.h" 34#include "viewmanager.h"
35 35
36#endif //KAB_EMBEDDED 36#endif //KAB_EMBEDDED
37 37
38 38
39#include <qlayout.h> 39#include <qlayout.h>
40//Added by qt3to4:
41#include <Q3VBoxLayout>
42#include <QPixmap>
40 43
41#include <kjanuswidget.h> 44#include <kjanuswidget.h>
42#include <kglobal.h> 45#include <kglobal.h>
43#include <klocale.h> 46#include <klocale.h>
44 47
45#include "viewconfigurewidget.h" 48#include "viewconfigurewidget.h"
46#include "viewconfigurefieldspage.h" 49#include "viewconfigurefieldspage.h"
47#include "viewconfigurefilterpage.h" 50#include "viewconfigurefilterpage.h"
48 51
49ViewConfigureWidget::ViewConfigureWidget( KABC::AddressBook *ab, QWidget *parent, 52ViewConfigureWidget::ViewConfigureWidget( KABC::AddressBook *ab, QWidget *parent,
50 const char *name ) 53 const char *name )
51 : ConfigureWidget( ab, parent, name ) 54 : ConfigureWidget( ab, parent, name )
52{ 55{
53 QVBoxLayout *topLayout = new QVBoxLayout( this ); 56 Q3VBoxLayout *topLayout = new Q3VBoxLayout( this );
54 57
55 mMainWidget = new KJanusWidget( this, "JanusWidget", KJanusWidget::Tabbed ); 58 mMainWidget = new KJanusWidget( this, "JanusWidget", KJanusWidget::Tabbed );
56 59
57 topLayout->addWidget( mMainWidget ); 60 topLayout->addWidget( mMainWidget );
58 61
59 // Add the first page, the attributes 62 // Add the first page, the attributes
60 QVBox *page = addPage( i18n( "Fields" ), QString::null, 63 Q3VBox *page = addPage( i18n( "Fields" ), QString::null,
61 KGlobal::iconLoader()->loadIcon( "view_detailed", 64 KGlobal::iconLoader()->loadIcon( "view_detailed",
62 KIcon::Panel, 16 ) ); 65 KIcon::Panel, 16 ) );
63 66
64 67
65 // Add the select fields page 68 // Add the select fields page
66 mFieldsPage = new ViewConfigureFieldsPage( addressBook(), (QWidget*)page ); 69 mFieldsPage = new ViewConfigureFieldsPage( addressBook(), (QWidget*)page );
67 70
68//US mFieldsPage->setMinimumSize(300,300); 71//US mFieldsPage->setMinimumSize(300,300);
69 72
70 // Add the second page, the filter selection 73 // Add the second page, the filter selection
71 page = addPage( i18n( "Default Filter" ), QString::null, 74 page = addPage( i18n( "Default Filter" ), QString::null,
72 KGlobal::iconLoader()->loadIcon( "filter", 75 KGlobal::iconLoader()->loadIcon( "filter",
73 KIcon::Panel, 16 ) ); 76 KIcon::Panel, 16 ) );
74 77
75 mFilterPage = new ViewConfigureFilterPage( (QWidget*)page ); 78 mFilterPage = new ViewConfigureFilterPage( (QWidget*)page );
76 //qDebug("+++++ViewConfigureWidget::ViewConfigureWidget "); 79 //qDebug("+++++ViewConfigureWidget::ViewConfigureWidget ");
77} 80}
78 81
79ViewConfigureWidget::~ViewConfigureWidget() 82ViewConfigureWidget::~ViewConfigureWidget()
80{ 83{
81 //qDebug("-----ViewConfigureWidget::~ViewConfigureWidget() "); 84 //qDebug("-----ViewConfigureWidget::~ViewConfigureWidget() ");
82} 85}
83 86
84void ViewConfigureWidget::restoreSettings( KConfig *config ) 87void ViewConfigureWidget::restoreSettings( KConfig *config )
85{ 88{
86 mFieldsPage->restoreSettings( config ); 89 mFieldsPage->restoreSettings( config );
87 mFilterPage->restoreSettings( config ); 90 mFilterPage->restoreSettings( config );
88} 91}
89 92
90void ViewConfigureWidget::saveSettings( KConfig *config ) 93void ViewConfigureWidget::saveSettings( KConfig *config )
91{ 94{
92 mFieldsPage->saveSettings( config ); 95 mFieldsPage->saveSettings( config );
93 mFilterPage->saveSettings( config ); 96 mFilterPage->saveSettings( config );
94} 97}
95 98
96QVBox *ViewConfigureWidget::addPage( const QString &item, const QString &header, 99Q3VBox *ViewConfigureWidget::addPage( const QString &item, const QString &header,
97 const QPixmap &pixmap ) 100 const QPixmap &pixmap )
98{ 101{
99 return mMainWidget->addVBoxPage( item, header, pixmap ); 102 return mMainWidget->addVBoxPage( item, header, pixmap );
100} 103}
101 104
102#include <qframe.h> 105#include <q3frame.h>
103#include <qlabel.h> 106#include <qlabel.h>
104#include <qlayout.h> 107#include <qlayout.h>
105#include <stdlib.h> 108#include <stdlib.h>
106 109
107ViewConfigureDialog::ViewConfigureDialog( ViewConfigureWidget *wdg, const QString &viewName, 110ViewConfigureDialog::ViewConfigureDialog( ViewConfigureWidget *wdg, const QString &viewName,
108 QWidget *parent, const char *name ) 111 QWidget *parent, const char *name )
109 : KDialogBase( Swallow, i18n( "Modify View: " ) + viewName, Help | Ok | Cancel, 112 : KDialogBase( Swallow, i18n( "Modify View: " ) + viewName, Help | Ok | Cancel,
110 Ok, parent, name, true, true ), mConfigWidget( wdg ) 113 Ok, parent, name, true, true ), mConfigWidget( wdg )
111{ 114{
112//US, I have to change the way, how to connect the ViewConfigureWidget. It looks 115//US, I have to change the way, how to connect the ViewConfigureWidget. It looks
113// like it has changed. 116// like it has changed.
114 //QFrame *topFrame = plainPage(); 117 //QFrame *topFrame = plainPage();
115 if ( mConfigWidget ) { 118 if ( mConfigWidget ) {
116 mConfigWidget->reparent(this, QPoint(0,0), true); 119 mConfigWidget->reparent(this, QPoint(0,0), true);
117 // QVBoxLayout * layout = new QVBoxLayout( this ); 120 // QVBoxLayout * layout = new QVBoxLayout( this );
118 //layout->addWidget(mConfigWidget ); 121 //layout->addWidget(mConfigWidget );
119 //mConfigWidget->reparent(topFrame, QPoint(1,1), true); 122 //mConfigWidget->reparent(topFrame, QPoint(1,1), true);
120 123
121 setMainWidget( mConfigWidget ); 124 setMainWidget( mConfigWidget );
122 } 125 }
123 126
124} 127}
125 128
126ViewConfigureDialog::~ViewConfigureDialog() 129ViewConfigureDialog::~ViewConfigureDialog()
127{ 130{
128} 131}
129void ViewConfigureDialog::setWidget( ViewConfigureWidget *wdg ) 132void ViewConfigureDialog::setWidget( ViewConfigureWidget *wdg )
130{ 133{
131 mConfigWidget = wdg ; 134 mConfigWidget = wdg ;
132 setMainWidget( mConfigWidget ); 135 setMainWidget( mConfigWidget );
133 136
134} 137}
135 138
136void ViewConfigureDialog::restoreSettings( KConfig *config ) 139void ViewConfigureDialog::restoreSettings( KConfig *config )
137{ 140{
138 mConfigWidget->restoreSettings( config ); 141 mConfigWidget->restoreSettings( config );
139} 142}
140 143
141void ViewConfigureDialog::saveSettings( KConfig *config ) 144void ViewConfigureDialog::saveSettings( KConfig *config )
142{ 145{
143 mConfigWidget->saveSettings( config ); 146 mConfigWidget->saveSettings( config );
144} 147}
145 148
146void ViewConfigureDialog::slotHelp() 149void ViewConfigureDialog::slotHelp()
147{ 150{
148#ifndef KAB_EMBEDDED 151#ifndef KAB_EMBEDDED
149 kapp->invokeHelp( "using-views" ); 152 kapp->invokeHelp( "using-views" );
150#else //KAB_EMBEDDED 153#else //KAB_EMBEDDED
151 qDebug("ViewConfigureDialog::slotHelp not yet implemented"); 154 qDebug("ViewConfigureDialog::slotHelp not yet implemented");
152#endif //KAB_EMBEDDED 155#endif //KAB_EMBEDDED
153} 156}
154 157
155#ifndef KAB_EMBEDDED 158#ifndef KAB_EMBEDDED_
156#include "viewconfigurewidget.moc" 159#include "moc_viewconfigurewidget.cpp"
157#endif //KAB_EMBEDDED 160#endif //KAB_EMBEDDED
158
159
diff --git a/kaddressbook/viewconfigurewidget.h b/kaddressbook/viewconfigurewidget.h
index 0c2b77c..e3b9b12 100644
--- a/kaddressbook/viewconfigurewidget.h
+++ b/kaddressbook/viewconfigurewidget.h
@@ -1,106 +1,106 @@
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 rremovePageedistribute it and/or modify 5 This program is free software; you can rremovePageedistribute 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 VIEWCONFIGUREWIDGET_H 24#ifndef VIEWCONFIGUREWIDGET_H
25#define VIEWCONFIGUREWIDGET_H 25#define VIEWCONFIGUREWIDGET_H
26 26
27 27
28 28
29#include "configurewidget.h" 29#include "configurewidget.h"
30 30
31class QVBox; 31class Q3VBox;
32 32
33#include <kdialogbase.h> 33#include <kdialogbase.h>
34#include <qpixmap.h> 34#include <qpixmap.h>
35 35
36class KJanusWidget; 36class KJanusWidget;
37class QString; 37class QString;
38class ViewConfigureFieldsPage; 38class ViewConfigureFieldsPage;
39class ViewConfigureFilterPage; 39class ViewConfigureFilterPage;
40class ViewConfigureDialog; 40class ViewConfigureDialog;
41/** 41/**
42 This widget is the base class for all view configuration widgets. The 42 This widget is the base class for all view configuration widgets. The
43 author of a view may wish to inherit from this widget and add config pages 43 author of a view may wish to inherit from this widget and add config pages
44 that add custom config options. The default implementation of this widget 44 that add custom config options. The default implementation of this widget
45 is to show a page with the select fields widget. For simple views this may 45 is to show a page with the select fields widget. For simple views this may
46 be sufficient. 46 be sufficient.
47*/ 47*/
48class ViewConfigureWidget : public ConfigureWidget 48class ViewConfigureWidget : public ConfigureWidget
49{ 49{
50 Q_OBJECT 50 Q_OBJECT
51 51
52 public: 52 public:
53 ViewConfigureWidget( KABC::AddressBook *ab, QWidget *parent, const char *name = 0 ); 53 ViewConfigureWidget( KABC::AddressBook *ab, QWidget *parent, const char *name = 0 );
54 virtual ~ViewConfigureWidget(); 54 virtual ~ViewConfigureWidget();
55 55
56 /** 56 /**
57 Reads the configuration from the config object and sets the values 57 Reads the configuration from the config object and sets the values
58 in the GUI. If this method is overloaded, be sure to call the base 58 in the GUI. If this method is overloaded, be sure to call the base
59 class's method. 59 class's method.
60 60
61 Do not change the group of the config object in this method. 61 Do not change the group of the config object in this method.
62 */ 62 */
63 virtual void restoreSettings( KConfig *config ); 63 virtual void restoreSettings( KConfig *config );
64 64
65 /** 65 /**
66 Writes the configuration from the GUI to the config object. If this 66 Writes the configuration from the GUI to the config object. If this
67 method is overloaded, be sure to call the base class's method. 67 method is overloaded, be sure to call the base class's method.
68 68
69 Do not change the group of the config object in this method. 69 Do not change the group of the config object in this method.
70 */ 70 */
71 virtual void saveSettings( KConfig *config ); 71 virtual void saveSettings( KConfig *config );
72 72
73 73
74 /** 74 /**
75 Use this method to add new pages to the widget. 75 Use this method to add new pages to the widget.
76 */ 76 */
77 QVBox *addPage( const QString &item, const QString &header = QString::null, 77 Q3VBox *addPage( const QString &item, const QString &header = QString::null,
78 const QPixmap &pixmap = QPixmap() ); 78 const QPixmap &pixmap = QPixmap() );
79 79
80 private: 80 private:
81 KJanusWidget *mMainWidget; 81 KJanusWidget *mMainWidget;
82 82
83 ViewConfigureFieldsPage *mFieldsPage; 83 ViewConfigureFieldsPage *mFieldsPage;
84 ViewConfigureFilterPage *mFilterPage; 84 ViewConfigureFilterPage *mFilterPage;
85}; 85};
86 86
87class ViewConfigureDialog : public KDialogBase 87class ViewConfigureDialog : public KDialogBase
88{ 88{
89 Q_OBJECT 89 Q_OBJECT
90 90
91 public: 91 public:
92 ViewConfigureDialog( ViewConfigureWidget *wdg, const QString &viewName, 92 ViewConfigureDialog( ViewConfigureWidget *wdg, const QString &viewName,
93 QWidget *parent, const char *name = 0 ); 93 QWidget *parent, const char *name = 0 );
94 ~ViewConfigureDialog(); 94 ~ViewConfigureDialog();
95 95
96 void restoreSettings( KConfig* ); 96 void restoreSettings( KConfig* );
97 void saveSettings( KConfig* ); 97 void saveSettings( KConfig* );
98 void setWidget( ViewConfigureWidget *wdg ); 98 void setWidget( ViewConfigureWidget *wdg );
99 protected slots: 99 protected slots:
100 void slotHelp(); 100 void slotHelp();
101 101
102 private: 102 private:
103 ViewConfigureWidget *mConfigWidget; 103 ViewConfigureWidget *mConfigWidget;
104}; 104};
105 105
106#endif 106#endif
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index b5d9419..5cfe3ad 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -1,748 +1,752 @@
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/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (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 <q3popupmenu.h>
54//Added by qt3to4:
55#include <Q3HBoxLayout>
56#include <QDropEvent>
54#include <kconfigbase.h> 57#include <kconfigbase.h>
55 58
56#endif //KAB_EMBEDDED 59#endif //KAB_EMBEDDED
57 60
58 61
59#include <kdebug.h> 62#include <kdebug.h>
60#include <kactionclasses.h> 63#include <kactionclasses.h>
61 64
62#include <qlayout.h> 65#include <qlayout.h>
63#include <qapplication.h> 66#include <qapplication.h>
64#include <qwidgetstack.h> 67#include <QDesktopWidget>
68#include <q3widgetstack.h>
65 69
66#include <kabc/addressbook.h> 70#include <kabc/addressbook.h>
67#include "filtereditdialog.h" 71#include "filtereditdialog.h"
68#include "addviewdialog.h" 72#include "addviewdialog.h"
69#include "kabcore.h" 73#include "kabcore.h"
70#include "kabprefs.h" 74#include "kabprefs.h"
71#include "viewmanager.h" 75#include "viewmanager.h"
72 76
73ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) 77ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name )
74 : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) 78 : QWidget( parent, name ), mCore( core ), mActiveView( 0 )
75{ 79{
76 initGUI(); 80 initGUI();
77 initActions(); 81 initActions();
78 82
79 mViewDict.setAutoDelete( true ); 83 mViewDict.setAutoDelete( true );
80 84
81 createViewFactories(); 85 createViewFactories();
82} 86}
83 87
84ViewManager::~ViewManager() 88ViewManager::~ViewManager()
85{ 89{
86 unloadViews(); 90 unloadViews();
87 mViewFactoryDict.clear(); 91 mViewFactoryDict.clear();
88} 92}
89void ViewManager::scrollUP() 93void ViewManager::scrollUP()
90{ 94{
91 if ( mActiveView ) 95 if ( mActiveView )
92 mActiveView->scrollUP(); 96 mActiveView->scrollUP();
93} 97}
94void ViewManager::scrollDOWN() 98void ViewManager::scrollDOWN()
95{ 99{
96 if ( mActiveView ) 100 if ( mActiveView )
97 mActiveView->scrollDOWN(); 101 mActiveView->scrollDOWN();
98} 102}
99void ViewManager::restoreSettings() 103void ViewManager::restoreSettings()
100{ 104{
101 mViewNameList = KABPrefs::instance()->mViewNames; 105 mViewNameList = KABPrefs::instance()->mViewNames;
102 QString activeViewName = KABPrefs::instance()->mCurrentView; 106 QString activeViewName = KABPrefs::instance()->mCurrentView;
103 107
104 mActionSelectView->setItems( mViewNameList ); 108 mActionSelectView->setItems( mViewNameList );
105 109
106 // Filter 110 // Filter
107 mFilterList = Filter::restore( mCore->config(), "Filter" ); 111 mFilterList = Filter::restore( mCore->config(), "Filter" );
108 mActionSelectFilter->setItems( filterNames() ); 112 mActionSelectFilter->setItems( filterNames() );
109 mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); 113 mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter );
110 int cw = 150; 114 int cw = 150;
111 if ( QApplication::desktop()->width() >= 800 ) 115 if ( QApplication::desktop()->width() >= 800 )
112 cw = 200; 116 cw = 200;
113 if (QApplication::desktop()->width() == 480 && !KABPrefs::instance()->mHideSearchOnSwitch) 117 if (QApplication::desktop()->width() == 480 && !KABPrefs::instance()->mHideSearchOnSwitch)
114 cw = 0; 118 cw = 0;
115 mActionSelectFilter->setComboWidth( cw ); 119 mActionSelectFilter->setComboWidth( cw );
116 // Tell the views to reread their config, since they may have 120 // Tell the views to reread their config, since they may have
117 // been modified by global settings 121 // been modified by global settings
118 QString _oldgroup = mCore->config()->group(); 122 QString _oldgroup = mCore->config()->group();
119 123
120 QDictIterator<KAddressBookView> it( mViewDict ); 124 Q3DictIterator<KAddressBookView> it( mViewDict );
121 for ( it.toFirst(); it.current(); ++it ) { 125 for ( it.toFirst(); it.current(); ++it ) {
122 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 126 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
123 it.current()->readConfig( mCore->config() ); 127 it.current()->readConfig( mCore->config() );
124 } 128 }
125 setActiveView( activeViewName ); 129 setActiveView( activeViewName );
126 130
127 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 131 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
128} 132}
129 133
130void ViewManager::saveSettings() 134void ViewManager::saveSettings()
131{ 135{
132 QString _oldgroup = mCore->config()->group(); 136 QString _oldgroup = mCore->config()->group();
133 137
134 QDictIterator<KAddressBookView> it( mViewDict ); 138 Q3DictIterator<KAddressBookView> it( mViewDict );
135 for ( it.toFirst(); it.current(); ++it ) { 139 for ( it.toFirst(); it.current(); ++it ) {
136 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 140 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
137#ifdef DESKTOP_VERSION 141#ifdef DESKTOP_VERSION
138 (*it)->writeConfig( mCore->config() ); 142 (*it)->writeConfig( mCore->config() );
139#else 143#else
140 (*it).writeConfig( mCore->config() ); 144 (*it).writeConfig( mCore->config() );
141#endif 145#endif
142 } 146 }
143 147
144 Filter::save( mCore->config(), "Filter", mFilterList ); 148 Filter::save( mCore->config(), "Filter", mFilterList );
145 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); 149 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem();
146 150
147 // write the view name list 151 // write the view name list
148 KABPrefs::instance()->mViewNames = mViewNameList; 152 KABPrefs::instance()->mViewNames = mViewNameList;
149 KABPrefs::instance()->mCurrentView = mActiveView->caption(); 153 KABPrefs::instance()->mCurrentView = mActiveView->caption();
150 154
151} 155}
152 156
153QStringList ViewManager::selectedUids() const 157QStringList ViewManager::selectedUids() const
154{ 158{
155 if ( mActiveView ) 159 if ( mActiveView )
156 return mActiveView->selectedUids(); 160 return mActiveView->selectedUids();
157 else 161 else
158 return QStringList(); 162 return QStringList();
159} 163}
160 164
161QStringList ViewManager::selectedEmails() const 165QStringList ViewManager::selectedEmails() const
162{ 166{
163 if ( mActiveView ) 167 if ( mActiveView )
164 return mActiveView->selectedEmails(); 168 return QStringList(mActiveView->selectedEmails());
165 else 169 else
166 return QStringList(); 170 return QStringList();
167} 171}
168 172
169KABC::Addressee::List ViewManager::selectedAddressees() const 173KABC::Addressee::List ViewManager::selectedAddressees() const
170{ 174{
171 KABC::Addressee::List list; 175 KABC::Addressee::List list;
172 if ( mActiveView ) { 176 if ( mActiveView ) {
173 QStringList uids = mActiveView->selectedUids(); 177 QStringList uids = mActiveView->selectedUids();
174 QStringList::Iterator it; 178 QStringList::Iterator it;
175 for ( it = uids.begin(); it != uids.end(); ++it ) { 179 for ( it = uids.begin(); it != uids.end(); ++it ) {
176 KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); 180 KABC::Addressee addr = mCore->addressBook()->findByUid( *it );
177 if ( !addr.isEmpty() ) 181 if ( !addr.isEmpty() )
178 list.append( addr ); 182 list.append( addr );
179 } 183 }
180 } 184 }
181 185
182 return list; 186 return list;
183} 187}
184//US added another method with no parameter, since my moc compiler does not support default parameters. 188//US added another method with no parameter, since my moc compiler does not support default parameters.
185void ViewManager::setSelected() 189void ViewManager::setSelected()
186{ 190{
187 setSelected( QString::null, true ); 191 setSelected( QString::null, true );
188} 192}
189 193
190void ViewManager::setSelected( const QString &uid, bool selected ) 194void ViewManager::setSelected( const QString &uid, bool selected )
191{ 195{
192 if ( mActiveView ) 196 if ( mActiveView )
193 mActiveView->setSelected( uid, selected ); 197 mActiveView->setSelected( uid, selected );
194} 198}
195 199
196void ViewManager::setListSelected(QStringList list) 200void ViewManager::setListSelected(QStringList list)
197{ 201{
198 int i, count = list.count(); 202 int i, count = list.count();
199 for ( i = 0; i < count;++i ) 203 for ( i = 0; i < count;++i )
200 setSelected( list[i], true ); 204 setSelected( list[i], true );
201 205
202} 206}
203void ViewManager::unloadViews() 207void ViewManager::unloadViews()
204{ 208{
205 mViewDict.clear(); 209 mViewDict.clear();
206 mActiveView = 0; 210 mActiveView = 0;
207} 211}
208 212
209void ViewManager::selectView( const QString &name ) 213void ViewManager::selectView( const QString &name )
210{ 214{
211 setActiveView( name ); 215 setActiveView( name );
212 mCore->saveSettings(); 216 mCore->saveSettings();
213} 217}
214void ViewManager::setActiveView( const QString &name ) 218void ViewManager::setActiveView( const QString &name )
215{ 219{
216 KAddressBookView *view = 0; 220 KAddressBookView *view = 0;
217 221
218 // Check that this isn't the same as the current active view 222 // Check that this isn't the same as the current active view
219 if ( mActiveView && ( mActiveView->caption() == name ) ) 223 if ( mActiveView && ( mActiveView->caption() == name ) )
220 return; 224 return;
221 225
222 // At this point we know the view that should be active is not 226 // At this point we know the view that should be active is not
223 // currently active. We will try to find the new on in the list. If 227 // currently active. We will try to find the new on in the list. If
224 // we can't find it, it means it hasn't been instantiated, so we will 228 // we can't find it, it means it hasn't been instantiated, so we will
225 // create it on demand. 229 // create it on demand.
226 230
227 view = mViewDict.find( name ); 231 view = mViewDict.find( name );
228 232
229 // Check if we found the view. If we didn't, then we need to create it 233 // Check if we found the view. If we didn't, then we need to create it
230 if ( view == 0 ) { 234 if ( view == 0 ) {
231 KConfig *config = mCore->config(); 235 KConfig *config = mCore->config();
232 236
233 KConfigGroupSaver saver( config, name ); 237 KConfigGroupSaver saver( config, name );
234 238
235 QString type = config->readEntry( "Type", "Table" ); 239 QString type = config->readEntry( "Type", "Table" );
236 240
237 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; 241 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl;
238 242
239 ViewFactory *factory = mViewFactoryDict.find( type ); 243 ViewFactory *factory = mViewFactoryDict.find( type );
240 if ( factory ) 244 if ( factory )
241 view = factory->view( mCore->addressBook(), mViewWidgetStack ); 245 view = factory->view( mCore->addressBook(), mViewWidgetStack );
242 246
243 if ( view ) { 247 if ( view ) {
244 if ( !mViewNameList.contains( name ) ) { 248 if ( !mViewNameList.contains( name ) ) {
245 mViewNameList.append( name ); 249 mViewNameList.append( name );
246 } 250 }
247 view->setCaption( name ); 251 view->setCaption( name );
248 mViewDict.insert( name, view ); 252 mViewDict.insert( name, view );
249//US my version needs an int as second parameter to addWidget 253//US my version needs an int as second parameter to addWidget
250 mViewWidgetStack->addWidget( view, -1 ); 254 mViewWidgetStack->addWidget( view, -1 );
251 view->readConfig( config ); 255 view->readConfig( config );
252 256
253 // The manager just relays the signals 257 // The manager just relays the signals
254 connect( view, SIGNAL( selected( const QString& ) ), 258 connect( view, SIGNAL( selected( const QString& ) ),
255 SIGNAL( selected( const QString & ) ) ); 259 SIGNAL( selected( const QString & ) ) );
256 connect( view, SIGNAL( executed( const QString& ) ), 260 connect( view, SIGNAL( executed( const QString& ) ),
257 SIGNAL( executed( const QString& ) ) ); 261 SIGNAL( executed( const QString& ) ) );
258 262
259 connect( view, SIGNAL( deleteRequest( ) ), 263 connect( view, SIGNAL( deleteRequest( ) ),
260 SIGNAL( deleteRequest( ) ) ); 264 SIGNAL( deleteRequest( ) ) );
261 265
262 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); 266 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) );
263 connect( view, SIGNAL( dropped( QDropEvent* ) ), 267 connect( view, SIGNAL( dropped( QDropEvent* ) ),
264 SLOT( dropped( QDropEvent* ) ) ); 268 SLOT( dropped( QDropEvent* ) ) );
265 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); 269 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) );
266 } 270 }
267 } 271 }
268 272
269 // If we found or created the view, raise it and refresh it 273 // If we found or created the view, raise it and refresh it
270 if ( view ) { 274 if ( view ) {
271 mActiveView = view; 275 mActiveView = view;
272 mViewWidgetStack->raiseWidget( view ); 276 mViewWidgetStack->raiseWidget( view );
273 // Set the proper filter in the view. By setting the combo 277 // Set the proper filter in the view. By setting the combo
274 // box, the activated slot will be called, which will push 278 // box, the activated slot will be called, which will push
275 // the filter to the view and refresh it. 279 // the filter to the view and refresh it.
276 280
277 if ( view->defaultFilterType() == KAddressBookView::None ) { 281 if ( view->defaultFilterType() == KAddressBookView::None ) {
278 282
279 mActionSelectFilter->setCurrentItem( 0 ); 283 mActionSelectFilter->setCurrentItem( 0 );
280 setActiveFilter( 0 ); 284 setActiveFilter( 0 );
281 } else if ( view->defaultFilterType() == KAddressBookView::Active ) { 285 } else if ( view->defaultFilterType() == KAddressBookView::Active ) {
282 setActiveFilter( mActionSelectFilter->currentItem() ); 286 setActiveFilter( mActionSelectFilter->currentItem() );
283 } else { 287 } else {
284 uint pos = filterPosition( view->defaultFilterName() ); 288 uint pos = filterPosition( view->defaultFilterName() );
285 mActionSelectFilter->setCurrentItem( pos ); 289 mActionSelectFilter->setCurrentItem( pos );
286 setActiveFilter( pos ); 290 setActiveFilter( pos );
287 } 291 }
288//US qDebug("ViewManager::setActiveView 6" ); 292//US qDebug("ViewManager::setActiveView 6" );
289 293
290 // Update the inc search widget to show the fields in the new active 294 // Update the inc search widget to show the fields in the new active
291 // view. 295 // view.
292 mCore->setSearchFields( mActiveView->fields() ); 296 mCore->setSearchFields( mActiveView->fields() );
293 297
294//US performance optimization. setActiveFilter calls also mActiveView->refresh() 298//US performance optimization. setActiveFilter calls also mActiveView->refresh()
295//US mActiveView->refresh(); 299//US mActiveView->refresh();
296 300
297 mActionSelectView->setItems( mViewNameList ); 301 mActionSelectView->setItems( mViewNameList );
298 mActionSelectView->setCurrentItem( mViewNameList.findIndex( mActiveView->caption() ) ); 302 mActionSelectView->setCurrentItem( mViewNameList.findIndex( mActiveView->caption() ) );
299 303
300 } 304 }
301 else 305 else
302 { 306 {
303 qDebug("ViewManager::setActiveView: unable to find view" ); 307 qDebug("ViewManager::setActiveView: unable to find view" );
304 } 308 }
305} 309}
306 310
307//US added another method with no parameter, since my moc compiler does not support default parameters. 311//US added another method with no parameter, since my moc compiler does not support default parameters.
308void ViewManager::refreshView() 312void ViewManager::refreshView()
309{ 313{
310 refreshView( QString::null ); 314 refreshView( QString::null );
311} 315}
312 316
313void ViewManager::refreshView( const QString &uid ) 317void ViewManager::refreshView( const QString &uid )
314{ 318{
315 if ( mActiveView ) 319 if ( mActiveView )
316 mActiveView->refresh( uid ); 320 mActiveView->refresh( uid );
317} 321}
318 322
319void ViewManager::setFocusAV() 323void ViewManager::setFocusAV()
320{ 324{
321 if ( mActiveView ) 325 if ( mActiveView )
322 mActiveView->setFocusAV(); 326 mActiveView->setFocusAV();
323} 327}
324void ViewManager::editView() 328void ViewManager::editView()
325{ 329{
326 if ( !mActiveView ) 330 if ( !mActiveView )
327 return; 331 return;
328 332
329 ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); 333 ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() );
330 ViewConfigureWidget *wdg = 0; 334 ViewConfigureWidget *wdg = 0;
331 ViewConfigureDialog* dlg = 0; 335 ViewConfigureDialog* dlg = 0;
332 if ( factory ) { 336 if ( factory ) {
333 // Save the filters so the dialog has the latest set 337 // Save the filters so the dialog has the latest set
334 Filter::save( mCore->config(), "Filter", mFilterList ); 338 Filter::save( mCore->config(), "Filter", mFilterList );
335 dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); 339 dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" );
336 wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); 340 wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" );
337 } else { 341 } else {
338 qDebug("ViewManager::editView()::cannot find viewfactory "); 342 qDebug("ViewManager::editView()::cannot find viewfactory ");
339 return; 343 return;
340 } 344 }
341 if ( wdg ) { 345 if ( wdg ) {
342 dlg->setWidget( wdg ); 346 dlg->setWidget( wdg );
343 347
344#ifndef DESKTOP_VERSION 348#ifndef DESKTOP_VERSION
345 //dlg.setMaximumSize( 640, 480 ); 349 //dlg.setMaximumSize( 640, 480 );
346 //dlg->setGeometry( 40,40, 400, 300); 350 //dlg->setGeometry( 40,40, 400, 300);
347 dlg->showMaximized(); 351 dlg->showMaximized();
348#endif 352#endif
349 353
350 KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); 354 KConfigGroupSaver saver( mCore->config(), mActiveView->caption() );
351 355
352 dlg->restoreSettings( mCore->config() ); 356 dlg->restoreSettings( mCore->config() );
353 357
354 if ( dlg->exec() ) { 358 if ( dlg->exec() ) {
355 dlg->saveSettings( mCore->config() ); 359 dlg->saveSettings( mCore->config() );
356 mActiveView->readConfig( mCore->config() ); 360 mActiveView->readConfig( mCore->config() );
357 361
358 // Set the proper filter in the view. By setting the combo 362 // Set the proper filter in the view. By setting the combo
359 // box, the activated slot will be called, which will push 363 // box, the activated slot will be called, which will push
360 // the filter to the view and refresh it. 364 // the filter to the view and refresh it.
361 if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { 365 if ( mActiveView->defaultFilterType() == KAddressBookView::None ) {
362 mActionSelectFilter->setCurrentItem( 0 ); 366 mActionSelectFilter->setCurrentItem( 0 );
363 setActiveFilter( 0 ); 367 setActiveFilter( 0 );
364 } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { 368 } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) {
365 setActiveFilter( mActionSelectFilter->currentItem() ); 369 setActiveFilter( mActionSelectFilter->currentItem() );
366 } else { 370 } else {
367 uint pos = filterPosition( mActiveView->defaultFilterName() ); 371 uint pos = filterPosition( mActiveView->defaultFilterName() );
368 mActionSelectFilter->setCurrentItem( pos ); 372 mActionSelectFilter->setCurrentItem( pos );
369 setActiveFilter( pos ); 373 setActiveFilter( pos );
370 } 374 }
371 mCore->setSearchFields( mActiveView->fields() ); 375 mCore->setSearchFields( mActiveView->fields() );
372//US performance optimization. setActiveFilter calls also mActiveView->refresh() 376//US performance optimization. setActiveFilter calls also mActiveView->refresh()
373//US mActiveView->refresh(); 377//US mActiveView->refresh();
374 378
375 379
376 //US this is a bugfix, that we get notified if we change a views configuration 380 //US this is a bugfix, that we get notified if we change a views configuration
377 emit modified(); 381 emit modified();
378 382
379 } 383 }
380 384
381 } 385 }
382 delete dlg; 386 delete dlg;
383} 387}
384 388
385void ViewManager::deleteView() 389void ViewManager::deleteView()
386{ 390{
387 QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) 391 QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" )
388 .arg( mActiveView->caption() ); 392 .arg( mActiveView->caption() );
389 QString caption = i18n( "Confirm Delete" ); 393 QString caption = i18n( "Confirm Delete" );
390 394
391 395
392 if (QMessageBox::information( this, caption, 396 if (QMessageBox::information( this, caption,
393 text, 397 text,
394 i18n("Yes!"), i18n("No"), 0, 0 ) == 0) 398 i18n("Yes!"), i18n("No"), 0, 0 ) == 0)
395 { 399 {
396 mViewNameList.remove( mActiveView->caption() ); 400 mViewNameList.remove( mActiveView->caption() );
397 401
398 // remove the view from the config file 402 // remove the view from the config file
399 KConfig *config = mCore->config(); 403 KConfig *config = mCore->config();
400 config->deleteGroup( mActiveView->caption() ); 404 config->deleteGroup( mActiveView->caption() );
401 405
402 mViewDict.remove( mActiveView->caption() ); 406 mViewDict.remove( mActiveView->caption() );
403 mActiveView = 0; 407 mActiveView = 0;
404 408
405 // we are in an invalid state now, but that should be fixed after 409 // we are in an invalid state now, but that should be fixed after
406 // we emit the signal 410 // we emit the signal
407 mActionSelectView->setItems( mViewNameList ); 411 mActionSelectView->setItems( mViewNameList );
408 if ( mViewNameList.count() > 0 ) { 412 if ( mViewNameList.count() > 0 ) {
409 mActionSelectView->setCurrentItem( 0 ); 413 mActionSelectView->setCurrentItem( 0 );
410 setActiveView( mViewNameList[ 0 ] ); 414 setActiveView( mViewNameList[ 0 ] );
411 } 415 }
412 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 416 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
413 } 417 }
414} 418}
415 419
416void ViewManager::addView() 420void ViewManager::addView()
417{ 421{
418 AddViewDialog dialog( &mViewFactoryDict, this ); 422 AddViewDialog dialog( &mViewFactoryDict, this );
419 423
420 if ( dialog.exec() ) { 424 if ( dialog.exec() ) {
421 QString newName = dialog.viewName(); 425 QString newName = dialog.viewName();
422 QString type = dialog.viewType(); 426 QString type = dialog.viewType();
423 427
424 // Check for name conflicts 428 // Check for name conflicts
425 bool firstConflict = true; 429 bool firstConflict = true;
426 int numTries = 1; 430 int numTries = 1;
427 while ( mViewNameList.contains( newName ) > 0 ) { 431 while ( mViewNameList.contains( newName ) > 0 ) {
428 if ( !firstConflict ) { 432 if ( !firstConflict ) {
429 newName = newName.left( newName.length() - 4 ); 433 newName = newName.left( newName.length() - 4 );
430 firstConflict = false; 434 firstConflict = false;
431 } 435 }
432 436
433 newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); 437 newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries );
434 numTries++; 438 numTries++;
435 } 439 }
436 440
437 // Add the new one to the list 441 // Add the new one to the list
438 mViewNameList.append( newName ); 442 mViewNameList.append( newName );
439 443
440 // write the view to the config file, 444 // write the view to the config file,
441 KConfig *config = mCore->config(); 445 KConfig *config = mCore->config();
442 446
443 config->deleteGroup( newName ); 447 config->deleteGroup( newName );
444 448
445 KConfigGroupSaver saver( config, newName ); 449 KConfigGroupSaver saver( config, newName );
446 450
447 config->writeEntry( "Type", type ); 451 config->writeEntry( "Type", type );
448 452
449 // try to set the active view 453 // try to set the active view
450 mActionSelectView->setItems( mViewNameList ); 454 mActionSelectView->setItems( mViewNameList );
451 mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); 455 mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) );
452 setActiveView( newName ); 456 setActiveView( newName );
453 457
454 editView(); 458 editView();
455 459
456 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 460 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
457 } 461 }
458} 462}
459 463
460void ViewManager::createViewFactories() 464void ViewManager::createViewFactories()
461{ 465{
462#ifndef KAB_EMBEDDED 466#ifndef KAB_EMBEDDED
463 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); 467 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" );
464 KTrader::OfferList::ConstIterator it; 468 KTrader::OfferList::ConstIterator it;
465 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 469 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
466 if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) 470 if ( !(*it)->hasServiceType( "KAddressBook/View" ) )
467 continue; 471 continue;
468 472
469 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); 473 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() );
470 474
471 if ( !factory ) { 475 if ( !factory ) {
472 kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; 476 kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl;
473 continue; 477 continue;
474 } 478 }
475 479
476 ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); 480 ViewFactory *viewFactory = static_cast<ViewFactory*>( factory );
477 481
478 if ( !viewFactory ) { 482 if ( !viewFactory ) {
479 kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; 483 kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl;
480 continue; 484 continue;
481 } 485 }
482 486
483 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 487 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
484 } 488 }
485 489
486#else //KAB_EMBEDDED 490#else //KAB_EMBEDDED
487 ViewFactory* viewFactory = new IconViewFactory(); 491 ViewFactory* viewFactory = new IconViewFactory();
488 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 492 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
489// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 493// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
490 494
491 viewFactory = new TableViewFactory(); 495 viewFactory = new TableViewFactory();
492 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 496 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
493// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 497// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
494 498
495 viewFactory = new CardViewFactory(); 499 viewFactory = new CardViewFactory();
496 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 500 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
497// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 501// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
498 502
499#endif //KAB_EMBEDDED 503#endif //KAB_EMBEDDED
500 504
501} 505}
502 506
503void ViewManager::dropped( QDropEvent *e ) 507void ViewManager::dropped( QDropEvent *e )
504{ 508{
505 509
506#ifndef KAB_EMBEDDED 510#ifndef KAB_EMBEDDED
507 511
508 QString clipText, vcards; 512 QString clipText, vcards;
509 KURL::List urls; 513 KURL::List urls;
510 514
511 if ( KURLDrag::decode( e, urls) ) { 515 if ( KURLDrag::decode( e, urls) ) {
512 KURL::List::Iterator it = urls.begin(); 516 KURL::List::Iterator it = urls.begin();
513 int c = urls.count(); 517 int c = urls.count();
514 if ( c > 1 ) { 518 if ( c > 1 ) {
515 QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); 519 QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c );
516 if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { 520 if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) {
517 for ( ; it != urls.end(); ++it ) 521 for ( ; it != urls.end(); ++it )
518 emit urlDropped( *it ); 522 emit urlDropped( *it );
519 } 523 }
520 } else if ( c == 1 ) 524 } else if ( c == 1 )
521 emit urlDropped( *it ); 525 emit urlDropped( *it );
522 } else if ( KVCardDrag::decode( e, vcards ) ) { 526 } else if ( KVCardDrag::decode( e, vcards ) ) {
523 KABC::Addressee addr; 527 KABC::Addressee addr;
524 KABC::VCardConverter converter; 528 KABC::VCardConverter converter;
525 QStringList list = QStringList::split( "\r\n\r\n", vcards ); 529 QStringList list = QStringList::split( "\r\n\r\n", vcards );
526 QStringList::Iterator it; 530 QStringList::Iterator it;
527 for ( it = list.begin(); it != list.end(); ++it ) { 531 for ( it = list.begin(); it != list.end(); ++it ) {
528 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { 532 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) {
529 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); 533 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() );
530 if ( a.isEmpty() ) { 534 if ( a.isEmpty() ) {
531 mCore->addressBook()->insertAddressee( addr ); 535 mCore->addressBook()->insertAddressee( addr );
532 emit modified(); 536 emit modified();
533 } 537 }
534 } 538 }
535 } 539 }
536 540
537 mActiveView->refresh(); 541 mActiveView->refresh();
538 } 542 }
539#else //KAB_EMBEDDED 543#else //KAB_EMBEDDED
540qDebug("ViewManager::dropped() has to be changed!!" ); 544qDebug("ViewManager::dropped() has to be changed!!" );
541#endif //KAB_EMBEDDED 545#endif //KAB_EMBEDDED
542 546
543} 547}
544 548
545void ViewManager::startDrag() 549void ViewManager::startDrag()
546{ 550{
547 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; 551 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl;
548 552
549#ifndef KAB_EMBEDDED 553#ifndef KAB_EMBEDDED
550 554
551 // Get the list of all the selected addressees 555 // Get the list of all the selected addressees
552 KABC::Addressee::List addrList; 556 KABC::Addressee::List addrList;
553 QStringList uidList = selectedUids(); 557 QStringList uidList = selectedUids();
554 QStringList::Iterator iter; 558 QStringList::Iterator iter;
555 for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) 559 for ( iter = uidList.begin(); iter != uidList.end(); ++iter )
556 addrList.append( mCore->addressBook()->findByUid( *iter ) ); 560 addrList.append( mCore->addressBook()->findByUid( *iter ) );
557 561
558 KMultipleDrag *drag = new KMultipleDrag( this ); 562 KMultipleDrag *drag = new KMultipleDrag( this );
559 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); 563 drag->addDragObject( new Q3TextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) );
560 KABC::Addressee::List::Iterator it; 564 KABC::Addressee::List::Iterator it;
561 QStringList vcards; 565 QStringList vcards;
562 for ( it = addrList.begin(); it != addrList.end(); ++it ) { 566 for ( it = addrList.begin(); it != addrList.end(); ++it ) {
563 QString vcard = QString::null; 567 QString vcard = QString::null;
564 KABC::VCardConverter converter; 568 KABC::VCardConverter converter;
565 if ( converter.addresseeToVCard( *it, vcard ) ) 569 if ( converter.addresseeToVCard( *it, vcard ) )
566 vcards.append( vcard ); 570 vcards.append( vcard );
567 } 571 }
568 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); 572 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) );
569 573
570 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); 574 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) );
571 drag->dragCopy(); 575 drag->dragCopy();
572 576
573#else //KAB_EMBEDDED 577#else //KAB_EMBEDDED
574qDebug("ViewManager::startDrag() has to be changed!!" ); 578qDebug("ViewManager::startDrag() has to be changed!!" );
575#endif //KAB_EMBEDDED 579#endif //KAB_EMBEDDED
576 580
577} 581}
578void ViewManager::doSearch( const QString& s,KABC::Field *field ) 582void ViewManager::doSearch( const QString& s,KABC::Field *field )
579{ 583{
580 if ( mActiveView ) 584 if ( mActiveView )
581 mActiveView->doSearch( s, field ); 585 mActiveView->doSearch( s, field );
582 586
583} 587}
584void ViewManager::setActiveFilter( int index ) 588void ViewManager::setActiveFilter( int index )
585{ 589{
586 Filter currentFilter; 590 Filter currentFilter;
587 591
588 if ( ( index - 1 ) < 0 ) 592 if ( ( index - 1 ) < 0 )
589 currentFilter = Filter(); 593 currentFilter = Filter();
590 else 594 else
591 currentFilter = mFilterList[ index - 1 ]; 595 currentFilter = mFilterList[ index - 1 ];
592 596
593 // Check if we have a view. Since the filter combo is created before 597 // Check if we have a view. Since the filter combo is created before
594 // the view, this slot could be called before there is a valid view. 598 // the view, this slot could be called before there is a valid view.
595 if ( mActiveView ) { 599 if ( mActiveView ) {
596 mActiveView->setFilter( currentFilter ); 600 mActiveView->setFilter( currentFilter );
597 mActiveView->refresh(); 601 mActiveView->refresh();
598 emit selected( QString::null ); 602 emit selected( QString::null );
599 } 603 }
600} 604}
601 605
602void ViewManager::configureFilters() 606void ViewManager::configureFilters()
603{ 607{
604 FilterDialog dlg( this ); 608 FilterDialog dlg( this );
605 609
606 dlg.setFilters( mFilterList ); 610 dlg.setFilters( mFilterList );
607 611
608 if ( dlg.exec() ) 612 if ( dlg.exec() )
609 mFilterList = dlg.filters(); 613 mFilterList = dlg.filters();
610 614
611 uint pos = mActionSelectFilter->currentItem(); 615 uint pos = mActionSelectFilter->currentItem();
612 mActionSelectFilter->setItems( filterNames() ); 616 mActionSelectFilter->setItems( filterNames() );
613 mActionSelectFilter->setCurrentItem( pos ); 617 mActionSelectFilter->setCurrentItem( pos );
614 setActiveFilter( pos ); 618 setActiveFilter( pos );
615 int cw = 150; 619 int cw = 150;
616 if ( QApplication::desktop()->width() >= 800 ) 620 if ( QApplication::desktop()->width() >= 800 )
617 cw = 200; 621 cw = 200;
618 if (QApplication::desktop()->width() == 480 && !KABPrefs::instance()->mHideSearchOnSwitch) 622 if (QApplication::desktop()->width() == 480 && !KABPrefs::instance()->mHideSearchOnSwitch)
619 cw = 0; 623 cw = 0;
620 mActionSelectFilter->setComboWidth( cw ); 624 mActionSelectFilter->setComboWidth( cw );
621 saveSettings(); 625 saveSettings();
622} 626}
623 627
624QStringList ViewManager::filterNames() const 628QStringList ViewManager::filterNames() const
625{ 629{
626 QStringList names( i18n( "No Filter" ) ); 630 QStringList names( i18n( "No Filter" ) );
627 631
628 Filter::List::ConstIterator it; 632 Filter::List::ConstIterator it;
629 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) 633 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
630 names.append( (*it).name() ); 634 names.append( (*it).name() );
631 635
632 return names; 636 return names;
633} 637}
634Filter ViewManager::getFilterByName( const QString &name ) const 638Filter ViewManager::getFilterByName( const QString &name ) const
635{ 639{
636 Filter::List::ConstIterator it; 640 Filter::List::ConstIterator it;
637 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) 641 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
638 if ( name == (*it).name() ) 642 if ( name == (*it).name() )
639 return (*it); 643 return (*it);
640 644
641 return Filter(); 645 return Filter();
642} 646}
643 647
644int ViewManager::filterPosition( const QString &name ) const 648int ViewManager::filterPosition( const QString &name ) const
645{ 649{
646 int pos = 0; 650 int pos = 0;
647 651
648 Filter::List::ConstIterator it; 652 Filter::List::ConstIterator it;
649 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) 653 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos )
650 if ( name == (*it).name() ) 654 if ( name == (*it).name() )
651 return pos + 1; 655 return pos + 1;
652 656
653 return 0; 657 return 0;
654} 658}
655 659
656void ViewManager::initActions() 660void ViewManager::initActions()
657{ 661{
658//US <ActionList name="view_loadedviews"/> 662//US <ActionList name="view_loadedviews"/>
659//US <Separator/> 663//US <Separator/>
660 664
661#ifdef KAB_EMBEDDED 665#ifdef KAB_EMBEDDED
662 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); 666 Q3PopupMenu *viewmenu = (Q3PopupMenu*)mCore->getViewMenu();
663 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); 667 Q3PopupMenu *settingsmenu = (Q3PopupMenu*)mCore->getSettingsMenu();
664 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); 668 Q3PopupMenu *filtermenu = (Q3PopupMenu*)mCore->getFilterMenu();
665#endif //KAB_EMBEDDED 669#endif //KAB_EMBEDDED
666 670
667 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); 671 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" );
668#if KDE_VERSION >= 309 672#if KDE_VERSION >= 309
669 mActionSelectView->setMenuAccelsEnabled( false ); 673 mActionSelectView->setMenuAccelsEnabled( false );
670#endif 674#endif
671 connect( mActionSelectView, SIGNAL( activated( const QString& ) ), 675 connect( mActionSelectView, SIGNAL( activated( const QString& ) ),
672 SLOT( selectView( const QString& ) ) ); 676 SLOT( selectView( const QString& ) ) );
673 677
674 678
675#ifdef KAB_EMBEDDED 679#ifdef KAB_EMBEDDED
676 mActionSelectView->plug(viewmenu); 680 mActionSelectView->plug(viewmenu);
677 viewmenu->insertSeparator(); 681 viewmenu->insertSeparator();
678#endif //KAB_EMBEDDED 682#endif //KAB_EMBEDDED
679 683
680 KAction *action; 684 KAction *action;
681 685
682 action = new KAction( i18n( "Modify View..." ), "configure", 0, this, 686 action = new KAction( i18n( "Modify View..." ), "configure", 0, this,
683 SLOT( editView() ), mCore->actionCollection(), "view_modify" ); 687 SLOT( editView() ), mCore->actionCollection(), "view_modify" );
684#ifndef KAB_EMBEDDED 688#ifndef KAB_EMBEDDED
685 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." ) ); 689 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." ) );
686#else //KAB_EMBEDDED 690#else //KAB_EMBEDDED
687 action->plug(viewmenu); 691 action->plug(viewmenu);
688#endif //KAB_EMBEDDED 692#endif //KAB_EMBEDDED
689 693
690 action = new KAction( i18n( "Add View..." ), "window_new", 0, this, 694 action = new KAction( i18n( "Add View..." ), "window_new", 0, this,
691 SLOT( addView() ), mCore->actionCollection(), "view_add" ); 695 SLOT( addView() ), mCore->actionCollection(), "view_add" );
692#ifndef KAB_EMBEDDED 696#ifndef KAB_EMBEDDED
693 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." ) ); 697 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." ) );
694#else //KAB_EMBEDDED 698#else //KAB_EMBEDDED
695 action->plug(viewmenu); 699 action->plug(viewmenu);
696#endif //KAB_EMBEDDED 700#endif //KAB_EMBEDDED
697 701
698 mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, 702 mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0,
699 this, SLOT( deleteView() ), 703 this, SLOT( deleteView() ),
700 mCore->actionCollection(), "view_delete" ); 704 mCore->actionCollection(), "view_delete" );
701#ifndef KAB_EMBEDDED 705#ifndef KAB_EMBEDDED
702 mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); 706 mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) );
703#else //KAB_EMBEDDED 707#else //KAB_EMBEDDED
704 mActionDeleteView->plug(viewmenu); 708 mActionDeleteView->plug(viewmenu);
705 viewmenu->insertSeparator(); 709 viewmenu->insertSeparator();
706#endif //KAB_EMBEDDED 710#endif //KAB_EMBEDDED
707 711
708#ifndef KAB_EMBEDDED 712#ifndef KAB_EMBEDDED
709 action = new KAction( i18n( "Refresh View" ), "reload", 0, this, 713 action = new KAction( i18n( "Refresh View" ), "reload", 0, this,
710 SLOT( refreshView(const QString &) ), mCore->actionCollection(), 714 SLOT( refreshView(const QString &) ), mCore->actionCollection(),
711 "view_refresh" ); 715 "view_refresh" );
712 action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); 716 action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) );
713#else //KAB_EMBEDDED 717#else //KAB_EMBEDDED
714 action = new KAction( i18n( "Refresh View" ), "reload", 0, this, 718 action = new KAction( i18n( "Refresh View" ), "reload", 0, this,
715 SLOT( refreshView()), mCore->actionCollection(), 719 SLOT( refreshView()), mCore->actionCollection(),
716 "view_refresh" ); 720 "view_refresh" );
717 action->plug(viewmenu); 721 action->plug(viewmenu);
718 //viewmenu->insertSeparator(); 722 //viewmenu->insertSeparator();
719#endif //KAB_EMBEDDED 723#endif //KAB_EMBEDDED
720 724
721 action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, 725 action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this,
722 SLOT( configureFilters() ), mCore->actionCollection(), 726 SLOT( configureFilters() ), mCore->actionCollection(),
723 "options_edit_filters" ); 727 "options_edit_filters" );
724 728
725 mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); 729 mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" );
726#if KDE_VERSION >= 309 730#if KDE_VERSION >= 309
727 mActionSelectFilter->setMenuAccelsEnabled( false ); 731 mActionSelectFilter->setMenuAccelsEnabled( false );
728#endif 732#endif
729 connect( mActionSelectFilter, SIGNAL( activated( int ) ), 733 connect( mActionSelectFilter, SIGNAL( activated( int ) ),
730 SLOT( setActiveFilter( int ) ) ); 734 SLOT( setActiveFilter( int ) ) );
731 735
732#ifdef KAB_EMBEDDED 736#ifdef KAB_EMBEDDED
733 action->plug(settingsmenu); 737 action->plug(settingsmenu);
734 mActionSelectFilter->plug(viewmenu,0); 738 mActionSelectFilter->plug(viewmenu,0);
735#endif //KAB_EMBEDDED 739#endif //KAB_EMBEDDED
736 740
737} 741}
738 742
739void ViewManager::initGUI() 743void ViewManager::initGUI()
740{ 744{
741 QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); 745 Q3HBoxLayout *layout = new Q3HBoxLayout( this, 0, 0 );
742 mViewWidgetStack = new QWidgetStack( this ); 746 mViewWidgetStack = new Q3WidgetStack( this );
743 layout->addWidget( mViewWidgetStack ); 747 layout->addWidget( mViewWidgetStack );
744} 748}
745 749
746#ifndef KAB_EMBEDDED 750#ifndef KAB_EMBEDDED_
747#include "viewmanager.moc" 751#include "moc_viewmanager.cpp"
748#endif //KAB_EMBEDDED 752#endif //KAB_EMBEDDED
diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h
index ab5d372..4bbdbc7 100644
--- a/kaddressbook/viewmanager.h
+++ b/kaddressbook/viewmanager.h
@@ -1,161 +1,163 @@
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//Added by qt3to4:
30#include <QDropEvent>
29#include <kaddressbookview.h> 31#include <kaddressbookview.h>
30#include <qdict.h> 32#include <q3dict.h>
31#include "filter.h" 33#include "filter.h"
32 34
33class KAction; 35class KAction;
34class KSelectAction; 36class KSelectAction;
35 37
36class KABCore; 38class KABCore;
37class QWidgetStack; 39class Q3WidgetStack;
38class QDropEvent; 40class QDropEvent;
39 41
40namespace KABC { class AddressBook; } 42namespace KABC { class AddressBook; }
41 43
42/** 44/**
43 The view manager manages the views and everything related to them. The 45 The view manager manages the views and everything related to them. The
44 manager will load the views at startup and display a view when told to 46 manager will load the views at startup and display a view when told to
45 make one active. 47 make one active.
46 48
47 The view manager will also create and manage all dialogs directly related to 49 The view manager will also create and manage all dialogs directly related to
48 views (ie: AddView, ConfigureView, DeleteView, etc). 50 views (ie: AddView, ConfigureView, DeleteView, etc).
49 */ 51 */
50class ViewManager : public QWidget 52class ViewManager : public QWidget
51{ 53{
52 Q_OBJECT 54 Q_OBJECT
53 public: 55 public:
54 ViewManager( KABCore *core, QWidget *parent, const char *name = 0 ); 56 ViewManager( KABCore *core, QWidget *parent, const char *name = 0 );
55 ~ViewManager(); 57 ~ViewManager();
56 58
57 void restoreSettings(); 59 void restoreSettings();
58 void saveSettings(); 60 void saveSettings();
59 void doSearch( const QString& s ,KABC::Field *field ); 61 void doSearch( const QString& s ,KABC::Field *field );
60 62
61 void unloadViews(); 63 void unloadViews();
62 KSelectAction * getFilterAction() { return mActionSelectFilter; } 64 KSelectAction * getFilterAction() { return mActionSelectFilter; }
63 Filter getFilterByName( const QString &name ) const; 65 Filter getFilterByName( const QString &name ) const;
64 66
65 QStringList selectedUids() const; 67 QStringList selectedUids() const;
66 QStringList selectedEmails() const; 68 QStringList selectedEmails() const;
67 KABC::Addressee::List selectedAddressees() const; 69 KABC::Addressee::List selectedAddressees() const;
68 void setListSelected(QStringList); 70 void setListSelected(QStringList);
69 void setFocusAV(); 71 void setFocusAV();
70 72
71 public slots: 73 public slots:
72 void printView() { if (mActiveView) mActiveView->printMyView() ;} 74 void printView() { if (mActiveView) mActiveView->printMyView() ;}
73 void scrollUP(); 75 void scrollUP();
74 void scrollDOWN(); 76 void scrollDOWN();
75 77
76//US void setSelected( const QString &uid = QString::null, bool selected = true ); 78//US void setSelected( const QString &uid = QString::null, bool selected = true );
77 void setSelected( const QString &uid, bool); 79 void setSelected( const QString &uid, bool);
78//US added another method with no parameter, since my moc compiler does not support default parameters. 80//US added another method with no parameter, since my moc compiler does not support default parameters.
79 void setSelected(); 81 void setSelected();
80 82
81 83
82 84
83//US added another method with no parameter, since my moc compiler does not support default parameters. 85//US added another method with no parameter, since my moc compiler does not support default parameters.
84 void refreshView(); 86 void refreshView();
85 void refreshView( const QString &uid); 87 void refreshView( const QString &uid);
86 88
87 void editView(); 89 void editView();
88 void deleteView(); 90 void deleteView();
89 void addView(); 91 void addView();
90 92
91 protected slots: 93 protected slots:
92 /** 94 /**
93 Called whenever the user drops something in the active view. 95 Called whenever the user drops something in the active view.
94 This method will try to decode what was dropped, and if it was 96 This method will try to decode what was dropped, and if it was
95 a valid addressee, add it to the addressbook. 97 a valid addressee, add it to the addressbook.
96 */ 98 */
97 void dropped( QDropEvent* ); 99 void dropped( QDropEvent* );
98 100
99 /** 101 /**
100 Called whenever the user attempts to start a drag in the view. 102 Called whenever the user attempts to start a drag in the view.
101 This method will convert all the selected addressees into text (vcard) 103 This method will convert all the selected addressees into text (vcard)
102 and create a drag object. 104 and create a drag object.
103 */ 105 */
104 void startDrag(); 106 void startDrag();
105 107
106 signals: 108 signals:
107 /** 109 /**
108 Emitted whenever the user selects an entry in the view. 110 Emitted whenever the user selects an entry in the view.
109 */ 111 */
110 void selected( const QString &uid ); 112 void selected( const QString &uid );
111 void deleteRequest( ); 113 void deleteRequest( );
112 114
113 /** 115 /**
114 Emitted whenever the user activates an entry in the view. 116 Emitted whenever the user activates an entry in the view.
115 */ 117 */
116 void executed( const QString &uid ); 118 void executed( const QString &uid );
117 119
118 /** 120 /**
119 Emitted whenever the address book is modified in some way. 121 Emitted whenever the address book is modified in some way.
120 */ 122 */
121 void modified(); 123 void modified();
122 124
123 /** 125 /**
124 Emitted whenever a url is dragged on a view. 126 Emitted whenever a url is dragged on a view.
125 */ 127 */
126 void urlDropped( const KURL& ); 128 void urlDropped( const KURL& );
127 129
128 private slots: 130 private slots:
129 void selectView( const QString &name ); 131 void selectView( const QString &name );
130 void setActiveView( const QString &name ); 132 void setActiveView( const QString &name );
131 void setActiveFilter( int index ); 133 void setActiveFilter( int index );
132 void configureFilters(); 134 void configureFilters();
133 135
134 private: 136 private:
135 void createViewFactories(); 137 void createViewFactories();
136 QStringList filterNames() const; 138 QStringList filterNames() const;
137 int filterPosition( const QString &name ) const; 139 int filterPosition( const QString &name ) const;
138 QStringList viewNames() const; 140 QStringList viewNames() const;
139 int viewPosition( const QString &name ) const; 141 int viewPosition( const QString &name ) const;
140 void initActions(); 142 void initActions();
141 void initGUI(); 143 void initGUI();
142 144
143 KABCore *mCore; 145 KABCore *mCore;
144 146
145 Filter mCurrentFilter; 147 Filter mCurrentFilter;
146 Filter::List mFilterList; 148 Filter::List mFilterList;
147 149
148 QDict<KAddressBookView> mViewDict; 150 Q3Dict<KAddressBookView> mViewDict;
149 QDict<ViewFactory> mViewFactoryDict; 151 Q3Dict<ViewFactory> mViewFactoryDict;
150 QStringList mViewNameList; 152 QStringList mViewNameList;
151 153
152 QWidgetStack *mViewWidgetStack; 154 Q3WidgetStack *mViewWidgetStack;
153 KAddressBookView *mActiveView; 155 KAddressBookView *mActiveView;
154 156
155 KAction *mActionDeleteView; 157 KAction *mActionDeleteView;
156 KSelectAction *mActionSelectFilter; 158 KSelectAction *mActionSelectFilter;
157 KSelectAction *mActionSelectView; 159 KSelectAction *mActionSelectView;
158 160
159}; 161};
160 162
161#endif 163#endif
diff --git a/kaddressbook/views/cardview.cpp b/kaddressbook/views/cardview.cpp
index b6e053f..1a29f41 100644
--- a/kaddressbook/views/cardview.cpp
+++ b/kaddressbook/views/cardview.cpp
@@ -1,1750 +1,1758 @@
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//BEGIN Includes 24//BEGIN Includes
25#include "cardview.h" 25#include "cardview.h"
26 26
27#include <limits.h> 27#include <limits.h>
28 28
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qlabel.h> 32#include <qlabel.h>
33#include <qstyle.h> 33#include <qstyle.h>
34#include <qcursor.h> 34#include <qcursor.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
36#include <qapplication.h> 36#include <qapplication.h>
37//Added by qt3to4:
38#include <QKeyEvent>
39#include <Q3PtrList>
40#include <QResizeEvent>
41#include <QFocusEvent>
42#include <QMouseEvent>
43#include <QEvent>
44#include <QWheelEvent>
37 45
38#include "kabprefs.h" 46#include "kabprefs.h"
39#include <kdebug.h> 47#include <kdebug.h>
40#include <kglobalsettings.h> 48#include <kglobalsettings.h>
41//END includes 49//END includes
42 50
43#define MIN_ITEM_WIDTH 80 51#define MIN_ITEM_WIDTH 80
44 52
45//BEGIN Helpers 53//BEGIN Helpers
46////////////////////////////////////// 54//////////////////////////////////////
47// CardViewTip 55// CardViewTip
48class CardViewTip : public QLabel { 56class CardViewTip : public QLabel {
49 public: 57 public:
50 CardViewTip(QWidget *parent=0, const char *name=0) : QLabel( parent, name ) 58 CardViewTip(QWidget *parent=0, const char *name=0) : QLabel( parent, name )
51 { 59 {
52 setPalette( QToolTip::palette() ); 60 setPalette( QToolTip::palette() );
53 setFrameStyle( Panel|Plain ); 61 setFrameStyle( Panel|Plain );
54 setMidLineWidth(0); 62 setMidLineWidth(0);
55 setIndent(1); 63 setIndent(1);
56 } 64 }
57 65
58 ~CardViewTip() {}; 66 ~CardViewTip() {};
59 protected: 67 protected:
60 void leaveEvent( QEvent * ) 68 void leaveEvent( QEvent * )
61 { 69 {
62 hide(); 70 hide();
63 } 71 }
64}; 72};
65 73
66////////////////////////////////////// 74//////////////////////////////////////
67// CardViewItemList 75// CardViewItemList
68 76
69 77
70// 78//
71// Warning: make sure you use findRef() instead of find() to find an 79// Warning: make sure you use findRef() instead of find() to find an
72// item! Only the pointer value is unique in the list. 80// item! Only the pointer value is unique in the list.
73// 81//
74class CardViewItemList : public QPtrList<CardViewItem> 82class CardViewItemList : public Q3PtrList<CardViewItem>
75{ 83{
76 protected: 84 protected:
77 virtual int compareItems(QPtrCollection::Item item1, 85 virtual int compareItems(Q3PtrCollection::Item item1,
78 QPtrCollection::Item item2) 86 Q3PtrCollection::Item item2)
79 { 87 {
80 CardViewItem *cItem1 = (CardViewItem*)item1; 88 CardViewItem *cItem1 = (CardViewItem*)item1;
81 CardViewItem *cItem2 = (CardViewItem*)item2; 89 CardViewItem *cItem2 = (CardViewItem*)item2;
82 90
83 if ( cItem1 == cItem2 ) 91 if ( cItem1 == cItem2 )
84 return 0; 92 return 0;
85 93
86 if ((cItem1 == 0) || (cItem2 == 0)) 94 if ((cItem1 == 0) || (cItem2 == 0))
87 return cItem1 ? -1 : 1; 95 return cItem1 ? -1 : 1;
88 96
89 if (cItem1->caption() < cItem2->caption()) 97 if (cItem1->caption() < cItem2->caption())
90 return -1; 98 return -1;
91 99
92 else if (cItem1->caption() > cItem2->caption()) 100 else if (cItem1->caption() > cItem2->caption())
93 return 1; 101 return 1;
94 102
95 return 0; 103 return 0;
96 } 104 }
97 105
98 private: 106 private:
99 /*int find( const CardViewItem * ) 107 /*int find( const CardViewItem * )
100 { 108 {
101 qDebug("DON'T USE CardViewItemList::find( item )! Use findRef( item )!"); 109 qDebug("DON'T USE CardViewItemList::find( item )! Use findRef( item )!");
102 }*/ 110 }*/
103}; 111};
104 112
105////////////////////////////////////// 113//////////////////////////////////////
106// CardViewSeparator 114// CardViewSeparator
107class CardViewSeparator 115class CardViewSeparator
108{ 116{
109 friend class CardView; 117 friend class CardView;
110 118
111 public: 119 public:
112 CardViewSeparator(CardView *view) 120 CardViewSeparator(CardView *view)
113 : mView(view) 121 : mView(view)
114 { 122 {
115 mRect = QRect(0, 0, view->separatorWidth(), 0); 123 mRect = QRect(0, 0, view->separatorWidth(), 0);
116 } 124 }
117 125
118 ~CardViewSeparator() {} 126 ~CardViewSeparator() {}
119 127
120 void paintSeparator(QPainter *p, QColorGroup &cg) 128 void paintSeparator(QPainter *p, QColorGroup &cg)
121 { 129 {
122 p->fillRect(0, 0, mRect.width(), mRect.height(), 130 p->fillRect(0, 0, mRect.width(), mRect.height(),
123 cg.brush(QColorGroup::Button)); 131 cg.brush(QColorGroup::Button));
124 } 132 }
125 133
126 void repaintSeparator() 134 void repaintSeparator()
127 { 135 {
128 mView->repaintContents(mRect); 136 mView->repaintContents(mRect);
129 } 137 }
130 138
131 private: 139 private:
132 CardView *mView; 140 CardView *mView;
133 QRect mRect; 141 QRect mRect;
134}; 142};
135 143
136//END Helpers 144//END Helpers
137 145
138//BEGIN Private Data 146//BEGIN Private Data
139 147
140class CardViewPrivate 148class CardViewPrivate
141{ 149{
142 public: 150 public:
143 CardViewPrivate() 151 CardViewPrivate()
144 : mSelectionMode( CardView::Multi ), 152 : mSelectionMode( CardView::Multi ),
145 mDrawCardBorder( true ), 153 mDrawCardBorder( true ),
146 mDrawFieldLabels( true ), 154 mDrawFieldLabels( true ),
147 mDrawSeparators( true), 155 mDrawSeparators( true),
148 mSepWidth( 2 ), 156 mSepWidth( 2 ),
149 mShowEmptyFields( false ), 157 mShowEmptyFields( false ),
150 mLayoutDirty( true ), 158 mLayoutDirty( true ),
151 mLastClickOnItem( false ), 159 mLastClickOnItem( false ),
152 mItemMargin( 0 ), 160 mItemMargin( 0 ),
153 mItemSpacing( 10 ), 161 mItemSpacing( 10 ),
154 mItemWidth( 200 ), 162 mItemWidth( 200 ),
155 mMaxFieldLines( INT_MAX ), 163 mMaxFieldLines( INT_MAX ),
156 mCurrentItem( 0L ), 164 mCurrentItem( 0L ),
157 mLastClickPos( QPoint(0, 0) ), 165 mLastClickPos( QPoint(0, 0) ),
158 mResizeAnchor(0), 166 mResizeAnchor(0),
159 mRubberBandAnchor( 0 ), 167 mRubberBandAnchor( 0 ),
160 mCompText( QString::null ) 168 mCompText( QString::null )
161 {}; 169 {};
162 170
163 CardViewItemList mItemList; 171 CardViewItemList mItemList;
164 QPtrList<CardViewSeparator> mSeparatorList; 172 Q3PtrList<CardViewSeparator> mSeparatorList;
165 QFontMetrics *mFm; 173 QFontMetrics *mFm;
166 QFontMetrics *mBFm; // bold font 174 QFontMetrics *mBFm; // bold font
167 QFont mHeaderFont; // custom header font 175 QFont mHeaderFont; // custom header font
168 CardView::SelectionMode mSelectionMode; 176 CardView::SelectionMode mSelectionMode;
169 bool mDrawCardBorder; 177 bool mDrawCardBorder;
170 bool mDrawFieldLabels; 178 bool mDrawFieldLabels;
171 bool mDrawSeparators; 179 bool mDrawSeparators;
172 int mSepWidth; 180 int mSepWidth;
173 bool mShowEmptyFields; 181 bool mShowEmptyFields;
174 bool mLayoutDirty; 182 bool mLayoutDirty;
175 bool mLastClickOnItem; 183 bool mLastClickOnItem;
176 uint mItemMargin; // internal margin in items 184 uint mItemMargin; // internal margin in items
177 uint mItemSpacing; // spacing between items, column seperators and border 185 uint mItemSpacing; // spacing between items, column seperators and border
178 int mItemWidth; // width of all items 186 int mItemWidth; // width of all items
179 uint mMaxFieldLines; // Max lines to dispaly pr field 187 uint mMaxFieldLines; // Max lines to dispaly pr field
180 CardViewItem *mCurrentItem; 188 CardViewItem *mCurrentItem;
181 QPoint mLastClickPos; 189 QPoint mLastClickPos;
182 QTimer *mTimer; // times out if mouse rests for more than 500 msecs 190 QTimer *mTimer; // times out if mouse rests for more than 500 msecs
183 CardViewTip *mTip; // passed to the item under a resting cursor to display full text 191 CardViewTip *mTip; // passed to the item under a resting cursor to display full text
184 bool mOnSeparator; // set/reset on mouse movement 192 bool mOnSeparator; // set/reset on mouse movement
185 // for resizing by dragging the separators 193 // for resizing by dragging the separators
186 int mResizeAnchor; // uint, ulong? the mouse down separator left 194 int mResizeAnchor; // uint, ulong? the mouse down separator left
187 int mRubberBandAnchor; // for erasing rubber bands 195 int mRubberBandAnchor; // for erasing rubber bands
188 // data used for resizing. 196 // data used for resizing.
189 // as they are beeded by each mouse move while resizing, we store them here, 197 // as they are beeded by each mouse move while resizing, we store them here,
190 // saving 8 calculations in each mouse move. 198 // saving 8 calculations in each mouse move.
191 int colspace; // amount of space between items pr column 199 int colspace; // amount of space between items pr column
192 uint first; // the first col to anchor at for painting rubber bands 200 uint first; // the first col to anchor at for painting rubber bands
193 int firstX; // X position of first in pixel 201 int firstX; // X position of first in pixel
194 int pressed; // the colummn that was pressed on at resizing start 202 int pressed; // the colummn that was pressed on at resizing start
195 int span; // pressed - first 203 int span; // pressed - first
196 // key completion 204 // key completion
197 QString mCompText; // current completion string 205 QString mCompText; // current completion string
198 QDateTime mCompUpdated; // ...was updated at this time 206 QDateTime mCompUpdated; // ...was updated at this time
199}; 207};
200 208
201class CardViewItemPrivate 209class CardViewItemPrivate
202{ 210{
203 public: 211 public:
204 CardViewItemPrivate() : 212 CardViewItemPrivate() :
205 mSelected( false ), 213 mSelected( false ),
206 x( 0 ), 214 x( 0 ),
207 y( 0 ){}; 215 y( 0 ){};
208 216
209 217
210 QString mCaption; 218 QString mCaption;
211 QPtrList< CardViewItem::Field > mFieldList; 219 Q3PtrList< CardViewItem::Field > mFieldList;
212 bool mSelected; 220 bool mSelected;
213 int x; // horizontal position, set by the view 221 int x; // horizontal position, set by the view
214 int y; // vertical position, set by the view 222 int y; // vertical position, set by the view
215 int maxLabelWidth; // the width of the widest label, according to the view font. 223 int maxLabelWidth; // the width of the widest label, according to the view font.
216 int hcache; // height cache 224 int hcache; // height cache
217}; 225};
218//END Private Data 226//END Private Data
219 227
220//BEGIN CardViewItem 228//BEGIN CardViewItem
221 229
222CardViewItem::CardViewItem(CardView *parent, QString caption) 230CardViewItem::CardViewItem(CardView *parent, QString caption)
223 : d(new CardViewItemPrivate()), mView(parent) 231 : d(new CardViewItemPrivate()), mView(parent)
224{ 232{
225 d->mCaption = caption; 233 d->mCaption = caption;
226 234
227 initialize(); 235 initialize();
228} 236}
229 237
230CardViewItem::~CardViewItem() 238CardViewItem::~CardViewItem()
231{ 239{
232 // Remove ourself from the view 240 // Remove ourself from the view
233 if (mView != 0) 241 if (mView != 0)
234 mView->takeItem(this); 242 mView->takeItem(this);
235 243
236 delete d; 244 delete d;
237 d = 0; 245 d = 0;
238} 246}
239 247
240void CardViewItem::initialize() 248void CardViewItem::initialize()
241{ 249{
242 d->mSelected = false; 250 d->mSelected = false;
243 d->mFieldList.setAutoDelete(true); 251 d->mFieldList.setAutoDelete(true);
244 d->maxLabelWidth = 0; 252 d->maxLabelWidth = 0;
245 d->hcache=0; 253 d->hcache=0;
246 254
247 //calcRect(); 255 //calcRect();
248 256
249 // Add ourself to the view 257 // Add ourself to the view
250 if (mView != 0) 258 if (mView != 0)
251 mView->insertItem(this); 259 mView->insertItem(this);
252} 260}
253 261
254void CardViewItem::paintCard(QPainter *p, QColorGroup &cg) 262void CardViewItem::paintCard(QPainter *p, QColorGroup &cg)
255{ 263{
256 264
257 if (!mView) 265 if (!mView)
258 return; 266 return;
259 267
260 QPen pen; 268 QPen pen;
261 QBrush brush; 269 QBrush brush;
262 QFontMetrics fm = *(mView->d->mFm); 270 QFontMetrics fm = *(mView->d->mFm);
263 QFontMetrics bFm = *(mView->d->mBFm); 271 QFontMetrics bFm = *(mView->d->mBFm);
264 bool drawLabels = mView->d->mDrawFieldLabels; 272 bool drawLabels = mView->d->mDrawFieldLabels;
265 bool drawBorder = mView->d->mDrawCardBorder; 273 bool drawBorder = mView->d->mDrawCardBorder;
266 int mg = mView->itemMargin(); 274 int mg = mView->itemMargin();
267 int w = mView->itemWidth() - (mg*2); 275 int w = mView->itemWidth() - (mg*2);
268 int h = height() - (mg*2); 276 int h = height() - (mg*2);
269 const int colonWidth( fm.width(":") ); 277 const int colonWidth( fm.width(":") );
270 int labelXPos = 2 + mg; 278 int labelXPos = 2 + mg;
271 int labelWidth = QMIN( w/2 - 4 - mg, d->maxLabelWidth + colonWidth + 4 ); 279 int labelWidth = QMIN( w/2 - 4 - mg, d->maxLabelWidth + colonWidth + 4 );
272 int valueXPos = labelWidth + 4 + mg; 280 int valueXPos = labelWidth + 4 + mg;
273 int valueWidth = w - labelWidth - 4 - mg; 281 int valueWidth = w - labelWidth - 4 - mg;
274 282
275 p->setFont( mView->font() ); 283 p->setFont( mView->font() );
276 labelWidth -= colonWidth; // extra space for the colon 284 labelWidth -= colonWidth; // extra space for the colon
277 285
278 if (!drawLabels) 286 if (!drawLabels)
279 { 287 {
280 valueXPos = labelXPos; 288 valueXPos = labelXPos;
281 valueWidth = w - 4; 289 valueWidth = w - 4;
282 } 290 }
283 291
284 // Draw a simple box 292 // Draw a simple box
285 if (isSelected()) 293 if (isSelected())
286 pen = QPen(cg.highlight(), 1); 294 pen = QPen(cg.highlight(), 1);
287 else 295 else
288 pen = QPen(cg.button(), 1); 296 pen = QPen(cg.button(), 1);
289 p->setPen(pen); 297 p->setPen(pen);
290 298
291 // Draw the border - this is only draw if the user asks for it. 299 // Draw the border - this is only draw if the user asks for it.
292 if (drawBorder) 300 if (drawBorder)
293 p->drawRect( mg, mg, w, h ); 301 p->drawRect( mg, mg, w, h );
294 302
295 // set the proper pen color for the caption box 303 // set the proper pen color for the caption box
296 if (isSelected()) 304 if (isSelected())
297 brush = cg.brush(QColorGroup::Highlight); 305 brush = cg.brush(QColorGroup::Highlight);
298 else 306 else
299 brush = cg.brush(QColorGroup::Button); 307 brush = cg.brush(QColorGroup::Button);
300 308
301 p->fillRect(mg, mg, w, 4 + bFm.height(), brush); 309 p->fillRect(mg, mg, w, 4 + bFm.height(), brush);
302 310
303 // Now paint the caption 311 // Now paint the caption
304 p->save(); 312 p->save();
305 QFont bFont = mView->headerFont(); 313 QFont bFont = mView->headerFont();
306 //bFont.setBold(true); 314 //bFont.setBold(true);
307 p->setFont(bFont); 315 p->setFont(bFont);
308 if (isSelected()) 316 if (isSelected())
309 p->setPen(cg.highlightedText()); 317 p->setPen(cg.highlightedText());
310 else 318 else
311 p->setPen(cg.buttonText()); 319 p->setPen(cg.buttonText());
312 p->drawText(2+mg, 2+mg + bFm.ascent()/*bFm.height()*//*-bFm.descent()*//*-bFm.leading()*/, trimString(d->mCaption, w-4, bFm)); 320 p->drawText(2+mg, 2+mg + bFm.ascent()/*bFm.height()*//*-bFm.descent()*//*-bFm.leading()*/, trimString(d->mCaption, w-4, bFm));
313 p->restore(); 321 p->restore();
314 322
315 // Go through the fields and draw them 323 // Go through the fields and draw them
316 QPtrListIterator< CardViewItem::Field > iter(d->mFieldList); 324 Q3PtrListIterator< CardViewItem::Field > iter(d->mFieldList);
317 QString label, value; 325 QString label, value;
318 int yPos = mg + 4 + bFm.height()/* + 1*/ + fm.height(); // why the + 1 ??? (anders) 326 int yPos = mg + 4 + bFm.height()/* + 1*/ + fm.height(); // why the + 1 ??? (anders)
319 p->setPen(cg.text()); 327 p->setPen(cg.text());
320 328
321 int fh = fm.height(); 329 int fh = fm.height();
322 int cln( 0 ); 330 int cln( 0 );
323 QString tmp; 331 QString tmp;
324 int maxLines = mView->maxFieldLines(); 332 int maxLines = mView->maxFieldLines();
325 for (iter.toFirst(); iter.current(); ++iter) 333 for (iter.toFirst(); iter.current(); ++iter)
326 { 334 {
327 value = (*iter)->second; 335 value = (*iter)->second;
328 if ( value.isEmpty() && ! mView->d->mShowEmptyFields ) 336 if ( value.isEmpty() && ! mView->d->mShowEmptyFields )
329 continue; 337 continue;
330 338
331 if (drawLabels) 339 if (drawLabels)
332 { 340 {
333 label = trimString((*iter)->first, labelWidth, fm); 341 label = trimString((*iter)->first, labelWidth, fm);
334 p->drawText(labelXPos, yPos, label + ":"); 342 p->drawText(labelXPos, yPos, label + ":");
335 } 343 }
336/* US original 344/* US original
337 for (cln=0; cln <= maxLines; cln++) 345 for (cln=0; cln <= maxLines; cln++)
338 { 346 {
339 tmp = value.section('\n',cln,cln); 347 tmp = value.section('\n',cln,cln);
340 if ( !tmp.isEmpty() ) p->drawText( valueXPos, yPos + cln*fh, trimString( tmp, valueWidth, fm ) ); 348 if ( !tmp.isEmpty() ) p->drawText( valueXPos, yPos + cln*fh, trimString( tmp, valueWidth, fm ) );
341 else break; 349 else break;
342 } 350 }
343*/ 351*/
344 352
345//US new implementation 353//US new implementation
346 QStringList strlst = QStringList::split('\n', value, true); 354 QStringList strlst = QStringList::split('\n', value, true);
347 355
348 for (cln=0; cln <= maxLines && cln <= (int)strlst.count(); cln++) 356 for (cln=0; cln <= maxLines && cln <= (int)strlst.count(); cln++)
349 { 357 {
350 tmp = strlst[cln]; 358 tmp = strlst[cln];
351 359
352 if ( !tmp.isEmpty() ) 360 if ( !tmp.isEmpty() )
353 p->drawText( valueXPos, yPos + cln*fh, trimString( tmp, valueWidth, fm ) ); 361 p->drawText( valueXPos, yPos + cln*fh, trimString( tmp, valueWidth, fm ) );
354 else 362 else
355 break; 363 break;
356 364
357 } 365 }
358 366
359 if ( cln == 0 ) cln = 1; 367 if ( cln == 0 ) cln = 1;
360 yPos += cln * fh + 2; 368 yPos += cln * fh + 2;
361 } 369 }
362 370
363 // if we are the current item and the view has focus, draw focus rect 371 // if we are the current item and the view has focus, draw focus rect
364 if ( mView->currentItem() == this && mView->hasFocus() ) 372 if ( mView->currentItem() == this && mView->hasFocus() )
365 { 373 {
366/*US 374/*US
367 mView->style().drawPrimitive( QStyle::PE_FocusRect, p, 375 mView->style().drawPrimitive( QStyle::PE_FocusRect, p,
368 QRect(0, 0, mView->itemWidth(), h+(2*mg)), cg, 376 QRect(0, 0, mView->itemWidth(), h+(2*mg)), cg,
369 QStyle::Style_FocusAtBorder, 377 QStyle::Style_FocusAtBorder,
370 QStyleOption( isSelected() ? cg.highlight() : cg.base() ) ); 378 QStyleOption( isSelected() ? cg.highlight() : cg.base() ) );
371*/ 379*/
372 380
373 const QColor pHighl = isSelected() ? cg.highlight() : cg.base(); 381 const QColor pHighl = isSelected() ? cg.highlight() : cg.base();
374 const QRect r(0, 0, mView->itemWidth(), h+(2*mg)); 382 const QRect r(0, 0, mView->itemWidth(), h+(2*mg));
375#ifndef DESKTOP_VERSION 383#ifndef DESKTOP_VERSION
376 mView->style().drawFocusRect(p, r, cg, &pHighl, true); 384 mView->style().drawFocusRect(p, r, cg, &pHighl, true);
377#endif 385#endif
378 } 386 }
379} 387}
380 388
381const QString &CardViewItem::caption() const 389const QString &CardViewItem::caption() const
382{ 390{
383 return d->mCaption; 391 return d->mCaption;
384} 392}
385 393
386 394
387int CardViewItem::height( bool allowCache ) const 395int CardViewItem::height( bool allowCache ) const
388{ 396{
389 // use cache 397 // use cache
390 if ( allowCache && d->hcache ) 398 if ( allowCache && d->hcache )
391 return d->hcache; 399 return d->hcache;
392 400
393 // Base height: 401 // Base height:
394 // 2 for line width 402 // 2 for line width
395 // 2 for top caption pad 403 // 2 for top caption pad
396 // 2 for bottom caption pad 404 // 2 for bottom caption pad
397 // 2 pad for the end 405 // 2 pad for the end
398 // + 2 times the advised margin 406 // + 2 times the advised margin
399 int baseHeight = 8 + ( 2 * mView->itemMargin() ); 407 int baseHeight = 8 + ( 2 * mView->itemMargin() );
400 408
401 // size of font for each field 409 // size of font for each field
402 // 2 pad for each field 410 // 2 pad for each field
403 411
404 // anders: if the view does not show empty fields, check for value 412 // anders: if the view does not show empty fields, check for value
405 bool sef = mView->showEmptyFields(); 413 bool sef = mView->showEmptyFields();
406 int fh = mView->d->mFm->height();//lineSpacing(); // font height 414 int fh = mView->d->mFm->height();//lineSpacing(); // font height
407 //int sp = QMAX( 0, 2- mView->d->mFm->leading() ); // field spacing NOTE make a property 415 //int sp = QMAX( 0, 2- mView->d->mFm->leading() ); // field spacing NOTE make a property
408 int fieldHeight = 0; 416 int fieldHeight = 0;
409 int lines; 417 int lines;
410 int maxLines( mView->maxFieldLines() ); 418 int maxLines( mView->maxFieldLines() );
411 QPtrListIterator< CardViewItem::Field > iter(d->mFieldList); 419 Q3PtrListIterator< CardViewItem::Field > iter(d->mFieldList);
412 for (iter.toFirst(); iter.current(); ++iter) 420 for (iter.toFirst(); iter.current(); ++iter)
413 { 421 {
414 if ( !sef && (*iter)->second.isEmpty() ) 422 if ( !sef && (*iter)->second.isEmpty() )
415 continue; 423 continue;
416 lines = QMIN( (*iter)->second.contains('\n') + 1, maxLines ); 424 lines = QMIN( (*iter)->second.count('\n') + 1, maxLines );
417 fieldHeight += ( lines * fh ) + 2;//sp; 425 fieldHeight += ( lines * fh ) + 2;//sp;
418 } 426 }
419 427
420 // height of caption font (bold) 428 // height of caption font (bold)
421 fieldHeight += mView->d->mBFm->height(); 429 fieldHeight += mView->d->mBFm->height();
422 d->hcache = baseHeight + fieldHeight; 430 d->hcache = baseHeight + fieldHeight;
423 return d->hcache; 431 return d->hcache;
424} 432}
425 433
426bool CardViewItem::isSelected() const 434bool CardViewItem::isSelected() const
427{ 435{
428 return d->mSelected; 436 return d->mSelected;
429} 437}
430 438
431void CardViewItem::setSelected(bool selected) 439void CardViewItem::setSelected(bool selected)
432{ 440{
433 d->mSelected = selected; 441 d->mSelected = selected;
434} 442}
435 443
436void CardViewItem::insertField(const QString &label, const QString &value) 444void CardViewItem::insertField(const QString &label, const QString &value)
437{ 445{
438 CardViewItem::Field *f = new CardViewItem::Field(label, value); 446 CardViewItem::Field *f = new CardViewItem::Field(label, value);
439 d->mFieldList.append(f); 447 d->mFieldList.append(f);
440 d->hcache=0; 448 d->hcache=0;
441 449
442 if (mView) 450 if (mView)
443 { 451 {
444 mView->setLayoutDirty(true); 452 mView->setLayoutDirty(true);
445 d->maxLabelWidth = QMAX( mView->d->mFm->width( label ), d->maxLabelWidth ); 453 d->maxLabelWidth = QMAX( mView->d->mFm->width( label ), d->maxLabelWidth );
446 } 454 }
447} 455}
448 456
449void CardViewItem::removeField(const QString &label) 457void CardViewItem::removeField(const QString &label)
450{ 458{
451 CardViewItem::Field *f; 459 CardViewItem::Field *f;
452 460
453 QPtrListIterator< CardViewItem::Field > iter(d->mFieldList); 461 Q3PtrListIterator< CardViewItem::Field > iter(d->mFieldList);
454 for (iter.toFirst(); iter.current(); ++iter) 462 for (iter.toFirst(); iter.current(); ++iter)
455 { 463 {
456 f = *iter; 464 f = *iter;
457 if (f->first == label) 465 if (f->first == label)
458 break; 466 break;
459 } 467 }
460 468
461 if (*iter) 469 if (*iter)
462 d->mFieldList.remove(*iter); 470 d->mFieldList.remove(*iter);
463 d->hcache = 0; 471 d->hcache = 0;
464 472
465 if (mView) 473 if (mView)
466 mView->setLayoutDirty(true); 474 mView->setLayoutDirty(true);
467} 475}
468 476
469void CardViewItem::clearFields() 477void CardViewItem::clearFields()
470{ 478{
471 d->mFieldList.clear(); 479 d->mFieldList.clear();
472 d->hcache = 0; 480 d->hcache = 0;
473 481
474 if (mView) 482 if (mView)
475 mView->setLayoutDirty(true); 483 mView->setLayoutDirty(true);
476} 484}
477 485
478QString CardViewItem::trimString(const QString &text, int width, 486QString CardViewItem::trimString(const QString &text, int width,
479 QFontMetrics &fm) 487 QFontMetrics &fm)
480{ 488{
481 if (fm.width(text) <= width) 489 if (fm.width(text) <= width)
482 return text; 490 return text;
483 491
484 QString dots = "..."; 492 QString dots = "...";
485 int dotWidth = fm.width(dots); 493 int dotWidth = fm.width(dots);
486 QString trimmed; 494 QString trimmed;
487 int charNum = 0; 495 int charNum = 0;
488 496
489 while (fm.width(trimmed) + dotWidth < width) 497 while (fm.width(trimmed) + dotWidth < width)
490 { 498 {
491 trimmed += text[charNum]; 499 trimmed += text[charNum];
492 charNum++; 500 charNum++;
493 } 501 }
494 502
495 // Now trim the last char, since it put the width over the top 503 // Now trim the last char, since it put the width over the top
496 trimmed = trimmed.left(trimmed.length()-1); 504 trimmed = trimmed.left(trimmed.length()-1);
497 trimmed += dots; 505 trimmed += dots;
498 506
499 return trimmed; 507 return trimmed;
500} 508}
501 509
502CardViewItem *CardViewItem::nextItem() 510CardViewItem *CardViewItem::nextItem()
503{ 511{
504 CardViewItem *item = 0; 512 CardViewItem *item = 0;
505 513
506 if (mView) 514 if (mView)
507 item = mView->itemAfter(this); 515 item = mView->itemAfter(this);
508 516
509 return item; 517 return item;
510} 518}
511 519
512void CardViewItem::repaintCard() 520void CardViewItem::repaintCard()
513{ 521{
514 if (mView) 522 if (mView)
515 mView->repaintItem(this); 523 mView->repaintItem(this);
516} 524}
517 525
518void CardViewItem::setCaption(const QString &caption) 526void CardViewItem::setCaption(const QString &caption)
519{ 527{
520 d->mCaption = caption; 528 d->mCaption = caption;
521 repaintCard(); 529 repaintCard();
522} 530}
523 531
524QString CardViewItem::fieldValue(const QString &label) 532QString CardViewItem::fieldValue(const QString &label)
525{ 533{
526 QPtrListIterator< CardViewItem::Field > iter(d->mFieldList); 534 Q3PtrListIterator< CardViewItem::Field > iter(d->mFieldList);
527 for (iter.toFirst(); iter.current(); ++iter) 535 for (iter.toFirst(); iter.current(); ++iter)
528 if ((*iter)->first == label) 536 if ((*iter)->first == label)
529 return (*iter)->second; 537 return (*iter)->second;
530 538
531 return QString(); 539 return QString();
532} 540}
533 541
534 542
535void CardViewItem::showFullString( const QPoint &itempos, CardViewTip *tip ) 543void CardViewItem::showFullString( const QPoint &itempos, CardViewTip *tip )
536{ 544{
537 bool trimmed( false ); 545 bool trimmed( false );
538 QString s; 546 QString s;
539 int mrg = mView->itemMargin(); 547 int mrg = mView->itemMargin();
540 int y = mView->d->mBFm->height() + 6 + mrg; 548 int y = mView->d->mBFm->height() + 6 + mrg;
541 int w = mView->itemWidth() - (2*mrg); 549 int w = mView->itemWidth() - (2*mrg);
542 int lw; 550 int lw;
543 bool drawLabels = mView->drawFieldLabels(); 551 bool drawLabels = mView->drawFieldLabels();
544 bool isLabel = drawLabels && itempos.x() < w/2 ? true : false; 552 bool isLabel = drawLabels && itempos.x() < w/2 ? true : false;
545 553
546 if ( itempos.y() < y ) 554 if ( itempos.y() < y )
547 { 555 {
548 if ( itempos.y() < 8 + mrg || itempos.y() > y - 4 ) 556 if ( itempos.y() < 8 + mrg || itempos.y() > y - 4 )
549 return; 557 return;
550 // this is the caption 558 // this is the caption
551 s = caption(); 559 s = caption();
552 trimmed = mView->d->mBFm->width( s ) > w - 4; 560 trimmed = mView->d->mBFm->width( s ) > w - 4;
553 y = 2 + mrg; 561 y = 2 + mrg;
554 lw = 0; 562 lw = 0;
555 isLabel=true; 563 isLabel=true;
556 } else { 564 } else {
557 // find the field 565 // find the field
558 Field *f = fieldAt( itempos ); 566 Field *f = fieldAt( itempos );
559 if ( !f || ( !mView->showEmptyFields() && f->second.isEmpty() ) ) 567 if ( !f || ( !mView->showEmptyFields() && f->second.isEmpty() ) )
560 return; 568 return;
561 569
562 // y position: 570 // y position:
563 // header font height + 4px hader margin + 2px leading + item margin 571 // header font height + 4px hader margin + 2px leading + item margin
564 // + actual field index * (fontheight + 2px leading) 572 // + actual field index * (fontheight + 2px leading)
565 int maxLines = mView->maxFieldLines(); 573 int maxLines = mView->maxFieldLines();
566 bool se = mView->showEmptyFields(); 574 bool se = mView->showEmptyFields();
567 int fh = mView->d->mFm->height(); 575 int fh = mView->d->mFm->height();
568// { 576// {
569 Field *_f; 577 Field *_f;
570 for (_f = d->mFieldList.first(); _f != f; _f = d->mFieldList.next()) 578 for (_f = d->mFieldList.first(); _f != f; _f = d->mFieldList.next())
571 if ( se || ! _f->second.isEmpty() ) 579 if ( se || ! _f->second.isEmpty() )
572 y += ( QMIN(_f->second.contains('\n')+1, maxLines) * fh ) + 2; 580 y += ( QMIN(_f->second.count('\n')+1, maxLines) * fh ) + 2;
573// } 581// }
574 if ( isLabel && itempos.y() > y + fh ) 582 if ( isLabel && itempos.y() > y + fh )
575 return; 583 return;
576 // label or data? 584 // label or data?
577 s = isLabel ? f->first : f->second; 585 s = isLabel ? f->first : f->second;
578 // trimmed? 586 // trimmed?
579 int colonWidth = mView->d->mFm->width(":"); 587 int colonWidth = mView->d->mFm->width(":");
580 lw = drawLabels ? // label width 588 lw = drawLabels ? // label width
581 QMIN( w/2 - 4 - mrg, d->maxLabelWidth + colonWidth + 4 ) : 589 QMIN( w/2 - 4 - mrg, d->maxLabelWidth + colonWidth + 4 ) :
582 0; 590 0;
583 int mw = isLabel ? lw - colonWidth : w - lw - (mrg*2); // max width for string 591 int mw = isLabel ? lw - colonWidth : w - lw - (mrg*2); // max width for string
584 if ( isLabel ) 592 if ( isLabel )
585 { 593 {
586 trimmed = mView->d->mFm->width( s ) > mw - colonWidth; 594 trimmed = mView->d->mFm->width( s ) > mw - colonWidth;
587 } else { 595 } else {
588 QRect r( mView->d->mFm->boundingRect( 0, 0, INT_MAX, INT_MAX, Qt::AlignTop|Qt::AlignLeft, s ) ); 596 QRect r( mView->d->mFm->boundingRect( 0, 0, INT_MAX, INT_MAX, Qt::AlignTop|Qt::AlignLeft, s ) );
589 trimmed = r.width() > mw || r.height()/fh > QMIN(s.contains('\n') + 1, maxLines); 597 trimmed = r.width() > mw || r.height()/fh > QMIN(s.count('\n') + 1, maxLines);
590 } 598 }
591 } 599 }
592 if ( trimmed ) 600 if ( trimmed )
593 { 601 {
594 tip->setFont( (isLabel && !lw) ? mView->headerFont() : mView->font() ); // if condition is true, a header 602 tip->setFont( (isLabel && !lw) ? mView->headerFont() : mView->font() ); // if condition is true, a header
595 tip->setText( s ); 603 tip->setText( s );
596 tip->adjustSize(); 604 tip->adjustSize();
597 // find a proper position 605 // find a proper position
598 int lx; 606 int lx;
599 lx = isLabel || !drawLabels ? mrg : lw + mrg + 2 /*-1*/; 607 lx = isLabel || !drawLabels ? mrg : lw + mrg + 2 /*-1*/;
600 QPoint pnt(mView->contentsToViewport( QPoint(d->x, d->y) )); 608 QPoint pnt(mView->contentsToViewport( QPoint(d->x, d->y) ));
601 pnt += QPoint(lx, y); 609 pnt += QPoint(lx, y);
602 if ( pnt.x() < 0 ) 610 if ( pnt.x() < 0 )
603 pnt.setX( 0 ); 611 pnt.setX( 0 );
604 if ( pnt.x() + tip->width() > mView->visibleWidth() ) 612 if ( pnt.x() + tip->width() > mView->visibleWidth() )
605 pnt.setX( mView->visibleWidth() - tip->width() ); 613 pnt.setX( mView->visibleWidth() - tip->width() );
606 if ( pnt.y() + tip->height() > mView->visibleHeight() ) 614 if ( pnt.y() + tip->height() > mView->visibleHeight() )
607 pnt.setY( QMAX( 0, mView->visibleHeight() - tip->height() ) ); 615 pnt.setY( QMAX( 0, mView->visibleHeight() - tip->height() ) );
608 // show 616 // show
609 tip->move( pnt ); 617 tip->move( pnt );
610 tip->show(); 618 tip->show();
611 } 619 }
612} 620}
613 621
614CardViewItem::Field *CardViewItem::fieldAt( const QPoint & itempos ) const 622CardViewItem::Field *CardViewItem::fieldAt( const QPoint & itempos ) const
615{ 623{
616 int ypos = mView->d->mBFm->height() + 7 + mView->d->mItemMargin; 624 int ypos = mView->d->mBFm->height() + 7 + mView->d->mItemMargin;
617 int iy = itempos.y(); 625 int iy = itempos.y();
618 // skip below caption 626 // skip below caption
619 if ( iy <= ypos ) 627 if ( iy <= ypos )
620 return 0; 628 return 0;
621 // try find a field 629 // try find a field
622 bool showEmpty = mView->showEmptyFields(); 630 bool showEmpty = mView->showEmptyFields();
623 int fh = mView->d->mFm->height(); 631 int fh = mView->d->mFm->height();
624 int maxLines = mView->maxFieldLines(); 632 int maxLines = mView->maxFieldLines();
625 Field *f; 633 Field *f;
626 for ( f = d->mFieldList.first(); f; f = d->mFieldList.next() ) 634 for ( f = d->mFieldList.first(); f; f = d->mFieldList.next() )
627 { 635 {
628 if ( showEmpty || !f->second.isEmpty() ) 636 if ( showEmpty || !f->second.isEmpty() )
629 ypos += ( QMIN( f->second.contains('\n')+1, maxLines ) *fh)+2; 637 ypos += ( QMIN( f->second.count('\n')+1, maxLines ) *fh)+2;
630 if ( iy <= ypos ) 638 if ( iy <= ypos )
631 break; 639 break;
632 } 640 }
633 return f ? f : 0; 641 return f ? f : 0;
634} 642}
635//END CardViewItem 643//END CardViewItem
636 644
637//BEGIN CardView 645//BEGIN CardView
638 646
639CardView::CardView(QWidget *parent, const char *name) 647CardView::CardView(QWidget *parent, const char *name)
640 : QScrollView(parent, name), 648 : Q3ScrollView(parent, name),
641 d(new CardViewPrivate()) 649 d(new CardViewPrivate())
642{ 650{
643 mFlagKeyPressed = false; 651 mFlagKeyPressed = false;
644 mFlagBlockKeyPressed = false; 652 mFlagBlockKeyPressed = false;
645 d->mItemList.setAutoDelete(true); 653 d->mItemList.setAutoDelete(true);
646 d->mSeparatorList.setAutoDelete(true); 654 d->mSeparatorList.setAutoDelete(true);
647 655
648 QFont f = font(); 656 QFont f = font();
649 d->mFm = new QFontMetrics(f); 657 d->mFm = new QFontMetrics(f);
650 f.setBold(true); 658 f.setBold(true);
651 d->mHeaderFont = f; 659 d->mHeaderFont = f;
652 d->mBFm = new QFontMetrics(f); 660 d->mBFm = new QFontMetrics(f);
653 d->mTip = ( new CardViewTip( viewport() ) ), 661 d->mTip = ( new CardViewTip( viewport() ) ),
654 d->mTip->hide(); 662 d->mTip->hide();
655 d->mTimer = ( new QTimer(this, "mouseTimer") ), 663 d->mTimer = ( new QTimer(this, "mouseTimer") ),
656 664
657 viewport()->setMouseTracking( true ); 665 viewport()->setMouseTracking( true );
658 viewport()->setFocusProxy(this); 666 viewport()->setFocusProxy(this);
659 viewport()->setFocusPolicy(WheelFocus); 667 viewport()->setFocusPolicy(Qt::WheelFocus);
660 viewport()->setBackgroundMode(PaletteBase); 668 viewport()->setBackgroundMode(Qt::PaletteBase);
661 669
662 connect( d->mTimer, SIGNAL(timeout()), this, SLOT(tryShowFullText()) ); 670 connect( d->mTimer, SIGNAL(timeout()), this, SLOT(tryShowFullText()) );
663 671
664//US setBackgroundMode(PaletteBackground, PaletteBase); 672//US setBackgroundMode(PaletteBackground, PaletteBase);
665 setBackgroundMode(PaletteBackground); 673 setBackgroundMode(Qt::PaletteBackground);
666 674
667 // no reason for a vertical scrollbar 675 // no reason for a vertical scrollbar
668 setVScrollBarMode(AlwaysOff); 676 setVScrollBarMode(AlwaysOff);
669} 677}
670 678
671CardView::~CardView() 679CardView::~CardView()
672{ 680{
673 delete d->mFm; 681 delete d->mFm;
674 delete d->mBFm; 682 delete d->mBFm;
675 delete d; 683 delete d;
676 d = 0; 684 d = 0;
677} 685}
678 686
679void CardView::insertItem(CardViewItem *item) 687void CardView::insertItem(CardViewItem *item)
680{ 688{
681 d->mItemList.inSort(item); 689 d->mItemList.inSort(item);
682 setLayoutDirty(true); 690 setLayoutDirty(true);
683} 691}
684 692
685void CardView::takeItem(CardViewItem *item) 693void CardView::takeItem(CardViewItem *item)
686{ 694{
687 if ( d->mCurrentItem == item ) 695 if ( d->mCurrentItem == item )
688 d->mCurrentItem = item->nextItem(); 696 d->mCurrentItem = item->nextItem();
689 d->mItemList.take(d->mItemList.findRef(item)); 697 d->mItemList.take(d->mItemList.findRef(item));
690 698
691 setLayoutDirty(true); 699 setLayoutDirty(true);
692} 700}
693 701
694void CardView::clear() 702void CardView::clear()
695{ 703{
696 d->mItemList.clear(); 704 d->mItemList.clear();
697 705
698 setLayoutDirty(true); 706 setLayoutDirty(true);
699} 707}
700 708
701CardViewItem *CardView::currentItem() 709CardViewItem *CardView::currentItem()
702{ 710{
703 if ( ! d->mCurrentItem && d->mItemList.count() ) 711 if ( ! d->mCurrentItem && d->mItemList.count() )
704 d->mCurrentItem = d->mItemList.first(); 712 d->mCurrentItem = d->mItemList.first();
705 return d->mCurrentItem; 713 return d->mCurrentItem;
706} 714}
707 715
708void CardView::setCurrentItem( CardViewItem *item ) 716void CardView::setCurrentItem( CardViewItem *item )
709{ 717{
710 if ( !item ) 718 if ( !item )
711 return; 719 return;
712 else if ( item->cardView() != this ) 720 else if ( item->cardView() != this )
713 { 721 {
714 kdDebug(5720)<<"CardView::setCurrentItem: Item ("<<item<<") not owned! Backing out.."<<endl; 722 kdDebug(5720)<<"CardView::setCurrentItem: Item ("<<item<<") not owned! Backing out.."<<endl;
715 return; 723 return;
716 } 724 }
717 else if ( item == currentItem() ) 725 else if ( item == currentItem() )
718 { 726 {
719 return; 727 return;
720 } 728 }
721 729
722 if ( d->mSelectionMode == Single ) 730 if ( d->mSelectionMode == Single )
723 { 731 {
724 setSelected( item, true ); 732 setSelected( item, true );
725 } 733 }
726 else 734 else
727 { 735 {
728 CardViewItem *it = d->mCurrentItem; 736 CardViewItem *it = d->mCurrentItem;
729 d->mCurrentItem = item; 737 d->mCurrentItem = item;
730 if ( it ) 738 if ( it )
731 it->repaintCard(); 739 it->repaintCard();
732 item->repaintCard(); 740 item->repaintCard();
733 } 741 }
734 if ( ! d->mOnSeparator ) 742 if ( ! d->mOnSeparator )
735 ensureItemVisible( item ); 743 ensureItemVisible( item );
736 emit currentChanged( item ); 744 emit currentChanged( item );
737} 745}
738 746
739CardViewItem *CardView::itemAt(const QPoint &viewPos) 747CardViewItem *CardView::itemAt(const QPoint &viewPos)
740{ 748{
741 CardViewItem *item = 0; 749 CardViewItem *item = 0;
742 QPtrListIterator<CardViewItem> iter(d->mItemList); 750 Q3PtrListIterator<CardViewItem> iter(d->mItemList);
743 bool found = false; 751 bool found = false;
744 for (iter.toFirst(); iter.current() && !found; ++iter) 752 for (iter.toFirst(); iter.current() && !found; ++iter)
745 { 753 {
746 item = *iter; 754 item = *iter;
747 //if (item->d->mRect.contains(viewPos)) 755 //if (item->d->mRect.contains(viewPos))
748 if (QRect(item->d->x, item->d->y, d->mItemWidth, item->height()).contains(viewPos)) 756 if (QRect(item->d->x, item->d->y, d->mItemWidth, item->height()).contains(viewPos))
749 found = true; 757 found = true;
750 } 758 }
751 759
752 if (found) 760 if (found)
753 return item; 761 return item;
754 762
755 return 0; 763 return 0;
756} 764}
757 765
758QRect CardView::itemRect(const CardViewItem *item) 766QRect CardView::itemRect(const CardViewItem *item)
759{ 767{
760 //return item->d->mRect; 768 //return item->d->mRect;
761 return QRect(item->d->x, item->d->y, d->mItemWidth, item->height()); 769 return QRect(item->d->x, item->d->y, d->mItemWidth, item->height());
762} 770}
763 771
764void CardView::ensureItemVisible(const CardViewItem *item) 772void CardView::ensureItemVisible(const CardViewItem *item)
765{ 773{
766 ensureVisible(item->d->x , item->d->y, d->mItemSpacing, 0); 774 ensureVisible(item->d->x , item->d->y, d->mItemSpacing, 0);
767 ensureVisible(item->d->x + d->mItemWidth, item->d->y, d->mItemSpacing, 0); 775 ensureVisible(item->d->x + d->mItemWidth, item->d->y, d->mItemSpacing, 0);
768} 776}
769 777
770void CardView::repaintItem(const CardViewItem *item) 778void CardView::repaintItem(const CardViewItem *item)
771{ 779{
772 //repaintContents(item->d->mRect); 780 //repaintContents(item->d->mRect);
773 repaintContents( QRect(item->d->x, item->d->y, d->mItemWidth, item->height()) ); 781 repaintContents( QRect(item->d->x, item->d->y, d->mItemWidth, item->height()) );
774} 782}
775 783
776void CardView::setSelectionMode(CardView::SelectionMode mode) 784void CardView::setSelectionMode(CardView::SelectionMode mode)
777{ 785{
778 selectAll(false); 786 selectAll(false);
779 787
780 d->mSelectionMode = mode; 788 d->mSelectionMode = mode;
781} 789}
782 790
783CardView::SelectionMode CardView::selectionMode() const 791CardView::SelectionMode CardView::selectionMode() const
784{ 792{
785 return d->mSelectionMode; 793 return d->mSelectionMode;
786} 794}
787 795
788void CardView::selectAll(bool state) 796void CardView::selectAll(bool state)
789{ 797{
790 QPtrListIterator<CardViewItem> iter(d->mItemList); 798 Q3PtrListIterator<CardViewItem> iter(d->mItemList);
791 if (!state) 799 if (!state)
792 { 800 {
793 for (iter.toFirst(); iter.current(); ++iter) 801 for (iter.toFirst(); iter.current(); ++iter)
794 { 802 {
795 if ((*iter)->isSelected()) 803 if ((*iter)->isSelected())
796 { 804 {
797 (*iter)->setSelected(false); 805 (*iter)->setSelected(false);
798 (*iter)->repaintCard(); 806 (*iter)->repaintCard();
799 } 807 }
800 } 808 }
801 //emit selectionChanged(); // WARNING FIXME 809 //emit selectionChanged(); // WARNING FIXME
802 emit selectionChanged(0); 810 emit selectionChanged(0);
803 } 811 }
804 else if (d->mSelectionMode != CardView::Single) 812 else if (d->mSelectionMode != CardView::Single)
805 { 813 {
806 for (iter.toFirst(); iter.current(); ++iter) 814 for (iter.toFirst(); iter.current(); ++iter)
807 { 815 {
808 (*iter)->setSelected(true); 816 (*iter)->setSelected(true);
809 } 817 }
810 818
811 if (d->mItemList.count() > 0) 819 if (d->mItemList.count() > 0)
812 { 820 {
813 // emit, since there must have been at least one selected 821 // emit, since there must have been at least one selected
814 emit selectionChanged(); 822 emit selectionChanged();
815 //repaint();//??? 823 //repaint();//???
816 viewport()->update(); 824 viewport()->update();
817 } 825 }
818 } 826 }
819} 827}
820 828
821void CardView::setSelected(CardViewItem *item, bool selected) 829void CardView::setSelected(CardViewItem *item, bool selected)
822{ 830{
823 if ((item == 0) || (item->isSelected() == selected)) 831 if ((item == 0) || (item->isSelected() == selected))
824 return; 832 return;
825 833
826 if ( selected && d->mCurrentItem != item ) 834 if ( selected && d->mCurrentItem != item )
827 { 835 {
828 CardViewItem *it = d->mCurrentItem; 836 CardViewItem *it = d->mCurrentItem;
829 d->mCurrentItem = item; 837 d->mCurrentItem = item;
830 if ( it ) 838 if ( it )
831 it->repaintCard(); 839 it->repaintCard();
832 } 840 }
833 841
834 if (d->mSelectionMode == CardView::Single) 842 if (d->mSelectionMode == CardView::Single)
835 { 843 {
836 bool b = signalsBlocked(); 844 bool b = signalsBlocked();
837 blockSignals(true); 845 blockSignals(true);
838 selectAll(false); 846 selectAll(false);
839 blockSignals(b); 847 blockSignals(b);
840 848
841 if (selected) 849 if (selected)
842 { 850 {
843 item->setSelected(selected); 851 item->setSelected(selected);
844 item->repaintCard(); 852 item->repaintCard();
845 emit selectionChanged(); 853 emit selectionChanged();
846 emit selectionChanged(item); 854 emit selectionChanged(item);
847 } 855 }
848 else 856 else
849 { 857 {
850 emit selectionChanged(); 858 emit selectionChanged();
851 emit selectionChanged(0); 859 emit selectionChanged(0);
852 } 860 }
853 } 861 }
854 else if (d->mSelectionMode == CardView::Multi) 862 else if (d->mSelectionMode == CardView::Multi)
855 { 863 {
856 item->setSelected(selected); 864 item->setSelected(selected);
857 item->repaintCard(); 865 item->repaintCard();
858 emit selectionChanged(); 866 emit selectionChanged();
859 } 867 }
860 else if (d->mSelectionMode == CardView::Extended) 868 else if (d->mSelectionMode == CardView::Extended)
861 { 869 {
862 bool b = signalsBlocked(); 870 bool b = signalsBlocked();
863 blockSignals(true); 871 blockSignals(true);
864 selectAll(false); 872 selectAll(false);
865 blockSignals(b); 873 blockSignals(b);
866 874
867 item->setSelected(selected); 875 item->setSelected(selected);
868 item->repaintCard(); 876 item->repaintCard();
869 emit selectionChanged(); 877 emit selectionChanged();
870 } 878 }
871} 879}
872 880
873bool CardView::isSelected(CardViewItem *item) const 881bool CardView::isSelected(CardViewItem *item) const
874{ 882{
875 return (item && item->isSelected()); 883 return (item && item->isSelected());
876} 884}
877 885
878CardViewItem *CardView::selectedItem() const 886CardViewItem *CardView::selectedItem() const
879{ 887{
880 // find the first selected item 888 // find the first selected item
881 QPtrListIterator<CardViewItem> iter(d->mItemList); 889 Q3PtrListIterator<CardViewItem> iter(d->mItemList);
882 for (iter.toFirst(); iter.current(); ++iter) 890 for (iter.toFirst(); iter.current(); ++iter)
883 { 891 {
884 if ((*iter)->isSelected()) 892 if ((*iter)->isSelected())
885 return *iter; 893 return *iter;
886 } 894 }
887 895
888 return 0; 896 return 0;
889} 897}
890 898
891CardViewItem *CardView::firstItem() const 899CardViewItem *CardView::firstItem() const
892{ 900{
893 return d->mItemList.first(); 901 return d->mItemList.first();
894} 902}
895 903
896int CardView::childCount() const 904int CardView::childCount() const
897{ 905{
898 return d->mItemList.count(); 906 return d->mItemList.count();
899} 907}
900/*US 908/*US
901CardViewItem *CardView::findItem(const QString &text, const QString &label, 909CardViewItem *CardView::findItem(const QString &text, const QString &label,
902 Qt::StringComparisonMode compare) 910 Qt::StringComparisonMode compare)
903{ 911{
904 // IF the text is empty, we will return null, since empty text will 912 // IF the text is empty, we will return null, since empty text will
905 // match anything! 913 // match anything!
906 if (text.isEmpty()) 914 if (text.isEmpty())
907 return 0; 915 return 0;
908 916
909 QPtrListIterator<CardViewItem> iter(d->mItemList); 917 QPtrListIterator<CardViewItem> iter(d->mItemList);
910 if (compare & Qt::BeginsWith) 918 if (compare & Qt::BeginsWith)
911 { 919 {
912 QString value; 920 QString value;
913 for (iter.toFirst(); iter.current(); ++iter) 921 for (iter.toFirst(); iter.current(); ++iter)
914 { 922 {
915 value = (*iter)->fieldValue(label).upper(); 923 value = (*iter)->fieldValue(label).upper();
916 if (value.startsWith(text.upper())) 924 if (value.startsWith(text.upper()))
917 return *iter; 925 return *iter;
918 } 926 }
919 } 927 }
920 else 928 else
921 { 929 {
922 kdDebug(5720) << "CardView::findItem: search method not implemented" << endl; 930 kdDebug(5720) << "CardView::findItem: search method not implemented" << endl;
923 } 931 }
924 932
925 return 0; 933 return 0;
926} 934}
927*/ 935*/
928 936
929uint CardView::columnWidth() 937uint CardView::columnWidth()
930{ 938{
931 return d->mDrawSeparators ? 939 return d->mDrawSeparators ?
932 d->mItemWidth + ( 2 * d->mItemSpacing ) + d->mSepWidth : 940 d->mItemWidth + ( 2 * d->mItemSpacing ) + d->mSepWidth :
933 d->mItemWidth + d->mItemSpacing; 941 d->mItemWidth + d->mItemSpacing;
934} 942}
935 943
936void CardView::drawContents(QPainter *p, int clipx, int clipy, 944void CardView::drawContents(QPainter *p, int clipx, int clipy,
937 int clipw, int cliph) 945 int clipw, int cliph)
938{ 946{
939 //QScrollView::drawContents(p, clipx, clipy, clipw, cliph); 947 //QScrollView::drawContents(p, clipx, clipy, clipw, cliph);
940 if (d->mLayoutDirty) 948 if (d->mLayoutDirty)
941 calcLayout(); 949 calcLayout();
942 950
943 //kdDebug() << "CardView::drawContents: " << clipx << ", " << clipy 951 //kdDebug() << "CardView::drawContents: " << clipx << ", " << clipy
944 // << ", " << clipw << ", " << cliph << endl; 952 // << ", " << clipw << ", " << cliph << endl;
945 953
946 QColorGroup cg = viewport()->palette().active(); // allow setting costum colors in the viewport pale 954 QColorGroup cg = viewport()->palette().active(); // allow setting costum colors in the viewport pale
947 int cX, cY; 955 int cX, cY;
948 contentsToViewport ( clipx, clipy, cX, cY ); 956 contentsToViewport ( clipx, clipy, cX, cY );
949 QRect clipRect(clipx, clipy, clipw, cliph); 957 QRect clipRect(clipx, clipy, clipw, cliph);
950 QRect cardRect; 958 QRect cardRect;
951 QRect sepRect; 959 QRect sepRect;
952 CardViewItem *item; 960 CardViewItem *item;
953 CardViewSeparator *sep; 961 CardViewSeparator *sep;
954 // make sure the viewport is a pure background 962 // make sure the viewport is a pure background
955 viewport()->erase( QRect ( cX, cY , clipw, cliph ) ); 963 viewport()->erase( QRect ( cX, cY , clipw, cliph ) );
956 964
957 // Now tell the cards to draw, if they are in the clip region 965 // Now tell the cards to draw, if they are in the clip region
958 QPtrListIterator<CardViewItem> iter(d->mItemList); 966 Q3PtrListIterator<CardViewItem> iter(d->mItemList);
959 for (iter.toFirst(); iter.current(); ++iter) 967 for (iter.toFirst(); iter.current(); ++iter)
960 { 968 {
961 item = *iter; 969 item = *iter;
962 cardRect.setRect( item->d->x, item->d->y, d->mItemWidth, item->height() ); 970 cardRect.setRect( item->d->x, item->d->y, d->mItemWidth, item->height() );
963 971
964 if (clipRect.intersects(cardRect) || clipRect.contains(cardRect)) 972 if (clipRect.intersects(cardRect) || clipRect.contains(cardRect))
965 { 973 {
966 //kdDebug() << "\trepainting card at: " << cardRect.x() << ", " 974 //kdDebug() << "\trepainting card at: " << cardRect.x() << ", "
967 // << cardRect.y() << endl; 975 // << cardRect.y() << endl;
968 976
969 // Tell the card to paint 977 // Tell the card to paint
970 p->save(); 978 p->save();
971 p->translate(cardRect.x(), cardRect.y()); 979 p->translate(cardRect.x(), cardRect.y());
972 item->paintCard(p, cg); 980 item->paintCard(p, cg);
973 p->restore(); 981 p->restore();
974 } 982 }
975 } 983 }
976 984
977 // Followed by the separators if they are in the clip region 985 // Followed by the separators if they are in the clip region
978 QPtrListIterator<CardViewSeparator> sepIter(d->mSeparatorList); 986 Q3PtrListIterator<CardViewSeparator> sepIter(d->mSeparatorList);
979 for (sepIter.toFirst(); sepIter.current(); ++sepIter) 987 for (sepIter.toFirst(); sepIter.current(); ++sepIter)
980 { 988 {
981 sep = *sepIter; 989 sep = *sepIter;
982 sepRect = sep->mRect; 990 sepRect = sep->mRect;
983 991
984 if (clipRect.intersects(sepRect) || clipRect.contains(sepRect)) 992 if (clipRect.intersects(sepRect) || clipRect.contains(sepRect))
985 { 993 {
986 p->save(); 994 p->save();
987 p->translate(sepRect.x(), sepRect.y()); 995 p->translate(sepRect.x(), sepRect.y());
988 sep->paintSeparator(p, cg); 996 sep->paintSeparator(p, cg);
989 p->restore(); 997 p->restore();
990 } 998 }
991 } 999 }
992} 1000}
993 1001
994void CardView::resizeEvent(QResizeEvent *e) 1002void CardView::resizeEvent(QResizeEvent *e)
995{ 1003{
996 QScrollView::resizeEvent(e); 1004 Q3ScrollView::resizeEvent(e);
997 1005
998 setLayoutDirty(true); 1006 setLayoutDirty(true);
999} 1007}
1000 1008
1001void CardView::calcLayout() 1009void CardView::calcLayout()
1002{ 1010{
1003 //kdDebug() << "CardView::calcLayout:" << endl; 1011 //kdDebug() << "CardView::calcLayout:" << endl;
1004 1012
1005 // Start in the upper left corner and layout all the 1013 // Start in the upper left corner and layout all the
1006 // cars using their height and width 1014 // cars using their height and width
1007 int maxWidth = 0; 1015 int maxWidth = 0;
1008 int maxHeight = 0; 1016 int maxHeight = 0;
1009 int xPos = 0; 1017 int xPos = 0;
1010 int yPos = 0; 1018 int yPos = 0;
1011 int cardSpacing = d->mItemSpacing; 1019 int cardSpacing = d->mItemSpacing;
1012 1020
1013 // delete the old separators 1021 // delete the old separators
1014 d->mSeparatorList.clear(); 1022 d->mSeparatorList.clear();
1015 1023
1016 QPtrListIterator<CardViewItem> iter(d->mItemList); 1024 Q3PtrListIterator<CardViewItem> iter(d->mItemList);
1017 CardViewItem *item = 0; 1025 CardViewItem *item = 0;
1018 CardViewSeparator *sep = 0; 1026 CardViewSeparator *sep = 0;
1019 xPos += cardSpacing; 1027 xPos += cardSpacing;
1020 1028
1021 for (iter.toFirst(); iter.current(); ++iter) 1029 for (iter.toFirst(); iter.current(); ++iter)
1022 { 1030 {
1023 item = *iter; 1031 item = *iter;
1024 1032
1025 yPos += cardSpacing; 1033 yPos += cardSpacing;
1026 1034
1027 if (yPos + item->height() + cardSpacing >= height() - horizontalScrollBar()->height()) 1035 if (yPos + item->height() + cardSpacing >= height() - horizontalScrollBar()->height())
1028 { 1036 {
1029 maxHeight = QMAX(maxHeight, yPos); 1037 maxHeight = QMAX(maxHeight, yPos);
1030 1038
1031 // Drawing in this column would be greater than the height 1039 // Drawing in this column would be greater than the height
1032 // of the scroll view, so move to next column 1040 // of the scroll view, so move to next column
1033 yPos = cardSpacing; 1041 yPos = cardSpacing;
1034 xPos += cardSpacing + maxWidth; 1042 xPos += cardSpacing + maxWidth;
1035 if (d->mDrawSeparators) 1043 if (d->mDrawSeparators)
1036 { 1044 {
1037 // Create a separator since the user asked 1045 // Create a separator since the user asked
1038 sep = new CardViewSeparator(this); 1046 sep = new CardViewSeparator(this);
1039 sep->mRect.moveTopLeft(QPoint(xPos, yPos+d->mItemMargin)); 1047 sep->mRect.moveTopLeft(QPoint(xPos, yPos+d->mItemMargin));
1040 xPos += d->mSepWidth + cardSpacing; 1048 xPos += d->mSepWidth + cardSpacing;
1041 d->mSeparatorList.append(sep); 1049 d->mSeparatorList.append(sep);
1042 } 1050 }
1043 1051
1044 maxWidth = 0; 1052 maxWidth = 0;
1045 } 1053 }
1046 1054
1047 item->d->x = xPos; 1055 item->d->x = xPos;
1048 item->d->y = yPos; 1056 item->d->y = yPos;
1049 1057
1050 yPos += item->height(); 1058 yPos += item->height();
1051 maxWidth = QMAX(maxWidth, d->mItemWidth); 1059 maxWidth = QMAX(maxWidth, d->mItemWidth);
1052 } 1060 }
1053 1061
1054 xPos += maxWidth; 1062 xPos += maxWidth;
1055 resizeContents( xPos + cardSpacing, maxHeight ); 1063 resizeContents( xPos + cardSpacing, maxHeight );
1056 1064
1057 // Update the height of all the separators now that we know the 1065 // Update the height of all the separators now that we know the
1058 // max height of a column 1066 // max height of a column
1059 QPtrListIterator<CardViewSeparator> sepIter(d->mSeparatorList); 1067 Q3PtrListIterator<CardViewSeparator> sepIter(d->mSeparatorList);
1060 for (sepIter.toFirst(); sepIter.current(); ++sepIter) 1068 for (sepIter.toFirst(); sepIter.current(); ++sepIter)
1061 { 1069 {
1062 (*sepIter)->mRect.setHeight(maxHeight - 2*cardSpacing - 2*d->mItemMargin); 1070 (*sepIter)->mRect.setHeight(maxHeight - 2*cardSpacing - 2*d->mItemMargin);
1063 } 1071 }
1064 1072
1065 d->mLayoutDirty = false; 1073 d->mLayoutDirty = false;
1066} 1074}
1067 1075
1068CardViewItem *CardView::itemAfter(CardViewItem *item) 1076CardViewItem *CardView::itemAfter(CardViewItem *item)
1069{ 1077{
1070 /*int pos = */d->mItemList.findRef(item); 1078 /*int pos = */d->mItemList.findRef(item);
1071 return d->mItemList.next();//at(pos+1); 1079 return d->mItemList.next();//at(pos+1);
1072} 1080}
1073 1081
1074uint CardView::itemMargin() 1082uint CardView::itemMargin()
1075{ 1083{
1076 return d->mItemMargin; 1084 return d->mItemMargin;
1077} 1085}
1078 1086
1079void CardView::setItemMargin( uint margin ) 1087void CardView::setItemMargin( uint margin )
1080{ 1088{
1081 if ( margin == d->mItemMargin ) 1089 if ( margin == d->mItemMargin )
1082 return; 1090 return;
1083 1091
1084 d->mItemMargin = margin; 1092 d->mItemMargin = margin;
1085 setLayoutDirty( true ); 1093 setLayoutDirty( true );
1086} 1094}
1087 1095
1088uint CardView::itemSpacing() 1096uint CardView::itemSpacing()
1089{ 1097{
1090 return d->mItemSpacing; 1098 return d->mItemSpacing;
1091} 1099}
1092 1100
1093void CardView::setItemSpacing( uint spacing ) 1101void CardView::setItemSpacing( uint spacing )
1094{ 1102{
1095 if ( spacing == d->mItemSpacing ) 1103 if ( spacing == d->mItemSpacing )
1096 return; 1104 return;
1097 1105
1098 d->mItemSpacing = spacing; 1106 d->mItemSpacing = spacing;
1099 setLayoutDirty( true ); 1107 setLayoutDirty( true );
1100} 1108}
1101 1109
1102void CardView::contentsMousePressEvent(QMouseEvent *e) 1110void CardView::contentsMousePressEvent(QMouseEvent *e)
1103{ 1111{
1104 QScrollView::contentsMousePressEvent(e); 1112 Q3ScrollView::contentsMousePressEvent(e);
1105 1113
1106 QPoint pos = e->pos(); 1114 QPoint pos = e->pos();
1107 d->mLastClickPos = pos; 1115 d->mLastClickPos = pos;
1108 1116
1109 CardViewItem *item = itemAt(pos); 1117 CardViewItem *item = itemAt(pos);
1110 1118
1111 if (item == 0) 1119 if (item == 0)
1112 { 1120 {
1113 d->mLastClickOnItem = false; 1121 d->mLastClickOnItem = false;
1114 if ( d->mOnSeparator) 1122 if ( d->mOnSeparator)
1115 { 1123 {
1116 d->mResizeAnchor = e->x()+contentsX(); 1124 d->mResizeAnchor = e->x()+contentsX();
1117 d->colspace = (2*d->mItemSpacing) /*+ (2*d->mItemMargin)*/; 1125 d->colspace = (2*d->mItemSpacing) /*+ (2*d->mItemMargin)*/;
1118 int ccw = d->mItemWidth + d->colspace + d->mSepWidth; 1126 int ccw = d->mItemWidth + d->colspace + d->mSepWidth;
1119 d->first = (contentsX()+d->mSepWidth)/ccw; 1127 d->first = (contentsX()+d->mSepWidth)/ccw;
1120 d->pressed = (d->mResizeAnchor+d->mSepWidth)/ccw; 1128 d->pressed = (d->mResizeAnchor+d->mSepWidth)/ccw;
1121 d->span = d->pressed - d->first; 1129 d->span = d->pressed - d->first;
1122 d->firstX = d->first * ccw; 1130 d->firstX = d->first * ccw;
1123 if ( d->firstX ) d->firstX -= d->mSepWidth; // (no sep in col 0) 1131 if ( d->firstX ) d->firstX -= d->mSepWidth; // (no sep in col 0)
1124 } 1132 }
1125 else 1133 else
1126 { 1134 {
1127 selectAll(false); 1135 selectAll(false);
1128 } 1136 }
1129 return; 1137 return;
1130 } 1138 }
1131 1139
1132 d->mLastClickOnItem = true; 1140 d->mLastClickOnItem = true;
1133 1141
1134 CardViewItem *other = d->mCurrentItem; 1142 CardViewItem *other = d->mCurrentItem;
1135 setCurrentItem( item ); 1143 setCurrentItem( item );
1136 1144
1137 // Always emit the selection 1145 // Always emit the selection
1138 emit clicked(item); 1146 emit clicked(item);
1139 1147
1140 // Check the selection type and update accordingly 1148 // Check the selection type and update accordingly
1141 if (d->mSelectionMode == CardView::Single) 1149 if (d->mSelectionMode == CardView::Single)
1142 { 1150 {
1143 // make sure it isn't already selected 1151 // make sure it isn't already selected
1144 if (item->isSelected()) 1152 if (item->isSelected())
1145 return; 1153 return;
1146 1154
1147 bool b = signalsBlocked(); 1155 bool b = signalsBlocked();
1148 blockSignals(true); 1156 blockSignals(true);
1149 selectAll(false); 1157 selectAll(false);
1150 blockSignals(b); 1158 blockSignals(b);
1151 1159
1152 item->setSelected(true); 1160 item->setSelected(true);
1153 item->repaintCard(); 1161 item->repaintCard();
1154 emit selectionChanged(item); 1162 emit selectionChanged(item);
1155 } 1163 }
1156 1164
1157 else if (d->mSelectionMode == CardView::Multi) 1165 else if (d->mSelectionMode == CardView::Multi)
1158 { 1166 {
1159 // toggle the selection 1167 // toggle the selection
1160 item->setSelected(!item->isSelected()); 1168 item->setSelected(!item->isSelected());
1161 item->repaintCard(); 1169 item->repaintCard();
1162 emit selectionChanged(); 1170 emit selectionChanged();
1163 } 1171 }
1164 1172
1165 else if (d->mSelectionMode == CardView::Extended) 1173 else if (d->mSelectionMode == CardView::Extended)
1166 { 1174 {
1167 if ((e->button() & Qt::LeftButton) && 1175 if ((e->button() & Qt::LeftButton) &&
1168 (e->state() & Qt::ShiftButton)) 1176 (e->state() & Qt::ShiftButton))
1169 { 1177 {
1170 if ( item == other ) return; 1178 if ( item == other ) return;
1171 1179
1172 bool s = ! item->isSelected(); 1180 bool s = ! item->isSelected();
1173 1181
1174 if ( s && ! (e->state() & ControlButton) ) 1182 if ( s && ! (e->state() & Qt::ControlButton) )
1175 { 1183 {
1176 bool b = signalsBlocked(); 1184 bool b = signalsBlocked();
1177 blockSignals(true); 1185 blockSignals(true);
1178 selectAll(false); 1186 selectAll(false);
1179 blockSignals(b); 1187 blockSignals(b);
1180 } 1188 }
1181 1189
1182 int from, to, a, b; 1190 int from, to, a, b;
1183 a = d->mItemList.findRef( item ); 1191 a = d->mItemList.findRef( item );
1184 b = d->mItemList.findRef( other ); 1192 b = d->mItemList.findRef( other );
1185 from = a < b ? a : b; 1193 from = a < b ? a : b;
1186 to = a > b ? a : b; 1194 to = a > b ? a : b;
1187 //kdDebug()<<"selecting items "<<from<<" - "<<to<<" ( "<<s<<" )"<<endl; 1195 //kdDebug()<<"selecting items "<<from<<" - "<<to<<" ( "<<s<<" )"<<endl;
1188 CardViewItem *aItem; 1196 CardViewItem *aItem;
1189 for ( ; from <= to; from++ ) 1197 for ( ; from <= to; from++ )
1190 { 1198 {
1191 aItem = d->mItemList.at( from ); 1199 aItem = d->mItemList.at( from );
1192 aItem->setSelected( s ); 1200 aItem->setSelected( s );
1193 repaintItem( aItem ); 1201 repaintItem( aItem );
1194 } 1202 }
1195 emit selectionChanged(); 1203 emit selectionChanged();
1196 } 1204 }
1197 else if ((e->button() & Qt::LeftButton) && 1205 else if ((e->button() & Qt::LeftButton) &&
1198 (e->state() & Qt::ControlButton)) 1206 (e->state() & Qt::ControlButton))
1199 { 1207 {
1200 item->setSelected(!item->isSelected()); 1208 item->setSelected(!item->isSelected());
1201 item->repaintCard(); 1209 item->repaintCard();
1202 emit selectionChanged(); 1210 emit selectionChanged();
1203 } 1211 }
1204 1212
1205 else if (e->button() & Qt::LeftButton) 1213 else if (e->button() & Qt::LeftButton)
1206 { 1214 {
1207 bool b = signalsBlocked(); 1215 bool b = signalsBlocked();
1208 blockSignals(true); 1216 blockSignals(true);
1209 selectAll(false); 1217 selectAll(false);
1210 blockSignals(b); 1218 blockSignals(b);
1211 1219
1212 item->setSelected(true); 1220 item->setSelected(true);
1213 item->repaintCard(); 1221 item->repaintCard();
1214 emit selectionChanged(); 1222 emit selectionChanged();
1215 } 1223 }
1216 } 1224 }
1217 1225
1218} 1226}
1219 1227
1220void CardView::contentsMouseReleaseEvent(QMouseEvent *e) 1228void CardView::contentsMouseReleaseEvent(QMouseEvent *e)
1221{ 1229{
1222 QScrollView::contentsMouseReleaseEvent(e); 1230 Q3ScrollView::contentsMouseReleaseEvent(e);
1223 1231
1224 if ( d->mResizeAnchor ) 1232 if ( d->mResizeAnchor )
1225 { 1233 {
1226 // finish the resizing: 1234 // finish the resizing:
1227 unsetCursor(); 1235 unsetCursor();
1228 // hide rubber bands 1236 // hide rubber bands
1229 int newiw = d->mItemWidth - ((d->mResizeAnchor - d->mRubberBandAnchor)/d->span); 1237 int newiw = d->mItemWidth - ((d->mResizeAnchor - d->mRubberBandAnchor)/d->span);
1230 drawRubberBands( 0 ); 1238 drawRubberBands( 0 );
1231 // we should move to reflect the new position if we are scrolled. 1239 // we should move to reflect the new position if we are scrolled.
1232 if ( contentsX() ) 1240 if ( contentsX() )
1233 { 1241 {
1234 int newX = QMAX( 0, ( d->pressed * ( newiw + d->colspace + d->mSepWidth ) ) - e->x() ); 1242 int newX = QMAX( 0, ( d->pressed * ( newiw + d->colspace + d->mSepWidth ) ) - e->x() );
1235 setContentsPos( newX, contentsY() ); 1243 setContentsPos( newX, contentsY() );
1236 } 1244 }
1237 // set new item width 1245 // set new item width
1238 setItemWidth( newiw ); 1246 setItemWidth( newiw );
1239 // reset anchors 1247 // reset anchors
1240 d->mResizeAnchor = 0; 1248 d->mResizeAnchor = 0;
1241 d->mRubberBandAnchor = 0; 1249 d->mRubberBandAnchor = 0;
1242 return; 1250 return;
1243 } 1251 }
1244 1252
1245 // If there are accel keys, we will not emit signals 1253 // If there are accel keys, we will not emit signals
1246 if ((e->state() & Qt::ShiftButton) || (e->state() & Qt::ControlButton)) 1254 if ((e->state() & Qt::ShiftButton) || (e->state() & Qt::ControlButton))
1247 return; 1255 return;
1248 1256
1249 // Get the item at this position 1257 // Get the item at this position
1250 CardViewItem *item = itemAt(e->pos()); 1258 CardViewItem *item = itemAt(e->pos());
1251 1259
1252 if (item && KABPrefs::instance()->mHonorSingleClick) 1260 if (item && KABPrefs::instance()->mHonorSingleClick)
1253 { 1261 {
1254 emit executed(item); 1262 emit executed(item);
1255 } 1263 }
1256} 1264}
1257 1265
1258void CardView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1266void CardView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1259{ 1267{
1260 QScrollView::contentsMouseDoubleClickEvent(e); 1268 Q3ScrollView::contentsMouseDoubleClickEvent(e);
1261 1269
1262 CardViewItem *item = itemAt(e->pos()); 1270 CardViewItem *item = itemAt(e->pos());
1263 1271
1264 if (item) 1272 if (item)
1265 { 1273 {
1266 d->mCurrentItem = item; 1274 d->mCurrentItem = item;
1267 } 1275 }
1268 1276
1269 if (item && !KABPrefs::instance()->mHonorSingleClick) 1277 if (item && !KABPrefs::instance()->mHonorSingleClick)
1270 { 1278 {
1271 emit executed(item); 1279 emit executed(item);
1272 } else 1280 } else
1273 emit doubleClicked(item); 1281 emit doubleClicked(item);
1274} 1282}
1275 1283
1276void CardView::contentsMouseMoveEvent( QMouseEvent *e ) 1284void CardView::contentsMouseMoveEvent( QMouseEvent *e )
1277{ 1285{
1278 // resizing 1286 // resizing
1279 if ( d->mResizeAnchor ) 1287 if ( d->mResizeAnchor )
1280 { 1288 {
1281 int x = e->x(); 1289 int x = e->x();
1282 if ( x != d->mRubberBandAnchor ) 1290 if ( x != d->mRubberBandAnchor )
1283 drawRubberBands( x ); 1291 drawRubberBands( x );
1284 return; 1292 return;
1285 } 1293 }
1286 1294
1287 if (d->mLastClickOnItem && (e->state() & Qt::LeftButton) && 1295 if (d->mLastClickOnItem && (e->state() & Qt::LeftButton) &&
1288 ((e->pos() - d->mLastClickPos).manhattanLength() > 4)) { 1296 ((e->pos() - d->mLastClickPos).manhattanLength() > 4)) {
1289 1297
1290 startDrag(); 1298 startDrag();
1291 return; 1299 return;
1292 } 1300 }
1293 1301
1294 d->mTimer->start( 500 ); 1302 d->mTimer->start( 500 );
1295 1303
1296 // see if we are over a separator 1304 // see if we are over a separator
1297 // only if we actually have them painted? 1305 // only if we actually have them painted?
1298 if ( d->mDrawSeparators ) 1306 if ( d->mDrawSeparators )
1299 { 1307 {
1300 int colcontentw = d->mItemWidth + (2*d->mItemSpacing); 1308 int colcontentw = d->mItemWidth + (2*d->mItemSpacing);
1301 int colw = colcontentw + d->mSepWidth; 1309 int colw = colcontentw + d->mSepWidth;
1302 int m = e->x()%colw; 1310 int m = e->x()%colw;
1303 if ( m >= colcontentw && m > 0 ) 1311 if ( m >= colcontentw && m > 0 )
1304 { 1312 {
1305 setCursor( SplitVCursor ); // Why does this fail sometimes? 1313 setCursor( Qt::SplitVCursor ); // Why does this fail sometimes?
1306 d->mOnSeparator = true; 1314 d->mOnSeparator = true;
1307 } 1315 }
1308 else 1316 else
1309 { 1317 {
1310 setCursor( ArrowCursor ); 1318 setCursor( Qt::ArrowCursor );
1311 d->mOnSeparator = false; 1319 d->mOnSeparator = false;
1312 } 1320 }
1313 } 1321 }
1314} 1322}
1315 1323
1316void CardView::enterEvent( QEvent * ) 1324void CardView::enterEvent( QEvent * )
1317{ 1325{
1318 d->mTimer->start( 500 ); 1326 d->mTimer->start( 500 );
1319} 1327}
1320 1328
1321void CardView::leaveEvent( QEvent * ) 1329void CardView::leaveEvent( QEvent * )
1322{ 1330{
1323 d->mTimer->stop(); 1331 d->mTimer->stop();
1324 if (d->mOnSeparator) 1332 if (d->mOnSeparator)
1325 { 1333 {
1326 d->mOnSeparator = false; 1334 d->mOnSeparator = false;
1327 setCursor( ArrowCursor ); 1335 setCursor( Qt::ArrowCursor );
1328 } 1336 }
1329} 1337}
1330 1338
1331void CardView::focusInEvent( QFocusEvent * ) 1339void CardView::focusInEvent( QFocusEvent * )
1332{ 1340{
1333 if (!d->mCurrentItem && d->mItemList.count() ) 1341 if (!d->mCurrentItem && d->mItemList.count() )
1334 { 1342 {
1335 setCurrentItem( d->mItemList.first() ); 1343 setCurrentItem( d->mItemList.first() );
1336 } 1344 }
1337 else if ( d->mCurrentItem ) 1345 else if ( d->mCurrentItem )
1338 { 1346 {
1339 d->mCurrentItem->repaintCard(); 1347 d->mCurrentItem->repaintCard();
1340 } 1348 }
1341} 1349}
1342 1350
1343void CardView::focusOutEvent( QFocusEvent * ) 1351void CardView::focusOutEvent( QFocusEvent * )
1344{ 1352{
1345 if (d->mCurrentItem) 1353 if (d->mCurrentItem)
1346 d->mCurrentItem->repaintCard(); 1354 d->mCurrentItem->repaintCard();
1347} 1355}
1348 1356
1349void CardView::keyPressEvent( QKeyEvent *e ) 1357void CardView::keyPressEvent( QKeyEvent *e )
1350{ 1358{
1351 if ( ! ( childCount() && d->mCurrentItem ) ) 1359 if ( ! ( childCount() && d->mCurrentItem ) )
1352 { 1360 {
1353 e->ignore(); 1361 e->ignore();
1354 return; 1362 return;
1355 } 1363 }
1356 if ( mFlagBlockKeyPressed ) 1364 if ( mFlagBlockKeyPressed )
1357 return; 1365 return;
1358 qApp->processEvents(); 1366 qApp->processEvents();
1359 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1367 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1360 e->accept(); 1368 e->accept();
1361 return; 1369 return;
1362 } 1370 }
1363 if (! e->isAutoRepeat() ) 1371 if (! e->isAutoRepeat() )
1364 mFlagKeyPressed = true; 1372 mFlagKeyPressed = true;
1365 uint pos = d->mItemList.findRef( d->mCurrentItem ); 1373 uint pos = d->mItemList.findRef( d->mCurrentItem );
1366 CardViewItem *aItem = 0L; // item that gets the focus 1374 CardViewItem *aItem = 0L; // item that gets the focus
1367 CardViewItem *old = d->mCurrentItem; 1375 CardViewItem *old = d->mCurrentItem;
1368 1376
1369 switch ( e->key() ) 1377 switch ( e->key() )
1370 { 1378 {
1371 case Key_Up: 1379 case Qt::Key_Up:
1372 if ( pos > 0 ) 1380 if ( pos > 0 )
1373 { 1381 {
1374 aItem = d->mItemList.at( pos - 1 ); 1382 aItem = d->mItemList.at( pos - 1 );
1375 setCurrentItem( aItem ); 1383 setCurrentItem( aItem );
1376 } 1384 }
1377 break; 1385 break;
1378 case Key_Down: 1386 case Qt::Key_Down:
1379 if ( pos < d->mItemList.count() - 1 ) 1387 if ( pos < d->mItemList.count() - 1 )
1380 { 1388 {
1381 aItem = d->mItemList.at( pos + 1 ); 1389 aItem = d->mItemList.at( pos + 1 );
1382 setCurrentItem( aItem ); 1390 setCurrentItem( aItem );
1383 } 1391 }
1384 break; 1392 break;
1385 case Key_Left: 1393 case Qt::Key_Left:
1386 { 1394 {
1387 // look for an item in the previous/next column, starting from 1395 // look for an item in the previous/next column, starting from
1388 // the vertical middle of the current item. 1396 // the vertical middle of the current item.
1389 // FIXME use nice calculatd measures!!! 1397 // FIXME use nice calculatd measures!!!
1390 QPoint aPoint( d->mCurrentItem->d->x, d->mCurrentItem->d->y ); 1398 QPoint aPoint( d->mCurrentItem->d->x, d->mCurrentItem->d->y );
1391 aPoint -= QPoint( 30,-(d->mCurrentItem->height()/2) ); 1399 aPoint -= QPoint( 30,-(d->mCurrentItem->height()/2) );
1392 aItem = itemAt( aPoint ); 1400 aItem = itemAt( aPoint );
1393 // maybe we hit some space below an item 1401 // maybe we hit some space below an item
1394 while ( !aItem && aPoint.y() > 27 ) 1402 while ( !aItem && aPoint.y() > 27 )
1395 { 1403 {
1396 aPoint -= QPoint( 0, 16 ); 1404 aPoint -= QPoint( 0, 16 );
1397 aItem = itemAt( aPoint ); 1405 aItem = itemAt( aPoint );
1398 } 1406 }
1399 if ( aItem ) 1407 if ( aItem )
1400 setCurrentItem( aItem ); 1408 setCurrentItem( aItem );
1401 } 1409 }
1402 break; 1410 break;
1403 case Key_Right: 1411 case Qt::Key_Right:
1404 { 1412 {
1405 // FIXME use nice calculated measures!!! 1413 // FIXME use nice calculated measures!!!
1406 QPoint aPoint( d->mCurrentItem->d->x + d->mItemWidth, d->mCurrentItem->d->y ); 1414 QPoint aPoint( d->mCurrentItem->d->x + d->mItemWidth, d->mCurrentItem->d->y );
1407 aPoint += QPoint( 30,(d->mCurrentItem->height()/2) ); 1415 aPoint += QPoint( 30,(d->mCurrentItem->height()/2) );
1408 aItem = itemAt( aPoint ); 1416 aItem = itemAt( aPoint );
1409 while ( !aItem && aPoint.y() > 27 ) 1417 while ( !aItem && aPoint.y() > 27 )
1410 { 1418 {
1411 aPoint -= QPoint( 0, 16 ); 1419 aPoint -= QPoint( 0, 16 );
1412 aItem = itemAt( aPoint ); 1420 aItem = itemAt( aPoint );
1413 } 1421 }
1414 if ( aItem ) 1422 if ( aItem )
1415 setCurrentItem( aItem ); 1423 setCurrentItem( aItem );
1416 } 1424 }
1417 break; 1425 break;
1418 case Key_Home: 1426 case Qt::Key_Home:
1419 aItem = d->mItemList.first(); 1427 aItem = d->mItemList.first();
1420 setCurrentItem( aItem ); 1428 setCurrentItem( aItem );
1421 break; 1429 break;
1422 case Key_End: 1430 case Qt::Key_End:
1423 aItem = d->mItemList.last(); 1431 aItem = d->mItemList.last();
1424 setCurrentItem( aItem ); 1432 setCurrentItem( aItem );
1425 break; 1433 break;
1426 case Key_Prior: // PageUp 1434 case Qt::Key_Prior: // PageUp
1427 { 1435 {
1428 // QListView: "Make the item above the top visible and current" 1436 // QListView: "Make the item above the top visible and current"
1429 // TODO if contentsY(), pick the top item of the leftmost visible column 1437 // TODO if contentsY(), pick the top item of the leftmost visible column
1430 if ( contentsX() <= 0 ) 1438 if ( contentsX() <= 0 )
1431 return; 1439 return;
1432 int cw = columnWidth(); 1440 int cw = columnWidth();
1433 int theCol = ( QMAX( 0, ( contentsX()/cw) * cw ) ) + d->mItemSpacing; 1441 int theCol = ( QMAX( 0, ( contentsX()/cw) * cw ) ) + d->mItemSpacing;
1434 aItem = itemAt( QPoint( theCol + 1, d->mItemSpacing + 1 ) ); 1442 aItem = itemAt( QPoint( theCol + 1, d->mItemSpacing + 1 ) );
1435 if ( aItem ) 1443 if ( aItem )
1436 setCurrentItem( aItem ); 1444 setCurrentItem( aItem );
1437 } 1445 }
1438 break; 1446 break;
1439 case Key_Next: // PageDown 1447 case Qt::Key_Next: // PageDown
1440 { 1448 {
1441 // QListView: "Make the item below the bottom visible and current" 1449 // QListView: "Make the item below the bottom visible and current"
1442 // find the first not fully visible column. 1450 // find the first not fully visible column.
1443 // TODO: consider if a partly visible (or even hidden) item at the 1451 // TODO: consider if a partly visible (or even hidden) item at the
1444 // bottom of the rightmost column exists 1452 // bottom of the rightmost column exists
1445 int cw = columnWidth(); 1453 int cw = columnWidth();
1446 int theCol = ( (( contentsX() + visibleWidth() )/cw) * cw ) + d->mItemSpacing + 1; 1454 int theCol = ( (( contentsX() + visibleWidth() )/cw) * cw ) + d->mItemSpacing + 1;
1447 // if separators are on, we may need to we may be one column further right if only the spacing/sep is hidden 1455 // if separators are on, we may need to we may be one column further right if only the spacing/sep is hidden
1448 if ( d->mDrawSeparators && cw - (( contentsX() + visibleWidth() )%cw) <= int( d->mItemSpacing + d->mSepWidth ) ) 1456 if ( d->mDrawSeparators && cw - (( contentsX() + visibleWidth() )%cw) <= int( d->mItemSpacing + d->mSepWidth ) )
1449 theCol += cw; 1457 theCol += cw;
1450 1458
1451 // make sure this is not too far right 1459 // make sure this is not too far right
1452 while ( theCol > contentsWidth() ) 1460 while ( theCol > contentsWidth() )
1453 theCol -= columnWidth(); 1461 theCol -= columnWidth();
1454 1462
1455 aItem = itemAt( QPoint( theCol, d->mItemSpacing + 1 ) ); 1463 aItem = itemAt( QPoint( theCol, d->mItemSpacing + 1 ) );
1456 1464
1457 if ( aItem ) 1465 if ( aItem )
1458 setCurrentItem( aItem ); 1466 setCurrentItem( aItem );
1459 } 1467 }
1460 break; 1468 break;
1461 case Key_Space: 1469 case Qt::Key_Space:
1462 setSelected( d->mCurrentItem, !d->mCurrentItem->isSelected() ); 1470 setSelected( d->mCurrentItem, !d->mCurrentItem->isSelected() );
1463 emit selectionChanged(); 1471 emit selectionChanged();
1464 break; 1472 break;
1465 case Key_Return: 1473 case Qt::Key_Return:
1466 case Key_Enter: 1474 case Qt::Key_Enter:
1467 { 1475 {
1468 emit returnPressed( d->mCurrentItem ); 1476 emit returnPressed( d->mCurrentItem );
1469 emit executed( d->mCurrentItem ); 1477 emit executed( d->mCurrentItem );
1470 } 1478 }
1471 break; 1479 break;
1472 default: 1480 default:
1473 if ( (e->state() & ControlButton) && e->key() == Key_A ) 1481 if ( (e->state() & Qt::ControlButton) && e->key() == Qt::Key_A )
1474 { 1482 {
1475 // select all 1483 // select all
1476 selectAll( true ); 1484 selectAll( true );
1477 break; 1485 break;
1478 } 1486 }
1479 // if we have a string, do autosearch 1487 // if we have a string, do autosearch
1480 else if ( ! e->text().isEmpty() && e->text()[0].isPrint() ) 1488 else if ( ! e->text().isEmpty() && e->text()[0].isPrint() )
1481 { 1489 {
1482 1490
1483 } 1491 }
1484 break; 1492 break;
1485 } 1493 }
1486 // handle selection 1494 // handle selection
1487 if ( aItem ) 1495 if ( aItem )
1488 { 1496 {
1489 if ( d->mSelectionMode == CardView::Extended ) 1497 if ( d->mSelectionMode == CardView::Extended )
1490 { 1498 {
1491 if ( (e->state() & ShiftButton) ) 1499 if ( (e->state() & Qt::ShiftButton) )
1492 { 1500 {
1493 // shift button: toggle range 1501 // shift button: toggle range
1494 // if control button is pressed, leave all items 1502 // if control button is pressed, leave all items
1495 // and toggle selection current->old current 1503 // and toggle selection current->old current
1496 // otherwise, ?????? 1504 // otherwise, ??????
1497 bool s = ! aItem->isSelected(); 1505 bool s = ! aItem->isSelected();
1498 int from, to, a, b; 1506 int from, to, a, b;
1499 a = d->mItemList.findRef( aItem ); 1507 a = d->mItemList.findRef( aItem );
1500 b = d->mItemList.findRef( old ); 1508 b = d->mItemList.findRef( old );
1501 from = a < b ? a : b; 1509 from = a < b ? a : b;
1502 to = a > b ? a : b; 1510 to = a > b ? a : b;
1503 1511
1504 if ( to - from > 1 ) 1512 if ( to - from > 1 )
1505 { 1513 {
1506 bool b = signalsBlocked(); 1514 bool b = signalsBlocked();
1507 blockSignals(true); 1515 blockSignals(true);
1508 selectAll(false); 1516 selectAll(false);
1509 blockSignals(b); 1517 blockSignals(b);
1510 } 1518 }
1511 1519
1512 //kdDebug()<<"selecting items "<<from<<" - "<<to<<" ( "<<s<<" )"<<endl; 1520 //kdDebug()<<"selecting items "<<from<<" - "<<to<<" ( "<<s<<" )"<<endl;
1513 CardViewItem *item; 1521 CardViewItem *item;
1514 for ( ; from <= to; from++ ) 1522 for ( ; from <= to; from++ )
1515 { 1523 {
1516 item = d->mItemList.at( from ); 1524 item = d->mItemList.at( from );
1517 item->setSelected( s ); 1525 item->setSelected( s );
1518 repaintItem( item ); 1526 repaintItem( item );
1519 } 1527 }
1520 emit selectionChanged(); 1528 emit selectionChanged();
1521 } 1529 }
1522 else if ( (e->state() & ControlButton) ) 1530 else if ( (e->state() & Qt::ControlButton) )
1523 { 1531 {
1524 // control button: do nothing 1532 // control button: do nothing
1525 } 1533 }
1526 else 1534 else
1527 { 1535 {
1528 // no button: move selection to this item 1536 // no button: move selection to this item
1529 bool b = signalsBlocked(); 1537 bool b = signalsBlocked();
1530 blockSignals(true); 1538 blockSignals(true);
1531 selectAll(false); 1539 selectAll(false);
1532 blockSignals(b); 1540 blockSignals(b);
1533 1541
1534 setSelected( aItem, true ); 1542 setSelected( aItem, true );
1535 emit selectionChanged(); 1543 emit selectionChanged();
1536 } 1544 }
1537 } 1545 }
1538 } 1546 }
1539} 1547}
1540 1548
1541void CardView::contentsWheelEvent( QWheelEvent * e ) 1549void CardView::contentsWheelEvent( QWheelEvent * e )
1542{ 1550{
1543 scrollBy(2*e->delta()/-3, 0); 1551 scrollBy(2*e->delta()/-3, 0);
1544} 1552}
1545 1553
1546void CardView::setLayoutDirty(bool dirty) 1554void CardView::setLayoutDirty(bool dirty)
1547{ 1555{
1548 if (d->mLayoutDirty != dirty) 1556 if (d->mLayoutDirty != dirty)
1549 { 1557 {
1550 d->mLayoutDirty = dirty; 1558 d->mLayoutDirty = dirty;
1551 repaint(); 1559 repaint();
1552 } 1560 }
1553} 1561}
1554 1562
1555void CardView::setDrawCardBorder(bool enabled) 1563void CardView::setDrawCardBorder(bool enabled)
1556{ 1564{
1557 if (enabled != d->mDrawCardBorder) 1565 if (enabled != d->mDrawCardBorder)
1558 { 1566 {
1559 d->mDrawCardBorder = enabled; 1567 d->mDrawCardBorder = enabled;
1560 repaint(); 1568 repaint();
1561 } 1569 }
1562} 1570}
1563 1571
1564bool CardView::drawCardBorder() const 1572bool CardView::drawCardBorder() const
1565{ 1573{
1566 return d->mDrawCardBorder; 1574 return d->mDrawCardBorder;
1567} 1575}
1568 1576
1569void CardView::setDrawColSeparators(bool enabled) 1577void CardView::setDrawColSeparators(bool enabled)
1570{ 1578{
1571 if (enabled != d->mDrawSeparators) 1579 if (enabled != d->mDrawSeparators)
1572 { 1580 {
1573 d->mDrawSeparators = enabled; 1581 d->mDrawSeparators = enabled;
1574 setLayoutDirty(true); 1582 setLayoutDirty(true);
1575 } 1583 }
1576} 1584}
1577 1585
1578bool CardView::drawColSeparators() const 1586bool CardView::drawColSeparators() const
1579{ 1587{
1580 return d->mDrawSeparators; 1588 return d->mDrawSeparators;
1581} 1589}
1582 1590
1583void CardView::setDrawFieldLabels(bool enabled) 1591void CardView::setDrawFieldLabels(bool enabled)
1584{ 1592{
1585 if (enabled != d->mDrawFieldLabels) 1593 if (enabled != d->mDrawFieldLabels)
1586 { 1594 {
1587 d->mDrawFieldLabels = enabled; 1595 d->mDrawFieldLabels = enabled;
1588 repaint(); 1596 repaint();
1589 } 1597 }
1590} 1598}
1591 1599
1592bool CardView::drawFieldLabels() const 1600bool CardView::drawFieldLabels() const
1593{ 1601{
1594 return d->mDrawFieldLabels; 1602 return d->mDrawFieldLabels;
1595} 1603}
1596 1604
1597void CardView::setShowEmptyFields(bool show) 1605void CardView::setShowEmptyFields(bool show)
1598{ 1606{
1599 if (show != d->mShowEmptyFields) 1607 if (show != d->mShowEmptyFields)
1600 { 1608 {
1601 d->mShowEmptyFields = show; 1609 d->mShowEmptyFields = show;
1602 setLayoutDirty(true); 1610 setLayoutDirty(true);
1603 } 1611 }
1604} 1612}
1605 1613
1606bool CardView::showEmptyFields() const 1614bool CardView::showEmptyFields() const
1607{ 1615{
1608 return d->mShowEmptyFields; 1616 return d->mShowEmptyFields;
1609} 1617}
1610 1618
1611void CardView::startDrag() 1619void CardView::startDrag()
1612{ 1620{
1613 // The default implementation is a no-op. It must be 1621 // The default implementation is a no-op. It must be
1614 // reimplemented in a subclass to be useful 1622 // reimplemented in a subclass to be useful
1615} 1623}
1616void CardView::tryShowFullText() 1624void CardView::tryShowFullText()
1617{ 1625{
1618 d->mTimer->stop(); 1626 d->mTimer->stop();
1619 // if we have an item 1627 // if we have an item
1620 QPoint cpos = viewportToContents( viewport()->mapFromGlobal( QCursor::pos() ) ); 1628 QPoint cpos = viewportToContents( viewport()->mapFromGlobal( QCursor::pos() ) );
1621 CardViewItem *item = itemAt( cpos ); 1629 CardViewItem *item = itemAt( cpos );
1622 if ( item ) 1630 if ( item )
1623 { 1631 {
1624 // query it for a value to display 1632 // query it for a value to display
1625 //QString s = item ? item->caption() : "(no item)"; 1633 //QString s = item ? item->caption() : "(no item)";
1626 //kdDebug()<<"MOUSE REST: "<<s<<endl; 1634 //kdDebug()<<"MOUSE REST: "<<s<<endl;
1627 QPoint ipos = cpos - itemRect( item ).topLeft(); 1635 QPoint ipos = cpos - itemRect( item ).topLeft();
1628 item->showFullString( ipos, d->mTip ); 1636 item->showFullString( ipos, d->mTip );
1629 } 1637 }
1630} 1638}
1631 1639
1632void CardView::drawRubberBands( int pos ) 1640void CardView::drawRubberBands( int pos )
1633{ 1641{
1634 if ( pos && ((pos-d->firstX)/d->span) - d->colspace - d->mSepWidth < MIN_ITEM_WIDTH ) return; 1642 if ( pos && ((pos-d->firstX)/d->span) - d->colspace - d->mSepWidth < MIN_ITEM_WIDTH ) return;
1635 1643
1636 int tmpcw = (d->mRubberBandAnchor-d->firstX)/d->span; 1644 int tmpcw = (d->mRubberBandAnchor-d->firstX)/d->span;
1637 int x = d->firstX + tmpcw - d->mSepWidth - contentsX(); 1645 int x = d->firstX + tmpcw - d->mSepWidth - contentsX();
1638 int h = visibleHeight(); 1646 int h = visibleHeight();
1639 1647
1640 QPainter p( viewport() ); 1648 QPainter p( viewport() );
1641 p.setRasterOp( XorROP ); 1649 p.setCompositionMode( QPainter::CompositionMode_Xor );
1642 p.setPen( gray ); 1650 p.setPen( Qt::gray );
1643 p.setBrush( gray ); 1651 p.setBrush( Qt::gray );
1644 uint n = d->first; 1652 uint n = d->first;
1645 // erase 1653 // erase
1646 if ( d->mRubberBandAnchor ) 1654 if ( d->mRubberBandAnchor )
1647 do { 1655 do {
1648 p.drawRect( x, 0, 2, h ); 1656 p.drawRect( x, 0, 2, h );
1649 x += tmpcw; 1657 x += tmpcw;
1650 n++; 1658 n++;
1651 } while ( x < visibleWidth() && n < d->mSeparatorList.count() ); 1659 } while ( x < visibleWidth() && n < d->mSeparatorList.count() );
1652 // paint new 1660 // paint new
1653 if ( ! pos ) return; 1661 if ( ! pos ) return;
1654 tmpcw = (pos - d->firstX)/d->span; 1662 tmpcw = (pos - d->firstX)/d->span;
1655 n = d->first; 1663 n = d->first;
1656 x = d->firstX + tmpcw - d->mSepWidth - contentsX(); 1664 x = d->firstX + tmpcw - d->mSepWidth - contentsX();
1657 do { 1665 do {
1658 p.drawRect( x, 0, 2, h ); 1666 p.drawRect( x, 0, 2, h );
1659 x += tmpcw; 1667 x += tmpcw;
1660 n++; 1668 n++;
1661 } while ( x < visibleWidth() && n < d->mSeparatorList.count() ); 1669 } while ( x < visibleWidth() && n < d->mSeparatorList.count() );
1662 d->mRubberBandAnchor = pos; 1670 d->mRubberBandAnchor = pos;
1663} 1671}
1664 1672
1665 1673
1666int CardView::itemWidth() const 1674int CardView::itemWidth() const
1667{ 1675{
1668 return d->mItemWidth; 1676 return d->mItemWidth;
1669} 1677}
1670 1678
1671void CardView::setItemWidth( int w ) 1679void CardView::setItemWidth( int w )
1672{ 1680{
1673 if ( w == d->mItemWidth ) 1681 if ( w == d->mItemWidth )
1674 return; 1682 return;
1675 if ( w < MIN_ITEM_WIDTH ) 1683 if ( w < MIN_ITEM_WIDTH )
1676 w = MIN_ITEM_WIDTH; 1684 w = MIN_ITEM_WIDTH;
1677 d->mItemWidth = w; 1685 d->mItemWidth = w;
1678 setLayoutDirty( true ); 1686 setLayoutDirty( true );
1679#ifndef KAB_EMBEDDED 1687#ifndef KAB_EMBEDDED
1680 updateContents(); 1688 updateContents();
1681#else //KAB_EMBEDDED 1689#else //KAB_EMBEDDED
1682//US updateContents( d->contentsX(), d->contentsY(), visibleWidth(), visibleHeight() ); 1690//US updateContents( d->contentsX(), d->contentsY(), visibleWidth(), visibleHeight() );
1683qDebug("CardView::setItemWidth has to be verified"); 1691qDebug("CardView::setItemWidth has to be verified");
1684 updateContents( contentsX(), contentsY(), visibleWidth(), visibleHeight() ); 1692 updateContents( contentsX(), contentsY(), visibleWidth(), visibleHeight() );
1685#endif //KAB_EMBEDDED 1693#endif //KAB_EMBEDDED
1686} 1694}
1687 1695
1688void CardView::setHeaderFont( const QFont &fnt ) 1696void CardView::setHeaderFont( const QFont &fnt )
1689{ 1697{
1690 d->mHeaderFont = fnt; 1698 d->mHeaderFont = fnt;
1691 delete d->mBFm; 1699 delete d->mBFm;
1692 d->mBFm = new QFontMetrics( fnt ); 1700 d->mBFm = new QFontMetrics( fnt );
1693} 1701}
1694 1702
1695QFont CardView::headerFont() const 1703QFont CardView::headerFont() const
1696{ 1704{
1697 return d->mHeaderFont; 1705 return d->mHeaderFont;
1698} 1706}
1699 1707
1700void CardView::setFont( const QFont &fnt ) 1708void CardView::setFont( const QFont &fnt )
1701{ 1709{
1702 QScrollView::setFont( fnt ); 1710 Q3ScrollView::setFont( fnt );
1703 delete d->mFm; 1711 delete d->mFm;
1704 d->mFm = new QFontMetrics( fnt ); 1712 d->mFm = new QFontMetrics( fnt );
1705} 1713}
1706 1714
1707int CardView::separatorWidth() 1715int CardView::separatorWidth()
1708{ 1716{
1709 return d->mSepWidth; 1717 return d->mSepWidth;
1710} 1718}
1711 1719
1712void CardView::setSeparatorWidth( int width ) 1720void CardView::setSeparatorWidth( int width )
1713{ 1721{
1714 d->mSepWidth = width; 1722 d->mSepWidth = width;
1715 setLayoutDirty( true ); // hmm, actually I could just adjust the x'es... 1723 setLayoutDirty( true ); // hmm, actually I could just adjust the x'es...
1716} 1724}
1717 1725
1718int CardView::maxFieldLines() const 1726int CardView::maxFieldLines() const
1719{ 1727{
1720 return d->mMaxFieldLines; 1728 return d->mMaxFieldLines;
1721} 1729}
1722 1730
1723void CardView::setMaxFieldLines( int howmany ) 1731void CardView::setMaxFieldLines( int howmany )
1724{ 1732{
1725 d->mMaxFieldLines = howmany ? howmany : INT_MAX; 1733 d->mMaxFieldLines = howmany ? howmany : INT_MAX;
1726 // FIXME update, forcing the items to recalc height!! 1734 // FIXME update, forcing the items to recalc height!!
1727} 1735}
1728 1736
1729void CardView::keyReleaseEvent ( QKeyEvent * e ) 1737void CardView::keyReleaseEvent ( QKeyEvent * e )
1730{ 1738{
1731 if ( mFlagBlockKeyPressed ) 1739 if ( mFlagBlockKeyPressed )
1732 return; 1740 return;
1733 if ( !e->isAutoRepeat() ) { 1741 if ( !e->isAutoRepeat() ) {
1734 mFlagBlockKeyPressed = true; 1742 mFlagBlockKeyPressed = true;
1735 qApp->processEvents(); 1743 qApp->processEvents();
1736 mFlagBlockKeyPressed = false; 1744 mFlagBlockKeyPressed = false;
1737 mFlagKeyPressed = false; 1745 mFlagKeyPressed = false;
1738 } 1746 }
1739 QScrollView::keyReleaseEvent ( e ); 1747 Q3ScrollView::keyReleaseEvent ( e );
1740} 1748}
1741 1749
1742 1750
1743 1751
1744 1752
1745 1753
1746//END Cardview 1754//END Cardview
1747 1755
1748#ifndef KAB_EMBEDDED 1756#ifndef KAB_EMBEDDED_
1749#include "cardview.moc" 1757#include "moc_cardview.cpp"
1750#endif //KAB_EMBEDDED 1758#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/cardview.h b/kaddressbook/views/cardview.h
index 2ea3771..9c245ea 100644
--- a/kaddressbook/views/cardview.h
+++ b/kaddressbook/views/cardview.h
@@ -1,476 +1,484 @@
1#ifndef CARDVIEW_H 1#ifndef CARDVIEW_H
2#define CARDVIEW_H 2#define CARDVIEW_H
3 3
4#include <qscrollview.h> 4#include <q3scrollview.h>
5#include <qptrlist.h> 5#include <q3ptrlist.h>
6#include <qstring.h> 6#include <qstring.h>
7#include <qrect.h> 7#include <qrect.h>
8#include <qpair.h> 8#include <qpair.h>
9#include <qpoint.h> 9#include <qpoint.h>
10//Added by qt3to4:
11#include <QWheelEvent>
12#include <QResizeEvent>
13#include <QFocusEvent>
14#include <QLabel>
15#include <QMouseEvent>
16#include <QKeyEvent>
17#include <QEvent>
10 18
11class QLabel; 19class QLabel;
12class QPainter; 20class QPainter;
13class QResizeEvent; 21class QResizeEvent;
14class QMouseEvent; 22class QMouseEvent;
15class CardView; 23class CardView;
16class CardViewPrivate; 24class CardViewPrivate;
17class CardViewItemPrivate; 25class CardViewItemPrivate;
18class CardViewTip; 26class CardViewTip;
19 27
20/** Represents a single card (item) in the card view. A card has a caption 28/** Represents a single card (item) in the card view. A card has a caption
21* and a list of fields. A Field is a label<->value pair. The labels in a 29* and a list of fields. A Field is a label<->value pair. The labels in a
22* card should be unique, since they will be used to index the values. 30* card should be unique, since they will be used to index the values.
23*/ 31*/
24class CardViewItem 32class CardViewItem
25{ 33{
26 friend class CardView; 34 friend class CardView;
27 35
28 public: 36 public:
29 /** A single field in the card view. The first item is the label 37 /** A single field in the card view. The first item is the label
30 * and the second item is the value. 38 * and the second item is the value.
31 */ 39 */
32 typedef QPair<QString, QString> Field; 40 typedef QPair<QString, QString> Field;
33 41
34 /** Constructor. 42 /** Constructor.
35 * 43 *
36 * @param parent The CardView that this card should be displayed on. 44 * @param parent The CardView that this card should be displayed on.
37 * @param caption The caption of the card. This is the text that will 45 * @param caption The caption of the card. This is the text that will
38 * appear at the top of the card. This is also the string that will 46 * appear at the top of the card. This is also the string that will
39 * be used to sort the cards in the view. 47 * be used to sort the cards in the view.
40 */ 48 */
41 CardViewItem(CardView *parent, QString caption = QString::null); 49 CardViewItem(CardView *parent, QString caption = QString::null);
42 virtual ~CardViewItem(); 50 virtual ~CardViewItem();
43 51
44 /** @return The caption of the card, or QString::null if none was ever 52 /** @return The caption of the card, or QString::null if none was ever
45 * set. 53 * set.
46 */ 54 */
47 const QString &caption() const; 55 const QString &caption() const;
48 56
49 /** Sets the caption of the card. This is the text that will 57 /** Sets the caption of the card. This is the text that will
50 * appear at the top of the card. This is also the string that will 58 * appear at the top of the card. This is also the string that will
51 * be used to sort the cards in the view. 59 * be used to sort the cards in the view.
52 */ 60 */
53 void setCaption(const QString &caption); 61 void setCaption(const QString &caption);
54 62
55 /** Paints the card using the given painter and color group. The 63 /** Paints the card using the given painter and color group. The
56 * card will handle painting itself selected if it is selected. 64 * card will handle painting itself selected if it is selected.
57 */ 65 */
58 virtual void paintCard(QPainter *p, QColorGroup &cg); 66 virtual void paintCard(QPainter *p, QColorGroup &cg);
59 67
60 /** Repaints the card. This is done by sending a repaint event to the 68 /** Repaints the card. This is done by sending a repaint event to the
61 * view with the clip rect defined as this card. 69 * view with the clip rect defined as this card.
62 */ 70 */
63 virtual void repaintCard(); 71 virtual void repaintCard();
64 72
65 /** Adds a field to the card. 73 /** Adds a field to the card.
66 * 74 *
67 * @param label The label of the field. The field labels must be unique 75 * @param label The label of the field. The field labels must be unique
68 * within a card. 76 * within a card.
69 * @param The value of the field. 77 * @param The value of the field.
70 */ 78 */
71 void insertField(const QString &label, const QString &value); 79 void insertField(const QString &label, const QString &value);
72 80
73 /** Removes the field with label <i>label</i> from the card. 81 /** Removes the field with label <i>label</i> from the card.
74 */ 82 */
75 void removeField(const QString &label); 83 void removeField(const QString &label);
76 84
77 /** @return The value of the field with label <i>label</i>. 85 /** @return The value of the field with label <i>label</i>.
78 */ 86 */
79 QString fieldValue(const QString &label); 87 QString fieldValue(const QString &label);
80 88
81 /** Removes all the fields from this card. 89 /** Removes all the fields from this card.
82 */ 90 */
83 void clearFields(); 91 void clearFields();
84 92
85 /** @return The next card item. The order of the items will be the same 93 /** @return The next card item. The order of the items will be the same
86 * as the display order in the view. 0 will be returned if this is the 94 * as the display order in the view. 0 will be returned if this is the
87 * last card. 95 * last card.
88 */ 96 */
89 CardViewItem *nextItem(); 97 CardViewItem *nextItem();
90 98
91 /** @return True if this card is currently selected, false otherwise. 99 /** @return True if this card is currently selected, false otherwise.
92 */ 100 */
93 bool isSelected() const; 101 bool isSelected() const;
94 102
95 /** Called by the parent card view when the mouse has been resting for 103 /** Called by the parent card view when the mouse has been resting for
96 * a certain amount of time. If the label or value at pos is obscured 104 * a certain amount of time. If the label or value at pos is obscured
97 * (trimmed) make the label display the full text. 105 * (trimmed) make the label display the full text.
98 */ 106 */
99 void showFullString( const QPoint &pos, CardViewTip *tip ); 107 void showFullString( const QPoint &pos, CardViewTip *tip );
100 108
101 /** @return a pointer to the Field at the position itempos 109 /** @return a pointer to the Field at the position itempos
102 * in this item. 0 is returned if itempos is in the caption. 110 * in this item. 0 is returned if itempos is in the caption.
103 * @param itempos the position in item coordinates 111 * @param itempos the position in item coordinates
104 */ 112 */
105 Field *fieldAt( const QPoint &itempos ) const; 113 Field *fieldAt( const QPoint &itempos ) const;
106 114
107 CardView *cardView() { return mView; }; 115 CardView *cardView() { return mView; };
108 116
109 /** @return The height of this item as rendered, in pixels. 117 /** @return The height of this item as rendered, in pixels.
110 118
111 if @p allowCache is true, the item may use an internally 119 if @p allowCache is true, the item may use an internally
112 cached value rather than recalculating from scratch. The 120 cached value rather than recalculating from scratch. The
113 argument is mainly to allow the cardView to change global settings (like 121 argument is mainly to allow the cardView to change global settings (like
114 maxFieldLines) that might influence the items heights 122 maxFieldLines) that might influence the items heights
115 */ 123 */
116 int height( bool allowCache=true ) const; 124 int height( bool allowCache=true ) const;
117 125
118 protected: 126 protected:
119 /** Sets the card as selected. This is usually only called from the 127 /** Sets the card as selected. This is usually only called from the
120 * card view. 128 * card view.
121 */ 129 */
122 void setSelected(bool selected); 130 void setSelected(bool selected);
123 131
124 private: 132 private:
125 /** Sets the default values. 133 /** Sets the default values.
126 */ 134 */
127 void initialize(); 135 void initialize();
128 136
129 /** Trims a string to the width <i>width</i> using the font metrics 137 /** Trims a string to the width <i>width</i> using the font metrics
130 * to determine the width of each char. If the string is longer than 138 * to determine the width of each char. If the string is longer than
131 * <i>width</i>, then the string will be trimmed and a '...' will 139 * <i>width</i>, then the string will be trimmed and a '...' will
132 * be appended. 140 * be appended.
133 */ 141 */
134 QString trimString(const QString &text, int width, QFontMetrics &fm); 142 QString trimString(const QString &text, int width, QFontMetrics &fm);
135 143
136 CardViewItemPrivate *d; 144 CardViewItemPrivate *d;
137 CardView *mView; 145 CardView *mView;
138}; 146};
139 147
140/** The CardView is a method of displaying data in cards. This idea is 148/** The CardView is a method of displaying data in cards. This idea is
141* similar to the idea of a rolodex or business cards. Each card has a 149* similar to the idea of a rolodex or business cards. Each card has a
142* caption and a list of fields, which are label<->value pairs. The CardView 150* caption and a list of fields, which are label<->value pairs. The CardView
143* displays multiple cards in a grid. The Cards are sorted based on their 151* displays multiple cards in a grid. The Cards are sorted based on their
144* caption. 152* caption.
145* 153*
146* The CardView class is designed to mirror the API of the QListView or 154* The CardView class is designed to mirror the API of the QListView or
147* QIconView. The CardView is also completely independant of KAddressBook and 155* QIconView. The CardView is also completely independant of KAddressBook and
148* can be used elsewhere. With the exception of a few simple config checks, 156* can be used elsewhere. With the exception of a few simple config checks,
149* the CardView is also 100% independant of KDE. 157* the CardView is also 100% independant of KDE.
150*/ 158*/
151class CardView : public QScrollView 159class CardView : public Q3ScrollView
152{ 160{
153 friend class CardViewItem; 161 friend class CardViewItem;
154 162
155 Q_OBJECT 163 Q_OBJECT
156 164
157 public: 165 public:
158 /** Constructor. 166 /** Constructor.
159 */ 167 */
160 CardView(QWidget *parent, const char *name); 168 CardView(QWidget *parent, const char *name);
161 virtual ~CardView(); 169 virtual ~CardView();
162 170
163 /** Inserts the item into the card view. This method does not have 171 /** Inserts the item into the card view. This method does not have
164 * to be called if you created the item with a proper parent. Once 172 * to be called if you created the item with a proper parent. Once
165 * inserted, the CardView takes ownership of the item. 173 * inserted, the CardView takes ownership of the item.
166 */ 174 */
167 void insertItem(CardViewItem *item); 175 void insertItem(CardViewItem *item);
168 176
169 /** Takes the item from the view. The item will not be deleted and 177 /** Takes the item from the view. The item will not be deleted and
170 * ownership of the item is returned to the caller. 178 * ownership of the item is returned to the caller.
171 */ 179 */
172 void takeItem(CardViewItem *item); 180 void takeItem(CardViewItem *item);
173 181
174 /** Clears the view and deletes all card view items 182 /** Clears the view and deletes all card view items
175 */ 183 */
176 void clear(); 184 void clear();
177 185
178 /** @return The current item, the item that has the focus. 186 /** @return The current item, the item that has the focus.
179 * Whenever the view has focus, this item has a focus rectangle painted 187 * Whenever the view has focus, this item has a focus rectangle painted
180 * at it's border. 188 * at it's border.
181 * @sa setCurrentItem() 189 * @sa setCurrentItem()
182 */ 190 */
183 CardViewItem *currentItem(); 191 CardViewItem *currentItem();
184 192
185 /** Sets the CardViewItem @p item to the current item in the view. 193 /** Sets the CardViewItem @p item to the current item in the view.
186 */ 194 */
187 void setCurrentItem( CardViewItem *item ); 195 void setCurrentItem( CardViewItem *item );
188 196
189 /** @return The item found at the given point, or 0 if there is no item 197 /** @return The item found at the given point, or 0 if there is no item
190 * at that point. 198 * at that point.
191 */ 199 */
192 CardViewItem *itemAt(const QPoint &viewPos); 200 CardViewItem *itemAt(const QPoint &viewPos);
193 201
194 /** @return The bounding rect of the given item. 202 /** @return The bounding rect of the given item.
195 */ 203 */
196 QRect itemRect(const CardViewItem *item); 204 QRect itemRect(const CardViewItem *item);
197 205
198 /** Ensures that the given item is in the viewable area of the widget 206 /** Ensures that the given item is in the viewable area of the widget
199 */ 207 */
200 void ensureItemVisible(const CardViewItem *item); 208 void ensureItemVisible(const CardViewItem *item);
201 209
202 /** Repaints the given item. 210 /** Repaints the given item.
203 */ 211 */
204 void repaintItem(const CardViewItem *item); 212 void repaintItem(const CardViewItem *item);
205 213
206 enum SelectionMode { Single, Multi, Extended, NoSelection }; 214 enum SelectionMode { Single, Multi, Extended, NoSelection };
207 215
208 /** Sets the selection mode. 216 /** Sets the selection mode.
209 * 217 *
210 * @see QListView 218 * @see QListView
211 */ 219 */
212 void setSelectionMode(SelectionMode mode); 220 void setSelectionMode(SelectionMode mode);
213 221
214 /** @return The current selection mode. 222 /** @return The current selection mode.
215 */ 223 */
216 SelectionMode selectionMode() const; 224 SelectionMode selectionMode() const;
217 225
218 /** Selects or deselects the given item. This method honors the current 226 /** Selects or deselects the given item. This method honors the current
219 * selection mode, so if other items are selected, they may be unselected. 227 * selection mode, so if other items are selected, they may be unselected.
220 */ 228 */
221 void setSelected(CardViewItem *item, bool selected); 229 void setSelected(CardViewItem *item, bool selected);
222 230
223 /** Selects or deselects all items. 231 /** Selects or deselects all items.
224 */ 232 */
225 void selectAll(bool state); 233 void selectAll(bool state);
226 234
227 /** @return True if the given item is selected, false otherwise. 235 /** @return True if the given item is selected, false otherwise.
228 */ 236 */
229 bool isSelected(CardViewItem *item) const; 237 bool isSelected(CardViewItem *item) const;
230 238
231 /** @return The first selected item. In single select mode, this will be 239 /** @return The first selected item. In single select mode, this will be
232 * the only selected item, in other modes this will be the first selected 240 * the only selected item, in other modes this will be the first selected
233 * item, but others may exist. 0 if no item is selected. 241 * item, but others may exist. 0 if no item is selected.
234 */ 242 */
235 CardViewItem *selectedItem() const; 243 CardViewItem *selectedItem() const;
236 244
237 /** @return The first item in the view. This may be 0 if no items have 245 /** @return The first item in the view. This may be 0 if no items have
238 * been inserted. This method combined with CardViewItem::nextItem() 246 * been inserted. This method combined with CardViewItem::nextItem()
239 * can be used to iterator through the list of items. 247 * can be used to iterator through the list of items.
240 */ 248 */
241 CardViewItem *firstItem() const; 249 CardViewItem *firstItem() const;
242 250
243 /** @return The item after the given item or 0 if the item is the last 251 /** @return The item after the given item or 0 if the item is the last
244 * item. 252 * item.
245 */ 253 */
246 CardViewItem *itemAfter(CardViewItem *item); 254 CardViewItem *itemAfter(CardViewItem *item);
247 255
248 /** @return The number of items in the view. 256 /** @return The number of items in the view.
249 */ 257 */
250 int childCount() const; 258 int childCount() const;
251 259
252 /** Attempts to find the first item matching the params. 260 /** Attempts to find the first item matching the params.
253 * 261 *
254 * @param text The text to match. 262 * @param text The text to match.
255 * @param label The label of the field to match against. 263 * @param label The label of the field to match against.
256 * @param compare The compare method to use in doing the search. 264 * @param compare The compare method to use in doing the search.
257 * 265 *
258 * @return The first matching item, or 0 if no items match. 266 * @return The first matching item, or 0 if no items match.
259 */ 267 */
260/*US 268/*US
261 CardViewItem *findItem(const QString &text, const QString &label, 269 CardViewItem *findItem(const QString &text, const QString &label,
262 Qt::StringComparisonMode compare = Qt::BeginsWith); 270 Qt::StringComparisonMode compare = Qt::BeginsWith);
263*/ 271*/
264 272
265 /** Returns the amounts of pixels required for one column. 273 /** Returns the amounts of pixels required for one column.
266 * This depends on wheather drawSeparators is enabled: 274 * This depends on wheather drawSeparators is enabled:
267 * If so, it is itemWidth + 2*itemSpacing + separatorWidth 275 * If so, it is itemWidth + 2*itemSpacing + separatorWidth
268 * If not, it is itemWidth + itemSpacing 276 * If not, it is itemWidth + itemSpacing
269 * @see itemWidth(), setItemWidth(), itemSpacing() and setItemSpacing() 277 * @see itemWidth(), setItemWidth(), itemSpacing() and setItemSpacing()
270 */ 278 */
271 uint columnWidth(); 279 uint columnWidth();
272 280
273 /** Sets if the border around a card should be draw. The border is a thing 281 /** Sets if the border around a card should be draw. The border is a thing
274 * (1 or 2 pixel) line that bounds the card. When drawn, it shows when 282 * (1 or 2 pixel) line that bounds the card. When drawn, it shows when
275 * a card is highlighted and when it isn't. 283 * a card is highlighted and when it isn't.
276 */ 284 */
277 void setDrawCardBorder(bool enabled); 285 void setDrawCardBorder(bool enabled);
278 286
279 /** @return True if borders are drawn, false otherwise. 287 /** @return True if borders are drawn, false otherwise.
280 */ 288 */
281 bool drawCardBorder() const; 289 bool drawCardBorder() const;
282 290
283 /** Sets if the column separator should be drawn. The column separator 291 /** Sets if the column separator should be drawn. The column separator
284 * is a thin verticle line (1 or 2 pixels) that is used to separate the 292 * is a thin verticle line (1 or 2 pixels) that is used to separate the
285 * columns in the list view. The separator is just for esthetics and it 293 * columns in the list view. The separator is just for esthetics and it
286 * does not serve a functional purpose. 294 * does not serve a functional purpose.
287 */ 295 */
288 void setDrawColSeparators(bool enabled); 296 void setDrawColSeparators(bool enabled);
289 297
290 /** @return True if column separators are drawn, false otherwise. 298 /** @return True if column separators are drawn, false otherwise.
291 */ 299 */
292 bool drawColSeparators() const; 300 bool drawColSeparators() const;
293 301
294 /** Sets if the field labels should be drawn. The field labels are the 302 /** Sets if the field labels should be drawn. The field labels are the
295 * unique strings used to identify the fields. Sometimes drawing these 303 * unique strings used to identify the fields. Sometimes drawing these
296 * labels makes sense as a source of clarity for the user, othertimes they 304 * labels makes sense as a source of clarity for the user, othertimes they
297 * waste too much space and do not assist the user. 305 * waste too much space and do not assist the user.
298 */ 306 */
299 void setDrawFieldLabels(bool enabled); 307 void setDrawFieldLabels(bool enabled);
300 308
301 /** @return True if the field labels are drawn, false otherwise. 309 /** @return True if the field labels are drawn, false otherwise.
302 */ 310 */
303 bool drawFieldLabels() const; 311 bool drawFieldLabels() const;
304 312
305 /** Sets if fields with no value should be drawn (of cause the label only, 313 /** Sets if fields with no value should be drawn (of cause the label only,
306 * but it allows for embedded editing sometimes...) 314 * but it allows for embedded editing sometimes...)
307 */ 315 */
308 void setShowEmptyFields(bool show); 316 void setShowEmptyFields(bool show);
309 317
310 /** @return Wheather empty fields should be shown 318 /** @return Wheather empty fields should be shown
311 */ 319 */
312 bool showEmptyFields() const; 320 bool showEmptyFields() const;
313 321
314 /** @return the advisory internal margin in items. Setting a value above 1 means 322 /** @return the advisory internal margin in items. Setting a value above 1 means
315 * a space between the item contents and the focus recttangle drawn around 323 * a space between the item contents and the focus recttangle drawn around
316 * the current item. The default value is 0. 324 * the current item. The default value is 0.
317 * The value should be used by CardViewItem and derived classes. 325 * The value should be used by CardViewItem and derived classes.
318 * Note that this should not be greater than half of the minimal item width, 326 * Note that this should not be greater than half of the minimal item width,
319 * which is 80. It is currently not checked, so setting a value greater than 40 327 * which is 80. It is currently not checked, so setting a value greater than 40
320 * will probably mean a crash in the items painting routine. 328 * will probably mean a crash in the items painting routine.
321 * @private Note: I looked for a value in QStyle::PixelMetric to use, but I could 329 * @private Note: I looked for a value in QStyle::PixelMetric to use, but I could
322 * not see a usefull one. One may turn up in a future version of Qt. 330 * not see a usefull one. One may turn up in a future version of Qt.
323 */ 331 */
324 uint itemMargin(); 332 uint itemMargin();
325 333
326 /** Sets the internal item margin. @see itemMargin(). 334 /** Sets the internal item margin. @see itemMargin().
327 */ 335 */
328 void setItemMargin( uint margin ); 336 void setItemMargin( uint margin );
329 337
330 /** @return the item spacing. 338 /** @return the item spacing.
331 * The item spacing is the space (in pixels) between each item in a 339 * The item spacing is the space (in pixels) between each item in a
332 * column, between the items and column separators if drawn, and between 340 * column, between the items and column separators if drawn, and between
333 * the items and the borders of the widget. The default value is set to 341 * the items and the borders of the widget. The default value is set to
334 * 10. 342 * 10.
335 * @private Note: There is no usefull QStyle::PixelMetric to use for this atm. 343 * @private Note: There is no usefull QStyle::PixelMetric to use for this atm.
336 * An option would be using KDialog::spacingHint(). 344 * An option would be using KDialog::spacingHint().
337 */ 345 */
338 uint itemSpacing(); 346 uint itemSpacing();
339 347
340 /** Sets the item spacing. 348 /** Sets the item spacing.
341 * @see itemSpacing() 349 * @see itemSpacing()
342 */ 350 */
343 void setItemSpacing( uint spacing ); 351 void setItemSpacing( uint spacing );
344 352
345 /** @return the width made available to the card items. */ 353 /** @return the width made available to the card items. */
346 int itemWidth() const; 354 int itemWidth() const;
347 355
348 /** Sets the width made available to card items. */ 356 /** Sets the width made available to card items. */
349 void setItemWidth( int width ); 357 void setItemWidth( int width );
350 358
351 /** Sets the header font */ 359 /** Sets the header font */
352 void setHeaderFont( const QFont &fnt ); 360 void setHeaderFont( const QFont &fnt );
353 361
354 /** @return the header font */ 362 /** @return the header font */
355 QFont headerFont() const; 363 QFont headerFont() const;
356 364
357 /** @reimp */ 365 /** @reimp */
358 void setFont( const QFont &fnt ); 366 void setFont( const QFont &fnt );
359 367
360 /** Sets the column separator width */ 368 /** Sets the column separator width */
361 void setSeparatorWidth( int width ); 369 void setSeparatorWidth( int width );
362 370
363 /** @return the column separator width */ 371 /** @return the column separator width */
364 int separatorWidth(); 372 int separatorWidth();
365 373
366 /** Sets the maximum number of lines to display pr field. 374 /** Sets the maximum number of lines to display pr field.
367 If set to 0 (the default) all lines will be displayed. 375 If set to 0 (the default) all lines will be displayed.
368 */ 376 */
369 void setMaxFieldLines( int howmany ); 377 void setMaxFieldLines( int howmany );
370 378
371 /** @return the maximum number of lines pr field */ 379 /** @return the maximum number of lines pr field */
372 int maxFieldLines() const; 380 int maxFieldLines() const;
373 381
374 signals: 382 signals:
375 /** Emitted whenever the selection changes. This means a user highlighted 383 /** Emitted whenever the selection changes. This means a user highlighted
376 * a new item or unhighlighted a currently selected item. 384 * a new item or unhighlighted a currently selected item.
377 */ 385 */
378 void selectionChanged(); 386 void selectionChanged();
379 387
380 /** Same as above method, only it carries the item that was selected. This 388 /** Same as above method, only it carries the item that was selected. This
381 * method will only be emitted in single select mode, since it defineds 389 * method will only be emitted in single select mode, since it defineds
382 * which item was selected. 390 * which item was selected.
383 */ 391 */
384 void selectionChanged(CardViewItem *); 392 void selectionChanged(CardViewItem *);
385 393
386 /** This method is emitted whenever an item is clicked. 394 /** This method is emitted whenever an item is clicked.
387 */ 395 */
388 void clicked(CardViewItem *); 396 void clicked(CardViewItem *);
389 397
390 /** Emitted whenever the user 'executes' an item. This is dependant on 398 /** Emitted whenever the user 'executes' an item. This is dependant on
391 * the KDE global config. This could be a single click or a doubleclick. 399 * the KDE global config. This could be a single click or a doubleclick.
392 * Also emitted when the return key is pressed on an item. 400 * Also emitted when the return key is pressed on an item.
393 */ 401 */
394 void executed(CardViewItem *); 402 void executed(CardViewItem *);
395 403
396 /** Emitted whenever the user double clicks on an item. 404 /** Emitted whenever the user double clicks on an item.
397 */ 405 */
398 void doubleClicked(CardViewItem *); 406 void doubleClicked(CardViewItem *);
399 407
400 /** Emitted when the current item changes 408 /** Emitted when the current item changes
401 */ 409 */
402 void currentChanged( CardViewItem * ); 410 void currentChanged( CardViewItem * );
403 411
404 /** Emitted when the return key is pressed in an item. 412 /** Emitted when the return key is pressed in an item.
405 */ 413 */
406 void returnPressed( CardViewItem * ); 414 void returnPressed( CardViewItem * );
407 415
408 protected: 416 protected:
409 bool mFlagKeyPressed; 417 bool mFlagKeyPressed;
410 bool mFlagBlockKeyPressed; 418 bool mFlagBlockKeyPressed;
411 virtual void keyPressEvent ( QKeyEvent * ); 419 virtual void keyPressEvent ( QKeyEvent * );
412 virtual void keyReleaseEvent ( QKeyEvent * ); 420 virtual void keyReleaseEvent ( QKeyEvent * );
413 /** Determines which cards intersect that region and tells them to paint 421 /** Determines which cards intersect that region and tells them to paint
414 * themselves. 422 * themselves.
415 */ 423 */
416 void drawContents(QPainter *p, int clipx, int clipy, int clipw, int cliph); 424 void drawContents(QPainter *p, int clipx, int clipy, int clipw, int cliph);
417 425
418 /** Sets the layout to dirty and repaints. 426 /** Sets the layout to dirty and repaints.
419 */ 427 */
420 void resizeEvent(QResizeEvent *e); 428 void resizeEvent(QResizeEvent *e);
421 429
422 /** Changes the direction the canvas scolls. 430 /** Changes the direction the canvas scolls.
423 */ 431 */
424 void contentsWheelEvent(QWheelEvent *e); 432 void contentsWheelEvent(QWheelEvent *e);
425 433
426 /** Sets the layout to dirty and calls for a repaint. 434 /** Sets the layout to dirty and calls for a repaint.
427 */ 435 */
428 void setLayoutDirty(bool dirty); 436 void setLayoutDirty(bool dirty);
429 437
430 /** Does the math based on the bounding rect of the cards to properly 438 /** Does the math based on the bounding rect of the cards to properly
431 * lay the cards out on the screen. This is only done if the layout is 439 * lay the cards out on the screen. This is only done if the layout is
432 * marked as dirty. 440 * marked as dirty.
433 */ 441 */
434 void calcLayout(); 442 void calcLayout();
435 443
436// virtual void mousePressEvent(QMouseEvent *e); 444// virtual void mousePressEvent(QMouseEvent *e);
437// virtual void mouseReleaseEvent(QMouseEvent *e); 445// virtual void mouseReleaseEvent(QMouseEvent *e);
438// virtual void mouseMoveEvent(QMouseEvent *e); 446// virtual void mouseMoveEvent(QMouseEvent *e);
439 447
440 virtual void contentsMousePressEvent(QMouseEvent *e); 448 virtual void contentsMousePressEvent(QMouseEvent *e);
441 virtual void contentsMouseMoveEvent(QMouseEvent *e); 449 virtual void contentsMouseMoveEvent(QMouseEvent *e);
442 virtual void contentsMouseReleaseEvent(QMouseEvent *e); 450 virtual void contentsMouseReleaseEvent(QMouseEvent *e);
443 virtual void contentsMouseDoubleClickEvent(QMouseEvent *e); 451 virtual void contentsMouseDoubleClickEvent(QMouseEvent *e);
444 452
445 virtual void enterEvent( QEvent * ); 453 virtual void enterEvent( QEvent * );
446 virtual void leaveEvent( QEvent * ); 454 virtual void leaveEvent( QEvent * );
447 455
448 virtual void focusInEvent( QFocusEvent * ); 456 virtual void focusInEvent( QFocusEvent * );
449 virtual void focusOutEvent( QFocusEvent * ); 457 virtual void focusOutEvent( QFocusEvent * );
450 458
451 459
452 /** Overload this method to be told when a drag should be started. 460 /** Overload this method to be told when a drag should be started.
453 * In most cases you will want to start a drag event with the currently 461 * In most cases you will want to start a drag event with the currently
454 * selected item. 462 * selected item.
455 */ 463 */
456 virtual void startDrag(); 464 virtual void startDrag();
457 465
458 private slots: 466 private slots:
459 /** Called by a timer to display a label with truncated text. 467 /** Called by a timer to display a label with truncated text.
460 * Pop up a label, if there is a field with obscured text or 468 * Pop up a label, if there is a field with obscured text or
461 * label at the cursor position. 469 * label at the cursor position.
462 */ 470 */
463 void tryShowFullText(); 471 void tryShowFullText();
464 472
465 private: 473 private:
466 /** draws and erases the rubber bands while columns are resized. 474 /** draws and erases the rubber bands while columns are resized.
467 * @p pos is the horizontal position inside the viewport to use as 475 * @p pos is the horizontal position inside the viewport to use as
468 * the anchor. 476 * the anchor.
469 * If pos is 0, only erase is done. 477 * If pos is 0, only erase is done.
470 */ 478 */
471 void drawRubberBands( int pos ); 479 void drawRubberBands( int pos );
472 480
473 CardViewPrivate *d; 481 CardViewPrivate *d;
474}; 482};
475 483
476#endif 484#endif
diff --git a/kaddressbook/views/colorlistbox.cpp b/kaddressbook/views/colorlistbox.cpp
index 2bddca6..46a59a1 100644
--- a/kaddressbook/views/colorlistbox.cpp
+++ b/kaddressbook/views/colorlistbox.cpp
@@ -1,245 +1,250 @@
1/* 1/*
2 * kmail: KDE mail client 2 * kmail: KDE mail client
3 * This file: Copyright (C) 2000 Espen Sand, espen@kde.org 3 * This file: Copyright (C) 2000 Espen Sand, espen@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 */ 19 */
20 20
21#include <qpainter.h> 21#include <qpainter.h>
22//Added by qt3to4:
23#include <QDragEnterEvent>
24#include <QDropEvent>
25#include <QDragMoveEvent>
26#include <QDragLeaveEvent>
22 27
23#include <kcolordialog.h> 28#include <kcolordialog.h>
24 29
25#ifndef KAB_EMBEDDED 30#ifndef KAB_EMBEDDED
26#include <kcolordrag.h> 31#include <kcolordrag.h>
27#endif //KAB_EMBEDDED 32#endif //KAB_EMBEDDED
28 33
29#include "colorlistbox.h" 34#include "colorlistbox.h"
30#ifdef DESKTOP_VERSION 35#ifdef DESKTOP_VERSION
31#include <qcolordialog.h> 36#include <qcolordialog.h>
32#endif 37#endif
33 38
34ColorListBox::ColorListBox( QWidget *parent, const char *name, WFlags f ) 39ColorListBox::ColorListBox( QWidget *parent, const char *name, Qt::WFlags f )
35 :KListBox( parent, name, f ), mCurrentOnDragEnter(-1) 40 :KListBox( parent, name, f ), mCurrentOnDragEnter(-1)
36{ 41{
37 connect( this, SIGNAL(selected(int)), this, SLOT(newColor(int)) ); 42 connect( this, SIGNAL(selected(int)), this, SLOT(newColor(int)) );
38 connect( this, SIGNAL(clicked(QListBoxItem *)), this, SLOT(slotNewColor(QListBoxItem *)) ); 43 connect( this, SIGNAL(clicked(Q3ListBoxItem *)), this, SLOT(slotNewColor(Q3ListBoxItem *)) );
39 setAcceptDrops( true); 44 setAcceptDrops( true);
40} 45}
41 46
42 47
43void ColorListBox::setEnabled( bool state ) 48void ColorListBox::setEnabled( bool state )
44{ 49{
45 if( state == isEnabled() ) 50 if( state == isEnabled() )
46 { 51 {
47 return; 52 return;
48 } 53 }
49 54
50 QListBox::setEnabled( state ); 55 Q3ListBox::setEnabled( state );
51 for( uint i=0; i<count(); i++ ) 56 for( uint i=0; i<count(); i++ )
52 { 57 {
53 updateItem( i ); 58 updateItem( i );
54 } 59 }
55} 60}
56 61
57 62
58void ColorListBox::setColor( uint index, const QColor &color ) 63void ColorListBox::setColor( uint index, const QColor &color )
59{ 64{
60 if( index < count() ) 65 if( index < count() )
61 { 66 {
62 ColorListItem *colorItem = (ColorListItem*)item(index); 67 ColorListItem *colorItem = (ColorListItem*)item(index);
63 colorItem->setColor(color); 68 colorItem->setColor(color);
64 updateItem( colorItem ); 69 updateItem( colorItem );
65 } 70 }
66} 71}
67 72
68 73
69QColor ColorListBox::color( uint index ) const 74QColor ColorListBox::color( uint index ) const
70{ 75{
71 if( index < count() ) 76 if( index < count() )
72 { 77 {
73 ColorListItem *colorItem = (ColorListItem*)item(index); 78 ColorListItem *colorItem = (ColorListItem*)item(index);
74 return( colorItem->color() ); 79 return( colorItem->color() );
75 } 80 }
76 else 81 else
77 { 82 {
78 return( black ); 83 return( Qt::black );
79 } 84 }
80} 85}
81void ColorListBox::slotNewColor(QListBoxItem * i) 86void ColorListBox::slotNewColor(Q3ListBoxItem * i)
82{ 87{
83 if ( i ) 88 if ( i )
84 newColor( index( i ) ); 89 newColor( index( i ) );
85} 90}
86 91
87void ColorListBox::newColor( int index ) 92void ColorListBox::newColor( int index )
88{ 93{
89 if( isEnabled() == false ) 94 if( isEnabled() == false )
90 { 95 {
91 return; 96 return;
92 } 97 }
93 98
94 if( (uint)index < count() ) 99 if( (uint)index < count() )
95 { 100 {
96 QColor c = color( index ); 101 QColor c = color( index );
97#ifndef KAB_EMBEDDED 102#ifndef KAB_EMBEDDED
98 if( KColorDialog::getColor( c, this ) != QDialog::Rejected ) 103 if( KColorDialog::getColor( c, this ) != QDialog::Rejected )
99 { 104 {
100 setColor( index, c ); 105 setColor( index, c );
101 } 106 }
102#else //KAB_EMBEDDED 107#else //KAB_EMBEDDED
103#ifdef DESKTOP_VERSION 108#ifdef DESKTOP_VERSION
104 QColor col = QColorDialog::getColor ( c ); 109 QColor col = QColorDialog::getColor ( c );
105 if ( col.isValid () ) { 110 if ( col.isValid () ) {
106 setColor( index, col ); 111 setColor( index, col );
107 } 112 }
108#else 113#else
109 KColorDialog* k = new KColorDialog( this ); 114 KColorDialog* k = new KColorDialog( this );
110 k->setColor( c ); 115 k->setColor( c );
111 int res = k->exec(); 116 int res = k->exec();
112 if ( res ) { 117 if ( res ) {
113 setColor( index, k->getColor() ); 118 setColor( index, k->getColor() );
114 } 119 }
115 delete k; 120 delete k;
116#endif 121#endif
117#endif //KAB_EMBEDDED 122#endif //KAB_EMBEDDED
118 123
119 } 124 }
120} 125}
121 126
122 127
123void ColorListBox::dragEnterEvent( QDragEnterEvent *e ) 128void ColorListBox::dragEnterEvent( QDragEnterEvent *e )
124{ 129{
125#ifndef KAB_EMBEDDED 130#ifndef KAB_EMBEDDED
126 if( KColorDrag::canDecode(e) && isEnabled() ) 131 if( KColorDrag::canDecode(e) && isEnabled() )
127 { 132 {
128 mCurrentOnDragEnter = currentItem(); 133 mCurrentOnDragEnter = currentItem();
129 e->accept( true ); 134 e->accept( true );
130 } 135 }
131 else 136 else
132 { 137 {
133 mCurrentOnDragEnter = -1; 138 mCurrentOnDragEnter = -1;
134 e->accept( false ); 139 e->accept( false );
135 } 140 }
136#else //KAB_EMBEDDED 141#else //KAB_EMBEDDED
137qDebug("ColorListBox::dragEnterEvent drag&drop currently not supported"); 142qDebug("ColorListBox::dragEnterEvent drag&drop currently not supported");
138#endif //KAB_EMBEDDED 143#endif //KAB_EMBEDDED
139 144
140} 145}
141 146
142 147
143void ColorListBox::dragLeaveEvent( QDragLeaveEvent * ) 148void ColorListBox::dragLeaveEvent( QDragLeaveEvent * )
144{ 149{
145#ifndef KAB_EMBEDDED 150#ifndef KAB_EMBEDDED
146 151
147 if( mCurrentOnDragEnter != -1 ) 152 if( mCurrentOnDragEnter != -1 )
148 { 153 {
149 setCurrentItem( mCurrentOnDragEnter ); 154 setCurrentItem( mCurrentOnDragEnter );
150 mCurrentOnDragEnter = -1; 155 mCurrentOnDragEnter = -1;
151 } 156 }
152#else //KAB_EMBEDDED 157#else //KAB_EMBEDDED
153qDebug("ColorListBox::dragLeaveEvent drag&drop currently not supported"); 158qDebug("ColorListBox::dragLeaveEvent drag&drop currently not supported");
154#endif //KAB_EMBEDDED 159#endif //KAB_EMBEDDED
155} 160}
156 161
157 162
158void ColorListBox::dragMoveEvent( QDragMoveEvent *e ) 163void ColorListBox::dragMoveEvent( QDragMoveEvent *e )
159{ 164{
160#ifndef KAB_EMBEDDED 165#ifndef KAB_EMBEDDED
161 if( KColorDrag::canDecode(e) && isEnabled() ) 166 if( KColorDrag::canDecode(e) && isEnabled() )
162 { 167 {
163 ColorListItem *item = (ColorListItem*)itemAt( e->pos() ); 168 ColorListItem *item = (ColorListItem*)itemAt( e->pos() );
164 if( item != 0 ) 169 if( item != 0 )
165 { 170 {
166 setCurrentItem ( item ); 171 setCurrentItem ( item );
167 } 172 }
168 } 173 }
169#else //KAB_EMBEDDED 174#else //KAB_EMBEDDED
170qDebug("ColorListBox::dragMoveEvent drag&drop currently not supported"); 175qDebug("ColorListBox::dragMoveEvent drag&drop currently not supported");
171#endif //KAB_EMBEDDED 176#endif //KAB_EMBEDDED
172 177
173} 178}
174 179
175 180
176void ColorListBox::dropEvent( QDropEvent *e ) 181void ColorListBox::dropEvent( QDropEvent *e )
177{ 182{
178#ifndef KAB_EMBEDDED 183#ifndef KAB_EMBEDDED
179 QColor color; 184 QColor color;
180 if( KColorDrag::decode( e, color ) ) 185 if( KColorDrag::decode( e, color ) )
181 { 186 {
182 int index = currentItem(); 187 int index = currentItem();
183 if( index != -1 ) 188 if( index != -1 )
184 { 189 {
185 ColorListItem *colorItem = (ColorListItem*)item(index); 190 ColorListItem *colorItem = (ColorListItem*)item(index);
186 colorItem->setColor(color); 191 colorItem->setColor(color);
187 triggerUpdate( false ); // Redraw item 192 triggerUpdate( false ); // Redraw item
188 } 193 }
189 mCurrentOnDragEnter = -1; 194 mCurrentOnDragEnter = -1;
190 } 195 }
191 196
192#else //KAB_EMBEDDED 197#else //KAB_EMBEDDED
193qDebug("ColorListBox::dropEvent drag&drop currently not supported"); 198qDebug("ColorListBox::dropEvent drag&drop currently not supported");
194#endif //KAB_EMBEDDED 199#endif //KAB_EMBEDDED
195 200
196} 201}
197 202
198 203
199 204
200ColorListItem::ColorListItem( const QString &text, const QColor &color ) 205ColorListItem::ColorListItem( const QString &text, const QColor &color )
201 : QListBoxItem(), mColor( color ), mBoxWidth( 30 ) 206 : Q3ListBoxItem(), mColor( color ), mBoxWidth( 30 )
202{ 207{
203 setText( text ); 208 setText( text );
204} 209}
205 210
206 211
207const QColor &ColorListItem::color( void ) 212const QColor &ColorListItem::color( void )
208{ 213{
209 return( mColor ); 214 return( mColor );
210} 215}
211 216
212 217
213void ColorListItem::setColor( const QColor &color ) 218void ColorListItem::setColor( const QColor &color )
214{ 219{
215 mColor = color; 220 mColor = color;
216} 221}
217 222
218 223
219void ColorListItem::paint( QPainter *p ) 224void ColorListItem::paint( QPainter *p )
220{ 225{
221 QFontMetrics fm = p->fontMetrics(); 226 QFontMetrics fm = p->fontMetrics();
222 int h = fm.height(); 227 int h = fm.height();
223 228
224 p->drawText( mBoxWidth+3*2, fm.ascent() + fm.leading()/2, text() ); 229 p->drawText( mBoxWidth+3*2, fm.ascent() + fm.leading()/2, text() );
225 230
226 p->setPen( Qt::black ); 231 p->setPen( Qt::black );
227 p->drawRect( 3, 1, mBoxWidth, h-1 ); 232 p->drawRect( 3, 1, mBoxWidth, h-1 );
228 p->fillRect( 4, 2, mBoxWidth-2, h-3, mColor ); 233 p->fillRect( 4, 2, mBoxWidth-2, h-3, mColor );
229} 234}
230 235
231 236
232int ColorListItem::height(const QListBox *lb ) const 237int ColorListItem::height(const Q3ListBox *lb ) const
233{ 238{
234 return( lb->fontMetrics().lineSpacing()+1 ); 239 return( lb->fontMetrics().lineSpacing()+1 );
235} 240}
236 241
237 242
238int ColorListItem::width(const QListBox *lb ) const 243int ColorListItem::width(const Q3ListBox *lb ) const
239{ 244{
240 return( mBoxWidth + lb->fontMetrics().width( text() ) + 6 ); 245 return( mBoxWidth + lb->fontMetrics().width( text() ) + 6 );
241} 246}
242 247
243#ifndef KAB_EMBEDDED 248#ifndef KAB_EMBEDDED_
244#include "colorlistbox.moc" 249#include "moc_colorlistbox.cpp"
245#endif //KAB_EMBEDDED 250#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/colorlistbox.h b/kaddressbook/views/colorlistbox.h
index bb91484..31a8085 100644
--- a/kaddressbook/views/colorlistbox.h
+++ b/kaddressbook/views/colorlistbox.h
@@ -1,77 +1,82 @@
1/* 1/*
2 * kmail: KDE mail client 2 * kmail: KDE mail client
3 * This file: Copyright (C) 2000 Espen Sand, espen@kde.org 3 * This file: Copyright (C) 2000 Espen Sand, espen@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 */ 19 */
20 20
21#ifndef _COLOR_LISTBOX_H_ 21#ifndef _COLOR_LISTBOX_H_
22#define _COLOR_LISTBOX_H_ 22#define _COLOR_LISTBOX_H_
23 23
24#include <klistbox.h> 24#include <klistbox.h>
25//Added by qt3to4:
26#include <QDragMoveEvent>
27#include <QDragLeaveEvent>
28#include <QDropEvent>
29#include <QDragEnterEvent>
25 30
26class QDragEnterEvent; 31class QDragEnterEvent;
27class QDragLeaveEvent; 32class QDragLeaveEvent;
28class QDragMoveEvent; 33class QDragMoveEvent;
29class QDropEvent; 34class QDropEvent;
30 35
31class ColorListBox : public KListBox 36class ColorListBox : public KListBox
32{ 37{
33 Q_OBJECT 38 Q_OBJECT
34 39
35 public: 40 public:
36 ColorListBox( QWidget *parent=0, const char * name=0, WFlags f=0 ); 41 ColorListBox( QWidget *parent=0, const char * name=0, Qt::WFlags f=0 );
37 void setColor( uint index, const QColor &color ); 42 void setColor( uint index, const QColor &color );
38 QColor color( uint index ) const; 43 QColor color( uint index ) const;
39 44
40 public slots: 45 public slots:
41 virtual void setEnabled( bool state ); 46 virtual void setEnabled( bool state );
42 47
43 protected: 48 protected:
44 void dragEnterEvent( QDragEnterEvent *e ); 49 void dragEnterEvent( QDragEnterEvent *e );
45 void dragLeaveEvent( QDragLeaveEvent *e ); 50 void dragLeaveEvent( QDragLeaveEvent *e );
46 void dragMoveEvent( QDragMoveEvent *e ); 51 void dragMoveEvent( QDragMoveEvent *e );
47 void dropEvent( QDropEvent *e ); 52 void dropEvent( QDropEvent *e );
48 53
49 private slots: 54 private slots:
50 void newColor( int index ); 55 void newColor( int index );
51 void slotNewColor(QListBoxItem * i); 56 void slotNewColor(Q3ListBoxItem * i);
52 57
53 private: 58 private:
54 int mCurrentOnDragEnter; 59 int mCurrentOnDragEnter;
55 60
56}; 61};
57 62
58 63
59class ColorListItem : public QListBoxItem 64class ColorListItem : public Q3ListBoxItem
60{ 65{
61 public: 66 public:
62 ColorListItem( const QString &text, const QColor &color=Qt::black ); 67 ColorListItem( const QString &text, const QColor &color=Qt::black );
63 const QColor &color( void ); 68 const QColor &color( void );
64 void setColor( const QColor &color ); 69 void setColor( const QColor &color );
65 70
66 protected: 71 protected:
67 virtual void paint( QPainter * ); 72 virtual void paint( QPainter * );
68 virtual int height( const QListBox * ) const; 73 virtual int height( const Q3ListBox * ) const;
69 virtual int width( const QListBox * ) const; 74 virtual int width( const Q3ListBox * ) const;
70 75
71 private: 76 private:
72 QColor mColor; 77 QColor mColor;
73 int mBoxWidth; 78 int mBoxWidth;
74}; 79};
75 80
76#endif 81#endif
77 82
diff --git a/kaddressbook/views/configurecardviewdialog.cpp b/kaddressbook/views/configurecardviewdialog.cpp
index e0fbd21..b6327fe 100644
--- a/kaddressbook/views/configurecardviewdialog.cpp
+++ b/kaddressbook/views/configurecardviewdialog.cpp
@@ -1,369 +1,372 @@
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#include <qstring.h> 24#include <qstring.h>
25#include <qlayout.h> 25#include <qlayout.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qcheckbox.h> 27#include <qcheckbox.h>
28#include <qvbox.h> 28#include <q3vbox.h>
29#include <qgroupbox.h> 29#include <q3groupbox.h>
30#include <qspinbox.h> 30#include <qspinbox.h>
31#include <qtabwidget.h> 31#include <qtabwidget.h>
32#include <qwhatsthis.h> 32#include <q3whatsthis.h>
33//Added by qt3to4:
34#include <Q3GridLayout>
35#include <Q3Frame>
33 36
34#include <kdebug.h> 37#include <kdebug.h>
35#include <kglobal.h> 38#include <kglobal.h>
36#include <kglobalsettings.h> 39#include <kglobalsettings.h>
37#include <klocale.h> 40#include <klocale.h>
38#include <kiconloader.h> 41#include <kiconloader.h>
39#include <kconfig.h> 42#include <kconfig.h>
40#include <kfontdialog.h> 43#include <kfontdialog.h>
41 44
42#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
43#include <kpushbutton.h> 46#include <kpushbutton.h>
44#else //KAB_EMBEDDED 47#else //KAB_EMBEDDED
45#include <qpushbutton.h> 48#include <qpushbutton.h>
46#endif //KAB_EMBEDDED 49#endif //KAB_EMBEDDED
47 50
48#include "colorlistbox.h" 51#include "colorlistbox.h"
49 52
50#include "configurecardviewdialog.h" 53#include "configurecardviewdialog.h"
51 54
52///////////////////////////////// 55/////////////////////////////////
53// ConfigureCardViewDialog 56// ConfigureCardViewDialog
54 57
55ConfigureCardViewWidget::ConfigureCardViewWidget( KABC::AddressBook *ab, QWidget *parent, 58ConfigureCardViewWidget::ConfigureCardViewWidget( KABC::AddressBook *ab, QWidget *parent,
56 const char *name ) 59 const char *name )
57 : ViewConfigureWidget( ab, parent, name ) 60 : ViewConfigureWidget( ab, parent, name )
58{ 61{
59#ifndef KAB_EMBEDDED 62#ifndef KAB_EMBEDDED
60 QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, 63 QWidget *page = addPage( i18n( "Look & Feel" ), QString::null,
61 DesktopIcon( "looknfeel" ) ); 64 DesktopIcon( "looknfeel" ) );
62#else //KAB_EMBEDDED 65#else //KAB_EMBEDDED
63 QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, 66 QWidget *page = addPage( i18n( "Look & Feel" ), QString::null,
64 KGlobal::iconLoader()->loadIcon( "looknfeel", 67 KGlobal::iconLoader()->loadIcon( "looknfeel",
65 KIcon::Panel ) ); 68 KIcon::Panel ) );
66#endif //KAB_EMBEDDED 69#endif //KAB_EMBEDDED
67 70
68 mAdvancedPage = new CardViewLookNFeelPage( page ); 71 mAdvancedPage = new CardViewLookNFeelPage( page );
69} 72}
70 73
71ConfigureCardViewWidget::~ConfigureCardViewWidget() 74ConfigureCardViewWidget::~ConfigureCardViewWidget()
72{ 75{
73} 76}
74 77
75void ConfigureCardViewWidget::restoreSettings( KConfig *config ) 78void ConfigureCardViewWidget::restoreSettings( KConfig *config )
76{ 79{
77 ViewConfigureWidget::restoreSettings( config ); 80 ViewConfigureWidget::restoreSettings( config );
78 81
79 mAdvancedPage->restoreSettings( config ); 82 mAdvancedPage->restoreSettings( config );
80} 83}
81 84
82void ConfigureCardViewWidget::saveSettings( KConfig *config ) 85void ConfigureCardViewWidget::saveSettings( KConfig *config )
83{ 86{
84 ViewConfigureWidget::saveSettings( config ); 87 ViewConfigureWidget::saveSettings( config );
85 88
86 mAdvancedPage->saveSettings( config ); 89 mAdvancedPage->saveSettings( config );
87} 90}
88 91
89//////////////////////// 92////////////////////////
90// CardViewLookNFeelPage 93// CardViewLookNFeelPage
91CardViewLookNFeelPage::CardViewLookNFeelPage( QWidget *parent, const char *name ) 94CardViewLookNFeelPage::CardViewLookNFeelPage( QWidget *parent, const char *name )
92 : QVBox( parent, name ) 95 : Q3VBox( parent, name )
93{ 96{
94 initGUI(); 97 initGUI();
95} 98}
96 99
97CardViewLookNFeelPage::~CardViewLookNFeelPage() 100CardViewLookNFeelPage::~CardViewLookNFeelPage()
98{ 101{
99} 102}
100 103
101void CardViewLookNFeelPage::restoreSettings( KConfig *config ) 104void CardViewLookNFeelPage::restoreSettings( KConfig *config )
102{ 105{
103 // colors 106 // colors
104 cbEnableCustomColors->setChecked( config->readBoolEntry( "EnableCustomColors", false ) ); 107 cbEnableCustomColors->setChecked( config->readBoolEntry( "EnableCustomColors", false ) );
105 QColor c; 108 QColor c;
106qDebug("CardViewLookNFeelPage::restoreSettings make base color configurable"); 109qDebug("CardViewLookNFeelPage::restoreSettings make base color configurable");
107 110
108#ifndef KAB_EMBEDDED 111#ifndef KAB_EMBEDDED
109 c = KGlobalSettings::baseColor(); 112 c = KGlobalSettings::baseColor();
110#else //KAB_EMBEDDED 113#else //KAB_EMBEDDED
111 c = QColor(0,0,0); 114 c = QColor(0,0,0);
112#endif //KAB_EMBEDDED 115#endif //KAB_EMBEDDED
113 116
114 c = colorGroup().background(); 117 c = colorGroup().background();
115 lbColors->insertItem( new ColorListItem( i18n("Background Color"), 118 lbColors->insertItem( new ColorListItem( i18n("Background Color"),
116 config->readColorEntry( "BackgroundColor", &c ) ) ); 119 config->readColorEntry( "BackgroundColor", &c ) ) );
117 c = colorGroup().foreground(); 120 c = colorGroup().foreground();
118 lbColors->insertItem( new ColorListItem( i18n("Text Color"), 121 lbColors->insertItem( new ColorListItem( i18n("Text Color"),
119 config->readColorEntry( "TextColor", &c ) ) ); 122 config->readColorEntry( "TextColor", &c ) ) );
120 c = colorGroup().button(); 123 c = colorGroup().button();
121 lbColors->insertItem( new ColorListItem( i18n("Header, Border and Separator Color"), 124 lbColors->insertItem( new ColorListItem( i18n("Header, Border and Separator Color"),
122 config->readColorEntry( "HeaderColor", &c ) ) ); 125 config->readColorEntry( "HeaderColor", &c ) ) );
123 c = colorGroup().buttonText(); 126 c = colorGroup().buttonText();
124 lbColors->insertItem( new ColorListItem( i18n("Header Text Color"), 127 lbColors->insertItem( new ColorListItem( i18n("Header Text Color"),
125 config->readColorEntry( "HeaderTextColor", &c ) ) ); 128 config->readColorEntry( "HeaderTextColor", &c ) ) );
126 c = colorGroup().highlight(); 129 c = colorGroup().highlight();
127 lbColors->insertItem( new ColorListItem( i18n("Highlight Color"), 130 lbColors->insertItem( new ColorListItem( i18n("Highlight Color"),
128 config->readColorEntry( "HighlightColor", &c ) ) ); 131 config->readColorEntry( "HighlightColor", &c ) ) );
129 c = colorGroup().highlightedText(); 132 c = colorGroup().highlightedText();
130 lbColors->insertItem( new ColorListItem( i18n("Highlighted Text Color"), 133 lbColors->insertItem( new ColorListItem( i18n("Highlighted Text Color"),
131 config->readColorEntry( "HighlightedTextColor", &c ) ) ); 134 config->readColorEntry( "HighlightedTextColor", &c ) ) );
132 135
133 enableColors(); 136 enableColors();
134 137
135 // fonts 138 // fonts
136 QFont fnt = font(); 139 QFont fnt = font();
137 updateFontLabel( config->readFontEntry( "TextFont", &fnt ), (QLabel*)lTextFont ); 140 updateFontLabel( config->readFontEntry( "TextFont", &fnt ), (QLabel*)lTextFont );
138 fnt.setBold( true ); 141 fnt.setBold( true );
139 updateFontLabel( config->readFontEntry( "HeaderFont", &fnt ), (QLabel*)lHeaderFont ); 142 updateFontLabel( config->readFontEntry( "HeaderFont", &fnt ), (QLabel*)lHeaderFont );
140 cbEnableCustomFonts->setChecked( config->readBoolEntry( "EnableCustomFonts", false ) ); 143 cbEnableCustomFonts->setChecked( config->readBoolEntry( "EnableCustomFonts", false ) );
141 enableFonts(); 144 enableFonts();
142 145
143 // layout 146 // layout
144 sbMargin->setValue( config->readNumEntry( "ItemMargin", 0 ) ); 147 sbMargin->setValue( config->readNumEntry( "ItemMargin", 0 ) );
145 sbSpacing->setValue( config->readNumEntry( "ItemSpacing", 10 ) ); 148 sbSpacing->setValue( config->readNumEntry( "ItemSpacing", 10 ) );
146 sbSepWidth->setValue( config->readNumEntry( "SeparatorWidth", 2 ) ); 149 sbSepWidth->setValue( config->readNumEntry( "SeparatorWidth", 2 ) );
147 cbDrawSeps->setChecked( config->readBoolEntry( "DrawSeparators", true ) ); 150 cbDrawSeps->setChecked( config->readBoolEntry( "DrawSeparators", true ) );
148 cbDrawBorders->setChecked( config->readBoolEntry( "DrawBorder", true ) ); 151 cbDrawBorders->setChecked( config->readBoolEntry( "DrawBorder", true ) );
149 152
150 // behaviour 153 // behaviour
151 cbShowFieldLabels->setChecked( config->readBoolEntry( "DrawFieldLabels", false ) ); 154 cbShowFieldLabels->setChecked( config->readBoolEntry( "DrawFieldLabels", false ) );
152 cbShowEmptyFields->setChecked( config->readBoolEntry( "ShowEmptyFields", false ) ); 155 cbShowEmptyFields->setChecked( config->readBoolEntry( "ShowEmptyFields", false ) );
153} 156}
154 157
155void CardViewLookNFeelPage::saveSettings( KConfig *config ) 158void CardViewLookNFeelPage::saveSettings( KConfig *config )
156{ 159{
157 // colors 160 // colors
158 config->writeEntry( "EnableCustomColors", cbEnableCustomColors->isChecked() ); 161 config->writeEntry( "EnableCustomColors", cbEnableCustomColors->isChecked() );
159 if ( cbEnableCustomColors->isChecked() ) // ?? - Hmmm. 162 if ( cbEnableCustomColors->isChecked() ) // ?? - Hmmm.
160 { 163 {
161 config->writeEntry( "BackgroundColor", lbColors->color( 0 ) ); 164 config->writeEntry( "BackgroundColor", lbColors->color( 0 ) );
162 config->writeEntry( "TextColor", lbColors->color( 1 ) ); 165 config->writeEntry( "TextColor", lbColors->color( 1 ) );
163 config->writeEntry( "HeaderColor", lbColors->color( 2 ) ); 166 config->writeEntry( "HeaderColor", lbColors->color( 2 ) );
164 config->writeEntry( "HeaderTextColor", lbColors->color( 3 ) ); 167 config->writeEntry( "HeaderTextColor", lbColors->color( 3 ) );
165 config->writeEntry( "HighlightColor", lbColors->color( 4 ) ); 168 config->writeEntry( "HighlightColor", lbColors->color( 4 ) );
166 config->writeEntry( "HighlightedTextColor", lbColors->color( 5 ) ); 169 config->writeEntry( "HighlightedTextColor", lbColors->color( 5 ) );
167 } 170 }
168 // fonts 171 // fonts
169 config->writeEntry( "EnableCustomFonts", cbEnableCustomFonts->isChecked() ); 172 config->writeEntry( "EnableCustomFonts", cbEnableCustomFonts->isChecked() );
170 if ( cbEnableCustomFonts->isChecked() ) 173 if ( cbEnableCustomFonts->isChecked() )
171 { 174 {
172 config->writeEntry( "TextFont", lTextFont->font() ); 175 config->writeEntry( "TextFont", lTextFont->font() );
173 config->writeEntry( "HeaderFont", lHeaderFont->font() ); 176 config->writeEntry( "HeaderFont", lHeaderFont->font() );
174 } 177 }
175 // layout 178 // layout
176 config->writeEntry( "ItemMargin", sbMargin->value() ); 179 config->writeEntry( "ItemMargin", sbMargin->value() );
177 config->writeEntry( "ItemSpacing", sbSpacing->value() ); 180 config->writeEntry( "ItemSpacing", sbSpacing->value() );
178 config->writeEntry( "SeparatorWidth", sbSepWidth->value() ); 181 config->writeEntry( "SeparatorWidth", sbSepWidth->value() );
179 config->writeEntry("DrawBorder", cbDrawBorders->isChecked()); 182 config->writeEntry("DrawBorder", cbDrawBorders->isChecked());
180 config->writeEntry("DrawSeparators", cbDrawSeps->isChecked()); 183 config->writeEntry("DrawSeparators", cbDrawSeps->isChecked());
181 184
182 // behaviour 185 // behaviour
183 config->writeEntry("DrawFieldLabels", cbShowFieldLabels->isChecked()); 186 config->writeEntry("DrawFieldLabels", cbShowFieldLabels->isChecked());
184 config->writeEntry("ShowEmptyFields", cbShowEmptyFields->isChecked()); 187 config->writeEntry("ShowEmptyFields", cbShowEmptyFields->isChecked());
185} 188}
186 189
187void CardViewLookNFeelPage::setTextFont() 190void CardViewLookNFeelPage::setTextFont()
188{ 191{
189 QFont f( lTextFont->font() ); 192 QFont f( lTextFont->font() );
190#ifndef KAB_EMBEDDED 193#ifndef KAB_EMBEDDED
191 if ( KFontDialog::getFont( f, false, this ) == QDialog::Accepted ) 194 if ( KFontDialog::getFont( f, false, this ) == QDialog::Accepted )
192 updateFontLabel( f, lTextFont ); 195 updateFontLabel( f, lTextFont );
193#else //KAB_EMBEDDED 196#else //KAB_EMBEDDED
194 bool ok; 197 bool ok;
195 QFont fout = KFontDialog::getFont( f, ok); 198 QFont fout = KFontDialog::getFont( f, ok);
196 if ( ok ) 199 if ( ok )
197 updateFontLabel( fout, lTextFont ); 200 updateFontLabel( fout, lTextFont );
198#endif //KAB_EMBEDDED 201#endif //KAB_EMBEDDED
199} 202}
200 203
201void CardViewLookNFeelPage::setHeaderFont() 204void CardViewLookNFeelPage::setHeaderFont()
202{ 205{
203 QFont f( lHeaderFont->font() ); 206 QFont f( lHeaderFont->font() );
204#ifndef KAB_EMBEDDED 207#ifndef KAB_EMBEDDED
205 if ( KFontDialog::getFont( f,false, this ) == QDialog::Accepted ) 208 if ( KFontDialog::getFont( f,false, this ) == QDialog::Accepted )
206 updateFontLabel( f, lHeaderFont ); 209 updateFontLabel( f, lHeaderFont );
207#else //KAB_EMBEDDED 210#else //KAB_EMBEDDED
208 bool ok; 211 bool ok;
209 QFont fout = KFontDialog::getFont( f, ok); 212 QFont fout = KFontDialog::getFont( f, ok);
210 if ( ok ) 213 if ( ok )
211 updateFontLabel( fout, lHeaderFont ); 214 updateFontLabel( fout, lHeaderFont );
212#endif //KAB_EMBEDDED 215#endif //KAB_EMBEDDED
213} 216}
214 217
215void CardViewLookNFeelPage::enableFonts() 218void CardViewLookNFeelPage::enableFonts()
216{ 219{
217 vbFonts->setEnabled( cbEnableCustomFonts->isChecked() ); 220 vbFonts->setEnabled( cbEnableCustomFonts->isChecked() );
218 if ( cbEnableCustomFonts->isChecked() ) 221 if ( cbEnableCustomFonts->isChecked() )
219 vbFonts->setFocus(); 222 vbFonts->setFocus();
220} 223}
221 224
222void CardViewLookNFeelPage::enableColors() 225void CardViewLookNFeelPage::enableColors()
223{ 226{
224 lbColors->setEnabled( cbEnableCustomColors->isChecked() ); 227 lbColors->setEnabled( cbEnableCustomColors->isChecked() );
225 if ( cbEnableCustomColors->isChecked() ) 228 if ( cbEnableCustomColors->isChecked() )
226 lbColors->setFocus(); 229 lbColors->setFocus();
227} 230}
228 231
229void CardViewLookNFeelPage::initGUI() 232void CardViewLookNFeelPage::initGUI()
230{ 233{
231 int spacing = KDialog::spacingHint(); 234 int spacing = KDialog::spacingHint();
232 int margin = KDialog::marginHint(); 235 int margin = KDialog::marginHint();
233 236
234 QTabWidget *tabs = new QTabWidget( this ); 237 QTabWidget *tabs = new QTabWidget( this );
235 238
236 // Layout 239 // Layout
237 QVBox *loTab = new QVBox( this, "layouttab" ); 240 Q3VBox *loTab = new Q3VBox( this, "layouttab" );
238 241
239 loTab->setSpacing( spacing ); 242 loTab->setSpacing( spacing );
240 loTab->setMargin( margin ); 243 loTab->setMargin( margin );
241 244
242 QGroupBox *gbGeneral = new QGroupBox( 1, Qt::Horizontal, i18n("General"), loTab ); 245 Q3GroupBox *gbGeneral = new Q3GroupBox( 1, Qt::Horizontal, i18n("General"), loTab );
243 246
244 cbDrawSeps = new QCheckBox( i18n("Draw &separators"), gbGeneral ); 247 cbDrawSeps = new QCheckBox( i18n("Draw &separators"), gbGeneral );
245 248
246 QHBox *hbSW = new QHBox( gbGeneral ); 249 Q3HBox *hbSW = new Q3HBox( gbGeneral );
247 QLabel *lSW = new QLabel( i18n("Separator &width:"), hbSW ); 250 QLabel *lSW = new QLabel( i18n("Separator &width:"), hbSW );
248 sbSepWidth = new QSpinBox( 1, 50, 1, hbSW ); 251 sbSepWidth = new QSpinBox( 1, 50, 1, hbSW );
249 lSW->setBuddy( sbSepWidth); 252 lSW->setBuddy( sbSepWidth);
250 253
251 QHBox *hbPadding = new QHBox( gbGeneral ); 254 Q3HBox *hbPadding = new Q3HBox( gbGeneral );
252 QLabel *lSpacing = new QLabel( i18n("&Padding:"), hbPadding ); 255 QLabel *lSpacing = new QLabel( i18n("&Padding:"), hbPadding );
253 sbSpacing = new QSpinBox( 0, 100, 1, hbPadding ); 256 sbSpacing = new QSpinBox( 0, 100, 1, hbPadding );
254 lSpacing->setBuddy( sbSpacing ); 257 lSpacing->setBuddy( sbSpacing );
255 258
256 QGroupBox *gbCards = new QGroupBox( 1, Qt::Horizontal, i18n("Cards"), loTab ); 259 Q3GroupBox *gbCards = new Q3GroupBox( 1, Qt::Horizontal, i18n("Cards"), loTab );
257 260
258 QHBox *hbMargin = new QHBox( gbCards ); 261 Q3HBox *hbMargin = new Q3HBox( gbCards );
259 QLabel *lMargin = new QLabel( i18n("&Margin:"), hbMargin ); 262 QLabel *lMargin = new QLabel( i18n("&Margin:"), hbMargin );
260 sbMargin = new QSpinBox( 0, 100, 1, hbMargin ); 263 sbMargin = new QSpinBox( 0, 100, 1, hbMargin );
261 lMargin->setBuddy( sbMargin ); 264 lMargin->setBuddy( sbMargin );
262 265
263 cbDrawBorders = new QCheckBox( i18n("Draw &borders"), gbCards ); 266 cbDrawBorders = new QCheckBox( i18n("Draw &borders"), gbCards );
264 267
265 loTab->setStretchFactor( new QWidget( loTab ), 1 ); 268 loTab->setStretchFactor( new QWidget( loTab ), 1 );
266 269
267 QWhatsThis::add( sbMargin, i18n( 270 Q3WhatsThis::add( sbMargin, i18n(
268 "The item margin is the distance (in pixels) between the item edge and the item data. Most noticeably, " 271 "The item margin is the distance (in pixels) between the item edge and the item data. Most noticeably, "
269 "incrementing the item margin will add space between the focus rectangle and the item data." 272 "incrementing the item margin will add space between the focus rectangle and the item data."
270 ) ); 273 ) );
271 QWhatsThis::add( lMargin, QWhatsThis::textFor( sbMargin ) ); 274 /* TODO:hacker: Q3WhatsThis::add( lMargin, Q3WhatsThis::textFor( sbMargin ) ); */
272 QWhatsThis::add( sbSpacing, i18n( 275 Q3WhatsThis::add( sbSpacing, i18n(
273 "The Item Spacing decides the distance (in pixels) between the items and anything else: the view " 276 "The Item Spacing decides the distance (in pixels) between the items and anything else: the view "
274 "borders, other items or column separators." 277 "borders, other items or column separators."
275 ) ); 278 ) );
276 QWhatsThis::add( lSpacing, QWhatsThis::textFor( sbSpacing ) ); 279 /* TODO:hacker: Q3WhatsThis::add( lSpacing, Q3WhatsThis::textFor( sbSpacing ) ); */
277 QWhatsThis::add( sbSepWidth, i18n("Sets the width of column separators") ); 280 Q3WhatsThis::add( sbSepWidth, i18n("Sets the width of column separators") );
278 QWhatsThis::add( lSW, QWhatsThis::textFor( sbSepWidth ) ); 281 /* TODO:hacker: Q3WhatsThis::add( lSW, Q3WhatsThis::textFor( sbSepWidth ) ); */
279 282
280 tabs->addTab( loTab, i18n("&Layout") ); 283 tabs->addTab( loTab, i18n("&Layout") );
281 284
282 // Colors 285 // Colors
283 QVBox *colorTab = new QVBox( this, "colortab" ); 286 Q3VBox *colorTab = new Q3VBox( this, "colortab" );
284 colorTab->setSpacing( spacing ); 287 colorTab->setSpacing( spacing );
285 colorTab->setMargin( spacing ); 288 colorTab->setMargin( spacing );
286 cbEnableCustomColors = new QCheckBox( i18n("&Enable custom Colors"), colorTab ); 289 cbEnableCustomColors = new QCheckBox( i18n("&Enable custom Colors"), colorTab );
287 connect( cbEnableCustomColors, SIGNAL(clicked()), this, SLOT(enableColors()) ); 290 connect( cbEnableCustomColors, SIGNAL(clicked()), this, SLOT(enableColors()) );
288 lbColors = new ColorListBox( colorTab ); 291 lbColors = new ColorListBox( colorTab );
289 tabs->addTab( colorTab, i18n("&Colors") ); 292 tabs->addTab( colorTab, i18n("&Colors") );
290 293
291 QWhatsThis::add( cbEnableCustomColors, i18n( 294 Q3WhatsThis::add( cbEnableCustomColors, i18n(
292 "If custom colors are enabled, you may choose the colors for the view below. " 295 "If custom colors are enabled, you may choose the colors for the view below. "
293 "Otherwise colors from your current KDE color scheme are used." 296 "Otherwise colors from your current KDE color scheme are used."
294 ) ); 297 ) );
295 QWhatsThis::add( lbColors, i18n( 298 Q3WhatsThis::add( lbColors, i18n(
296 "Double click or press RETURN on a item to select a color for the related strings in the view." 299 "Double click or press RETURN on a item to select a color for the related strings in the view."
297 ) ); 300 ) );
298 301
299 // Fonts 302 // Fonts
300 QVBox *fntTab = new QVBox( this, "fonttab" ); 303 Q3VBox *fntTab = new Q3VBox( this, "fonttab" );
301 304
302 fntTab->setSpacing( spacing ); 305 fntTab->setSpacing( spacing );
303 fntTab->setMargin( spacing ); 306 fntTab->setMargin( spacing );
304 307
305 cbEnableCustomFonts = new QCheckBox( i18n("&Enable custom fonts"), fntTab ); 308 cbEnableCustomFonts = new QCheckBox( i18n("&Enable custom fonts"), fntTab );
306 connect( cbEnableCustomFonts, SIGNAL(clicked()), this, SLOT(enableFonts()) ); 309 connect( cbEnableCustomFonts, SIGNAL(clicked()), this, SLOT(enableFonts()) );
307 310
308 vbFonts = new QWidget( fntTab ); 311 vbFonts = new QWidget( fntTab );
309 QGridLayout *gFnts = new QGridLayout( vbFonts, 2, 3 ); 312 Q3GridLayout *gFnts = new Q3GridLayout( vbFonts, 2, 3 );
310 gFnts->setSpacing( spacing ); 313 gFnts->setSpacing( spacing );
311 gFnts->setAutoAdd( true ); 314 gFnts->setAutoAdd( true );
312 gFnts->setColStretch( 1, 1 ); 315 gFnts->setColStretch( 1, 1 );
313 QLabel *lTFnt = new QLabel( i18n("&Text font:"), vbFonts ); 316 QLabel *lTFnt = new QLabel( i18n("&Text font:"), vbFonts );
314 lTextFont = new QLabel( vbFonts ); 317 lTextFont = new QLabel( vbFonts );
315 lTextFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); 318 lTextFont->setFrameStyle( Q3Frame::Panel|Q3Frame::Sunken );
316#ifndef KAB_EMBEDDED 319#ifndef KAB_EMBEDDED
317 btnFont = new KPushButton( i18n("Choose..."), vbFonts ); 320 btnFont = new KPushButton( i18n("Choose..."), vbFonts );
318#else //KAB_EMBEDDED 321#else //KAB_EMBEDDED
319 btnFont = new QPushButton( i18n("Choose..."), vbFonts ); 322 btnFont = new QPushButton( i18n("Choose..."), vbFonts );
320#endif //KAB_EMBEDDED 323#endif //KAB_EMBEDDED
321 324
322 lTFnt->setBuddy( btnFont ); 325 lTFnt->setBuddy( btnFont );
323 326
324 connect( btnFont, SIGNAL(clicked()), this, SLOT(setTextFont()) ); 327 connect( btnFont, SIGNAL(clicked()), this, SLOT(setTextFont()) );
325 328
326 QLabel *lHFnt = new QLabel( i18n("&Header font:"), vbFonts ); 329 QLabel *lHFnt = new QLabel( i18n("&Header font:"), vbFonts );
327 lHeaderFont = new QLabel( vbFonts ); 330 lHeaderFont = new QLabel( vbFonts );
328 lHeaderFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); 331 lHeaderFont->setFrameStyle( Q3Frame::Panel|Q3Frame::Sunken );
329#ifndef KAB_EMBEDDED 332#ifndef KAB_EMBEDDED
330 btnHeaderFont = new KPushButton( i18n("Choose..."), vbFonts ); 333 btnHeaderFont = new KPushButton( i18n("Choose..."), vbFonts );
331#else //KAB_EMBEDDED 334#else //KAB_EMBEDDED
332 btnHeaderFont = new QPushButton( i18n("Choose..."), vbFonts ); 335 btnHeaderFont = new QPushButton( i18n("Choose..."), vbFonts );
333#endif //KAB_EMBEDDED 336#endif //KAB_EMBEDDED
334 lHFnt->setBuddy( btnHeaderFont ); 337 lHFnt->setBuddy( btnHeaderFont );
335 connect( btnHeaderFont, SIGNAL(clicked()), this, SLOT(setHeaderFont()) ); 338 connect( btnHeaderFont, SIGNAL(clicked()), this, SLOT(setHeaderFont()) );
336 339
337 fntTab->setStretchFactor( new QWidget( fntTab ), 1 ); 340 fntTab->setStretchFactor( new QWidget( fntTab ), 1 );
338 341
339 QWhatsThis::add( cbEnableCustomFonts, i18n( 342 Q3WhatsThis::add( cbEnableCustomFonts, i18n(
340 "If custom fonts are enabled, you may choose which fonts to use for this view below. " 343 "If custom fonts are enabled, you may choose which fonts to use for this view below. "
341 "Otherwise the default KDE font will be used, in bold style for the header and " 344 "Otherwise the default KDE font will be used, in bold style for the header and "
342 "normal style for the data." 345 "normal style for the data."
343 ) ); 346 ) );
344 347
345 tabs->addTab( fntTab, i18n("&Fonts") ); 348 tabs->addTab( fntTab, i18n("&Fonts") );
346 349
347 // Behaviour 350 // Behaviour
348 QVBox *behaviourTab = new QVBox( this ); 351 Q3VBox *behaviourTab = new Q3VBox( this );
349 behaviourTab->setMargin( margin ); 352 behaviourTab->setMargin( margin );
350 behaviourTab->setSpacing( spacing ); 353 behaviourTab->setSpacing( spacing );
351 354
352 cbShowEmptyFields = new QCheckBox( i18n("Show &empty fields"), behaviourTab ); 355 cbShowEmptyFields = new QCheckBox( i18n("Show &empty fields"), behaviourTab );
353 cbShowFieldLabels = new QCheckBox( i18n("Show field &labels"), behaviourTab ); 356 cbShowFieldLabels = new QCheckBox( i18n("Show field &labels"), behaviourTab );
354 357
355 behaviourTab->setStretchFactor( new QWidget( behaviourTab ), 1 ); 358 behaviourTab->setStretchFactor( new QWidget( behaviourTab ), 1 );
356 359
357 tabs->addTab( behaviourTab, i18n("Be&havior") ); 360 tabs->addTab( behaviourTab, i18n("Be&havior") );
358 361
359} 362}
360 363
361void CardViewLookNFeelPage::updateFontLabel( QFont fnt, QLabel *l ) 364void CardViewLookNFeelPage::updateFontLabel( QFont fnt, QLabel *l )
362{ 365{
363 l->setFont( fnt ); 366 l->setFont( fnt );
364 l->setText( QString( fnt.family() + " %1" ).arg( fnt.pointSize() ) ); 367 l->setText( QString( fnt.family() + " %1" ).arg( fnt.pointSize() ) );
365} 368}
366 369
367#ifndef KAB_EMBEDDED 370#ifndef KAB_EMBEDDED_
368#include "configurecardviewdialog.moc" 371#include "moc_configurecardviewdialog.cpp"
369#endif //KAB_EMBEDDED 372#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/configurecardviewdialog.h b/kaddressbook/views/configurecardviewdialog.h
index 7a62226..4af475d 100644
--- a/kaddressbook/views/configurecardviewdialog.h
+++ b/kaddressbook/views/configurecardviewdialog.h
@@ -1,117 +1,119 @@
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 CONFIGURECARDVIEWDIALOG_H 24#ifndef CONFIGURECARDVIEWDIALOG_H
25#define CONFIGURECARDVIEWDIALOG_H 25#define CONFIGURECARDVIEWDIALOG_H
26 26
27#include "viewconfigurewidget.h" 27#include "viewconfigurewidget.h"
28 28
29#include <qvbox.h> 29#include <q3vbox.h>
30#include <qwidget.h> 30#include <qwidget.h>
31#include <qfont.h> 31#include <qfont.h>
32//Added by qt3to4:
33#include <QLabel>
32 34
33class QString; 35class QString;
34class QWidget; 36class QWidget;
35class QCheckBox; 37class QCheckBox;
36class QLabel; 38class QLabel;
37class KConfig; 39class KConfig;
38 40
39namespace KABC { class AddressBook; } 41namespace KABC { class AddressBook; }
40 42
41class CardViewLookAndFeelPage; 43class CardViewLookAndFeelPage;
42 44
43/** 45/**
44 Configure dialog for the card view. This dialog inherits from the 46 Configure dialog for the card view. This dialog inherits from the
45 standard view dialog in order to add a custom page for the card 47 standard view dialog in order to add a custom page for the card
46 view. 48 view.
47 */ 49 */
48class ConfigureCardViewWidget : public ViewConfigureWidget 50class ConfigureCardViewWidget : public ViewConfigureWidget
49{ 51{
50 public: 52 public:
51 ConfigureCardViewWidget( KABC::AddressBook *ab, QWidget *parent, const char *name ); 53 ConfigureCardViewWidget( KABC::AddressBook *ab, QWidget *parent, const char *name );
52 virtual ~ConfigureCardViewWidget(); 54 virtual ~ConfigureCardViewWidget();
53 55
54 virtual void restoreSettings( KConfig* ); 56 virtual void restoreSettings( KConfig* );
55 virtual void saveSettings( KConfig* ); 57 virtual void saveSettings( KConfig* );
56 58
57 private: 59 private:
58 class CardViewLookNFeelPage *mAdvancedPage; 60 class CardViewLookNFeelPage *mAdvancedPage;
59}; 61};
60 62
61/** 63/**
62 Card View Advanced LookNFeel settings widget: 64 Card View Advanced LookNFeel settings widget:
63 this is a tabbed widget with 3 tabs: 65 this is a tabbed widget with 3 tabs:
64 Fonts 66 Fonts
65 * text font 67 * text font
66 * header font 68 * header font
67 69
68 Colors 70 Colors
69 * background color 71 * background color
70 * text color 72 * text color
71 * highlight color 73 * highlight color
72 * title/sep text color 74 * title/sep text color
73 * title/sep bg color 75 * title/sep bg color
74 76
75 Layout 77 Layout
76 * item margin 78 * item margin
77 * item spacing 79 * item spacing
78*/ 80*/
79 81
80class CardViewLookNFeelPage : public QVBox { 82class CardViewLookNFeelPage : public Q3VBox {
81 83
82 Q_OBJECT 84 Q_OBJECT
83 85
84 public: 86 public:
85 CardViewLookNFeelPage( QWidget *parent=0, const char *name=0 ); 87 CardViewLookNFeelPage( QWidget *parent=0, const char *name=0 );
86 ~CardViewLookNFeelPage(); 88 ~CardViewLookNFeelPage();
87 89
88 void restoreSettings( KConfig* ); 90 void restoreSettings( KConfig* );
89 void saveSettings( KConfig* ); 91 void saveSettings( KConfig* );
90 92
91 private slots: 93 private slots:
92 void setTextFont(); 94 void setTextFont();
93 void setHeaderFont(); 95 void setHeaderFont();
94 void enableFonts(); 96 void enableFonts();
95 void enableColors(); 97 void enableColors();
96 98
97 private: 99 private:
98 void initGUI(); 100 void initGUI();
99 void updateFontLabel( QFont, QLabel * ); 101 void updateFontLabel( QFont, QLabel * );
100 102
101 QCheckBox *cbEnableCustomFonts, 103 QCheckBox *cbEnableCustomFonts,
102 *cbEnableCustomColors, 104 *cbEnableCustomColors,
103 *cbDrawSeps, *cbDrawBorders, 105 *cbDrawSeps, *cbDrawBorders,
104 *cbShowFieldLabels, *cbShowEmptyFields; 106 *cbShowFieldLabels, *cbShowEmptyFields;
105 class ColorListBox *lbColors; 107 class ColorListBox *lbColors;
106 QLabel *lTextFont, *lHeaderFont; 108 QLabel *lTextFont, *lHeaderFont;
107#ifndef KAB_EMBEDDED 109#ifndef KAB_EMBEDDED
108 class KPushButton *btnFont, *btnHeaderFont; 110 class KPushButton *btnFont, *btnHeaderFont;
109#else //KAB_EMBEDDED 111#else //KAB_EMBEDDED
110 class QPushButton *btnFont, *btnHeaderFont; 112 class QPushButton *btnFont, *btnHeaderFont;
111#endif //KAB_EMBEDDED 113#endif //KAB_EMBEDDED
112 class QSpinBox *sbMargin, *sbSpacing, *sbSepWidth; 114 class QSpinBox *sbMargin, *sbSpacing, *sbSepWidth;
113 115
114 class QWidget *vbFonts; 116 class QWidget *vbFonts;
115}; 117};
116 118
117#endif 119#endif
diff --git a/kaddressbook/views/configuretableviewdialog.cpp b/kaddressbook/views/configuretableviewdialog.cpp
index c329cd9..7ed897a 100644
--- a/kaddressbook/views/configuretableviewdialog.cpp
+++ b/kaddressbook/views/configuretableviewdialog.cpp
@@ -1,345 +1,348 @@
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#include <qstring.h> 24#include <qstring.h>
25#include <qwidget.h> 25#include <qwidget.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qradiobutton.h> 28#include <qradiobutton.h>
29#include <qcheckbox.h> 29#include <qcheckbox.h>
30#include <qvbox.h> 30#include <q3vbox.h>
31#include <qbuttongroup.h> 31#include <q3buttongroup.h>
32#include <qtabwidget.h> 32#include <qtabwidget.h>
33#include <qwhatsthis.h> 33#include <q3whatsthis.h>
34#include <qpushbutton.h> 34#include <qpushbutton.h>
35//Added by qt3to4:
36#include <Q3GridLayout>
37#include <Q3Frame>
35 38
36#include <kglobal.h> 39#include <kglobal.h>
37#include <klocale.h> 40#include <klocale.h>
38#include <klineedit.h> 41#include <klineedit.h>
39#include <kurlrequester.h> 42#include <kurlrequester.h>
40#include <kiconloader.h> 43#include <kiconloader.h>
41#include <kfontdialog.h> 44#include <kfontdialog.h>
42 45
43#ifndef KAB_EMBEDDED 46#ifndef KAB_EMBEDDED
44#include <kimageio.h> 47#include <kimageio.h>
45#else //KAB_EMBEDDED 48#else //KAB_EMBEDDED
46#endif //KAB_EMBEDDED 49#endif //KAB_EMBEDDED
47 50
48#include <kconfig.h> 51#include <kconfig.h>
49 52
50#include "colorlistbox.h" 53#include "colorlistbox.h"
51 54
52#include "configuretableviewdialog.h" 55#include "configuretableviewdialog.h"
53 56
54ConfigureTableViewWidget::ConfigureTableViewWidget( KABC::AddressBook *ab, 57ConfigureTableViewWidget::ConfigureTableViewWidget( KABC::AddressBook *ab,
55 QWidget *parent, 58 QWidget *parent,
56 const char *name ) 59 const char *name )
57 : ViewConfigureWidget( ab, parent, name ) 60 : ViewConfigureWidget( ab, parent, name )
58{ 61{
59 QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, 62 QWidget *page = addPage( i18n( "Look & Feel" ), QString::null,
60 KGlobal::iconLoader()->loadIcon( "looknfeel", 63 KGlobal::iconLoader()->loadIcon( "looknfeel",
61 KIcon::Panel ) ); 64 KIcon::Panel ) );
62 65
63 mPage = new LookAndFeelPage( page ); 66 mPage = new LookAndFeelPage( page );
64} 67}
65 68
66ConfigureTableViewWidget::~ConfigureTableViewWidget() 69ConfigureTableViewWidget::~ConfigureTableViewWidget()
67{ 70{
68} 71}
69 72
70void ConfigureTableViewWidget::restoreSettings( KConfig *config ) 73void ConfigureTableViewWidget::restoreSettings( KConfig *config )
71{ 74{
72 ViewConfigureWidget::restoreSettings( config ); 75 ViewConfigureWidget::restoreSettings( config );
73 76
74 mPage->restoreSettings( config ); 77 mPage->restoreSettings( config );
75} 78}
76 79
77void ConfigureTableViewWidget::saveSettings( KConfig *config ) 80void ConfigureTableViewWidget::saveSettings( KConfig *config )
78{ 81{
79 ViewConfigureWidget::saveSettings( config ); 82 ViewConfigureWidget::saveSettings( config );
80 83
81 mPage->saveSettings( config ); 84 mPage->saveSettings( config );
82} 85}
83 86
84 87
85 88
86LookAndFeelPage::LookAndFeelPage(QWidget *parent, const char *name) 89LookAndFeelPage::LookAndFeelPage(QWidget *parent, const char *name)
87 : QVBox(parent, name) 90 : Q3VBox(parent, name)
88{ 91{
89 initGUI(); 92 initGUI();
90 93
91 // Set initial state 94 // Set initial state
92 enableBackgroundToggled(mBackgroundBox->isChecked()); 95 enableBackgroundToggled(mBackgroundBox->isChecked());
93} 96}
94 97
95void LookAndFeelPage::restoreSettings( KConfig *config ) 98void LookAndFeelPage::restoreSettings( KConfig *config )
96{ 99{
97 mAlternateButton->setChecked(config->readBoolEntry("ABackground", true)); 100 mAlternateButton->setChecked(config->readBoolEntry("ABackground", true));
98 mLineButton->setChecked(config->readBoolEntry("SingleLine", false)); 101 mLineButton->setChecked(config->readBoolEntry("SingleLine", false));
99 mToolTipBox->setChecked(config->readBoolEntry("ToolTips", true)); 102 mToolTipBox->setChecked(config->readBoolEntry("ToolTips", true));
100 103
101 if (!mAlternateButton->isChecked() & !mLineButton->isChecked()) 104 if (!mAlternateButton->isChecked() & !mLineButton->isChecked())
102 mNoneButton->setChecked(true); 105 mNoneButton->setChecked(true);
103 106
104 mBackgroundBox->setChecked(config->readBoolEntry("Background", false)); 107 mBackgroundBox->setChecked(config->readBoolEntry("Background", false));
105 mBackgroundName->lineEdit()->setText(config->readEntry("BackgroundName")); 108 mBackgroundName->lineEdit()->setText(config->readEntry("BackgroundName"));
106 109
107 // colors 110 // colors
108 cbEnableCustomColors->setChecked( config->readBoolEntry( "EnableCustomColors", false ) ); 111 cbEnableCustomColors->setChecked( config->readBoolEntry( "EnableCustomColors", false ) );
109 QColor c; 112 QColor c;
110 //qDebug("LookAndFeelPage::restoreSettings make base color configurable"); 113 //qDebug("LookAndFeelPage::restoreSettings make base color configurable");
111 114
112#ifndef KAB_EMBEDDED 115#ifndef KAB_EMBEDDED
113 c = KGlobalSettings::baseColor(); 116 c = KGlobalSettings::baseColor();
114#else //KAB_EMBEDDED 117#else //KAB_EMBEDDED
115 c = QColor(0,0,0); 118 c = QColor(0,0,0);
116#endif //KAB_EMBEDDED 119#endif //KAB_EMBEDDED
117 120
118 c = colorGroup().background(); 121 c = colorGroup().background();
119 lbColors->insertItem( new ColorListItem( i18n("Background Color"), 122 lbColors->insertItem( new ColorListItem( i18n("Background Color"),
120 config->readColorEntry( "BackgroundColor", &c ) ) ); 123 config->readColorEntry( "BackgroundColor", &c ) ) );
121 c = colorGroup().foreground(); 124 c = colorGroup().foreground();
122 lbColors->insertItem( new ColorListItem( i18n("Text Color"), 125 lbColors->insertItem( new ColorListItem( i18n("Text Color"),
123 config->readColorEntry( "TextColor", &c ) ) ); 126 config->readColorEntry( "TextColor", &c ) ) );
124 c = colorGroup().button(); 127 c = colorGroup().button();
125 lbColors->insertItem( new ColorListItem( i18n("Header Background Color"), 128 lbColors->insertItem( new ColorListItem( i18n("Header Background Color"),
126 config->readColorEntry( "HeaderBackgroundColor", &c ) ) ); 129 config->readColorEntry( "HeaderBackgroundColor", &c ) ) );
127 c = colorGroup().buttonText(); 130 c = colorGroup().buttonText();
128 lbColors->insertItem( new ColorListItem( i18n("Header Text Color"), 131 lbColors->insertItem( new ColorListItem( i18n("Header Text Color"),
129 config->readColorEntry( "HeaderTextColor", &c ) ) ); 132 config->readColorEntry( "HeaderTextColor", &c ) ) );
130 c = colorGroup().highlight(); 133 c = colorGroup().highlight();
131 lbColors->insertItem( new ColorListItem( i18n("Highlight Color"), 134 lbColors->insertItem( new ColorListItem( i18n("Highlight Color"),
132 config->readColorEntry( "HighlightColor", &c ) ) ); 135 config->readColorEntry( "HighlightColor", &c ) ) );
133 c = colorGroup().highlightedText(); 136 c = colorGroup().highlightedText();
134 lbColors->insertItem( new ColorListItem( i18n("Highlighted Text Color"), 137 lbColors->insertItem( new ColorListItem( i18n("Highlighted Text Color"),
135 config->readColorEntry( "HighlightedTextColor", &c ) ) ); 138 config->readColorEntry( "HighlightedTextColor", &c ) ) );
136 c = colorGroup().background(); 139 c = colorGroup().background();
137 lbColors->insertItem( new ColorListItem( i18n("Alternating Background Color"), 140 lbColors->insertItem( new ColorListItem( i18n("Alternating Background Color"),
138 config->readColorEntry( "AlternatingBackgroundColor", &c ) ) ); 141 config->readColorEntry( "AlternatingBackgroundColor", &c ) ) );
139 142
140 enableColors(); 143 enableColors();
141 144
142 // fonts 145 // fonts
143 QFont fnt = font(); 146 QFont fnt = font();
144 updateFontLabel( config->readFontEntry( "TextFont", &fnt ), (QLabel*)lTextFont ); 147 updateFontLabel( config->readFontEntry( "TextFont", &fnt ), (QLabel*)lTextFont );
145 fnt.setBold( true ); 148 fnt.setBold( true );
146 updateFontLabel( config->readFontEntry( "HeaderFont", &fnt ), (QLabel*)lHeaderFont ); 149 updateFontLabel( config->readFontEntry( "HeaderFont", &fnt ), (QLabel*)lHeaderFont );
147 cbEnableCustomFonts->setChecked( config->readBoolEntry( "EnableCustomFonts", false ) ); 150 cbEnableCustomFonts->setChecked( config->readBoolEntry( "EnableCustomFonts", false ) );
148 enableFonts(); 151 enableFonts();
149 152
150} 153}
151 154
152void LookAndFeelPage::saveSettings( KConfig *config ) 155void LookAndFeelPage::saveSettings( KConfig *config )
153{ 156{
154 config->writeEntry("ABackground", mAlternateButton->isChecked()); 157 config->writeEntry("ABackground", mAlternateButton->isChecked());
155 config->writeEntry("SingleLine", mLineButton->isChecked()); 158 config->writeEntry("SingleLine", mLineButton->isChecked());
156 config->writeEntry("ToolTips", mToolTipBox->isChecked()); 159 config->writeEntry("ToolTips", mToolTipBox->isChecked());
157 config->writeEntry("Background", mBackgroundBox->isChecked()); 160 config->writeEntry("Background", mBackgroundBox->isChecked());
158 config->writeEntry("BackgroundName", mBackgroundName->lineEdit()->text()); 161 config->writeEntry("BackgroundName", mBackgroundName->lineEdit()->text());
159 162
160 // colors 163 // colors
161 config->writeEntry( "EnableCustomColors", cbEnableCustomColors->isChecked() ); 164 config->writeEntry( "EnableCustomColors", cbEnableCustomColors->isChecked() );
162 if ( cbEnableCustomColors->isChecked() ) // ?? - Hmmm. 165 if ( cbEnableCustomColors->isChecked() ) // ?? - Hmmm.
163 { 166 {
164 config->writeEntry( "BackgroundColor", lbColors->color( 0 ) ); 167 config->writeEntry( "BackgroundColor", lbColors->color( 0 ) );
165 config->writeEntry( "TextColor", lbColors->color( 1 ) ); 168 config->writeEntry( "TextColor", lbColors->color( 1 ) );
166 config->writeEntry( "HeaderBackgroundColor", lbColors->color( 2 ) ); 169 config->writeEntry( "HeaderBackgroundColor", lbColors->color( 2 ) );
167 config->writeEntry( "HeaderTextColor", lbColors->color( 3 ) ); 170 config->writeEntry( "HeaderTextColor", lbColors->color( 3 ) );
168 config->writeEntry( "HighlightColor", lbColors->color( 4 ) ); 171 config->writeEntry( "HighlightColor", lbColors->color( 4 ) );
169 config->writeEntry( "HighlightedTextColor", lbColors->color( 5 ) ); 172 config->writeEntry( "HighlightedTextColor", lbColors->color( 5 ) );
170 config->writeEntry( "AlternatingBackgroundColor", lbColors->color( 6 ) ); 173 config->writeEntry( "AlternatingBackgroundColor", lbColors->color( 6 ) );
171 } 174 }
172 // fonts 175 // fonts
173 config->writeEntry( "EnableCustomFonts", cbEnableCustomFonts->isChecked() ); 176 config->writeEntry( "EnableCustomFonts", cbEnableCustomFonts->isChecked() );
174 if ( cbEnableCustomFonts->isChecked() ) 177 if ( cbEnableCustomFonts->isChecked() )
175 { 178 {
176 config->writeEntry( "TextFont", lTextFont->font() ); 179 config->writeEntry( "TextFont", lTextFont->font() );
177 config->writeEntry( "HeaderFont", lHeaderFont->font() ); 180 config->writeEntry( "HeaderFont", lHeaderFont->font() );
178 } 181 }
179 182
180} 183}
181 184
182void LookAndFeelPage::setTextFont() 185void LookAndFeelPage::setTextFont()
183{ 186{
184 QFont f( lTextFont->font() ); 187 QFont f( lTextFont->font() );
185#ifndef KAB_EMBEDDED 188#ifndef KAB_EMBEDDED
186 if ( KFontDialog::getFont( f, false, this ) == QDialog::Accepted ) 189 if ( KFontDialog::getFont( f, false, this ) == QDialog::Accepted )
187 updateFontLabel( f, lTextFont ); 190 updateFontLabel( f, lTextFont );
188#else //KAB_EMBEDDED 191#else //KAB_EMBEDDED
189 bool ok; 192 bool ok;
190 QFont fout = KFontDialog::getFont( f, ok); 193 QFont fout = KFontDialog::getFont( f, ok);
191 if ( ok ) 194 if ( ok )
192 updateFontLabel( fout, lTextFont ); 195 updateFontLabel( fout, lTextFont );
193#endif //KAB_EMBEDDED 196#endif //KAB_EMBEDDED
194} 197}
195 198
196void LookAndFeelPage::setHeaderFont() 199void LookAndFeelPage::setHeaderFont()
197{ 200{
198 QFont f( lHeaderFont->font() ); 201 QFont f( lHeaderFont->font() );
199#ifndef KAB_EMBEDDED 202#ifndef KAB_EMBEDDED
200 if ( KFontDialog::getFont( f,false, this ) == QDialog::Accepted ) 203 if ( KFontDialog::getFont( f,false, this ) == QDialog::Accepted )
201 updateFontLabel( f, lHeaderFont ); 204 updateFontLabel( f, lHeaderFont );
202#else //KAB_EMBEDDED 205#else //KAB_EMBEDDED
203 bool ok; 206 bool ok;
204 QFont fout = KFontDialog::getFont( f, ok); 207 QFont fout = KFontDialog::getFont( f, ok);
205 if ( ok ) 208 if ( ok )
206 updateFontLabel( fout, lHeaderFont ); 209 updateFontLabel( fout, lHeaderFont );
207#endif //KAB_EMBEDDED 210#endif //KAB_EMBEDDED
208} 211}
209 212
210void LookAndFeelPage::enableFonts() 213void LookAndFeelPage::enableFonts()
211{ 214{
212 vbFonts->setEnabled( cbEnableCustomFonts->isChecked() ); 215 vbFonts->setEnabled( cbEnableCustomFonts->isChecked() );
213 if ( cbEnableCustomFonts->isChecked() ) 216 if ( cbEnableCustomFonts->isChecked() )
214 vbFonts->setFocus(); 217 vbFonts->setFocus();
215} 218}
216 219
217void LookAndFeelPage::enableColors() 220void LookAndFeelPage::enableColors()
218{ 221{
219 lbColors->setEnabled( cbEnableCustomColors->isChecked() ); 222 lbColors->setEnabled( cbEnableCustomColors->isChecked() );
220 if ( cbEnableCustomColors->isChecked() ) 223 if ( cbEnableCustomColors->isChecked() )
221 lbColors->setFocus(); 224 lbColors->setFocus();
222} 225}
223 226
224void LookAndFeelPage::initGUI() 227void LookAndFeelPage::initGUI()
225{ 228{
226 int spacing = KDialog::spacingHint(); 229 int spacing = KDialog::spacingHint();
227 int margin = KDialog::marginHint(); 230 int margin = KDialog::marginHint();
228 231
229 QTabWidget *tabs = new QTabWidget( this ); 232 QTabWidget *tabs = new QTabWidget( this );
230 233
231 // General 234 // General
232 QVBox *generalTab = new QVBox( this, "generaltab" ); 235 Q3VBox *generalTab = new Q3VBox( this, "generaltab" );
233 236
234 generalTab->setSpacing( spacing ); 237 generalTab->setSpacing( spacing );
235 generalTab->setMargin( margin ); 238 generalTab->setMargin( margin );
236 239
237 QButtonGroup *group = new QButtonGroup(1, Qt::Horizontal, 240 Q3ButtonGroup *group = new Q3ButtonGroup(1, Qt::Horizontal,
238 i18n("Row Separator"), generalTab); 241 i18n("Row Separator"), generalTab);
239 242
240 mAlternateButton = new QRadioButton(i18n("Alternating backgrounds"), 243 mAlternateButton = new QRadioButton(i18n("Alternating backgrounds"),
241 group, "mAlternateButton"); 244 group, "mAlternateButton");
242 mLineButton = new QRadioButton(i18n("Single line"), group, "mLineButton"); 245 mLineButton = new QRadioButton(i18n("Single line"), group, "mLineButton");
243 mNoneButton = new QRadioButton(i18n("None"), group, "mNoneButton"); 246 mNoneButton = new QRadioButton(i18n("None"), group, "mNoneButton");
244 247
245 mBackgroundBox = new QCheckBox(i18n("Enable background image:"), generalTab, 248 mBackgroundBox = new QCheckBox(i18n("Enable background image:"), generalTab,
246 "mBackgroundBox"); 249 "mBackgroundBox");
247 connect(mBackgroundBox, SIGNAL(toggled(bool)), 250 connect(mBackgroundBox, SIGNAL(toggled(bool)),
248 SLOT(enableBackgroundToggled(bool))); 251 SLOT(enableBackgroundToggled(bool)));
249 // LR image not implemented 252 // LR image not implemented
250 mBackgroundBox->setEnabled( false ); 253 mBackgroundBox->setEnabled( false );
251 mBackgroundName = new KURLRequester(generalTab, "mBackgroundName"); 254 mBackgroundName = new KURLRequester(generalTab, "mBackgroundName");
252#ifndef KAB_EMBEDDED 255#ifndef KAB_EMBEDDED
253 mBackgroundName->setMode(KFile::File | KFile::ExistingOnly | 256 mBackgroundName->setMode(KFile::File | KFile::ExistingOnly |
254 KFile::LocalOnly); 257 KFile::LocalOnly);
255 mBackgroundName->setFilter(KImageIO::pattern(KImageIO::Reading)); 258 mBackgroundName->setFilter(KImageIO::pattern(KImageIO::Reading));
256#endif //KAB_EMBEDDED 259#endif //KAB_EMBEDDED
257 260
258 // ToolTip Checkbox 261 // ToolTip Checkbox
259 mToolTipBox = new QCheckBox(i18n("Enable contact tooltips"), generalTab, 262 mToolTipBox = new QCheckBox(i18n("Enable contact tooltips"), generalTab,
260 "mToolTipBox"); 263 "mToolTipBox");
261 264
262 tabs->addTab( generalTab, i18n("&General") ); 265 tabs->addTab( generalTab, i18n("&General") );
263 266
264 // Colors 267 // Colors
265 QVBox *colorTab = new QVBox( this, "colortab" ); 268 Q3VBox *colorTab = new Q3VBox( this, "colortab" );
266 colorTab->setSpacing( spacing ); 269 colorTab->setSpacing( spacing );
267 colorTab->setMargin( spacing ); 270 colorTab->setMargin( spacing );
268 cbEnableCustomColors = new QCheckBox( i18n("&Enable custom Colors"), colorTab ); 271 cbEnableCustomColors = new QCheckBox( i18n("&Enable custom Colors"), colorTab );
269 connect( cbEnableCustomColors, SIGNAL(clicked()), this, SLOT(enableColors()) ); 272 connect( cbEnableCustomColors, SIGNAL(clicked()), this, SLOT(enableColors()) );
270 lbColors = new ColorListBox( colorTab ); 273 lbColors = new ColorListBox( colorTab );
271 tabs->addTab( colorTab, i18n("&Colors") ); 274 tabs->addTab( colorTab, i18n("&Colors") );
272 275
273 QWhatsThis::add( cbEnableCustomColors, i18n( 276 Q3WhatsThis::add( cbEnableCustomColors, i18n(
274 "If custom colors are enabled, you may choose the colors for the view below. " 277 "If custom colors are enabled, you may choose the colors for the view below. "
275 "Otherwise colors from your current KDE color scheme are used." 278 "Otherwise colors from your current KDE color scheme are used."
276 ) ); 279 ) );
277 QWhatsThis::add( lbColors, i18n( 280 Q3WhatsThis::add( lbColors, i18n(
278 "Double click or press RETURN on a item to select a color for the related strings in the view." 281 "Double click or press RETURN on a item to select a color for the related strings in the view."
279 ) ); 282 ) );
280 283
281 // Fonts 284 // Fonts
282 QVBox *fntTab = new QVBox( this, "fonttab" ); 285 Q3VBox *fntTab = new Q3VBox( this, "fonttab" );
283 286
284 fntTab->setSpacing( spacing ); 287 fntTab->setSpacing( spacing );
285 fntTab->setMargin( spacing ); 288 fntTab->setMargin( spacing );
286 289
287 cbEnableCustomFonts = new QCheckBox( i18n("&Enable custom fonts"), fntTab ); 290 cbEnableCustomFonts = new QCheckBox( i18n("&Enable custom fonts"), fntTab );
288 connect( cbEnableCustomFonts, SIGNAL(clicked()), this, SLOT(enableFonts()) ); 291 connect( cbEnableCustomFonts, SIGNAL(clicked()), this, SLOT(enableFonts()) );
289 292
290 vbFonts = new QWidget( fntTab ); 293 vbFonts = new QWidget( fntTab );
291 QGridLayout *gFnts = new QGridLayout( vbFonts, 2, 3 ); 294 Q3GridLayout *gFnts = new Q3GridLayout( vbFonts, 2, 3 );
292 gFnts->setSpacing( spacing ); 295 gFnts->setSpacing( spacing );
293 gFnts->setAutoAdd( true ); 296 gFnts->setAutoAdd( true );
294 gFnts->setColStretch( 1, 1 ); 297 gFnts->setColStretch( 1, 1 );
295 QLabel *lTFnt = new QLabel( i18n("&Text font:"), vbFonts ); 298 QLabel *lTFnt = new QLabel( i18n("&Text font:"), vbFonts );
296 lTextFont = new QLabel( vbFonts ); 299 lTextFont = new QLabel( vbFonts );
297 lTextFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); 300 lTextFont->setFrameStyle( Q3Frame::Panel|Q3Frame::Sunken );
298#ifndef KAB_EMBEDDED 301#ifndef KAB_EMBEDDED
299 btnFont = new KPushButton( i18n("Choose..."), vbFonts ); 302 btnFont = new KPushButton( i18n("Choose..."), vbFonts );
300#else //KAB_EMBEDDED 303#else //KAB_EMBEDDED
301 btnFont = new QPushButton( i18n("Choose..."), vbFonts ); 304 btnFont = new QPushButton( i18n("Choose..."), vbFonts );
302#endif //KAB_EMBEDDED 305#endif //KAB_EMBEDDED
303 306
304 lTFnt->setBuddy( btnFont ); 307 lTFnt->setBuddy( btnFont );
305 308
306 connect( btnFont, SIGNAL(clicked()), this, SLOT(setTextFont()) ); 309 connect( btnFont, SIGNAL(clicked()), this, SLOT(setTextFont()) );
307 310
308 QLabel *lHFnt = new QLabel( i18n("&Header font:"), vbFonts ); 311 QLabel *lHFnt = new QLabel( i18n("&Header font:"), vbFonts );
309 lHeaderFont = new QLabel( vbFonts ); 312 lHeaderFont = new QLabel( vbFonts );
310 lHeaderFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); 313 lHeaderFont->setFrameStyle( Q3Frame::Panel|Q3Frame::Sunken );
311#ifndef KAB_EMBEDDED 314#ifndef KAB_EMBEDDED
312 btnHeaderFont = new KPushButton( i18n("Choose..."), vbFonts ); 315 btnHeaderFont = new KPushButton( i18n("Choose..."), vbFonts );
313#else //KAB_EMBEDDED 316#else //KAB_EMBEDDED
314 btnHeaderFont = new QPushButton( i18n("Choose..."), vbFonts ); 317 btnHeaderFont = new QPushButton( i18n("Choose..."), vbFonts );
315#endif //KAB_EMBEDDED 318#endif //KAB_EMBEDDED
316 lHFnt->setBuddy( btnHeaderFont ); 319 lHFnt->setBuddy( btnHeaderFont );
317 connect( btnHeaderFont, SIGNAL(clicked()), this, SLOT(setHeaderFont()) ); 320 connect( btnHeaderFont, SIGNAL(clicked()), this, SLOT(setHeaderFont()) );
318 321
319 fntTab->setStretchFactor( new QWidget( fntTab ), 1 ); 322 fntTab->setStretchFactor( new QWidget( fntTab ), 1 );
320 323
321 QWhatsThis::add( cbEnableCustomFonts, i18n( 324 Q3WhatsThis::add( cbEnableCustomFonts, i18n(
322 "If custom fonts are enabled, you may choose which fonts to use for this view below. " 325 "If custom fonts are enabled, you may choose which fonts to use for this view below. "
323 "Otherwise the default KDE font will be used, in bold style for the header and " 326 "Otherwise the default KDE font will be used, in bold style for the header and "
324 "normal style for the data." 327 "normal style for the data."
325 ) ); 328 ) );
326 329
327 tabs->addTab( fntTab, i18n("&Fonts") ); 330 tabs->addTab( fntTab, i18n("&Fonts") );
328 331
329} 332}
330 333
331void LookAndFeelPage::enableBackgroundToggled(bool enabled) 334void LookAndFeelPage::enableBackgroundToggled(bool enabled)
332{ 335{
333 mBackgroundName->setEnabled(enabled); 336 mBackgroundName->setEnabled(enabled);
334} 337}
335 338
336 339
337void LookAndFeelPage::updateFontLabel( QFont fnt, QLabel *l ) 340void LookAndFeelPage::updateFontLabel( QFont fnt, QLabel *l )
338{ 341{
339 l->setFont( fnt ); 342 l->setFont( fnt );
340 l->setText( QString( fnt.family() + " %1" ).arg( fnt.pointSize() ) ); 343 l->setText( QString( fnt.family() + " %1" ).arg( fnt.pointSize() ) );
341} 344}
342 345
343#ifndef KAB_EMBEDDED 346#ifndef KAB_EMBEDDED_
344#include "configuretableviewdialog.moc" 347#include "moc_configuretableviewdialog.cpp"
345#endif //KAB_EMBEDDED 348#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/configuretableviewdialog.h b/kaddressbook/views/configuretableviewdialog.h
index 003ccf8..8125fc9 100644
--- a/kaddressbook/views/configuretableviewdialog.h
+++ b/kaddressbook/views/configuretableviewdialog.h
@@ -1,103 +1,105 @@
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 CONFIGURETABLEVIEWDIALOG_H 24#ifndef CONFIGURETABLEVIEWDIALOG_H
25#define CONFIGURETABLEVIEWDIALOG_H 25#define CONFIGURETABLEVIEWDIALOG_H
26 26
27#include "viewconfigurewidget.h" 27#include "viewconfigurewidget.h"
28 28
29#include <qvbox.h> 29#include <q3vbox.h>
30//Added by qt3to4:
31#include <QLabel>
30 32
31class QString; 33class QString;
32class QWidget; 34class QWidget;
33class QRadioButton; 35class QRadioButton;
34class QCheckBox; 36class QCheckBox;
35class KURLRequester; 37class KURLRequester;
36class KConfig; 38class KConfig;
37class QLabel; 39class QLabel;
38 40
39namespace KABC { class AddressBook; } 41namespace KABC { class AddressBook; }
40 42
41class LookAndFeelPage; 43class LookAndFeelPage;
42 44
43/** 45/**
44 Configure dialog for the table view. This dialog inherits from the 46 Configure dialog for the table view. This dialog inherits from the
45 standard view dialog in order to add a custom page for the table 47 standard view dialog in order to add a custom page for the table
46 view. 48 view.
47 */ 49 */
48class ConfigureTableViewWidget : public ViewConfigureWidget 50class ConfigureTableViewWidget : public ViewConfigureWidget
49{ 51{
50 public: 52 public:
51 ConfigureTableViewWidget( KABC::AddressBook *ab, QWidget *parent, const char *name ); 53 ConfigureTableViewWidget( KABC::AddressBook *ab, QWidget *parent, const char *name );
52 virtual ~ConfigureTableViewWidget(); 54 virtual ~ConfigureTableViewWidget();
53 55
54 virtual void restoreSettings( KConfig* ); 56 virtual void restoreSettings( KConfig* );
55 virtual void saveSettings( KConfig* ); 57 virtual void saveSettings( KConfig* );
56 58
57 private: 59 private:
58 void initGUI(); 60 void initGUI();
59 61
60 LookAndFeelPage *mPage; 62 LookAndFeelPage *mPage;
61}; 63};
62 64
63/** 65/**
64 Internal class. It is only defined here for moc 66 Internal class. It is only defined here for moc
65*/ 67*/
66class LookAndFeelPage : public QVBox 68class LookAndFeelPage : public Q3VBox
67{ 69{
68 Q_OBJECT 70 Q_OBJECT
69 71
70 public: 72 public:
71 LookAndFeelPage( QWidget *parent, const char *name = 0 ); 73 LookAndFeelPage( QWidget *parent, const char *name = 0 );
72 ~LookAndFeelPage() {} 74 ~LookAndFeelPage() {}
73 75
74 void restoreSettings( KConfig* ); 76 void restoreSettings( KConfig* );
75 void saveSettings( KConfig* ); 77 void saveSettings( KConfig* );
76 78
77 protected slots: 79 protected slots:
78 void enableBackgroundToggled( bool ); 80 void enableBackgroundToggled( bool );
79 void setTextFont(); 81 void setTextFont();
80 void setHeaderFont(); 82 void setHeaderFont();
81 void enableFonts(); 83 void enableFonts();
82 void enableColors(); 84 void enableColors();
83 85
84 private: 86 private:
85 void initGUI(); 87 void initGUI();
86 void updateFontLabel( QFont, QLabel * ); 88 void updateFontLabel( QFont, QLabel * );
87 89
88 QCheckBox *cbEnableCustomFonts, 90 QCheckBox *cbEnableCustomFonts,
89 *cbEnableCustomColors; 91 *cbEnableCustomColors;
90 class ColorListBox *lbColors; 92 class ColorListBox *lbColors;
91 QLabel *lTextFont, *lHeaderFont; 93 QLabel *lTextFont, *lHeaderFont;
92 class QPushButton *btnFont, *btnHeaderFont; 94 class QPushButton *btnFont, *btnHeaderFont;
93 class QWidget* vbFonts; 95 class QWidget* vbFonts;
94 96
95 QRadioButton *mAlternateButton; 97 QRadioButton *mAlternateButton;
96 QRadioButton *mLineButton; 98 QRadioButton *mLineButton;
97 QRadioButton *mNoneButton; 99 QRadioButton *mNoneButton;
98 QCheckBox *mToolTipBox; 100 QCheckBox *mToolTipBox;
99 KURLRequester *mBackgroundName; 101 KURLRequester *mBackgroundName;
100 QCheckBox *mBackgroundBox; 102 QCheckBox *mBackgroundBox;
101}; 103};
102 104
103#endif 105#endif
diff --git a/kaddressbook/views/contactlistview.cpp b/kaddressbook/views/contactlistview.cpp
index 9accf78..227645d 100644
--- a/kaddressbook/views/contactlistview.cpp
+++ b/kaddressbook/views/contactlistview.cpp
@@ -1,429 +1,435 @@
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#include <qheader.h> 24#include <q3header.h>
25#include <qiconset.h> 25#include <qicon.h>
26#include <qimage.h> 26#include <qimage.h>
27#include <qdragobject.h> 27#include <q3dragobject.h>
28#include <qcombobox.h> 28#include <qcombobox.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qbrush.h> 30#include <qbrush.h>
31#include <qevent.h> 31#include <qevent.h>
32#include <qapplication.h> 32#include <qapplication.h>
33//Added by qt3to4:
34#include <QDropEvent>
35#include <QPixmap>
36#include <QMouseEvent>
37#include <QKeyEvent>
33 38
34#include <klocale.h> 39#include <klocale.h>
35#include <kglobalsettings.h> 40#include <kglobalsettings.h>
36#include <kiconloader.h> 41#include <kiconloader.h>
37#include <kdebug.h> 42#include <kdebug.h>
38#include <kconfig.h> 43#include <kconfig.h>
39#include <kapplication.h> 44#include <kapplication.h>
40#include <kurl.h> 45#include <kurl.h>
41 46
42#include "kaddressbooktableview.h" 47#include "kaddressbooktableview.h"
43 48
44#include "contactlistview.h" 49#include "contactlistview.h"
45 50
46///////////////////////////////// 51/////////////////////////////////
47// DynamicTip Methods 52// DynamicTip Methods
48 53
49DynamicTip::DynamicTip( ContactListView *parent) 54DynamicTip::DynamicTip( ContactListView *parent)
50 : QToolTip( parent ) 55 /* TODO:hacker:: QToolTip( parent ) */
51{ 56{
52} 57}
53 58
54void DynamicTip::maybeTip( const QPoint &pos ) 59void DynamicTip::maybeTip( const QPoint &pos )
55{ 60{
61 /* TODO:hacker:
56 static bool ishidden = true; 62 static bool ishidden = true;
57 if (!parentWidget()->inherits( "ContactListView" )) 63 if (!parentWidget()->inherits( "ContactListView" ))
58 return; 64 return;
59 65
60 ContactListView *plv = (ContactListView*)parentWidget(); 66 ContactListView *plv = (ContactListView*)parentWidget();
61 if (!plv->tooltips()) 67 if (!plv->tooltips())
62 return; 68 return;
63 69
64 QPoint posVp = plv->viewport()->pos(); 70 QPoint posVp = plv->viewport()->pos();
65 71
66 QListViewItem *lvi = plv->itemAt( pos - posVp ); 72 Q3ListViewItem *lvi = plv->itemAt( pos - posVp );
67 if (!lvi) 73 if (!lvi)
68 return; 74 return;
69 75
70#ifndef KAB_EMBEDDED 76#ifndef KAB_EMBEDDED
71 ContactListViewItem *plvi = dynamic_cast< ContactListViewItem* >(lvi); 77 ContactListViewItem *plvi = dynamic_cast< ContactListViewItem* >(lvi);
72#else //KAB_EMBEDDED 78#else //KAB_EMBEDDED
73 ContactListViewItem *plvi = (ContactListViewItem*)(lvi); 79 ContactListViewItem *plvi = (ContactListViewItem*)(lvi);
74#endif //KAB_EMBEDDED 80#endif //KAB_EMBEDDED
75 81
76 if (!plvi) 82 if (!plvi)
77 return; 83 return;
78 84
79 if (ishidden) { 85 if (ishidden) {
80 QString s; 86 QString s;
81 QRect r = plv->itemRect( lvi ); 87 QRect r = plv->itemRect( lvi );
82 r.moveBy( posVp.x(), posVp.y() ); 88 r.moveBy( posVp.x(), posVp.y() );
83 89
84 //kdDebug() << "Tip rec: " << r.x() << "," << r.y() << "," << r.width() 90 //kdDebug() << "Tip rec: " << r.x() << "," << r.y() << "," << r.width()
85 // << "," << r.height() << endl; 91 // << "," << r.height() << endl;
86 92
87 KABC::Addressee a = plvi->addressee(); 93 KABC::Addressee a = plvi->addressee();
88 if (a.isEmpty()) 94 if (a.isEmpty())
89 return; 95 return;
90 96
91 s += i18n("label: value", "%1: %2").arg(a.formattedNameLabel()) 97 s += i18n("label: value", "%1: %2").arg(a.formattedNameLabel())
92 .arg(a.formattedName()); 98 .arg(a.formattedName());
93 99
94 s += '\n'; 100 s += '\n';
95 s += i18n("label: value", "%1: %2").arg(a.organizationLabel()) 101 s += i18n("label: value", "%1: %2").arg(a.organizationLabel())
96 .arg(a.organization()); 102 .arg(a.organization());
97 103
98 QString notes = a.note().stripWhiteSpace(); 104 QString notes = a.note().stripWhiteSpace();
99 if ( !notes.isEmpty() ) { 105 if ( !notes.isEmpty() ) {
100 notes += '\n'; 106 notes += '\n';
101 s += '\n' + i18n("label: value", "%1: \n").arg(a.noteLabel()); 107 s += '\n' + i18n("label: value", "%1: \n").arg(a.noteLabel());
102 QFontMetrics fm( font() ); 108 QFontMetrics fm( font() );
103 109
104 // Begin word wrap code based on QMultiLineEdit code 110 // Begin word wrap code based on QMultiLineEdit code
105 int i = 0; 111 int i = 0;
106 bool doBreak = false; 112 bool doBreak = false;
107 int linew = 0; 113 int linew = 0;
108 int lastSpace = -1; 114 int lastSpace = -1;
109 int a = 0; 115 int a = 0;
110 int lastw = 0; 116 int lastw = 0;
111 117
112 while ( i < int(notes.length()) ) { 118 while ( i < int(notes.length()) ) {
113 doBreak = FALSE; 119 doBreak = FALSE;
114 if ( notes[i] != '\n' ) 120 if ( notes[i] != '\n' )
115 linew += fm.width( notes[i] ); 121 linew += fm.width( notes[i] );
116 122
117 if ( lastSpace >= a && notes[i] != '\n' ) 123 if ( lastSpace >= a && notes[i] != '\n' )
118 if (linew >= parentWidget()->width()) { 124 if (linew >= parentWidget()->width()) {
119 doBreak = TRUE; 125 doBreak = TRUE;
120 if ( lastSpace > a ) { 126 if ( lastSpace > a ) {
121 i = lastSpace; 127 i = lastSpace;
122 linew = lastw; 128 linew = lastw;
123 } 129 }
124 else 130 else
125 i = QMAX( a, i-1 ); 131 i = QMAX( a, i-1 );
126 } 132 }
127 133
128 if ( notes[i] == '\n' || doBreak ) { 134 if ( notes[i] == '\n' || doBreak ) {
129 s += notes.mid( a, i - a + (doBreak?1:0) ) +"\n"; 135 s += notes.mid( a, i - a + (doBreak?1:0) ) +"\n";
130 136
131 a = i + 1; 137 a = i + 1;
132 lastSpace = a; 138 lastSpace = a;
133 linew = 0; 139 linew = 0;
134 } 140 }
135 141
136 if ( notes[i].isSpace() ) { 142 if ( notes[i].isSpace() ) {
137 lastSpace = i; 143 lastSpace = i;
138 lastw = linew; 144 lastw = linew;
139 } 145 }
140 146
141 if ( lastSpace <= a ) { 147 if ( lastSpace <= a ) {
142 lastw = linew; 148 lastw = linew;
143 } 149 }
144 150
145 ++i; 151 ++i;
146 } 152 }
147 } 153 }
148 154
149 tip( r, s ); 155 tip( r, s );
150 } 156 }
151 else 157 else
152 hide(); 158 hide();
153 ishidden = !ishidden; 159 ishidden = !ishidden;
154 160 */
155} 161}
156 162
157/////////////////////////// 163///////////////////////////
158// ContactListViewItem Methods 164// ContactListViewItem Methods
159 165
160ContactListViewItem::ContactListViewItem(const KABC::Addressee &a, 166ContactListViewItem::ContactListViewItem(const KABC::Addressee &a,
161 ContactListView *parent, 167 ContactListView *parent,
162 KABC::AddressBook *doc, 168 KABC::AddressBook *doc,
163 const KABC::Field::List &fields ) 169 const KABC::Field::List &fields )
164 : KListViewItem(parent), mAddressee(a), mFields( fields ), 170 : KListViewItem(parent), mAddressee(a), mFields( fields ),
165 parentListView( parent ), mDocument(doc) 171 parentListView( parent ), mDocument(doc)
166{ 172{
167 refresh(); 173 refresh();
168} 174}
169 175
170QString ContactListViewItem::key(int column, bool ascending) const 176QString ContactListViewItem::key(int column, bool ascending) const
171{ 177{
172#ifndef DESKTOP_VERSION 178#ifndef DESKTOP_VERSION
173 int lan = KGlobal::locale()->language(); 179 int lan = KGlobal::locale()->language();
174 //qDebug("language %d ", lan); 180 //qDebug("language %d ", lan);
175 if ( lan == 1 ) { //GERMAN 181 if ( lan == 1 ) { //GERMAN
176 QString ret = QListViewItem::key(column, ascending).lower().utf8(); 182 QString ret = Q3ListViewItem::key(column, ascending).lower().utf8();
177 int start = -1; 183 int start = -1;
178 while ( (start = ret.find( 'ä', start+1)) > 0 ) { 184 while ( (start = ret.find( 'ä', start+1)) > 0 ) {
179 ret.at(start-1) = 'a'; 185 ret.at(start-1) = 'a';
180 } 186 }
181 start = -1; 187 start = -1;
182 while ( (start = ret.find( 'ö', start+1)) > 0 ) { 188 while ( (start = ret.find( 'ö', start+1)) > 0 ) {
183 ret.at(start-1) = 'o'; 189 ret.at(start-1) = 'o';
184 } 190 }
185 start = -1; 191 start = -1;
186 while ( (start = ret.find( 'ü', start+1)) > 0 ) { 192 while ( (start = ret.find( 'ü', start+1)) > 0 ) {
187 ret.at(start-1) = 'o'; 193 ret.at(start-1) = 'o';
188 } 194 }
189 start = -1; 195 start = -1;
190 while ( (start = ret.find( 'ß', start+1)) > 0 ) { 196 while ( (start = ret.find( 'ß', start+1)) > 0 ) {
191 ret.at(start-1) = 's'; 197 ret.at(start-1) = 's';
192 } 198 }
193 //qDebug("conv string %s ", ret.latin1()); 199 //qDebug("conv string %s ", ret.latin1());
194 200
195 return ret; 201 return ret;
196 202
197 } 203 }
198 else 204 else
199#endif 205#endif
200 return QListViewItem::key(column, ascending).lower(); 206 return Q3ListViewItem::key(column, ascending).lower();
201} 207}
202 208
203void ContactListViewItem::paintCell(QPainter * p, 209void ContactListViewItem::paintCell(QPainter * p,
204 const QColorGroup & cg, 210 const QColorGroup & cg,
205 int column, 211 int column,
206 int width, 212 int width,
207 int align) 213 int align)
208{ 214{
209 KListViewItem::paintCell(p, cg, column, width, align); 215 KListViewItem::paintCell(p, cg, column, width, align);
210 216
211 if ( !p ) 217 if ( !p )
212 return; 218 return;
213 219
214 if (parentListView->singleLine()) { 220 if (parentListView->singleLine()) {
215 p->setPen( parentListView->alternateColor() ); 221 p->setPen( parentListView->alternateColor() );
216 p->drawLine( 0, height() - 1, width, height() - 1 ); 222 p->drawLine( 0, height() - 1, width, height() - 1 );
217 } 223 }
218} 224}
219 225
220 226
221ContactListView *ContactListViewItem::parent() 227ContactListView *ContactListViewItem::parent()
222{ 228{
223 return parentListView; 229 return parentListView;
224} 230}
225 231
226 232
227void ContactListViewItem::refresh() 233void ContactListViewItem::refresh()
228{ 234{
229 // Update our addressee, since it may have changed else were 235 // Update our addressee, since it may have changed else were
230 mAddressee = mDocument->findByUid(mAddressee.uid()); 236 mAddressee = mDocument->findByUid(mAddressee.uid());
231 if (mAddressee.isEmpty()) 237 if (mAddressee.isEmpty())
232 return; 238 return;
233 239
234 int i = 0; 240 int i = 0;
235 KABC::Field::List::ConstIterator it; 241 KABC::Field::List::ConstIterator it;
236 for( it = mFields.begin(); it != mFields.end(); ++it ) { 242 for( it = mFields.begin(); it != mFields.end(); ++it ) {
237 setText( i++, (*it)->value( mAddressee ) ); 243 setText( i++, (*it)->value( mAddressee ) );
238 } 244 }
239} 245}
240 246
241/////////////////////////////// 247///////////////////////////////
242// ContactListView 248// ContactListView
243 249
244ContactListView::ContactListView(KAddressBookTableView *view, 250ContactListView::ContactListView(KAddressBookTableView *view,
245 KABC::AddressBook* /* doc */, 251 KABC::AddressBook* /* doc */,
246 QWidget *parent, 252 QWidget *parent,
247 const char *name ) 253 const char *name )
248 : KListView( parent, name ), 254 : KListView( parent, name ),
249 pabWidget( view ), 255 pabWidget( view ),
250 oldColumn( 0 ) 256 oldColumn( 0 )
251{ 257{
252 mFlagBlockKeyPressed = false; 258 mFlagBlockKeyPressed = false;
253 mFlagKeyPressed = false; 259 mFlagKeyPressed = false;
254 mABackground = true; 260 mABackground = true;
255 mSingleLine = false; 261 mSingleLine = false;
256 mToolTips = true; 262 mToolTips = true;
257 263
258 mAlternateColor = KGlobalSettings::alternateBackgroundColor(); 264 mAlternateColor = KGlobalSettings::alternateBackgroundColor();
259 265
260 266
261 267
262 268
263 setAlternateBackgroundEnabled(mABackground); 269 setAlternateBackgroundEnabled(mABackground);
264 setAcceptDrops( true ); 270 setAcceptDrops( true );
265 viewport()->setAcceptDrops( true ); 271 viewport()->setAcceptDrops( true );
266 setAllColumnsShowFocus( true ); 272 setAllColumnsShowFocus( true );
267 setShowSortIndicator(true); 273 setShowSortIndicator(true);
268 274
269 setSelectionModeExt( KListView::Extended ); 275 setSelectionModeExt( KListView::Extended );
270 setDropVisualizer(false); 276 setDropVisualizer(false);
271 // setFrameStyle(QFrame::NoFrame); 277 // setFrameStyle(QFrame::NoFrame);
272 //setLineWidth ( 0 ); 278 //setLineWidth ( 0 );
273 //setMidLineWidth ( 0 ); 279 //setMidLineWidth ( 0 );
274 //setMargin ( 0 ); 280 //setMargin ( 0 );
275#ifndef KAB_EMBEDDED 281#ifndef KAB_EMBEDDED
276 connect(this, SIGNAL(dropped(QDropEvent*)), 282 connect(this, SIGNAL(dropped(QDropEvent*)),
277 this, SLOT(itemDropped(QDropEvent*))); 283 this, SLOT(itemDropped(QDropEvent*)));
278#endif //KAB_EMBEDDED 284#endif //KAB_EMBEDDED
279 285
280 286
281 new DynamicTip( this ); 287 new DynamicTip( this );
282} 288}
283void ContactListView::printMe() 289void ContactListView::printMe()
284{ 290{
285#ifdef DESKTOP_VERSION 291#ifdef DESKTOP_VERSION
286 QPrinter printer; 292 QPrinter printer;
287 if (!printer.setup() ) 293 if (!printer.setup() )
288 return; 294 return;
289 QPainter p; 295 QPainter p;
290 p.begin ( &printer ); 296 p.begin ( &printer );
291 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 297 Q3PaintDeviceMetrics m = Q3PaintDeviceMetrics ( &printer );
292 float dx, dy; 298 float dx, dy;
293 int wid = (m.width() * 9)/10; 299 int wid = (m.width() * 9)/10;
294 dx = (float) wid/(float)contentsWidth (); 300 dx = (float) wid/(float)contentsWidth ();
295 dy = (float)(m.height()) / (float)contentsHeight (); 301 dy = (float)(m.height()) / (float)contentsHeight ();
296 float scale; 302 float scale;
297 // scale to fit the width or height of the paper 303 // scale to fit the width or height of the paper
298 if ( dx < dy ) 304 if ( dx < dy )
299 scale = dx; 305 scale = dx;
300 else 306 else
301 scale = dy; 307 scale = dy;
302 p.translate( m.width()/10,0 ); 308 p.translate( m.width()/10,0 );
303 p.scale( scale, scale ); 309 p.scale( scale, scale );
304 qDebug("scale %f ", scale); 310 qDebug("scale %f ", scale);
305 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); 311 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
306 p.end(); 312 p.end();
307 qDebug("Why does it not print??? "); 313 qDebug("Why does it not print??? ");
308#endif 314#endif
309} 315}
310 316
311void ContactListView::setAlternateColor(const QColor &m_AlternateColor) 317void ContactListView::setAlternateColor(const QColor &m_AlternateColor)
312{ 318{
313 mAlternateColor = m_AlternateColor; 319 mAlternateColor = m_AlternateColor;
314} 320}
315 321
316void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) 322void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect )
317{ 323{
318 QBrush b = palette().brush(QPalette::Active, QColorGroup::Base); 324 QBrush b = palette().brush(QPalette::Active, QColorGroup::Base);
319 325
320 // Get the brush, which will have the background pixmap if there is one. 326 // Get the brush, which will have the background pixmap if there is one.
321 if (b.pixmap()) 327 if (b.pixmap())
322 { 328 {
323 p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(), 329 p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(),
324 *(b.pixmap()), 330 *(b.pixmap()),
325 rect.left() + contentsX(), 331 rect.left() + contentsX(),
326 rect.top() + contentsY() ); 332 rect.top() + contentsY() );
327 } 333 }
328 334
329 else 335 else
330 { 336 {
331 // Do a normal paint 337 // Do a normal paint
332 KListView::paintEmptyArea(p, rect); 338 KListView::paintEmptyArea(p, rect);
333 } 339 }
334} 340}
335 341
336void ContactListView::contentsMousePressEvent(QMouseEvent* e) 342void ContactListView::contentsMousePressEvent(QMouseEvent* e)
337{ 343{
338 presspos = e->pos(); 344 presspos = e->pos();
339 KListView::contentsMousePressEvent(e); 345 KListView::contentsMousePressEvent(e);
340} 346}
341 347
342 348
343// To initiate a drag operation 349// To initiate a drag operation
344void ContactListView::contentsMouseMoveEvent( QMouseEvent *e ) 350void ContactListView::contentsMouseMoveEvent( QMouseEvent *e )
345{ 351{
346 if ((e->state() & LeftButton) && (e->pos() - presspos).manhattanLength() > 4 ) { 352 if ((e->state() & Qt::LeftButton) && (e->pos() - presspos).manhattanLength() > 4 ) {
347 emit startAddresseeDrag(); 353 emit startAddresseeDrag();
348 } 354 }
349 else 355 else
350 KListView::contentsMouseMoveEvent( e ); 356 KListView::contentsMouseMoveEvent( e );
351} 357}
352 358
353bool ContactListView::acceptDrag(QDropEvent *e) const 359bool ContactListView::acceptDrag(QDropEvent *e) const
354{ 360{
355#ifndef KAB_EMBEDDED 361#ifndef KAB_EMBEDDED
356 return QTextDrag::canDecode(e); 362 return Q3TextDrag::canDecode(e);
357#else //KAB_EMBEDDED 363#else //KAB_EMBEDDED
358qDebug("ContactListView::acceptDrag has to be fixed"); 364qDebug("ContactListView::acceptDrag has to be fixed");
359 return false; 365 return false;
360#endif //KAB_EMBEDDED 366#endif //KAB_EMBEDDED
361} 367}
362 368
363void ContactListView::itemDropped(QDropEvent *e) 369void ContactListView::itemDropped(QDropEvent *e)
364{ 370{
365 contentsDropEvent(e); 371 contentsDropEvent(e);
366} 372}
367 373
368void ContactListView::contentsDropEvent( QDropEvent *e ) 374void ContactListView::contentsDropEvent( QDropEvent *e )
369{ 375{
370 emit addresseeDropped(e); 376 emit addresseeDropped(e);
371} 377}
372 378
373void ContactListView::setAlternateBackgroundEnabled(bool enabled) 379void ContactListView::setAlternateBackgroundEnabled(bool enabled)
374{ 380{
375 mABackground = enabled; 381 mABackground = enabled;
376 382
377 if (mABackground) 383 if (mABackground)
378 { 384 {
379 setAlternateBackground(mAlternateColor); 385 setAlternateBackground(mAlternateColor);
380 } 386 }
381 else 387 else
382 { 388 {
383 setAlternateBackground(QColor()); 389 setAlternateBackground(QColor());
384 } 390 }
385} 391}
386 392
387void ContactListView::setBackgroundPixmap(const QString &filename) 393void ContactListView::setBackgroundPixmap(const QString &filename)
388{ 394{
389 if (filename.isEmpty()) 395 if (filename.isEmpty())
390 { 396 {
391 unsetPalette(); 397 unsetPalette();
392 } 398 }
393 else 399 else
394 { 400 {
395 qDebug("ContactListView::setBackgroundPixmap has to be verified"); 401 qDebug("ContactListView::setBackgroundPixmap has to be verified");
396//US setPaletteBackgroundPixmap(QPixmap(filename)); 402//US setPaletteBackgroundPixmap(QPixmap(filename));
397 KListView::setBackgroundPixmap((const QPixmap&)QPixmap(filename)); 403 KListView::setBackgroundPixmap((const QPixmap&)QPixmap(filename));
398 } 404 }
399 405
400} 406}
401 407
402void ContactListView::keyPressEvent ( QKeyEvent * e ) 408void ContactListView::keyPressEvent ( QKeyEvent * e )
403{ 409{
404 if ( mFlagBlockKeyPressed ) 410 if ( mFlagBlockKeyPressed )
405 return; 411 return;
406 qApp->processEvents(); 412 qApp->processEvents();
407 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 413 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
408 e->accept(); 414 e->accept();
409 return; 415 return;
410 } 416 }
411 if (! e->isAutoRepeat() ) 417 if (! e->isAutoRepeat() )
412 mFlagKeyPressed = true; 418 mFlagKeyPressed = true;
413 KListView::keyPressEvent ( e ); 419 KListView::keyPressEvent ( e );
414} 420}
415void ContactListView::keyReleaseEvent ( QKeyEvent * e ) 421void ContactListView::keyReleaseEvent ( QKeyEvent * e )
416{ 422{
417 if ( mFlagBlockKeyPressed ) 423 if ( mFlagBlockKeyPressed )
418 return; 424 return;
419 if ( !e->isAutoRepeat() ) { 425 if ( !e->isAutoRepeat() ) {
420 mFlagBlockKeyPressed = true; 426 mFlagBlockKeyPressed = true;
421 qApp->processEvents(); 427 qApp->processEvents();
422 mFlagBlockKeyPressed = false; 428 mFlagBlockKeyPressed = false;
423 mFlagKeyPressed = false; 429 mFlagKeyPressed = false;
424 } 430 }
425 KListView::keyReleaseEvent ( e ); 431 KListView::keyReleaseEvent ( e );
426} 432}
427#ifndef KAB_EMBEDDED 433#ifndef KAB_EMBEDDED_
428#include "contactlistview.moc" 434#include "moc_contactlistview.cpp"
429#endif //KAB_EMBEDDED 435#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/contactlistview.h b/kaddressbook/views/contactlistview.h
index 46477e1..c92b002 100644
--- a/kaddressbook/views/contactlistview.h
+++ b/kaddressbook/views/contactlistview.h
@@ -1,134 +1,138 @@
1#ifndef CONTACTLISTVIEW_H 1#ifndef CONTACTLISTVIEW_H
2#define CONTACTLISTVIEW_H 2#define CONTACTLISTVIEW_H
3 3
4#include <qcolor.h> 4#include <qcolor.h>
5#include <qpixmap.h> 5#include <qpixmap.h>
6#include <qtooltip.h> 6#include <qtooltip.h>
7#include <qstring.h> 7#include <qstring.h>
8//Added by qt3to4:
9#include <QDropEvent>
10#include <QMouseEvent>
11#include <QKeyEvent>
8 12
9#include <klistview.h> 13#include <klistview.h>
10 14
11#include <kabc/field.h> 15#include <kabc/field.h>
12#include <kabc/addressee.h> 16#include <kabc/addressee.h>
13#include <kabc/addressbook.h> 17#include <kabc/addressbook.h>
14 18
15 19
16class QDropEvent; 20class QDropEvent;
17class KAddressBookTableView; 21class KAddressBookTableView;
18class ContactListView; 22class ContactListView;
19 23
20/** The whole tooltip design needs a lot of work. Currently it is 24/** The whole tooltip design needs a lot of work. Currently it is
21* hacked together to function. 25* hacked together to function.
22*/ 26*/
23class DynamicTip : public QToolTip 27class DynamicTip /* TODO:hacker: : public QToolTip */
24{ 28{
25 public: 29 public:
26 DynamicTip( ContactListView * parent ); 30 DynamicTip( ContactListView * parent );
27 31
28 protected: 32 protected:
29 void maybeTip( const QPoint & ); 33 void maybeTip( const QPoint & );
30 34
31 private: 35 private:
32}; 36};
33 37
34class ContactListViewItem : public KListViewItem 38class ContactListViewItem : public KListViewItem
35{ 39{
36 40
37public: 41public:
38 ContactListViewItem(const KABC::Addressee &a, ContactListView* parent, 42 ContactListViewItem(const KABC::Addressee &a, ContactListView* parent,
39 KABC::AddressBook *doc, const KABC::Field::List &fields ); 43 KABC::AddressBook *doc, const KABC::Field::List &fields );
40 const KABC::Addressee &addressee() const { return mAddressee; } 44 const KABC::Addressee &addressee() const { return mAddressee; }
41 virtual void refresh(); 45 virtual void refresh();
42 virtual ContactListView* parent(); 46 virtual ContactListView* parent();
43 virtual QString key ( int, bool ) const; 47 virtual QString key ( int, bool ) const;
44 48
45 /** Adds the border around the cell if the user wants it. 49 /** Adds the border around the cell if the user wants it.
46 * This is how the single line config option is implemented. 50 * This is how the single line config option is implemented.
47 */ 51 */
48 virtual void paintCell(QPainter * p, const QColorGroup & cg, 52 virtual void paintCell(QPainter * p, const QColorGroup & cg,
49 int column, int width, int align ); 53 int column, int width, int align );
50 54
51private: 55private:
52 KABC::Addressee mAddressee; 56 KABC::Addressee mAddressee;
53 KABC::Field::List mFields; 57 KABC::Field::List mFields;
54 ContactListView *parentListView; 58 ContactListView *parentListView;
55 KABC::AddressBook *mDocument; 59 KABC::AddressBook *mDocument;
56}; 60};
57 61
58 62
59///////////////////////////////////////////// 63/////////////////////////////////////////////
60// ContactListView 64// ContactListView
61 65
62class ContactListView : public KListView 66class ContactListView : public KListView
63{ 67{
64 Q_OBJECT 68 Q_OBJECT
65 69
66public: 70public:
67 ContactListView(KAddressBookTableView *view, 71 ContactListView(KAddressBookTableView *view,
68 KABC::AddressBook *doc, 72 KABC::AddressBook *doc,
69 QWidget *parent, 73 QWidget *parent,
70 const char *name = 0L ); 74 const char *name = 0L );
71 virtual ~ContactListView() {} 75 virtual ~ContactListView() {}
72 //void resort(); 76 //void resort();
73 77
74 /** Returns true if tooltips should be displayed, false otherwise 78 /** Returns true if tooltips should be displayed, false otherwise
75 */ 79 */
76 bool tooltips() const { return mToolTips; } 80 bool tooltips() const { return mToolTips; }
77 void setToolTipsEnabled(bool enabled) { mToolTips = enabled; } 81 void setToolTipsEnabled(bool enabled) { mToolTips = enabled; }
78 82
79 bool alternateBackground() const { return mABackground; } 83 bool alternateBackground() const { return mABackground; }
80 void setAlternateBackgroundEnabled(bool enabled); 84 void setAlternateBackgroundEnabled(bool enabled);
81 85
82 bool singleLine() const { return mSingleLine; } 86 bool singleLine() const { return mSingleLine; }
83 void setSingleLineEnabled(bool enabled) { mSingleLine = enabled; } 87 void setSingleLineEnabled(bool enabled) { mSingleLine = enabled; }
84 88
85 const QColor &alternateColor() const { return mAlternateColor; } 89 const QColor &alternateColor() const { return mAlternateColor; }
86 void setAlternateColor(const QColor &mAlternateColor); 90 void setAlternateColor(const QColor &mAlternateColor);
87 91
88 /** Sets the background pixmap to <i>filename</i>. If the 92 /** Sets the background pixmap to <i>filename</i>. If the
89 * QString is empty (QString::isEmpty()), then the background 93 * QString is empty (QString::isEmpty()), then the background
90 * pixmap will be disabled. 94 * pixmap will be disabled.
91 */ 95 */
92 void setBackgroundPixmap(const QString &filename); 96 void setBackgroundPixmap(const QString &filename);
93 97
94protected: 98protected:
95 bool mFlagKeyPressed; 99 bool mFlagKeyPressed;
96 bool mFlagBlockKeyPressed; 100 bool mFlagBlockKeyPressed;
97 virtual void keyPressEvent ( QKeyEvent * ); 101 virtual void keyPressEvent ( QKeyEvent * );
98 virtual void keyReleaseEvent ( QKeyEvent * ); 102 virtual void keyReleaseEvent ( QKeyEvent * );
99 /** Paints the background pixmap in the empty area. This method is needed 103 /** Paints the background pixmap in the empty area. This method is needed
100 * since Qt::FixedPixmap will not scroll with the list view. 104 * since Qt::FixedPixmap will not scroll with the list view.
101 */ 105 */
102 virtual void paintEmptyArea( QPainter * p, const QRect & rect ); 106 virtual void paintEmptyArea( QPainter * p, const QRect & rect );
103 virtual void contentsMousePressEvent(QMouseEvent*); 107 virtual void contentsMousePressEvent(QMouseEvent*);
104 void contentsMouseMoveEvent( QMouseEvent *e ); 108 void contentsMouseMoveEvent( QMouseEvent *e );
105 void contentsDropEvent( QDropEvent *e ); 109 void contentsDropEvent( QDropEvent *e );
106 virtual bool acceptDrag(QDropEvent *e) const; 110 virtual bool acceptDrag(QDropEvent *e) const;
107 111
108protected slots: 112protected slots:
109 void itemDropped(QDropEvent *e); 113 void itemDropped(QDropEvent *e);
110 114
111public slots: 115public slots:
112 void printMe(); 116 void printMe();
113 117
114signals: 118signals:
115 void startAddresseeDrag(); 119 void startAddresseeDrag();
116 void addresseeDropped(QDropEvent *); 120 void addresseeDropped(QDropEvent *);
117 121
118private: 122private:
119 KAddressBookTableView *pabWidget; 123 KAddressBookTableView *pabWidget;
120 int oldColumn; 124 int oldColumn;
121 int column; 125 int column;
122 bool ascending; 126 bool ascending;
123 127
124 bool mABackground; 128 bool mABackground;
125 bool mSingleLine; 129 bool mSingleLine;
126 bool mToolTips; 130 bool mToolTips;
127 131
128 QColor mAlternateColor; 132 QColor mAlternateColor;
129 133
130 QPoint presspos; 134 QPoint presspos;
131}; 135};
132 136
133 137
134#endif 138#endif
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp
index b503652..1e5a556 100644
--- a/kaddressbook/views/kaddressbookcardview.cpp
+++ b/kaddressbook/views/kaddressbookcardview.cpp
@@ -1,525 +1,530 @@
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#include <qdragobject.h> 24#include <q3dragobject.h>
25#include <qevent.h> 25#include <qevent.h>
26#include <qiconview.h> 26#include <q3iconview.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <qregexp.h> 29#include <qregexp.h>
30#include <qapplication.h> 30#include <qapplication.h>
31//Added by qt3to4:
32#include <QDropEvent>
33#include <QKeyEvent>
34#include <Q3VBoxLayout>
35#include <QDragEnterEvent>
31 36
32#include <kabc/addressbook.h> 37#include <kabc/addressbook.h>
33#include <kabc/addressee.h> 38#include <kabc/addressee.h>
34#include <kconfig.h> 39#include <kconfig.h>
35#include <kdebug.h> 40#include <kdebug.h>
36#include <klocale.h> 41#include <klocale.h>
37 42
38#include "kabprefs.h" 43#include "kabprefs.h"
39#include "viewmanager.h" 44#include "viewmanager.h"
40 45
41 46
42#include "kaddressbookcardview.h" 47#include "kaddressbookcardview.h"
43 48
44#ifndef KAB_EMBEDDED 49#ifndef KAB_EMBEDDED
45extern "C" { 50extern "C" {
46 void *init_libkaddrbk_cardview() 51 void *init_libkaddrbk_cardview()
47 { 52 {
48 return ( new CardViewFactory ); 53 return ( new CardViewFactory );
49 } 54 }
50} 55}
51#endif //KAB_EMBEDDED 56#endif //KAB_EMBEDDED
52 57
53//////////////////////////////// 58////////////////////////////////
54// AddresseeCardViewItem (internal class) 59// AddresseeCardViewItem (internal class)
55class AddresseeCardViewItem : public CardViewItem 60class AddresseeCardViewItem : public CardViewItem
56{ 61{
57 public: 62 public:
58 AddresseeCardViewItem(const KABC::Field::List &fields, 63 AddresseeCardViewItem(const KABC::Field::List &fields,
59 bool showEmptyFields, 64 bool showEmptyFields,
60 KABC::AddressBook *doc, const KABC::Addressee &a, 65 KABC::AddressBook *doc, const KABC::Addressee &a,
61 CardView *parent) 66 CardView *parent)
62 : CardViewItem(parent, a.realName() ), 67 : CardViewItem(parent, a.realName() ),
63 mFields( fields ), mShowEmptyFields(showEmptyFields), 68 mFields( fields ), mShowEmptyFields(showEmptyFields),
64 mDocument(doc), mAddressee(a) 69 mDocument(doc), mAddressee(a)
65 { 70 {
66 if ( mFields.isEmpty() ) { 71 if ( mFields.isEmpty() ) {
67 mFields = KABC::Field::defaultFields(); 72 mFields = KABC::Field::defaultFields();
68 } 73 }
69 refresh(); 74 refresh();
70 } 75 }
71 76
72 const KABC::Addressee &addressee() const { return mAddressee; } 77 const KABC::Addressee &addressee() const { return mAddressee; }
73 78
74 void refresh() 79 void refresh()
75 { 80 {
76 // Update our addressee, since it may have changed elsewhere 81 // Update our addressee, since it may have changed elsewhere
77 mAddressee = mDocument->findByUid(mAddressee.uid()); 82 mAddressee = mDocument->findByUid(mAddressee.uid());
78 83
79 if (!mAddressee.isEmpty()) 84 if (!mAddressee.isEmpty())
80 { 85 {
81 clearFields(); 86 clearFields();
82 87
83 // Try all the selected fields until we find one with text. 88 // Try all the selected fields until we find one with text.
84 // This will limit the number of unlabeled icons in the view 89 // This will limit the number of unlabeled icons in the view
85 KABC::Field::List::Iterator iter; 90 KABC::Field::List::Iterator iter;
86 for (iter = mFields.begin(); iter != mFields.end(); ++iter) 91 for (iter = mFields.begin(); iter != mFields.end(); ++iter)
87 { 92 {
88 // insert empty fields or not? not doing so saves a bit of memory and CPU 93 // insert empty fields or not? not doing so saves a bit of memory and CPU
89 // (during geometry calculations), but prevents having equally 94 // (during geometry calculations), but prevents having equally
90 // wide label columns in all cards, unless CardViewItem/CardView search 95 // wide label columns in all cards, unless CardViewItem/CardView search
91 // globally for the widest label. (anders) 96 // globally for the widest label. (anders)
92 //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty()) 97 //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty())
93 insertField((*iter)->label(), (*iter)->value( mAddressee )); 98 insertField((*iter)->label(), (*iter)->value( mAddressee ));
94 } 99 }
95 100
96 // We might want to make this the first field. hmm... -mpilone 101 // We might want to make this the first field. hmm... -mpilone
97 setCaption( mAddressee.realName() ); 102 setCaption( mAddressee.realName() );
98 } 103 }
99 } 104 }
100 105
101 private: 106 private:
102 KABC::Field::List mFields; 107 KABC::Field::List mFields;
103 bool mShowEmptyFields; 108 bool mShowEmptyFields;
104 KABC::AddressBook *mDocument; 109 KABC::AddressBook *mDocument;
105 KABC::Addressee mAddressee; 110 KABC::Addressee mAddressee;
106}; 111};
107 112
108/////////////////////////////// 113///////////////////////////////
109// AddresseeCardView 114// AddresseeCardView
110 115
111AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) 116AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name)
112 : CardView(parent, name) 117 : CardView(parent, name)
113{ 118{
114 setAcceptDrops(true); 119 setAcceptDrops(true);
115} 120}
116 121
117AddresseeCardView::~AddresseeCardView() 122AddresseeCardView::~AddresseeCardView()
118{ 123{
119} 124}
120void AddresseeCardView::printMe() 125void AddresseeCardView::printMe()
121{ 126{
122#ifdef DESKTOP_VERSION 127#ifdef DESKTOP_VERSION
123 QPrinter printer; 128 QPrinter printer;
124 if (!printer.setup() ) 129 if (!printer.setup() )
125 return; 130 return;
126 QPainter p; 131 QPainter p;
127 p.begin ( &printer ); 132 p.begin ( &printer );
128 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 133 Q3PaintDeviceMetrics m = Q3PaintDeviceMetrics ( &printer );
129 float dx, dy; 134 float dx, dy;
130 int wid = (m.width() * 9)/10; 135 int wid = (m.width() * 9)/10;
131 dx = (float) wid/(float)contentsWidth (); 136 dx = (float) wid/(float)contentsWidth ();
132 dy = (float)(m.height()) / (float)contentsHeight (); 137 dy = (float)(m.height()) / (float)contentsHeight ();
133 float scale; 138 float scale;
134 // scale to fit the width or height of the paper 139 // scale to fit the width or height of the paper
135 if ( dx < dy ) 140 if ( dx < dy )
136 scale = dx; 141 scale = dx;
137 else 142 else
138 scale = dy; 143 scale = dy;
139 p.translate( m.width()/10,0 ); 144 p.translate( m.width()/10,0 );
140 p.scale( scale, scale ); 145 p.scale( scale, scale );
141 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); 146 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
142 p.end(); 147 p.end();
143 repaint(); 148 repaint();
144#endif 149#endif
145} 150}
146 151
147 152
148void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) 153void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e)
149{ 154{
150#ifndef KAB_EMBEDDED 155#ifndef KAB_EMBEDDED
151 if (QTextDrag::canDecode(e)) 156 if (Q3TextDrag::canDecode(e))
152 e->accept(); 157 e->accept();
153#else //KAB_EMBEDDED 158#else //KAB_EMBEDDED
154qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); 159qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented");
155#endif //KAB_EMBEDDED 160#endif //KAB_EMBEDDED
156} 161}
157 162
158void AddresseeCardView::dropEvent(QDropEvent *e) 163void AddresseeCardView::dropEvent(QDropEvent *e)
159{ 164{
160 emit addresseeDropped(e); 165 emit addresseeDropped(e);
161} 166}
162 167
163void AddresseeCardView::startDrag() 168void AddresseeCardView::startDrag()
164{ 169{
165 emit startAddresseeDrag(); 170 emit startAddresseeDrag();
166} 171}
167 172
168 173
169/////////////////////////////// 174///////////////////////////////
170// KAddressBookCardView 175// KAddressBookCardView
171 176
172KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, 177KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab,
173 QWidget *parent, const char *name ) 178 QWidget *parent, const char *name )
174 : KAddressBookView( ab, parent, name ) 179 : KAddressBookView( ab, parent, name )
175{ 180{
176 mShowEmptyFields = false; 181 mShowEmptyFields = false;
177 182
178 // Init the GUI 183 // Init the GUI
179 QVBoxLayout *layout = new QVBoxLayout(viewWidget()); 184 Q3VBoxLayout *layout = new Q3VBoxLayout(viewWidget());
180 185
181 mCardView = new AddresseeCardView(viewWidget(), "mCardView"); 186 mCardView = new AddresseeCardView(viewWidget(), "mCardView");
182 mCardView->setSelectionMode(CardView::Extended); 187 mCardView->setSelectionMode(CardView::Extended);
183 layout->addWidget(mCardView); 188 layout->addWidget(mCardView);
184 189
185 // Connect up the signals 190 // Connect up the signals
186 connect(mCardView, SIGNAL(executed(CardViewItem *)), 191 connect(mCardView, SIGNAL(executed(CardViewItem *)),
187 this, SLOT(addresseeExecuted(CardViewItem *))); 192 this, SLOT(addresseeExecuted(CardViewItem *)));
188 connect(mCardView, SIGNAL(selectionChanged()), 193 connect(mCardView, SIGNAL(selectionChanged()),
189 this, SLOT(addresseeSelected())); 194 this, SLOT(addresseeSelected()));
190 connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), 195 connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)),
191 this, SIGNAL(dropped(QDropEvent*))); 196 this, SIGNAL(dropped(QDropEvent*)));
192 connect(mCardView, SIGNAL(startAddresseeDrag()), 197 connect(mCardView, SIGNAL(startAddresseeDrag()),
193 this, SIGNAL(startDrag())); 198 this, SIGNAL(startDrag()));
194 connect(this, SIGNAL(printView()), 199 connect(this, SIGNAL(printView()),
195 mCardView , SLOT(printMe())); 200 mCardView , SLOT(printMe()));
196} 201}
197 202
198KAddressBookCardView::~KAddressBookCardView() 203KAddressBookCardView::~KAddressBookCardView()
199{ 204{
200} 205}
201void KAddressBookCardView::setFocusAV() 206void KAddressBookCardView::setFocusAV()
202{ 207{
203 if ( mCardView ) 208 if ( mCardView )
204 mCardView->setFocus(); 209 mCardView->setFocus();
205 210
206} 211}
207void KAddressBookCardView::scrollUP() 212void KAddressBookCardView::scrollUP()
208{ 213{
209 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 214 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
210 QApplication::postEvent( mCardView, ev ); 215 QApplication::postEvent( mCardView, ev );
211 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Up, 0,0 ); 216 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Up, 0,0 );
212 QApplication::postEvent( mCardView, ev ); 217 QApplication::postEvent( mCardView, ev );
213 218
214} 219}
215void KAddressBookCardView::scrollDOWN() 220void KAddressBookCardView::scrollDOWN()
216{ 221{
217 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 222 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
218 QApplication::postEvent( mCardView, ev ); 223 QApplication::postEvent( mCardView, ev );
219 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Down, 0,0 ); 224 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Down, 0,0 );
220 QApplication::postEvent( mCardView, ev ); 225 QApplication::postEvent( mCardView, ev );
221} 226}
222void KAddressBookCardView::readConfig(KConfig *config) 227void KAddressBookCardView::readConfig(KConfig *config)
223{ 228{
224 KAddressBookView::readConfig(config); 229 KAddressBookView::readConfig(config);
225 230
226 // costum colors? 231 // costum colors?
227 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 232 if ( config->readBoolEntry( "EnableCustomColors", false ) )
228 { 233 {
229 QPalette p( mCardView->palette() ); 234 QPalette p( mCardView->palette() );
230 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 235 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
231 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 236 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
232 c = p.color(QPalette::Normal, QColorGroup::Text ); 237 c = p.color(QPalette::Normal, QColorGroup::Text );
233 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 238 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
234 c = p.color(QPalette::Normal, QColorGroup::Button ); 239 c = p.color(QPalette::Normal, QColorGroup::Button );
235 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 240 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
236 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 241 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
237 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 242 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
238 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 243 c = p.color(QPalette::Normal, QColorGroup::Highlight );
239 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 244 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
240 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 245 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
241 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 246 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
242 mCardView->viewport()->setPalette( p ); 247 mCardView->viewport()->setPalette( p );
243 } 248 }
244 else 249 else
245 { 250 {
246 // needed if turned off during a session. 251 // needed if turned off during a session.
247 mCardView->viewport()->setPalette( mCardView->palette() ); 252 mCardView->viewport()->setPalette( mCardView->palette() );
248 } 253 }
249 254
250 //custom fonts? 255 //custom fonts?
251 QFont f( font() ); 256 QFont f( font() );
252 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 257 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
253 { 258 {
254 mCardView->setFont( config->readFontEntry( "TextFont", &f) ); 259 mCardView->setFont( config->readFontEntry( "TextFont", &f) );
255 f.setBold( true ); 260 f.setBold( true );
256 mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 261 mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
257 } 262 }
258 else 263 else
259 { 264 {
260 mCardView->setFont( f ); 265 mCardView->setFont( f );
261 f.setBold( true ); 266 f.setBold( true );
262 mCardView->setHeaderFont( f ); 267 mCardView->setHeaderFont( f );
263 } 268 }
264 269
265 mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); 270 mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true));
266 mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", 271 mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators",
267 true)); 272 true));
268 mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); 273 mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false));
269 mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); 274 mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false);
270 275
271 mCardView->setShowEmptyFields( mShowEmptyFields ); 276 mCardView->setShowEmptyFields( mShowEmptyFields );
272 277
273 mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); 278 mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) );
274 mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); 279 mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) );
275 mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); 280 mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) );
276 mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); 281 mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) );
277 282
278#if 0 283#if 0
279 // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven 284 // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven
280 disconnect(mCardView, SIGNAL(executed(CardViewItem *)), 285 disconnect(mCardView, SIGNAL(executed(CardViewItem *)),
281 this, SLOT(addresseeExecuted(CardViewItem *))); 286 this, SLOT(addresseeExecuted(CardViewItem *)));
282 287
283 if (KABPrefs::instance()->mHonorSingleClick) 288 if (KABPrefs::instance()->mHonorSingleClick)
284 connect(mCardView, SIGNAL(executed(CardViewItem *)), 289 connect(mCardView, SIGNAL(executed(CardViewItem *)),
285 this, SLOT(addresseeExecuted(CardViewItem *))); 290 this, SLOT(addresseeExecuted(CardViewItem *)));
286 else 291 else
287 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), 292 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)),
288 this, SLOT(addresseeExecuted(CardViewItem *))); 293 this, SLOT(addresseeExecuted(CardViewItem *)));
289#endif 294#endif
290 295
291 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), 296 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)),
292 this, SLOT(addresseeExecuted(CardViewItem *))); 297 this, SLOT(addresseeExecuted(CardViewItem *)));
293} 298}
294 299
295void KAddressBookCardView::writeConfig( KConfig *config ) 300void KAddressBookCardView::writeConfig( KConfig *config )
296{ 301{
297 config->writeEntry( "ItemWidth", mCardView->itemWidth() ); 302 config->writeEntry( "ItemWidth", mCardView->itemWidth() );
298 KAddressBookView::writeConfig( config ); 303 KAddressBookView::writeConfig( config );
299} 304}
300void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) 305void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field )
301{ 306{
302 mCardView->clear(); 307 mCardView->clear();
303 if ( s.isEmpty() || s == "*" ) { 308 if ( s.isEmpty() || s == "*" ) {
304 refresh(); 309 refresh();
305 return; 310 return;
306 } 311 }
307 QRegExp re = getRegExp( s ); 312 QRegExp re = getRegExp( s );
308 if (!re.isValid()) 313 if (!re.isValid())
309 return; 314 return;
310 mCardView->viewport()->setUpdatesEnabled( false ); 315 mCardView->viewport()->setUpdatesEnabled( false );
311 KABC::Addressee::List addresseeList = addressees(); 316 KABC::Addressee::List addresseeList = addressees();
312 KABC::Addressee::List::Iterator it; 317 KABC::Addressee::List::Iterator it;
313 if ( field ) { 318 if ( field ) {
314 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 319 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
315 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 320 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
316 continue; 321 continue;
317#if QT_VERSION >= 0x030000 322#if QT_VERSION >= 0x030000
318 if (re.search(field->value( *it ).lower()) == 0) 323 if (re.search(field->value( *it ).lower()) == 0)
319#else 324#else
320 if (re.match(field->value( *it ).lower()) == 0) 325 if (re.match(field->value( *it ).lower()) == 0)
321#endif 326#endif
322 new AddresseeCardViewItem(fields(), mShowEmptyFields, 327 new AddresseeCardViewItem(fields(), mShowEmptyFields,
323 addressBook(), *it, mCardView); 328 addressBook(), *it, mCardView);
324 329
325 } 330 }
326 } else { 331 } else {
327 KABC::Field::List fieldList = allFields(); 332 KABC::Field::List fieldList = allFields();
328 KABC::Field::List::ConstIterator fieldIt; 333 KABC::Field::List::ConstIterator fieldIt;
329 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 334 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
330 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 335 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
331 continue; 336 continue;
332 bool match = false; 337 bool match = false;
333 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 338 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
334#if QT_VERSION >= 0x030000 339#if QT_VERSION >= 0x030000
335 if (re.search((*fieldIt)->value( *it ).lower()) == 0) 340 if (re.search((*fieldIt)->value( *it ).lower()) == 0)
336#else 341#else
337 if (re.match((*fieldIt)->value( *it ).lower()) == 0) 342 if (re.match((*fieldIt)->value( *it ).lower()) == 0)
338#endif 343#endif
339 { 344 {
340 new AddresseeCardViewItem(fields(), mShowEmptyFields, 345 new AddresseeCardViewItem(fields(), mShowEmptyFields,
341 addressBook(), *it, mCardView); 346 addressBook(), *it, mCardView);
342 match = true; 347 match = true;
343 break; 348 break;
344 } 349 }
345 } 350 }
346 if ( ! match ) { 351 if ( ! match ) {
347 if ( (*it).matchPhoneNumber( &re ) ) { 352 if ( (*it).matchPhoneNumber( &re ) ) {
348 new AddresseeCardViewItem(fields(), mShowEmptyFields, 353 new AddresseeCardViewItem(fields(), mShowEmptyFields,
349 addressBook(), *it, mCardView); 354 addressBook(), *it, mCardView);
350 match = true; 355 match = true;
351 break; 356 break;
352 } 357 }
353 } 358 }
354 if ( ! match ) { 359 if ( ! match ) {
355 if ( (*it).matchAddress( &re ) ) { 360 if ( (*it).matchAddress( &re ) ) {
356 new AddresseeCardViewItem(fields(), mShowEmptyFields, 361 new AddresseeCardViewItem(fields(), mShowEmptyFields,
357 addressBook(), *it, mCardView); 362 addressBook(), *it, mCardView);
358 match = true; 363 match = true;
359 break; 364 break;
360 } 365 }
361 } 366 }
362 } 367 }
363 } 368 }
364 mCardView->viewport()->setUpdatesEnabled( true ); 369 mCardView->viewport()->setUpdatesEnabled( true );
365 mCardView->viewport()->update(); 370 mCardView->viewport()->update();
366 if ( mCardView->firstItem() ) { 371 if ( mCardView->firstItem() ) {
367 mCardView->setCurrentItem ( mCardView->firstItem() ); 372 mCardView->setCurrentItem ( mCardView->firstItem() );
368 mCardView->setSelected ( mCardView->firstItem() , true ); 373 mCardView->setSelected ( mCardView->firstItem() , true );
369 } 374 }
370 else 375 else
371 emit selected(QString::null); 376 emit selected(QString::null);
372} 377}
373QStringList KAddressBookCardView::selectedUids() 378QStringList KAddressBookCardView::selectedUids()
374{ 379{
375 QStringList uidList; 380 QStringList uidList;
376 CardViewItem *item; 381 CardViewItem *item;
377 AddresseeCardViewItem *aItem; 382 AddresseeCardViewItem *aItem;
378 383
379 for (item = mCardView->firstItem(); item; item = item->nextItem()) 384 for (item = mCardView->firstItem(); item; item = item->nextItem())
380 { 385 {
381 if (item->isSelected()) 386 if (item->isSelected())
382 { 387 {
383#ifndef KAB_EMBEDDED 388#ifndef KAB_EMBEDDED
384 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 389 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
385#else //KAB_EMBEDDED 390#else //KAB_EMBEDDED
386 aItem = (AddresseeCardViewItem*)(item); 391 aItem = (AddresseeCardViewItem*)(item);
387#endif //KAB_EMBEDDED 392#endif //KAB_EMBEDDED
388 if (aItem) 393 if (aItem)
389 uidList << aItem->addressee().uid(); 394 uidList << aItem->addressee().uid();
390 } 395 }
391 } 396 }
392 397
393 return uidList; 398 return uidList;
394} 399}
395 400
396void KAddressBookCardView::refresh(QString uid) 401void KAddressBookCardView::refresh(QString uid)
397{ 402{
398 CardViewItem *item; 403 CardViewItem *item;
399 AddresseeCardViewItem *aItem; 404 AddresseeCardViewItem *aItem;
400 405
401 if (uid.isNull()) 406 if (uid.isNull())
402 { 407 {
403 // Rebuild the view 408 // Rebuild the view
404 mCardView->viewport()->setUpdatesEnabled( false ); 409 mCardView->viewport()->setUpdatesEnabled( false );
405 mCardView->clear(); 410 mCardView->clear();
406 411
407 KABC::Addressee::List addresseeList = addressees(); 412 KABC::Addressee::List addresseeList = addressees();
408 KABC::Addressee::List::Iterator iter; 413 KABC::Addressee::List::Iterator iter;
409 for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) 414 for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter)
410 { 415 {
411 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) 416 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") )
412 continue; 417 continue;
413 aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, 418 aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields,
414 addressBook(), *iter, mCardView); 419 addressBook(), *iter, mCardView);
415 } 420 }
416 mCardView->viewport()->setUpdatesEnabled( true ); 421 mCardView->viewport()->setUpdatesEnabled( true );
417 mCardView->viewport()->update(); 422 mCardView->viewport()->update();
418 423
419 // by default nothing is selected 424 // by default nothing is selected
420 emit selected(QString::null); 425 emit selected(QString::null);
421 } 426 }
422 else 427 else
423 { 428 {
424 // Try to find the one to refresh 429 // Try to find the one to refresh
425 bool found = false; 430 bool found = false;
426 for (item = mCardView->firstItem(); item && !found; 431 for (item = mCardView->firstItem(); item && !found;
427 item = item->nextItem()) 432 item = item->nextItem())
428 { 433 {
429#ifndef KAB_EMBEDDED 434#ifndef KAB_EMBEDDED
430 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 435 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
431#else //KAB_EMBEDDED 436#else //KAB_EMBEDDED
432 aItem = (AddresseeCardViewItem*)(item); 437 aItem = (AddresseeCardViewItem*)(item);
433#endif //KAB_EMBEDDED 438#endif //KAB_EMBEDDED
434 439
435 if ((aItem) && (aItem->addressee().uid() == uid)) 440 if ((aItem) && (aItem->addressee().uid() == uid))
436 { 441 {
437 aItem->refresh(); 442 aItem->refresh();
438 found = true; 443 found = true;
439 } 444 }
440 } 445 }
441 } 446 }
442} 447}
443 448
444void KAddressBookCardView::setSelected(QString uid, bool selected) 449void KAddressBookCardView::setSelected(QString uid, bool selected)
445{ 450{
446 CardViewItem *item; 451 CardViewItem *item;
447 AddresseeCardViewItem *aItem; 452 AddresseeCardViewItem *aItem;
448 453
449 if (uid.isNull()) 454 if (uid.isNull())
450 { 455 {
451 mCardView->selectAll(selected); 456 mCardView->selectAll(selected);
452 } 457 }
453 else 458 else
454 { 459 {
455 bool found = false; 460 bool found = false;
456 for (item = mCardView->firstItem(); item && !found; 461 for (item = mCardView->firstItem(); item && !found;
457 item = item->nextItem()) 462 item = item->nextItem())
458 { 463 {
459#ifndef KAB_EMBEDDED 464#ifndef KAB_EMBEDDED
460 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 465 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
461#else //KAB_EMBEDDED 466#else //KAB_EMBEDDED
462 aItem = (AddresseeCardViewItem*)(item); 467 aItem = (AddresseeCardViewItem*)(item);
463#endif //KAB_EMBEDDED 468#endif //KAB_EMBEDDED
464 469
465 if ((aItem) && (aItem->addressee().uid() == uid)) 470 if ((aItem) && (aItem->addressee().uid() == uid))
466 { 471 {
467 mCardView->setSelected(aItem, selected); 472 mCardView->setSelected(aItem, selected);
468 mCardView->ensureItemVisible(item); 473 mCardView->ensureItemVisible(item);
469 found = true; 474 found = true;
470 } 475 }
471 } 476 }
472 } 477 }
473} 478}
474 479
475//US added an additional method without parameter 480//US added an additional method without parameter
476void KAddressBookCardView::setSelected() 481void KAddressBookCardView::setSelected()
477{ 482{
478 setSelected(QString::null, true); 483 setSelected(QString::null, true);
479} 484}
480 485
481void KAddressBookCardView::addresseeExecuted(CardViewItem *item) 486void KAddressBookCardView::addresseeExecuted(CardViewItem *item)
482{ 487{
483#ifndef KAB_EMBEDDED 488#ifndef KAB_EMBEDDED
484 AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); 489 AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item);
485#else //KAB_EMBEDDED 490#else //KAB_EMBEDDED
486 AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); 491 AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item);
487#endif //KAB_EMBEDDED 492#endif //KAB_EMBEDDED
488 if (aItem) 493 if (aItem)
489 { 494 {
490 //kdDebug()<<"... even has a valid item:)"<<endl; 495 //kdDebug()<<"... even has a valid item:)"<<endl;
491 emit executed(aItem->addressee().uid()); 496 emit executed(aItem->addressee().uid());
492 } 497 }
493} 498}
494 499
495void KAddressBookCardView::addresseeSelected() 500void KAddressBookCardView::addresseeSelected()
496{ 501{
497 CardViewItem *item; 502 CardViewItem *item;
498 AddresseeCardViewItem *aItem; 503 AddresseeCardViewItem *aItem;
499 504
500 bool found = false; 505 bool found = false;
501 for (item = mCardView->firstItem(); item && !found; 506 for (item = mCardView->firstItem(); item && !found;
502 item = item->nextItem()) 507 item = item->nextItem())
503 { 508 {
504 if (item->isSelected()) 509 if (item->isSelected())
505 { 510 {
506#ifndef KAB_EMBEDDED 511#ifndef KAB_EMBEDDED
507 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 512 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
508#else //KAB_EMBEDDED 513#else //KAB_EMBEDDED
509 aItem = (AddresseeCardViewItem*)(item); 514 aItem = (AddresseeCardViewItem*)(item);
510#endif //KAB_EMBEDDED 515#endif //KAB_EMBEDDED
511 if ( aItem ) 516 if ( aItem )
512 { 517 {
513 emit selected(aItem->addressee().uid()); 518 emit selected(aItem->addressee().uid());
514 found = true; 519 found = true;
515 } 520 }
516 } 521 }
517 } 522 }
518 523
519 if (!found) 524 if (!found)
520 emit selected(QString::null); 525 emit selected(QString::null);
521 526
522} 527}
523#ifndef KAB_EMBEDDED 528#ifndef KAB_EMBEDDED_
524#include "kaddressbookcardview.moc" 529#include "moc_kaddressbookcardview.cpp"
525#endif //KAB_EMBEDDED 530#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/kaddressbookcardview.h b/kaddressbook/views/kaddressbookcardview.h
index 2a71f7e..8f8e48b 100644
--- a/kaddressbook/views/kaddressbookcardview.h
+++ b/kaddressbook/views/kaddressbookcardview.h
@@ -1,122 +1,125 @@
1#ifndef KADDRESSBOOKCARDVIEW_H 1#ifndef KADDRESSBOOKCARDVIEW_H
2#define KADDRESSBOOKCARDVIEW_H 2#define KADDRESSBOOKCARDVIEW_H
3 3
4/* 4/*
5 This file is part of KAddressBook. 5 This file is part of KAddressBook.
6 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 6 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
7 7
8 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or 10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 (at your option) any later version.
12 12
13 This program is distributed in the hope that it will be useful, 13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 GNU General Public License for more details.
17 17
18 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 21
22 As a special exception, permission is given to link this program 22 As a special exception, permission is given to link this program
23 with any edition of Qt, and distribute the resulting executable, 23 with any edition of Qt, and distribute the resulting executable,
24 without including the source code for Qt in the source distribution. 24 without including the source code for Qt in the source distribution.
25*/ 25*/
26 26
27#include <qstring.h> 27#include <qstring.h>
28//Added by qt3to4:
29#include <QDragEnterEvent>
30#include <QDropEvent>
28#ifndef KAB_EMBEDDED 31#ifndef KAB_EMBEDDED
29#include <kiconview.h> 32#include <kiconview.h>
30#else //KAB_EMBEDDED 33#else //KAB_EMBEDDED
31#include <klocale.h> 34#include <klocale.h>
32#endif //KAB_EMBEDDED 35#endif //KAB_EMBEDDED
33 36
34#include "cardview.h" 37#include "cardview.h"
35#include "kaddressbookview.h" 38#include "kaddressbookview.h"
36#include "configurecardviewdialog.h" 39#include "configurecardviewdialog.h"
37 40
38class QDragEnterEvent; 41class QDragEnterEvent;
39class QDragEntryEvent; 42class QDragEntryEvent;
40class QDropEvent; 43class QDropEvent;
41class KConfig; 44class KConfig;
42class AddresseeCardView; 45class AddresseeCardView;
43 46
44/** 47/**
45 This view uses the CardView class to create a card view. At some 48 This view uses the CardView class to create a card view. At some
46 point in the future I think this will be the default view of 49 point in the future I think this will be the default view of
47 KAddressBook. 50 KAddressBook.
48 */ 51 */
49class KAddressBookCardView : public KAddressBookView 52class KAddressBookCardView : public KAddressBookView
50{ 53{
51 Q_OBJECT 54 Q_OBJECT
52 55
53 public: 56 public:
54 KAddressBookCardView( KABC::AddressBook *ab, QWidget *parent, 57 KAddressBookCardView( KABC::AddressBook *ab, QWidget *parent,
55 const char *name = 0 ); 58 const char *name = 0 );
56 virtual ~KAddressBookCardView(); 59 virtual ~KAddressBookCardView();
57 void doSearch( const QString& s,KABC::Field *field ); 60 void doSearch( const QString& s,KABC::Field *field );
58 virtual QStringList selectedUids(); 61 virtual QStringList selectedUids();
59 virtual QString type() const { return "Card"; } 62 virtual QString type() const { return "Card"; }
60 63
61 virtual void readConfig(KConfig *config); 64 virtual void readConfig(KConfig *config);
62 virtual void writeConfig(KConfig *); 65 virtual void writeConfig(KConfig *);
63 virtual void scrollUP(); 66 virtual void scrollUP();
64 virtual void scrollDOWN(); 67 virtual void scrollDOWN();
65 virtual void setFocusAV(); 68 virtual void setFocusAV();
66 69
67 public slots: 70 public slots:
68 void refresh(QString uid = QString::null); 71 void refresh(QString uid = QString::null);
69 void setSelected(QString uid/*US = QString::null*/, bool selected/*US = true*/); 72 void setSelected(QString uid/*US = QString::null*/, bool selected/*US = true*/);
70//US added an additional method without parameter 73//US added an additional method without parameter
71 void setSelected(); 74 void setSelected();
72 75
73 protected slots: 76 protected slots:
74 void addresseeExecuted(CardViewItem *item); 77 void addresseeExecuted(CardViewItem *item);
75 void addresseeSelected(); 78 void addresseeSelected();
76 79
77 private: 80 private:
78 AddresseeCardView *mCardView; 81 AddresseeCardView *mCardView;
79 bool mShowEmptyFields; 82 bool mShowEmptyFields;
80}; 83};
81 84
82class AddresseeCardView : public CardView 85class AddresseeCardView : public CardView
83{ 86{
84 Q_OBJECT 87 Q_OBJECT
85 public: 88 public:
86 AddresseeCardView(QWidget *parent, const char *name = 0); 89 AddresseeCardView(QWidget *parent, const char *name = 0);
87 ~AddresseeCardView(); 90 ~AddresseeCardView();
88public slots: 91public slots:
89 void printMe(); 92 void printMe();
90 93
91 signals: 94 signals:
92 void startAddresseeDrag(); 95 void startAddresseeDrag();
93 void addresseeDropped(QDropEvent *); 96 void addresseeDropped(QDropEvent *);
94 97
95 protected: 98 protected:
96 virtual void dragEnterEvent(QDragEnterEvent *); 99 virtual void dragEnterEvent(QDragEnterEvent *);
97 virtual void dropEvent(QDropEvent *); 100 virtual void dropEvent(QDropEvent *);
98 virtual void startDrag(); 101 virtual void startDrag();
99}; 102};
100 103
101 104
102class CardViewFactory : public ViewFactory 105class CardViewFactory : public ViewFactory
103{ 106{
104 public: 107 public:
105 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) 108 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name )
106 { 109 {
107 return new KAddressBookCardView( ab, parent, name ); 110 return new KAddressBookCardView( ab, parent, name );
108 } 111 }
109 112
110 QString type() const { return "Card"; } 113 QString type() const { return "Card"; }
111 114
112 QString description() const { return i18n( "Rolodex style cards represent contacts." ); } 115 QString description() const { return i18n( "Rolodex style cards represent contacts." ); }
113 116
114 ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent, 117 ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent,
115 const char *name = 0 ) 118 const char *name = 0 )
116 { 119 {
117 return new ConfigureCardViewWidget( ab, parent, name ); 120 return new ConfigureCardViewWidget( ab, parent, name );
118 } 121 }
119}; 122};
120 123
121 124
122#endif 125#endif
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp
index d6ddec3..3a41a4b 100644
--- a/kaddressbook/views/kaddressbookiconview.cpp
+++ b/kaddressbook/views/kaddressbookiconview.cpp
@@ -1,481 +1,489 @@
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 KAB_EMBEDDED 24#ifndef KAB_EMBEDDED
25#include <qiconview.h> 25#include <q3iconview.h>
26#include <qstringlist.h> 26#include <qstringlist.h>
27 27
28#include <kabc/addressee.h> 28#include <kabc/addressee.h>
29#include <kconfig.h> 29#include <kconfig.h>
30#include <kdebug.h> 30#include <kdebug.h>
31#include <kglobal.h> 31#include <kglobal.h>
32#include <kiconloader.h> 32#include <kiconloader.h>
33#include <klocale.h> 33#include <klocale.h>
34 34
35#else //KAB_EMBEDDED 35#else //KAB_EMBEDDED
36#endif //KAB_EMBEDDED 36#endif //KAB_EMBEDDED
37 37
38//Added by qt3to4:
39#include <QDropEvent>
40#include <Q3ValueList>
41#include <QPixmap>
42#include <QKeyEvent>
43#include <QEvent>
44#include <Q3VBoxLayout>
45
38#include <kabc/addressbook.h> 46#include <kabc/addressbook.h>
39#include "kabprefs.h" 47#include "kabprefs.h"
40#include "viewmanager.h" 48#include "viewmanager.h"
41#include "kaddressbookiconview.h" 49#include "kaddressbookiconview.h"
42#include <qlayout.h> 50#include <qlayout.h>
43#include <qregexp.h> 51#include <qregexp.h>
44#include <qapplication.h> 52#include <qapplication.h>
45#include <kglobal.h> 53#include <kglobal.h>
46/*US transfered to the headerfile 54/*US transfered to the headerfile
47class IconViewFactory : public ViewFactory 55class IconViewFactory : public ViewFactory
48{ 56{
49 public: 57 public:
50 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) 58 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name )
51 { 59 {
52 return new KAddressBookIconView( ab, parent, name ); 60 return new KAddressBookIconView( ab, parent, name );
53 } 61 }
54 62
55 QString type() const { return "Icon"; } 63 QString type() const { return "Icon"; }
56 64
57 QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } 65 QString description() const { return i18n( "Icons represent contacts. Very simple view." ); }
58}; 66};
59 67
60*/ 68*/
61 69
62extern "C" { 70extern "C" {
63 void *init_libkaddrbk_iconview() 71 void *init_libkaddrbk_iconview()
64 { 72 {
65 return ( new IconViewFactory ); 73 return ( new IconViewFactory );
66 } 74 }
67} 75}
68 76
69//////////////////////////////// 77////////////////////////////////
70// AddresseeIconView (internal class) 78// AddresseeIconView (internal class)
71#ifndef KAB_EMBEDDED 79#ifndef KAB_EMBEDDED
72AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) 80AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name)
73 : KIconView(parent, name) 81 : KIconView(parent, name)
74#else //KAB_EMBEDDED 82#else //KAB_EMBEDDED
75AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) 83AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name)
76 : QIconView(parent, name) 84 : Q3IconView(parent, name)
77#endif //KAB_EMBEDDED 85#endif //KAB_EMBEDDED
78 86
79{ 87{
80 setSelectionMode( QIconView::Extended ); 88 setSelectionMode( Q3IconView::Extended );
81 setResizeMode( QIconView::Adjust ); 89 setResizeMode( Q3IconView::Adjust );
82 setWordWrapIconText( true ); 90 setWordWrapIconText( true );
83 setGridX( 100 ); 91 setGridX( 100 );
84 setItemsMovable(false); 92 setItemsMovable(false);
85 setSorting(true, true); 93 setSorting(true, true);
86 94
87 95
88//US ??? setMode( KIconView::Select ); 96//US ??? setMode( KIconView::Select );
89 97
90#ifndef KAB_EMBEDDED 98#ifndef KAB_EMBEDDED
91 99
92 connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), 100 connect(this, SIGNAL(dropped(QDropEvent*, const Q3ValueList<Q3IconDragItem>&)),
93 this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&))); 101 this, SLOT(itemDropped(QDropEvent*, const Q3ValueList<Q3IconDragItem>&)));
94#endif //KAB_EMBEDDED 102#endif //KAB_EMBEDDED
95} 103}
96 104
97AddresseeIconView::~AddresseeIconView() 105AddresseeIconView::~AddresseeIconView()
98{ 106{
99} 107}
100 108
101 109
102void AddresseeIconView::itemDropped(QDropEvent *e, 110void AddresseeIconView::itemDropped(QDropEvent *e,
103 const QValueList<QIconDragItem> &) 111 const Q3ValueList<Q3IconDragItem> &)
104{ 112{
105 emit addresseeDropped(e); 113 emit addresseeDropped(e);
106} 114}
107 115
108QDragObject *AddresseeIconView::dragObject() 116Q3DragObject *AddresseeIconView::dragObject()
109{ 117{
110 emit startAddresseeDrag(); 118 emit startAddresseeDrag();
111 119
112 // We never want IconView to start the drag 120 // We never want IconView to start the drag
113 return 0; 121 return 0;
114} 122}
115//////////////////////////////// 123////////////////////////////////
116// AddresseeIconViewItem (internal class) 124// AddresseeIconViewItem (internal class)
117#ifndef KAB_EMBEDDED 125#ifndef KAB_EMBEDDED
118class AddresseeIconViewItem : public KIconViewItem 126class AddresseeIconViewItem : public KIconViewItem
119#else //KAB_EMBEDDED 127#else //KAB_EMBEDDED
120class AddresseeIconViewItem : public QIconViewItem 128class AddresseeIconViewItem : public Q3IconViewItem
121#endif //KAB_EMBEDDED 129#endif //KAB_EMBEDDED
122{ 130{
123 public: 131 public:
124#ifndef KAB_EMBEDDED 132#ifndef KAB_EMBEDDED
125 AddresseeIconViewItem(const KABC::Field::List &fields, 133 AddresseeIconViewItem(const KABC::Field::List &fields,
126 KABC::AddressBook *doc, const KABC::Addressee &a, 134 KABC::AddressBook *doc, const KABC::Addressee &a,
127 QIconView *parent) 135 Q3IconView *parent)
128 : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) 136 : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a)
129#else //KAB_EMBEDDED 137#else //KAB_EMBEDDED
130 AddresseeIconViewItem(const KABC::Field::List &fields, 138 AddresseeIconViewItem(const KABC::Field::List &fields,
131 KABC::AddressBook *doc, const KABC::Addressee &a, 139 KABC::AddressBook *doc, const KABC::Addressee &a,
132 QIconView *parent) 140 Q3IconView *parent)
133 : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) 141 : Q3IconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a)
134#endif //KAB_EMBEDDED 142#endif //KAB_EMBEDDED
135 { 143 {
136 if ( mFields.isEmpty() ) { 144 if ( mFields.isEmpty() ) {
137 mFields = KABC::Field::defaultFields(); 145 mFields = KABC::Field::defaultFields();
138 } 146 }
139 refresh(); 147 refresh();
140 } 148 }
141 149
142 const KABC::Addressee &addressee() const { return mAddressee; } 150 const KABC::Addressee &addressee() const { return mAddressee; }
143 151
144 void refresh() 152 void refresh()
145 { 153 {
146 // Update our addressee, since it may have changed elsewhere 154 // Update our addressee, since it may have changed elsewhere
147 mAddressee = mDocument->findByUid(mAddressee.uid()); 155 mAddressee = mDocument->findByUid(mAddressee.uid());
148 156
149 if (!mAddressee.isEmpty()) 157 if (!mAddressee.isEmpty())
150 setText( mAddressee.givenName() + " " + mAddressee.familyName() ); 158 setText( mAddressee.givenName() + " " + mAddressee.familyName() );
151 159
152 QPixmap icon; 160 QPixmap icon;
153 161
154 KABC::Picture pic = mAddressee.photo(); 162 KABC::Picture pic = mAddressee.photo();
155 if ( pic.data().isNull() ) 163 if ( pic.data().isNull() )
156 pic = mAddressee.logo(); 164 pic = mAddressee.logo();
157 165
158 if ( pic.isIntern() && !pic.data().isNull() ) { 166 if ( pic.isIntern() && !pic.data().isNull() ) {
159 QImage img = pic.data(); 167 QImage img = pic.data();
160#ifndef KAB_EMBEDDED 168#ifndef KAB_EMBEDDED
161 if ( img.width() > img.height() ) 169 if ( img.width() > img.height() )
162 icon = img.scaleWidth( 32 ); 170 icon = img.scaleWidth( 32 );
163 else 171 else
164 icon = img.scaleHeight( 32 ); 172 icon = img.scaleHeight( 32 );
165#else //KAB_EMBEDDED 173#else //KAB_EMBEDDED
166 174
167 int wid = pic.data().width(); 175 int wid = pic.data().width();
168 int hei = pic.data().height(); 176 int hei = pic.data().height();
169 int max = 48; 177 int max = 48;
170 if ( wid > max || hei > max ) { 178 if ( wid > max || hei > max ) {
171 if ( wid > hei ) { 179 if ( wid > hei ) {
172 hei = (hei*max)/wid; 180 hei = (hei*max)/wid;
173 wid = max; 181 wid = max;
174 } else { 182 } else {
175 wid = (wid*max)/hei; 183 wid = (wid*max)/hei;
176 hei = max; 184 hei = max;
177 } 185 }
178 } 186 }
179 qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor"); 187 qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor");
180 icon.convertFromImage(img.smoothScale(wid, hei)); 188 icon.convertFromImage(img.smoothScale(wid, hei));
181#endif //KAB_EMBEDDED 189#endif //KAB_EMBEDDED
182 190
183 } else { 191 } else {
184 icon = KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ); 192 icon = KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 );
185 } 193 }
186 setPixmap( icon ); 194 setPixmap( icon );
187 } 195 }
188 196
189 private: 197 private:
190 KABC::Field::List mFields; 198 KABC::Field::List mFields;
191 KABC::AddressBook *mDocument; 199 KABC::AddressBook *mDocument;
192 KABC::Addressee mAddressee; 200 KABC::Addressee mAddressee;
193}; 201};
194 202
195/////////////////////////////// 203///////////////////////////////
196// KAddressBookView 204// KAddressBookView
197 205
198KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, 206KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab,
199 QWidget *parent, const char *name) 207 QWidget *parent, const char *name)
200 : KAddressBookView( ab, parent, name ) 208 : KAddressBookView( ab, parent, name )
201{ 209{
202 // Init the GUI 210 // Init the GUI
203 QVBoxLayout *layout = new QVBoxLayout(viewWidget()); 211 Q3VBoxLayout *layout = new Q3VBoxLayout(viewWidget());
204 212
205 mIconView = new AddresseeIconView(viewWidget(), "mIconView"); 213 mIconView = new AddresseeIconView(viewWidget(), "mIconView");
206 layout->addWidget(mIconView); 214 layout->addWidget(mIconView);
207 215
208 // Connect up the signals 216 // Connect up the signals
209 217
210//US method executed is part of KIconView 218//US method executed is part of KIconView
211//US connect(mIconView, SIGNAL(executed(QIconViewItem *)), 219//US connect(mIconView, SIGNAL(executed(QIconViewItem *)),
212//US this, SLOT(addresseeExecuted(QIconViewItem *))); 220//US this, SLOT(addresseeExecuted(QIconViewItem *)));
213 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 221 connect(mIconView, SIGNAL(selectionChanged(Q3IconViewItem *)),
214 this, SLOT(addresseeExecuted(QIconViewItem *))); 222 this, SLOT(addresseeExecuted(Q3IconViewItem *)));
215 223
216 connect(mIconView, SIGNAL(selectionChanged()), 224 connect(mIconView, SIGNAL(selectionChanged()),
217 this, SLOT(addresseeSelected())); 225 this, SLOT(addresseeSelected()));
218 connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), 226 connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)),
219 this, SIGNAL(dropped(QDropEvent*))); 227 this, SIGNAL(dropped(QDropEvent*)));
220 connect(mIconView, SIGNAL(startAddresseeDrag()), 228 connect(mIconView, SIGNAL(startAddresseeDrag()),
221 this, SIGNAL(startDrag())); 229 this, SIGNAL(startDrag()));
222} 230}
223 231
224KAddressBookIconView::~KAddressBookIconView() 232KAddressBookIconView::~KAddressBookIconView()
225{ 233{
226} 234}
227void KAddressBookIconView::setFocusAV() 235void KAddressBookIconView::setFocusAV()
228{ 236{
229 if ( mIconView ) 237 if ( mIconView )
230 mIconView->setFocus(); 238 mIconView->setFocus();
231} 239}
232 240
233 241
234void KAddressBookIconView::scrollUP() 242void KAddressBookIconView::scrollUP()
235{ 243{
236 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 244 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
237 QApplication::postEvent( mIconView, ev ); 245 QApplication::postEvent( mIconView, ev );
238} 246}
239void KAddressBookIconView::scrollDOWN() 247void KAddressBookIconView::scrollDOWN()
240{ 248{
241 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 249 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
242 QApplication::postEvent( mIconView, ev ); 250 QApplication::postEvent( mIconView, ev );
243} 251}
244void KAddressBookIconView::readConfig(KConfig *config) 252void KAddressBookIconView::readConfig(KConfig *config)
245{ 253{
246 KAddressBookView::readConfig(config); 254 KAddressBookView::readConfig(config);
247 255
248//US method executed is part of KIconView 256//US method executed is part of KIconView
249//US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), 257//US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)),
250//US this, SLOT(addresseeExecuted(QIconViewItem *))); 258//US this, SLOT(addresseeExecuted(QIconViewItem *)));
251 disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 259 disconnect(mIconView, SIGNAL(selectionChanged(Q3IconViewItem *)),
252 this, SLOT(addresseeExecuted(QIconViewItem *))); 260 this, SLOT(addresseeExecuted(Q3IconViewItem *)));
253 261
254//US method executed is part of KIconView. Use selectionChanged instead 262//US method executed is part of KIconView. Use selectionChanged instead
255/*US 263/*US
256 if (KABPrefs::instance()->mHonorSingleClick) 264 if (KABPrefs::instance()->mHonorSingleClick)
257 connect(mIconView, SIGNAL(executed(QIconViewItem *)), 265 connect(mIconView, SIGNAL(executed(QIconViewItem *)),
258 this, SLOT(addresseeExecuted(QIconViewItem *))); 266 this, SLOT(addresseeExecuted(QIconViewItem *)));
259 else 267 else
260 connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), 268 connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)),
261 this, SLOT(addresseeExecuted(QIconViewItem *))); 269 this, SLOT(addresseeExecuted(QIconViewItem *)));
262*/ 270*/
263 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 271 connect(mIconView, SIGNAL(selectionChanged(Q3IconViewItem *)),
264 this, SLOT(addresseeExecuted(QIconViewItem *))); 272 this, SLOT(addresseeExecuted(Q3IconViewItem *)));
265 273
266} 274}
267void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) 275void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field )
268{ 276{
269 mIconView->clear(); 277 mIconView->clear();
270 mIconList.clear(); 278 mIconList.clear();
271 if ( s.isEmpty() || s == "*" ) { 279 if ( s.isEmpty() || s == "*" ) {
272 refresh(); 280 refresh();
273 return; 281 return;
274 } 282 }
275 QRegExp re = getRegExp( s ); 283 QRegExp re = getRegExp( s );
276 if (!re.isValid()) 284 if (!re.isValid())
277 return; 285 return;
278 KABC::Addressee::List addresseeList = addressees(); 286 KABC::Addressee::List addresseeList = addressees();
279 KABC::Addressee::List::Iterator it; 287 KABC::Addressee::List::Iterator it;
280 if ( field ) { 288 if ( field ) {
281 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 289 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
282 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 290 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
283 continue; 291 continue;
284#if QT_VERSION >= 0x030000 292#if QT_VERSION >= 0x030000
285 if (re.search(field->value( *it ).lower()) == 0) 293 if (re.search(field->value( *it ).lower()) == 0)
286#else 294#else
287 if (re.match(field->value( *it ).lower()) == 0) 295 if (re.match(field->value( *it ).lower()) == 0)
288#endif 296#endif
289 mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 297 mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
290 298
291 299
292 } 300 }
293 } else { 301 } else {
294 KABC::Field::List fieldList = allFields(); 302 KABC::Field::List fieldList = allFields();
295 KABC::Field::List::ConstIterator fieldIt; 303 KABC::Field::List::ConstIterator fieldIt;
296 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 304 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
297 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 305 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
298 continue; 306 continue;
299 bool match = false; 307 bool match = false;
300 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 308 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
301#if QT_VERSION >= 0x030000 309#if QT_VERSION >= 0x030000
302 if (re.search((*fieldIt)->value( *it ).lower()) == 0) 310 if (re.search((*fieldIt)->value( *it ).lower()) == 0)
303#else 311#else
304 if (re.match((*fieldIt)->value( *it ).lower()) == 0) 312 if (re.match((*fieldIt)->value( *it ).lower()) == 0)
305#endif 313#endif
306 { 314 {
307 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 315 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
308 match = true; 316 match = true;
309 break; 317 break;
310 } 318 }
311 } 319 }
312 if ( ! match ) { 320 if ( ! match ) {
313 if ( (*it).matchPhoneNumber( &re ) ) { 321 if ( (*it).matchPhoneNumber( &re ) ) {
314 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 322 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
315 match = true; 323 match = true;
316 break; 324 break;
317 } 325 }
318 } 326 }
319 if ( ! match ) { 327 if ( ! match ) {
320 if ( (*it).matchAddress( &re ) ) { 328 if ( (*it).matchAddress( &re ) ) {
321 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 329 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
322 match = true; 330 match = true;
323 break; 331 break;
324 } 332 }
325 } 333 }
326 } 334 }
327 } 335 }
328 mIconView->arrangeItemsInGrid( true ); 336 mIconView->arrangeItemsInGrid( true );
329 if ( mIconView->firstItem() ) { 337 if ( mIconView->firstItem() ) {
330 mIconView->setCurrentItem ( mIconView->firstItem() ); 338 mIconView->setCurrentItem ( mIconView->firstItem() );
331 mIconView->setSelected ( mIconView->firstItem() , true ); 339 mIconView->setSelected ( mIconView->firstItem() , true );
332 } 340 }
333 else 341 else
334 emit selected(QString::null); 342 emit selected(QString::null);
335} 343}
336QStringList KAddressBookIconView::selectedUids() 344QStringList KAddressBookIconView::selectedUids()
337{ 345{
338 QStringList uidList; 346 QStringList uidList;
339 QIconViewItem *item; 347 Q3IconViewItem *item;
340 AddresseeIconViewItem *aItem; 348 AddresseeIconViewItem *aItem;
341 349
342 for (item = mIconView->firstItem(); item; item = item->nextItem()) 350 for (item = mIconView->firstItem(); item; item = item->nextItem())
343 { 351 {
344 if (item->isSelected()) 352 if (item->isSelected())
345 { 353 {
346#ifndef KAB_EMBEDDED 354#ifndef KAB_EMBEDDED
347 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 355 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
348#else //KAB_EMBEDDED 356#else //KAB_EMBEDDED
349 aItem = (AddresseeIconViewItem*)(item); 357 aItem = (AddresseeIconViewItem*)(item);
350#endif //KAB_EMBEDDED 358#endif //KAB_EMBEDDED
351 if (aItem) 359 if (aItem)
352 uidList << aItem->addressee().uid(); 360 uidList << aItem->addressee().uid();
353 } 361 }
354 } 362 }
355 363
356 return uidList; 364 return uidList;
357} 365}
358 366
359void KAddressBookIconView::refresh(QString uid) 367void KAddressBookIconView::refresh(QString uid)
360{ 368{
361 QIconViewItem *item; 369 Q3IconViewItem *item;
362 AddresseeIconViewItem *aItem; 370 AddresseeIconViewItem *aItem;
363 371
364 if ( uid.isNull() ) { 372 if ( uid.isNull() ) {
365 // Rebuild the view 373 // Rebuild the view
366 mIconView->clear(); 374 mIconView->clear();
367 mIconList.clear(); 375 mIconList.clear();
368 376
369 KABC::Addressee::List addresseeList = addressees(); 377 KABC::Addressee::List addresseeList = addressees();
370 KABC::Addressee::List::Iterator iter; 378 KABC::Addressee::List::Iterator iter;
371 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) { 379 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) {
372 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) 380 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") )
373 continue; 381 continue;
374 aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); 382 aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView );
375 } 383 }
376 384
377 mIconView->arrangeItemsInGrid( true ); 385 mIconView->arrangeItemsInGrid( true );
378 386
379 for ( item = mIconView->firstItem(); item; item = item->nextItem() ) 387 for ( item = mIconView->firstItem(); item; item = item->nextItem() )
380 { 388 {
381#ifndef KAB_EMBEDDED 389#ifndef KAB_EMBEDDED
382 AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item ); 390 AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item );
383#else //KAB_EMBEDDED 391#else //KAB_EMBEDDED
384 AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item ); 392 AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item );
385#endif //KAB_EMBEDDED 393#endif //KAB_EMBEDDED
386 mIconList.append( aivi ); 394 mIconList.append( aivi );
387 } 395 }
388 396
389 } else { 397 } else {
390 // Try to find the one to refresh 398 // Try to find the one to refresh
391 for ( item = mIconView->firstItem(); item; item = item->nextItem() ) { 399 for ( item = mIconView->firstItem(); item; item = item->nextItem() ) {
392#ifndef KAB_EMBEDDED 400#ifndef KAB_EMBEDDED
393 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 401 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
394#else //KAB_EMBEDDED 402#else //KAB_EMBEDDED
395 aItem = (AddresseeIconViewItem*)(item); 403 aItem = (AddresseeIconViewItem*)(item);
396#endif //KAB_EMBEDDED 404#endif //KAB_EMBEDDED
397 if ((aItem) && (aItem->addressee().uid() == uid)) { 405 if ((aItem) && (aItem->addressee().uid() == uid)) {
398 aItem->refresh(); 406 aItem->refresh();
399 mIconView->arrangeItemsInGrid( true ); 407 mIconView->arrangeItemsInGrid( true );
400 return; 408 return;
401 } 409 }
402 } 410 }
403 refresh( QString::null ); 411 refresh( QString::null );
404 } 412 }
405} 413}
406 414
407void KAddressBookIconView::setSelected(QString uid, bool selected) 415void KAddressBookIconView::setSelected(QString uid, bool selected)
408{ 416{
409 QIconViewItem *item; 417 Q3IconViewItem *item;
410 AddresseeIconViewItem *aItem; 418 AddresseeIconViewItem *aItem;
411 419
412 if (uid.isNull()) 420 if (uid.isNull())
413 { 421 {
414 mIconView->selectAll(selected); 422 mIconView->selectAll(selected);
415 } 423 }
416 else 424 else
417 { 425 {
418 bool found = false; 426 bool found = false;
419 for (item = mIconView->firstItem(); item && !found; 427 for (item = mIconView->firstItem(); item && !found;
420 item = item->nextItem()) 428 item = item->nextItem())
421 { 429 {
422#ifndef KAB_EMBEDDED 430#ifndef KAB_EMBEDDED
423 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 431 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
424#else //KAB_EMBEDDED 432#else //KAB_EMBEDDED
425 aItem = (AddresseeIconViewItem*)(item); 433 aItem = (AddresseeIconViewItem*)(item);
426#endif //KAB_EMBEDDED 434#endif //KAB_EMBEDDED
427 435
428 if ((aItem) && (aItem->addressee().uid() == uid)) 436 if ((aItem) && (aItem->addressee().uid() == uid))
429 { 437 {
430 mIconView->setSelected(aItem, selected); 438 mIconView->setSelected(aItem, selected);
431 mIconView->ensureItemVisible( aItem ); 439 mIconView->ensureItemVisible( aItem );
432 found = true; 440 found = true;
433 } 441 }
434 } 442 }
435 } 443 }
436} 444}
437 445
438void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) 446void KAddressBookIconView::addresseeExecuted(Q3IconViewItem *item)
439{ 447{
440#ifndef KAB_EMBEDDED 448#ifndef KAB_EMBEDDED
441 AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item); 449 AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item);
442#else //KAB_EMBEDDED 450#else //KAB_EMBEDDED
443 AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item); 451 AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item);
444#endif //KAB_EMBEDDED 452#endif //KAB_EMBEDDED
445 453
446 if (aItem) { 454 if (aItem) {
447 emit executed(aItem->addressee().uid()); 455 emit executed(aItem->addressee().uid());
448 } 456 }
449} 457}
450 458
451void KAddressBookIconView::addresseeSelected() 459void KAddressBookIconView::addresseeSelected()
452{ 460{
453 QIconViewItem *item; 461 Q3IconViewItem *item;
454 AddresseeIconViewItem *aItem; 462 AddresseeIconViewItem *aItem;
455 463
456 bool found = false; 464 bool found = false;
457 for (item = mIconView->firstItem(); item && !found; 465 for (item = mIconView->firstItem(); item && !found;
458 item = item->nextItem()) 466 item = item->nextItem())
459 { 467 {
460 if (item->isSelected()) 468 if (item->isSelected())
461 { 469 {
462#ifndef KAB_EMBEDDED 470#ifndef KAB_EMBEDDED
463 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 471 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
464#else //KAB_EMBEDDED 472#else //KAB_EMBEDDED
465 aItem = (AddresseeIconViewItem*)(item); 473 aItem = (AddresseeIconViewItem*)(item);
466#endif //KAB_EMBEDDED 474#endif //KAB_EMBEDDED
467 if (aItem) 475 if (aItem)
468 { 476 {
469 emit selected(aItem->addressee().uid()); 477 emit selected(aItem->addressee().uid());
470 found = true; 478 found = true;
471 } 479 }
472 } 480 }
473 } 481 }
474 482
475 if (!found) 483 if (!found)
476 emit selected(QString::null); 484 emit selected(QString::null);
477} 485}
478 486
479#ifndef KAB_EMBEDDED 487#ifndef KAB_EMBEDDED_
480#include "kaddressbookiconview.moc" 488#include "moc_kaddressbookiconview.cpp"
481#endif //KAB_EMBEDDED 489#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/kaddressbookiconview.h b/kaddressbook/views/kaddressbookiconview.h
index b0b9fea..6fad4c6 100644
--- a/kaddressbook/views/kaddressbookiconview.h
+++ b/kaddressbook/views/kaddressbookiconview.h
@@ -1,134 +1,137 @@
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 KADDRESSBOOKICONVIEW_H 24#ifndef KADDRESSBOOKICONVIEW_H
25#define KADDRESSBOOKICONVIEW_H 25#define KADDRESSBOOKICONVIEW_H
26 26
27#include <qstring.h> 27#include <qstring.h>
28//Added by qt3to4:
29#include <Q3ValueList>
30#include <QDropEvent>
28#ifndef KAB_EMBEDDED 31#ifndef KAB_EMBEDDED
29#include <kiconview.h> 32#include <kiconview.h>
30#else //KAB_EMBEDDED 33#else //KAB_EMBEDDED
31#include <qiconview.h> 34#include <q3iconview.h>
32#include <qptrlist.h> 35#include <q3ptrlist.h>
33#include <klocale.h> 36#include <klocale.h>
34#endif //KAB_EMBEDDED 37#endif //KAB_EMBEDDED
35#include "kaddressbookview.h" 38#include "kaddressbookview.h"
36 39
37class QIconViewItem; 40class Q3IconViewItem;
38class KConfig; 41class KConfig;
39class AddresseeIconView; 42class AddresseeIconView;
40class AddresseeIconViewItem; 43class AddresseeIconViewItem;
41class QIconDragItem; 44class Q3IconDragItem;
42class KAddressBookIconView; 45class KAddressBookIconView;
43 46
44namespace KABC { class AddressBook; } 47namespace KABC { class AddressBook; }
45 48
46/** This is an example kaddressbook view that is implemented using 49/** This is an example kaddressbook view that is implemented using
47* KIconView. This view is not the most useful view, but it displays 50* KIconView. This view is not the most useful view, but it displays
48* how simple implementing a new view can be. 51* how simple implementing a new view can be.
49*/ 52*/
50class KAddressBookIconView : public KAddressBookView 53class KAddressBookIconView : public KAddressBookView
51{ 54{
52 Q_OBJECT 55 Q_OBJECT
53 56
54 public: 57 public:
55 KAddressBookIconView( KABC::AddressBook *ab, QWidget *parent, 58 KAddressBookIconView( KABC::AddressBook *ab, QWidget *parent,
56 const char *name = 0 ); 59 const char *name = 0 );
57 virtual ~KAddressBookIconView(); 60 virtual ~KAddressBookIconView();
58 61
59 virtual QStringList selectedUids(); 62 virtual QStringList selectedUids();
60 virtual QString type() const { return "Icon"; } 63 virtual QString type() const { return "Icon"; }
61 void doSearch( const QString& s ,KABC::Field *field ); 64 void doSearch( const QString& s ,KABC::Field *field );
62 65
63 virtual void readConfig(KConfig *config); 66 virtual void readConfig(KConfig *config);
64 virtual void scrollUP(); 67 virtual void scrollUP();
65 virtual void scrollDOWN(); 68 virtual void scrollDOWN();
66 virtual void setFocusAV(); 69 virtual void setFocusAV();
67 70
68 public slots: 71 public slots:
69 void refresh(QString uid = QString::null); 72 void refresh(QString uid = QString::null);
70#ifndef KAB_EMBEDDED 73#ifndef KAB_EMBEDDED
71//MOC_SKIP_BEGIN 74#ifndef Q_MOC_RUN
72 void setSelected(QString uid = QString::null, bool selected = true); 75 void setSelected(QString uid = QString::null, bool selected = true);
73//MOC_SKIP_END 76#endif
74#else //KAB_EMBEDDED 77#else //KAB_EMBEDDED
75//US my MOC do not like default parameters ??? 78//US my MOC do not like default parameters ???
76 void setSelected(QString uid, bool selected); 79 void setSelected(QString uid, bool selected);
77#endif //KAB_EMBEDDED 80#endif //KAB_EMBEDDED
78 81
79 protected slots: 82 protected slots:
80 void addresseeExecuted(QIconViewItem *item); 83 void addresseeExecuted(Q3IconViewItem *item);
81 void addresseeSelected(); 84 void addresseeSelected();
82 85
83 private: 86 private:
84 AddresseeIconView *mIconView; 87 AddresseeIconView *mIconView;
85 QPtrList<AddresseeIconViewItem> mIconList; 88 Q3PtrList<AddresseeIconViewItem> mIconList;
86}; 89};
87 90
88 91
89#ifndef KAB_EMBEDDED 92#ifndef KAB_EMBEDDED
90//MOC_SKIP_BEGIN 93#ifndef Q_MOC_RUN
91class AddresseeIconView : public KIconView 94class AddresseeIconView : public KIconView
92//MOC_SKIP_END 95#endif
93#else //KAB_EMBEDDED 96#else //KAB_EMBEDDED
94class AddresseeIconView : public QIconView 97class AddresseeIconView : public Q3IconView
95#endif //KAB_EMBEDDED 98#endif //KAB_EMBEDDED
96{ 99{
97 Q_OBJECT 100 Q_OBJECT
98 101
99 public: 102 public:
100 AddresseeIconView(QWidget *parent, const char *name); 103 AddresseeIconView(QWidget *parent, const char *name);
101 ~AddresseeIconView(); 104 ~AddresseeIconView();
102 105
103 signals: 106 signals:
104 void addresseeDropped(QDropEvent *); 107 void addresseeDropped(QDropEvent *);
105 void startAddresseeDrag(); 108 void startAddresseeDrag();
106 109
107 protected: 110 protected:
108 virtual QDragObject *dragObject(); 111 virtual Q3DragObject *dragObject();
109 112
110 protected slots: 113 protected slots:
111 void itemDropped(QDropEvent *, const QValueList<QIconDragItem> &); 114 void itemDropped(QDropEvent *, const Q3ValueList<Q3IconDragItem> &);
112}; 115};
113 116
114class IconViewFactory : public ViewFactory 117class IconViewFactory : public ViewFactory
115{ 118{
116 public: 119 public:
117 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) 120 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name )
118 { 121 {
119 return new KAddressBookIconView( ab, parent, name ); 122 return new KAddressBookIconView( ab, parent, name );
120 } 123 }
121 124
122 QString type() const { return "Icon"; } 125 QString type() const { return "Icon"; }
123 126
124 QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } 127 QString description() const { return i18n( "Icons represent contacts. Very simple view." ); }
125}; 128};
126/* 129/*
127extern "C" { 130extern "C" {
128 void *init_libkaddrbk_iconview() 131 void *init_libkaddrbk_iconview()
129 { 132 {
130 return ( new IconViewFactory ); 133 return ( new IconViewFactory );
131 } 134 }
132} 135}
133*/ 136*/
134#endif 137#endif
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index 272f2eb..7efaaa9 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -1,492 +1,496 @@
1// $Id$ 1// $Id$
2 2
3#include <qvbox.h> 3#include <q3vbox.h>
4#include <qlistbox.h> 4#include <q3listbox.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 <q3dragobject.h>
11#include <qevent.h> 11#include <qevent.h>
12#include <qurl.h> 12#include <q3url.h>
13#include <qpixmap.h> 13#include <qpixmap.h>
14//Added by qt3to4:
15#include <QDropEvent>
16#include <QKeyEvent>
17#include <Q3VBoxLayout>
14 18
15#include <kabc/addressbook.h> 19#include <kabc/addressbook.h>
16#include <kapplication.h> 20#include <kapplication.h>
17#include <kconfig.h> 21#include <kconfig.h>
18#include <kcolorbutton.h> 22#include <kcolorbutton.h>
19#include <kdebug.h> 23#include <kdebug.h>
20#include <kglobal.h> 24#include <kglobal.h>
21#include <kiconloader.h> 25#include <kiconloader.h>
22#include <klineedit.h> 26#include <klineedit.h>
23#include <klocale.h> 27#include <klocale.h>
24#include <kmessagebox.h> 28#include <kmessagebox.h>
25#include <kurl.h> 29#include <kurl.h>
26#include <kurlrequester.h> 30#include <kurlrequester.h>
27 31
28//US#include "configuretableviewdialog.h" 32//US#include "configuretableviewdialog.h"
29#include "contactlistview.h" 33#include "contactlistview.h"
30#include "kabprefs.h" 34#include "kabprefs.h"
31#include "undocmds.h" 35#include "undocmds.h"
32#include "viewmanager.h" 36#include "viewmanager.h"
33 37
34#include <qlayout.h> 38#include <qlayout.h>
35#include <qheader.h> 39#include <q3header.h>
36#include <qregexp.h> 40#include <qregexp.h>
37 41
38#include "kaddressbooktableview.h" 42#include "kaddressbooktableview.h"
39 43
40 44
41KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, 45KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab,
42 QWidget *parent, const char *name ) 46 QWidget *parent, const char *name )
43 : KAddressBookView( ab, parent, name ) 47 : KAddressBookView( ab, parent, name )
44{ 48{
45 mainLayout = new QVBoxLayout( viewWidget(), 2 ); 49 mainLayout = new Q3VBoxLayout( viewWidget(), 2 );
46 50
47 // The list view will be created when the config is read. 51 // The list view will be created when the config is read.
48 mListView = 0; 52 mListView = 0;
49} 53}
50 54
51KAddressBookTableView::~KAddressBookTableView() 55KAddressBookTableView::~KAddressBookTableView()
52{ 56{
53} 57}
54void KAddressBookTableView::setFocusAV() 58void KAddressBookTableView::setFocusAV()
55{ 59{
56 if ( mListView ) 60 if ( mListView )
57 mListView->setFocus(); 61 mListView->setFocus();
58 62
59} 63}
60void KAddressBookTableView::scrollUP() 64void KAddressBookTableView::scrollUP()
61{ 65{
62 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 66 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
63 QApplication::postEvent( mListView, ev ); 67 QApplication::postEvent( mListView, ev );
64 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Up, 0,0 ); 68 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Up, 0,0 );
65 QApplication::postEvent( mListView, ev ); 69 QApplication::postEvent( mListView, ev );
66} 70}
67void KAddressBookTableView::scrollDOWN() 71void KAddressBookTableView::scrollDOWN()
68{ 72{
69 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 73 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
70 QApplication::postEvent( mListView, ev ); 74 QApplication::postEvent( mListView, ev );
71 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Down, 0,0 ); 75 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Down, 0,0 );
72 QApplication::postEvent( mListView, ev ); 76 QApplication::postEvent( mListView, ev );
73} 77}
74void KAddressBookTableView::reconstructListView() 78void KAddressBookTableView::reconstructListView()
75{ 79{
76 if (mListView) 80 if (mListView)
77 { 81 {
78 disconnect(mListView, SIGNAL(selectionChanged()), 82 disconnect(mListView, SIGNAL(selectionChanged()),
79 this, SLOT(addresseeSelected())); 83 this, SLOT(addresseeSelected()));
80 disconnect(mListView, SIGNAL(executed(QListViewItem*)), 84 disconnect(mListView, SIGNAL(executed(Q3ListViewItem*)),
81 this, SLOT(addresseeExecuted(QListViewItem*))); 85 this, SLOT(addresseeExecuted(Q3ListViewItem*)));
82 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 86 disconnect(mListView, SIGNAL(doubleClicked(Q3ListViewItem*)),
83 this, SLOT(addresseeExecuted(QListViewItem*))); 87 this, SLOT(addresseeExecuted(Q3ListViewItem*)));
84 disconnect(mListView, SIGNAL(startAddresseeDrag()), this, 88 disconnect(mListView, SIGNAL(startAddresseeDrag()), this,
85 SIGNAL(startDrag())); 89 SIGNAL(startDrag()));
86 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), 90 disconnect(mListView, SIGNAL(returnPressed(Q3ListViewItem*)),
87 this, SLOT(addresseeExecuted(QListViewItem*))); 91 this, SLOT(addresseeExecuted(Q3ListViewItem*)));
88 92
89 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 93 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
90 SIGNAL(dropped(QDropEvent*))); 94 SIGNAL(dropped(QDropEvent*)));
91 delete mListView; 95 delete mListView;
92 } 96 }
93 97
94 mListView = new ContactListView( this, addressBook(), viewWidget() ); 98 mListView = new ContactListView( this, addressBook(), viewWidget() );
95 99
96 connect(this, SIGNAL(printView()), 100 connect(this, SIGNAL(printView()),
97 mListView , SLOT(printMe())); 101 mListView , SLOT(printMe()));
98 //US set singleClick manually, because it is no global configparameter in embedded space 102 //US set singleClick manually, because it is no global configparameter in embedded space
99 mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); 103 mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick);
100 104
101 // Add the columns 105 // Add the columns
102 KABC::Field::List fieldList = fields(); 106 KABC::Field::List fieldList = fields();
103 KABC::Field::List::ConstIterator it; 107 KABC::Field::List::ConstIterator it;
104 108
105 int c = 0; 109 int c = 0;
106 for( it = fieldList.begin(); it != fieldList.end(); ++it ) { 110 for( it = fieldList.begin(); it != fieldList.end(); ++it ) {
107 mListView->addColumn( (*it)->label() ); 111 mListView->addColumn( (*it)->label() );
108 mListView->setColumnWidthMode(c++, QListView::Manual); 112 mListView->setColumnWidthMode(c++, Q3ListView::Manual);
109//US 113//US
110 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); 114 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1());
111 } 115 }
112 116
113 connect(mListView, SIGNAL(selectionChanged()), 117 connect(mListView, SIGNAL(selectionChanged()),
114 this, SLOT(addresseeSelected())); 118 this, SLOT(addresseeSelected()));
115 connect(mListView, SIGNAL(startAddresseeDrag()), this, 119 connect(mListView, SIGNAL(startAddresseeDrag()), this,
116 SIGNAL(startDrag())); 120 SIGNAL(startDrag()));
117 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 121 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
118 SIGNAL(dropped(QDropEvent*))); 122 SIGNAL(dropped(QDropEvent*)));
119 123
120 if (KABPrefs::instance()->mHonorSingleClick) { 124 if (KABPrefs::instance()->mHonorSingleClick) {
121 // qDebug("KAddressBookTableView::reconstructListView single"); 125 // qDebug("KAddressBookTableView::reconstructListView single");
122 connect(mListView, SIGNAL(executed(QListViewItem*)), 126 connect(mListView, SIGNAL(executed(Q3ListViewItem*)),
123 this, SLOT(addresseeExecuted(QListViewItem*))); 127 this, SLOT(addresseeExecuted(Q3ListViewItem*)));
124 } else { 128 } else {
125 // qDebug("KAddressBookTableView::reconstructListView double"); 129 // qDebug("KAddressBookTableView::reconstructListView double");
126 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 130 connect(mListView, SIGNAL(doubleClicked(Q3ListViewItem*)),
127 this, SLOT(addresseeExecuted(QListViewItem*))); 131 this, SLOT(addresseeExecuted(Q3ListViewItem*)));
128 } 132 }
129 connect(mListView, SIGNAL(returnPressed(QListViewItem*)), 133 connect(mListView, SIGNAL(returnPressed(Q3ListViewItem*)),
130 this, SLOT(addresseeExecuted(QListViewItem*))); 134 this, SLOT(addresseeExecuted(Q3ListViewItem*)));
131 connect(mListView, SIGNAL(signalDelete()), 135 connect(mListView, SIGNAL(signalDelete()),
132 this, SLOT(addresseeDeleted())); 136 this, SLOT(addresseeDeleted()));
133 137
134//US performceimprovement. Refresh is done from the outside 138//US performceimprovement. Refresh is done from the outside
135//US refresh(); 139//US refresh();
136 140
137 mListView->setSorting( 0, true ); 141 mListView->setSorting( 0, true );
138 mainLayout->addWidget( mListView ); 142 mainLayout->addWidget( mListView );
139 mainLayout->activate(); 143 mainLayout->activate();
140 mListView->show(); 144 mListView->show();
141} 145}
142 146
143void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) 147void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field )
144{ 148{
145 mListView->clear(); 149 mListView->clear();
146 if ( s.isEmpty() || s == "*" ) { 150 if ( s.isEmpty() || s == "*" ) {
147 refresh(); 151 refresh();
148 return; 152 return;
149 } 153 }
150 QRegExp re = getRegExp( s ); 154 QRegExp re = getRegExp( s );
151 if (!re.isValid()) 155 if (!re.isValid())
152 return; 156 return;
153 KABC::Addressee::List addresseeList = addressees(); 157 KABC::Addressee::List addresseeList = addressees();
154 KABC::Addressee::List::Iterator it; 158 KABC::Addressee::List::Iterator it;
155 if ( field ) { 159 if ( field ) {
156 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 160 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
157 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 161 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
158 continue; 162 continue;
159#if QT_VERSION >= 0x030000 163#if QT_VERSION >= 0x030000
160 if (re.search(field->value( *it ).lower()) == 0) 164 if (re.search(field->value( *it ).lower()) == 0)
161#else 165#else
162 if (re.match(field->value( *it ).lower()) == 0) 166 if (re.match(field->value( *it ).lower()) == 0)
163#endif 167#endif
164 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 168 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
165 169
166 } 170 }
167 } else { 171 } else {
168 KABC::Field::List fieldList = allFields(); 172 KABC::Field::List fieldList = allFields();
169 KABC::Field::List::ConstIterator fieldIt; 173 KABC::Field::List::ConstIterator fieldIt;
170 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 174 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
171 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 175 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
172 continue; 176 continue;
173 bool match = false; 177 bool match = false;
174 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 178 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
175#if QT_VERSION >= 0x030000 179#if QT_VERSION >= 0x030000
176 if (re.search((*fieldIt)->value( *it ).lower()) == 0) 180 if (re.search((*fieldIt)->value( *it ).lower()) == 0)
177#else 181#else
178 if (re.match((*fieldIt)->value( *it ).lower()) == 0) 182 if (re.match((*fieldIt)->value( *it ).lower()) == 0)
179#endif 183#endif
180 { 184 {
181 //qDebug("match %s %s %s", pattern.latin1(), (*fieldIt)->value( *it ).latin1(), (*fieldIt)->label().latin1() ); 185 //qDebug("match %s %s %s", pattern.latin1(), (*fieldIt)->value( *it ).latin1(), (*fieldIt)->label().latin1() );
182 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 186 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
183 match = true; 187 match = true;
184 break; 188 break;
185 } 189 }
186 } 190 }
187 if ( ! match ) { 191 if ( ! match ) {
188 if ( (*it).matchPhoneNumber( &re ) ) { 192 if ( (*it).matchPhoneNumber( &re ) ) {
189 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 193 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
190 match = true; 194 match = true;
191 break; 195 break;
192 } 196 }
193 } 197 }
194 if ( ! match ) { 198 if ( ! match ) {
195 if ( (*it).matchAddress( &re ) ) { 199 if ( (*it).matchAddress( &re ) ) {
196 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 200 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
197 match = true; 201 match = true;
198 break; 202 break;
199 } 203 }
200 } 204 }
201 } 205 }
202 } 206 }
203 // Sometimes the background pixmap gets messed up when we add lots 207 // Sometimes the background pixmap gets messed up when we add lots
204 // of items. 208 // of items.
205 //mListView->repaint(); 209 //mListView->repaint();
206 if ( mListView->firstChild() ) { 210 if ( mListView->firstChild() ) {
207 mListView->setCurrentItem ( mListView->firstChild() ); 211 mListView->setCurrentItem ( mListView->firstChild() );
208 mListView->setSelected ( mListView->firstChild(), true ); 212 mListView->setSelected ( mListView->firstChild(), true );
209 } 213 }
210 else 214 else
211 emit selected(QString::null); 215 emit selected(QString::null);
212 216
213} 217}
214void KAddressBookTableView::writeConfig(KConfig *config) 218void KAddressBookTableView::writeConfig(KConfig *config)
215{ 219{
216 KAddressBookView::writeConfig(config); 220 KAddressBookView::writeConfig(config);
217 221
218 mListView->saveLayout(config, config->group()); 222 mListView->saveLayout(config, config->group());
219} 223}
220 224
221void KAddressBookTableView::readConfig(KConfig *config) 225void KAddressBookTableView::readConfig(KConfig *config)
222{ 226{
223 KAddressBookView::readConfig( config ); 227 KAddressBookView::readConfig( config );
224 // The config could have changed the fields, so we need to reconstruct 228 // The config could have changed the fields, so we need to reconstruct
225 // the listview. 229 // the listview.
226 reconstructListView(); 230 reconstructListView();
227 231
228 // costum colors? 232 // costum colors?
229 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 233 if ( config->readBoolEntry( "EnableCustomColors", false ) )
230 { 234 {
231 QPalette p( mListView->palette() ); 235 QPalette p( mListView->palette() );
232 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 236 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
233 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 237 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
234 c = p.color(QPalette::Normal, QColorGroup::Text ); 238 c = p.color(QPalette::Normal, QColorGroup::Text );
235 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 239 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
236 c = p.color(QPalette::Normal, QColorGroup::Button ); 240 c = p.color(QPalette::Normal, QColorGroup::Button );
237 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 241 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
238 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 242 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
239 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 243 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
240 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 244 c = p.color(QPalette::Normal, QColorGroup::Highlight );
241 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 245 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
242 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 246 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
243 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 247 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
244#ifndef KAB_EMBEDDED 248#ifndef KAB_EMBEDDED
245 c = KGlobalSettings::alternateBackgroundColor(); 249 c = KGlobalSettings::alternateBackgroundColor();
246#else //KAB_EMBEDDED 250#else //KAB_EMBEDDED
247 c = QColor(240, 240, 240); 251 c = QColor(240, 240, 240);
248#endif //KAB_EMBEDDED 252#endif //KAB_EMBEDDED
249 c = config->readColorEntry ("AlternatingBackgroundColor", &c); 253 c = config->readColorEntry ("AlternatingBackgroundColor", &c);
250 mListView->setAlternateColor(c); 254 mListView->setAlternateColor(c);
251 255
252 256
253 //US mListView->viewport()->setPalette( p ); 257 //US mListView->viewport()->setPalette( p );
254 mListView->setPalette( p ); 258 mListView->setPalette( p );
255 } 259 }
256 else 260 else
257 { 261 {
258 // needed if turned off during a session. 262 // needed if turned off during a session.
259 //US mListView->viewport()->setPalette( mListView->palette() ); 263 //US mListView->viewport()->setPalette( mListView->palette() );
260 mListView->setPalette( mListView->palette() ); 264 mListView->setPalette( mListView->palette() );
261 } 265 }
262 266
263 //custom fonts? 267 //custom fonts?
264 QFont f( font() ); 268 QFont f( font() );
265 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 269 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
266 { 270 {
267 mListView->setFont( config->readFontEntry( "TextFont", &f) ); 271 mListView->setFont( config->readFontEntry( "TextFont", &f) );
268 f.setBold( true ); 272 f.setBold( true );
269 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 273 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
270 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); 274 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) );
271 } 275 }
272 else 276 else
273 { 277 {
274 mListView->setFont( f ); 278 mListView->setFont( f );
275 f.setBold( true ); 279 f.setBold( true );
276 //US mListView->setHeaderFont( f ); 280 //US mListView->setHeaderFont( f );
277 mListView->header()->setFont( f ); 281 mListView->header()->setFont( f );
278 } 282 }
279 283
280 // Set the list view options 284 // Set the list view options
281 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", 285 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground",
282 true)); 286 true));
283 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); 287 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false));
284 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); 288 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true));
285 289
286 if (config->readBoolEntry("Background", false)) 290 if (config->readBoolEntry("Background", false))
287 mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); 291 mListView->setBackgroundPixmap(config->readEntry("BackgroundName"));
288 292
289 // Restore the layout of the listview 293 // Restore the layout of the listview
290 mListView->restoreLayout(config, config->group()); 294 mListView->restoreLayout(config, config->group());
291} 295}
292 296
293void KAddressBookTableView::refresh(QString uid) 297void KAddressBookTableView::refresh(QString uid)
294{ 298{
295 // For now just repopulate. In reality this method should 299 // For now just repopulate. In reality this method should
296 // check the value of uid, and if valid iterate through 300 // check the value of uid, and if valid iterate through
297 // the listview to find the entry, then tell it to refresh. 301 // the listview to find the entry, then tell it to refresh.
298 302
299 if (uid.isNull()) { 303 if (uid.isNull()) {
300 // Clear the list view 304 // Clear the list view
301 QString currentUID, nextUID; 305 QString currentUID, nextUID;
302#ifndef KAB_EMBEDDED 306#ifndef KAB_EMBEDDED
303 ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); 307 ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() );
304#else //KAB_EMBEDDED 308#else //KAB_EMBEDDED
305 ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); 309 ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() );
306#endif //KAB_EMBEDDED 310#endif //KAB_EMBEDDED
307 311
308 if ( currentItem ) { 312 if ( currentItem ) {
309#ifndef KAB_EMBEDDED 313#ifndef KAB_EMBEDDED
310 ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); 314 ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() );
311#else //KAB_EMBEDDED 315#else //KAB_EMBEDDED
312 ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); 316 ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() );
313#endif //KAB_EMBEDDED 317#endif //KAB_EMBEDDED
314 if ( nextItem ) 318 if ( nextItem )
315 nextUID = nextItem->addressee().uid(); 319 nextUID = nextItem->addressee().uid();
316 currentUID = currentItem->addressee().uid(); 320 currentUID = currentItem->addressee().uid();
317 } 321 }
318 322
319 mListView->clear(); 323 mListView->clear();
320 324
321 currentItem = 0; 325 currentItem = 0;
322 KABC::Addressee::List addresseeList = addressees(); 326 KABC::Addressee::List addresseeList = addressees();
323 KABC::Addressee::List::Iterator it; 327 KABC::Addressee::List::Iterator it;
324 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 328 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
325 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 329 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
326 continue; 330 continue;
327 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 331 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
328 if ( (*it).uid() == currentUID ) 332 if ( (*it).uid() == currentUID )
329 currentItem = item; 333 currentItem = item;
330 else if ( (*it).uid() == nextUID && !currentItem ) 334 else if ( (*it).uid() == nextUID && !currentItem )
331 currentItem = item; 335 currentItem = item;
332 } 336 }
333 337
334 // Sometimes the background pixmap gets messed up when we add lots 338 // Sometimes the background pixmap gets messed up when we add lots
335 // of items. 339 // of items.
336 mListView->repaint(); 340 mListView->repaint();
337 if ( !currentItem ) 341 if ( !currentItem )
338 currentItem = (ContactListViewItem *)mListView->firstChild(); 342 currentItem = (ContactListViewItem *)mListView->firstChild();
339 if ( currentItem ) { 343 if ( currentItem ) {
340 mListView->setCurrentItem( currentItem ); 344 mListView->setCurrentItem( currentItem );
341 mListView->ensureItemVisible( currentItem ); 345 mListView->ensureItemVisible( currentItem );
342 mListView->setSelected( currentItem, true ); 346 mListView->setSelected( currentItem, true );
343 } 347 }
344 } else { 348 } else {
345 // Only need to update on entry. Iterate through and try to find it 349 // Only need to update on entry. Iterate through and try to find it
346 ContactListViewItem *ceItem; 350 ContactListViewItem *ceItem;
347 QListViewItemIterator it( mListView ); 351 Q3ListViewItemIterator it( mListView );
348 while ( it.current() ) { 352 while ( it.current() ) {
349#ifndef KAB_EMBEDDED 353#ifndef KAB_EMBEDDED
350 ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); 354 ceItem = dynamic_cast<ContactListViewItem*>( it.current() );
351#else //KAB_EMBEDDED 355#else //KAB_EMBEDDED
352 ceItem = (ContactListViewItem*)( it.current() ); 356 ceItem = (ContactListViewItem*)( it.current() );
353#endif //KAB_EMBEDDED 357#endif //KAB_EMBEDDED
354 358
355 if ( ceItem && ceItem->addressee().uid() == uid ) { 359 if ( ceItem && ceItem->addressee().uid() == uid ) {
356 ceItem->refresh(); 360 ceItem->refresh();
357 return; 361 return;
358 } 362 }
359 ++it; 363 ++it;
360 } 364 }
361 365
362 refresh( QString::null ); 366 refresh( QString::null );
363 } 367 }
364} 368}
365 369
366QStringList KAddressBookTableView::selectedUids() 370QStringList KAddressBookTableView::selectedUids()
367{ 371{
368 QStringList uidList; 372 QStringList uidList;
369 QListViewItem *item; 373 Q3ListViewItem *item;
370 ContactListViewItem *ceItem; 374 ContactListViewItem *ceItem;
371 375
372 for(item = mListView->firstChild(); item; item = item->itemBelow()) 376 for(item = mListView->firstChild(); item; item = item->itemBelow())
373 { 377 {
374 if (mListView->isSelected( item )) 378 if (mListView->isSelected( item ))
375 { 379 {
376#ifndef KAB_EMBEDDED 380#ifndef KAB_EMBEDDED
377 ceItem = dynamic_cast<ContactListViewItem*>(item); 381 ceItem = dynamic_cast<ContactListViewItem*>(item);
378#else //KAB_EMBEDDED 382#else //KAB_EMBEDDED
379 ceItem = (ContactListViewItem*)(item); 383 ceItem = (ContactListViewItem*)(item);
380#endif //KAB_EMBEDDED 384#endif //KAB_EMBEDDED
381 385
382 if (ceItem != 0L) 386 if (ceItem != 0L)
383 uidList << ceItem->addressee().uid(); 387 uidList << ceItem->addressee().uid();
384 } 388 }
385 } 389 }
386 if ( uidList.count() == 0 ) 390 if ( uidList.count() == 0 )
387 if ( mListView->currentItem() ) { 391 if ( mListView->currentItem() ) {
388 ceItem = (ContactListViewItem*)(mListView->currentItem()) ; 392 ceItem = (ContactListViewItem*)(mListView->currentItem()) ;
389 uidList << ceItem->addressee().uid(); 393 uidList << ceItem->addressee().uid();
390 } 394 }
391 395
392 return uidList; 396 return uidList;
393} 397}
394 398
395void KAddressBookTableView::setSelected(QString uid, bool selected) 399void KAddressBookTableView::setSelected(QString uid, bool selected)
396{ 400{
397 QListViewItem *item; 401 Q3ListViewItem *item;
398 ContactListViewItem *ceItem; 402 ContactListViewItem *ceItem;
399 403
400 if (uid.isNull()) 404 if (uid.isNull())
401 { 405 {
402 mListView->selectAll(selected); 406 mListView->selectAll(selected);
403 } 407 }
404 else 408 else
405 { 409 {
406 for(item = mListView->firstChild(); item; item = item->itemBelow()) 410 for(item = mListView->firstChild(); item; item = item->itemBelow())
407 { 411 {
408#ifndef KAB_EMBEDDED 412#ifndef KAB_EMBEDDED
409 ceItem = dynamic_cast<ContactListViewItem*>(item); 413 ceItem = dynamic_cast<ContactListViewItem*>(item);
410#else //KAB_EMBEDDED 414#else //KAB_EMBEDDED
411 ceItem = (ContactListViewItem*)(item); 415 ceItem = (ContactListViewItem*)(item);
412#endif //KAB_EMBEDDED 416#endif //KAB_EMBEDDED
413 417
414 418
415 if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) 419 if ((ceItem != 0L) && (ceItem->addressee().uid() == uid))
416 { 420 {
417 mListView->setSelected(item, selected); 421 mListView->setSelected(item, selected);
418 422
419 if (selected) 423 if (selected)
420 mListView->ensureItemVisible(item); 424 mListView->ensureItemVisible(item);
421 } 425 }
422 } 426 }
423 } 427 }
424} 428}
425 429
426void KAddressBookTableView::addresseeSelected() 430void KAddressBookTableView::addresseeSelected()
427{ 431{
428 // We need to try to find the first selected item. This might not be the 432 // We need to try to find the first selected item. This might not be the
429 // last selected item, but when QListView is in multiselection mode, 433 // last selected item, but when QListView is in multiselection mode,
430 // there is no way to figure out which one was 434 // there is no way to figure out which one was
431 // selected last. 435 // selected last.
432 QListViewItem *item; 436 Q3ListViewItem *item;
433 bool found =false; 437 bool found =false;
434 for (item = mListView->firstChild(); item && !found; 438 for (item = mListView->firstChild(); item && !found;
435 item = item->nextSibling()) 439 item = item->nextSibling())
436 { 440 {
437 if (item->isSelected()) 441 if (item->isSelected())
438 { 442 {
439 found = true; 443 found = true;
440#ifndef KAB_EMBEDDED 444#ifndef KAB_EMBEDDED
441 ContactListViewItem *ceItem 445 ContactListViewItem *ceItem
442 = dynamic_cast<ContactListViewItem*>(item); 446 = dynamic_cast<ContactListViewItem*>(item);
443#else //KAB_EMBEDDED 447#else //KAB_EMBEDDED
444 ContactListViewItem *ceItem 448 ContactListViewItem *ceItem
445 = (ContactListViewItem*)(item); 449 = (ContactListViewItem*)(item);
446#endif //KAB_EMBEDDED 450#endif //KAB_EMBEDDED
447 451
448 if ( ceItem ) emit selected(ceItem->addressee().uid()); 452 if ( ceItem ) emit selected(ceItem->addressee().uid());
449 } 453 }
450 } 454 }
451 455
452 if (!found) 456 if (!found)
453 emit selected(QString::null); 457 emit selected(QString::null);
454} 458}
455 459
456void KAddressBookTableView::addresseeExecuted(QListViewItem *item) 460void KAddressBookTableView::addresseeExecuted(Q3ListViewItem *item)
457{ 461{
458 if (item) 462 if (item)
459 { 463 {
460#ifndef KAB_EMBEDDED 464#ifndef KAB_EMBEDDED
461 ContactListViewItem *ceItem 465 ContactListViewItem *ceItem
462 = dynamic_cast<ContactListViewItem*>(item); 466 = dynamic_cast<ContactListViewItem*>(item);
463#else //KAB_EMBEDDED 467#else //KAB_EMBEDDED
464 ContactListViewItem *ceItem 468 ContactListViewItem *ceItem
465 = (ContactListViewItem*)(item); 469 = (ContactListViewItem*)(item);
466#endif //KAB_EMBEDDED 470#endif //KAB_EMBEDDED
467 471
468 if (ceItem) 472 if (ceItem)
469 { 473 {
470 emit executed(ceItem->addressee().uid()); 474 emit executed(ceItem->addressee().uid());
471 } 475 }
472 } 476 }
473 else 477 else
474 { 478 {
475 emit executed(QString::null); 479 emit executed(QString::null);
476 } 480 }
477} 481}
478 482
479void KAddressBookTableView::addresseeDeleted() 483void KAddressBookTableView::addresseeDeleted()
480{ 484{
481 485
482 emit deleteRequest(); 486 emit deleteRequest();
483 487
484} 488}
485 489
486 490
487 491
488 492
489 493
490#ifndef KAB_EMBEDDED 494#ifndef KAB_EMBEDDED_
491#include "kaddressbooktableview.moc" 495#include "moc_kaddressbooktableview.cpp"
492#endif //KAB_EMBEDDED 496#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/kaddressbooktableview.h b/kaddressbook/views/kaddressbooktableview.h
index 38db7b4..c3cb038 100644
--- a/kaddressbook/views/kaddressbooktableview.h
+++ b/kaddressbook/views/kaddressbooktableview.h
@@ -1,118 +1,120 @@
1#ifndef KADDRESSBOOKTABLEVIEW_H 1#ifndef KADDRESSBOOKTABLEVIEW_H
2#define KADDRESSBOOKTABLEVIEW_H 2#define KADDRESSBOOKTABLEVIEW_H
3 3
4 4
5#ifndef KAB_EMBEDDED 5#ifndef KAB_EMBEDDED
6 6
7 7
8#ifdef HAVE_CONFIG_H 8#ifdef HAVE_CONFIG_H
9#include <config.h> 9#include <config.h>
10#endif 10#endif
11 11
12#include <qwidget.h> 12#include <qwidget.h>
13#include <qlistview.h> 13#include <q3listview.h>
14#include <qstring.h> 14#include <qstring.h>
15#include <qdialog.h> 15#include <qdialog.h>
16#include <qtabdialog.h> 16#include <q3tabdialog.h>
17#include <qstringlist.h> 17#include <qstringlist.h>
18#include <qvaluelist.h> 18#include <q3valuelist.h>
19 19
20#include "undo.h" 20#include "undo.h"
21 21
22#else //KAB_EMBEDDED 22#else //KAB_EMBEDDED
23#include "views/configuretableviewdialog.h" 23#include "views/configuretableviewdialog.h"
24#endif //KAB_EMBEDDED 24#endif //KAB_EMBEDDED
25 25
26#include "klocale.h" 26#include "klocale.h"
27#include "kaddressbookview.h" 27#include "kaddressbookview.h"
28//Added by qt3to4:
29#include <Q3VBoxLayout>
28 30
29class QListViewItem; 31class Q3ListViewItem;
30class QListBox; 32class Q3ListBox;
31class QVBoxLayout; 33class Q3VBoxLayout;
32class KConfig; 34class KConfig;
33 35
34class ContactListViewItem; 36class ContactListViewItem;
35class ContactListView; 37class ContactListView;
36 38
37 39
38namespace KABC { class AddressBook; } 40namespace KABC { class AddressBook; }
39 41
40/** 42/**
41 * This class is the table view for kaddressbook. This view is a KListView 43 * This class is the table view for kaddressbook. This view is a KListView
42 * with multiple columns for the selected fields. 44 * with multiple columns for the selected fields.
43 * 45 *
44 * @short Table View 46 * @short Table View
45 * @author Don Sanders <dsanders@kde.org> 47 * @author Don Sanders <dsanders@kde.org>
46 * @version 0.1 48 * @version 0.1
47 */ 49 */
48class KAddressBookTableView : public KAddressBookView 50class KAddressBookTableView : public KAddressBookView
49{ 51{
50friend class ContactListView; 52friend class ContactListView;
51 53
52 Q_OBJECT 54 Q_OBJECT
53 55
54 public: 56 public:
55 KAddressBookTableView( KABC::AddressBook *ab, QWidget *parent, 57 KAddressBookTableView( KABC::AddressBook *ab, QWidget *parent,
56 const char *name = 0 ); 58 const char *name = 0 );
57 virtual ~KAddressBookTableView(); 59 virtual ~KAddressBookTableView();
58 60
59 virtual void refresh(QString uid = QString::null); 61 virtual void refresh(QString uid = QString::null);
60 virtual QStringList selectedUids(); 62 virtual QStringList selectedUids();
61 virtual void setSelected(QString uid = QString::null, bool selected = false); 63 virtual void setSelected(QString uid = QString::null, bool selected = false);
62 virtual void readConfig(KConfig *config); 64 virtual void readConfig(KConfig *config);
63 virtual void writeConfig(KConfig *config); 65 virtual void writeConfig(KConfig *config);
64 virtual QString type() const { return "Table"; } 66 virtual QString type() const { return "Table"; }
65 void doSearch( const QString& s ,KABC::Field *field ); 67 void doSearch( const QString& s ,KABC::Field *field );
66 virtual void scrollUP(); 68 virtual void scrollUP();
67 virtual void scrollDOWN(); 69 virtual void scrollDOWN();
68 virtual void setFocusAV(); 70 virtual void setFocusAV();
69 71
70 public slots: 72 public slots:
71 virtual void reconstructListView(); 73 virtual void reconstructListView();
72 74
73 protected slots: 75 protected slots:
74 /** Called whenever the user selects an addressee in the list view. 76 /** Called whenever the user selects an addressee in the list view.
75 */ 77 */
76 void addresseeSelected(); 78 void addresseeSelected();
77 void addresseeDeleted(); 79 void addresseeDeleted();
78 80
79 /** Called whenever the user executes an addressee. In terms of the 81 /** Called whenever the user executes an addressee. In terms of the
80 * list view, this is probably a double click 82 * list view, this is probably a double click
81 */ 83 */
82 void addresseeExecuted(QListViewItem*); 84 void addresseeExecuted(Q3ListViewItem*);
83 85
84 private: 86 private:
85 QVBoxLayout *mainLayout; 87 Q3VBoxLayout *mainLayout;
86 ContactListView *mListView; 88 ContactListView *mListView;
87}; 89};
88 90
89 91
90class TableViewFactory : public ViewFactory 92class TableViewFactory : public ViewFactory
91{ 93{
92 public: 94 public:
93 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) 95 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name )
94 { 96 {
95 return new KAddressBookTableView( ab, parent, name ); 97 return new KAddressBookTableView( ab, parent, name );
96 } 98 }
97 99
98 QString type() const { return "Table"; } 100 QString type() const { return "Table"; }
99 101
100 QString description() const { return i18n( "A listing of contacts in a table. Each cell of " 102 QString description() const { return i18n( "A listing of contacts in a table. Each cell of "
101 "the table holds a field of the contact." ); } 103 "the table holds a field of the contact." ); }
102 104
103 ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent, 105 ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent,
104 const char *name = 0 ) 106 const char *name = 0 )
105 { 107 {
106 return new ConfigureTableViewWidget( ab, parent, name ); 108 return new ConfigureTableViewWidget( ab, parent, name );
107 } 109 }
108}; 110};
109/*US 111/*US
110extern "C" { 112extern "C" {
111 void *init_libkaddrbk_tableview() 113 void *init_libkaddrbk_tableview()
112 { 114 {
113 return ( new TableViewFactory ); 115 return ( new TableViewFactory );
114 } 116 }
115} 117}
116*/ 118*/
117 119
118#endif 120#endif
diff --git a/kaddressbook/xxport/csv_xxport.cpp b/kaddressbook/xxport/csv_xxport.cpp
index 7281003..ed5807f 100644
--- a/kaddressbook/xxport/csv_xxport.cpp
+++ b/kaddressbook/xxport/csv_xxport.cpp
@@ -1,194 +1,192 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 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/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <qfile.h> 31#include <qfile.h>
32#include <qregexp.h> 32#include <qregexp.h>
33#include <qtextstream.h> 33#include <q3textstream.h>
34#include <qtextcodec.h> 34#include <qtextcodec.h>
35 35
36#include <kfiledialog.h> 36#include <kfiledialog.h>
37#ifndef KAB_EMBEDDED 37#ifndef KAB_EMBEDDED
38#include <kio/netaccess.h> 38#include <kio/netaccess.h>
39#endif //KAB_EMBEDDED 39#endif //KAB_EMBEDDED
40 40
41#include <klocale.h> 41#include <klocale.h>
42#include <kmessagebox.h> 42#include <kmessagebox.h>
43#include <ktempfile.h> 43#include <ktempfile.h>
44#include <kurl.h> 44#include <kurl.h>
45 45
46#include "csvimportdialog.h" 46#include "csvimportdialog.h"
47 47
48#include "csv_xxport.h" 48#include "csv_xxport.h"
49 49
50 50
51#ifndef KAB_EMBEDDED 51#ifndef KAB_EMBEDDED
52 52
53class CSVXXPortFactory : public XXPortFactory 53class CSVXXPortFactory : public XXPortFactory
54{ 54{
55 public: 55 public:
56 XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) 56 XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name )
57 { 57 {
58 return new CSVXXPort( ab, parent, name ); 58 return new CSVXXPort( ab, parent, name );
59 } 59 }
60}; 60};
61 61
62#endif //KAB_EMBEDDED 62#endif //KAB_EMBEDDED
63 63
64 64
65extern "C" 65extern "C"
66{ 66{
67#ifndef KAB_EMBEDDED 67#ifndef KAB_EMBEDDED
68 void *init_libkaddrbk_csv_xxport() 68 void *init_libkaddrbk_csv_xxport()
69#else //KAB_EMBEDDED 69#else //KAB_EMBEDDED
70 void *init_microkaddrbk_csv_xxport() 70 void *init_microkaddrbk_csv_xxport()
71#endif //KAB_EMBEDDED 71#endif //KAB_EMBEDDED
72 { 72 {
73 return ( new CSVXXPortFactory() ); 73 return ( new CSVXXPortFactory() );
74 } 74 }
75} 75}
76 76
77 77
78CSVXXPort::CSVXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) 78CSVXXPort::CSVXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name )
79 : XXPortObject( ab, parent, name ) 79 : XXPortObject( ab, parent, name )
80{ 80{
81 createImportAction( i18n( "Import CSV List..." ) ); 81 createImportAction( i18n( "Import CSV List..." ) );
82 createExportAction( i18n( "Export CSV List..." ) ); 82 createExportAction( i18n( "Export CSV List..." ) );
83} 83}
84 84
85bool CSVXXPort::exportContacts( const KABC::AddresseeList &list, const QString& ) 85bool CSVXXPort::exportContacts( const KABC::AddresseeList &list, const QString& )
86{ 86{
87#ifndef KAB_EMBEDDED 87#ifndef KAB_EMBEDDED
88 KURL url = KFileDialog::getSaveURL( "addressbook.csv" ); 88 KURL url = KFileDialog::getSaveURL( "addressbook.csv" );
89 if ( url.isEmpty() ) 89 if ( url.isEmpty() )
90 return true; 90 return true;
91 91
92 if ( !url.isLocalFile() ) { 92 if ( !url.isLocalFile() ) {
93 KTempFile tmpFile; 93 KTempFile tmpFile;
94 if ( tmpFile.status() != 0 ) { 94 if ( tmpFile.status() != 0 ) {
95 QString txt = i18n( "<qt>Unable to open file <b>%1</b>.%2.</qt>" ); 95 QString txt = i18n( "<qt>Unable to open file <b>%1</b>.%2.</qt>" );
96 KMessageBox::error( parentWidget(), txt.arg( url.url() ) 96 KMessageBox::error( parentWidget(), txt.arg( url.url() )
97 .arg( strerror( tmpFile.status() ) ) ); 97 .arg( strerror( tmpFile.status() ) ) );
98 return false; 98 return false;
99 } 99 }
100 100
101 doExport( tmpFile.file(), list ); 101 doExport( tmpFile.file(), list );
102 tmpFile.close(); 102 tmpFile.close();
103 103
104 return KIO::NetAccess::upload( tmpFile.name(), url, parentWidget() ); 104 return KIO::NetAccess::upload( tmpFile.name(), url, parentWidget() );
105 } else { 105 } else {
106 QFile file( url.path() ); 106 QFile file( url.path() );
107 if ( !file.open( IO_WriteOnly ) ) { 107 if ( !file.open( QIODevice::WriteOnly ) ) {
108 QString txt = i18n( "<qt>Unable to open file <b>%1</b>.</qt>" ); 108 QString txt = i18n( "<qt>Unable to open file <b>%1</b>.</qt>" );
109 KMessageBox::error( parentWidget(), txt.arg( url.path() ) ); 109 KMessageBox::error( parentWidget(), txt.arg( url.path() ) );
110 return false; 110 return false;
111 } 111 }
112 112
113 doExport( &file, list ); 113 doExport( &file, list );
114 file.close(); 114 file.close();
115 115
116 return true; 116 return true;
117 } 117 }
118 118
119#else //KAB_EMBEDDED 119#else //KAB_EMBEDDED
120 120
121 QString fileName = KFileDialog::getSaveFileName( "addressbook.csv", i18n("Save file"), parentWidget() ); 121 QString fileName = KFileDialog::getSaveFileName( "addressbook.csv", i18n("Save file"), parentWidget() );
122 122
123 if ( fileName.isEmpty() ) 123 if ( fileName.isEmpty() )
124 return false; 124 return false;
125 125
126 QFile file( fileName ); 126 QFile file( fileName );
127 if ( !file.open( IO_WriteOnly ) ) { 127 if ( !file.open( QIODevice::WriteOnly ) ) {
128 QString txt = i18n( "<qt>Unable to open file <b>%1</b>.</qt>" ); 128 QString txt = i18n( "<qt>Unable to open file <b>%1</b>.</qt>" );
129 KMessageBox::error( parentWidget(), txt.arg( fileName ) ); 129 KMessageBox::error( parentWidget(), txt.arg( fileName ) );
130 return false; 130 return false;
131 } 131 }
132 132
133 doExport( &file, list ); 133 doExport( &file, list );
134 file.close(); 134 file.close();
135 135
136 return true; 136 return true;
137 137
138 138
139#endif //KAB_EMBEDDED 139#endif //KAB_EMBEDDED
140 140
141} 141}
142 142
143KABC::AddresseeList CSVXXPort::importContacts( const QString& ) const 143KABC::AddresseeList CSVXXPort::importContacts( const QString& ) const
144{ 144{
145 CSVImportDialog dlg( addressBook(), parentWidget() ); 145 CSVImportDialog dlg( addressBook(), parentWidget() );
146 if ( dlg.exec() ) 146 if ( dlg.exec() )
147 return dlg.contacts(); 147 return dlg.contacts();
148 else 148 else
149 return KABC::AddresseeList(); 149 return KABC::AddresseeList();
150} 150}
151 151
152void CSVXXPort::doExport( QFile *fp, const KABC::AddresseeList &list ) 152void CSVXXPort::doExport( QFile *fp, const KABC::AddresseeList &list )
153{ 153{
154 QTextStream t( fp ); 154 Q3TextStream t( fp );
155 t.setCodec( QTextCodec::codecForName("utf8") ); 155 t.setCodec( QTextCodec::codecForName("utf8") );
156 156
157 KABC::AddresseeList::ConstIterator iter; 157 KABC::AddresseeList::ConstIterator iter;
158 KABC::Field::List fields = addressBook()->fields(); 158 KABC::Field::List fields = addressBook()->fields();
159 KABC::Field::List::Iterator fieldIter; 159 KABC::Field::List::Iterator fieldIter;
160 bool first = true; 160 bool first = true;
161 161
162 // First output the column headings 162 // First output the column headings
163 for ( fieldIter = fields.begin(); fieldIter != fields.end(); ++fieldIter ) { 163 for ( fieldIter = fields.begin(); fieldIter != fields.end(); ++fieldIter ) {
164 if ( !first ) 164 if ( !first )
165 t << ","; 165 t << ",";
166 166
167 t << "\"" << (*fieldIter)->label() << "\""; 167 t << "\"" << (*fieldIter)->label() << "\"";
168 first = false; 168 first = false;
169 } 169 }
170 t << "\n"; 170 t << "\n";
171 171
172 // Then all the addressee objects 172 // Then all the addressee objects
173 KABC::Addressee addr; 173 KABC::Addressee addr;
174 for ( iter = list.begin(); iter != list.end(); ++iter ) { 174 for ( iter = list.begin(); iter != list.end(); ++iter ) {
175 addr = *iter; 175 addr = *iter;
176 first = true; 176 first = true;
177 177
178 for ( fieldIter = fields.begin(); fieldIter != fields.end(); ++fieldIter ) { 178 for ( fieldIter = fields.begin(); fieldIter != fields.end(); ++fieldIter ) {
179 if ( !first ) 179 if ( !first )
180 t << ","; 180 t << ",";
181 181
182 t << "\"" << (*fieldIter)->value( addr ) << "\""; 182 t << "\"" << (*fieldIter)->value( addr ) << "\"";
183 first = false; 183 first = false;
184 } 184 }
185 185
186 t << "\n"; 186 t << "\n";
187 } 187 }
188} 188}
189 189
190#ifndef KAB_EMBEDDED 190#ifndef KAB_EMBEDDED_
191#include "csv_xxport.moc" 191#include "moc_csv_xxport.cpp"
192#endif //KAB_EMBEDDED 192#endif //KAB_EMBEDDED
193
194
diff --git a/kaddressbook/xxport/csvimportdialog.cpp b/kaddressbook/xxport/csvimportdialog.cpp
index 862241e..7959cac 100644
--- a/kaddressbook/xxport/csvimportdialog.cpp
+++ b/kaddressbook/xxport/csvimportdialog.cpp
@@ -1,969 +1,973 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (C) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (C) 2003 Tobias Koenig <tokoe@kde.org>
4 based on the code of KSpread's CSV Import Dialog 4 based on the code of KSpread's CSV Import Dialog
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29 29
30#include <qbuttongroup.h> 30#include <q3buttongroup.h>
31#include <qcheckbox.h> 31#include <qcheckbox.h>
32#include <qcombobox.h> 32#include <qcombobox.h>
33#ifdef DESKTOP_VERSION 33#ifdef DESKTOP_VERSION
34#include <qinputdialog.h> 34#include <qinputdialog.h>
35#else 35#else
36#include <qtcompat/qinputdialog.h> 36#include <qtcompat/qinputdialog.h>
37#endif 37#endif
38#include <qlabel.h> 38#include <qlabel.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qradiobutton.h> 41#include <qradiobutton.h>
42#include <qtable.h> 42#include <q3table.h>
43#include <qlayout.h> 43#include <qlayout.h>
44#include <qtextstream.h> 44#include <q3textstream.h>
45#include <qfile.h> 45#include <qfile.h>
46//Added by qt3to4:
47#include <Q3HBoxLayout>
48#include <Q3ValueList>
49#include <Q3GridLayout>
46 50
47#include <kapplication.h> 51#include <kapplication.h>
48#include <kdebug.h> 52#include <kdebug.h>
49#include <kdialogbase.h> 53#include <kdialogbase.h>
50#include <kfiledialog.h> 54#include <kfiledialog.h>
51#include <klineedit.h> 55#include <klineedit.h>
52#include <klocale.h> 56#include <klocale.h>
53#include <kglobal.h> 57#include <kglobal.h>
54#include <kmessagebox.h> 58#include <kmessagebox.h>
55#include <kstandarddirs.h> 59#include <kstandarddirs.h>
56#include <kurlrequester.h> 60#include <kurlrequester.h>
57 61
58#ifdef DESKTOP_VERSION 62#ifdef DESKTOP_VERSION
59#include "qtable.h" 63#include "q3table.h"
60#else 64#else
61#include "qcombotableitem.h" 65#include "qcombotableitem.h"
62#endif 66#endif
63#include "csvimportdialog.h" 67#include "csvimportdialog.h"
64 68
65CSVImportDialog::CSVImportDialog( KABC::AddressBook *ab, QWidget *parent, 69CSVImportDialog::CSVImportDialog( KABC::AddressBook *ab, QWidget *parent,
66 const char * name ) 70 const char * name )
67 : KDialogBase( Plain, i18n ( "CSV Import Dialog" ), Ok | Cancel | User1 | 71 : KDialogBase( Plain, i18n ( "CSV Import Dialog" ), Ok | Cancel | User1 |
68 User2, Ok, parent, name, true, true ), 72 User2, Ok, parent, name, true, true ),
69 mAdjustRows( false ), 73 mAdjustRows( false ),
70 mStartLine( 0 ), 74 mStartLine( 0 ),
71 mTextQuote( '"' ), 75 mTextQuote( '"' ),
72 mDelimiter( "," ), 76 mDelimiter( "," ),
73 mAddressBook( ab ) 77 mAddressBook( ab )
74{ 78{
75 initGUI(); 79 initGUI();
76 80
77 mTypeMap.insert( i18n( "Undefined" ), Undefined ); 81 mTypeMap.insert( i18n( "Undefined" ), Undefined );
78 mTypeMap.insert( KABC::Addressee::formattedNameLabel(), FormattedName ); 82 mTypeMap.insert( KABC::Addressee::formattedNameLabel(), FormattedName );
79 mTypeMap.insert( KABC::Addressee::familyNameLabel(), FamilyName ); 83 mTypeMap.insert( KABC::Addressee::familyNameLabel(), FamilyName );
80 mTypeMap.insert( KABC::Addressee::givenNameLabel(), GivenName ); 84 mTypeMap.insert( KABC::Addressee::givenNameLabel(), GivenName );
81 mTypeMap.insert( KABC::Addressee::additionalNameLabel(), AdditionalName ); 85 mTypeMap.insert( KABC::Addressee::additionalNameLabel(), AdditionalName );
82 mTypeMap.insert( KABC::Addressee::prefixLabel(), Prefix ); 86 mTypeMap.insert( KABC::Addressee::prefixLabel(), Prefix );
83 mTypeMap.insert( KABC::Addressee::suffixLabel(), Suffix ); 87 mTypeMap.insert( KABC::Addressee::suffixLabel(), Suffix );
84 mTypeMap.insert( KABC::Addressee::nickNameLabel(), NickName ); 88 mTypeMap.insert( KABC::Addressee::nickNameLabel(), NickName );
85 mTypeMap.insert( KABC::Addressee::birthdayLabel(), Birthday ); 89 mTypeMap.insert( KABC::Addressee::birthdayLabel(), Birthday );
86 90
87 mTypeMap.insert( KABC::Addressee::homeAddressStreetLabel(), HomeAddressStreet ); 91 mTypeMap.insert( KABC::Addressee::homeAddressStreetLabel(), HomeAddressStreet );
88 mTypeMap.insert( KABC::Addressee::homeAddressLocalityLabel(), 92 mTypeMap.insert( KABC::Addressee::homeAddressLocalityLabel(),
89 HomeAddressLocality ); 93 HomeAddressLocality );
90 mTypeMap.insert( KABC::Addressee::homeAddressRegionLabel(), HomeAddressRegion ); 94 mTypeMap.insert( KABC::Addressee::homeAddressRegionLabel(), HomeAddressRegion );
91 mTypeMap.insert( KABC::Addressee::homeAddressPostalCodeLabel(), 95 mTypeMap.insert( KABC::Addressee::homeAddressPostalCodeLabel(),
92 HomeAddressPostalCode ); 96 HomeAddressPostalCode );
93 mTypeMap.insert( KABC::Addressee::homeAddressCountryLabel(), 97 mTypeMap.insert( KABC::Addressee::homeAddressCountryLabel(),
94 HomeAddressCountry ); 98 HomeAddressCountry );
95 mTypeMap.insert( KABC::Addressee::homeAddressLabelLabel(), HomeAddressLabel ); 99 mTypeMap.insert( KABC::Addressee::homeAddressLabelLabel(), HomeAddressLabel );
96 100
97 mTypeMap.insert( KABC::Addressee::businessAddressStreetLabel(), 101 mTypeMap.insert( KABC::Addressee::businessAddressStreetLabel(),
98 BusinessAddressStreet ); 102 BusinessAddressStreet );
99 mTypeMap.insert( KABC::Addressee::businessAddressLocalityLabel(), 103 mTypeMap.insert( KABC::Addressee::businessAddressLocalityLabel(),
100 BusinessAddressLocality ); 104 BusinessAddressLocality );
101 mTypeMap.insert( KABC::Addressee::businessAddressRegionLabel(), 105 mTypeMap.insert( KABC::Addressee::businessAddressRegionLabel(),
102 BusinessAddressRegion ); 106 BusinessAddressRegion );
103 mTypeMap.insert( KABC::Addressee::businessAddressPostalCodeLabel(), 107 mTypeMap.insert( KABC::Addressee::businessAddressPostalCodeLabel(),
104 BusinessAddressPostalCode ); 108 BusinessAddressPostalCode );
105 mTypeMap.insert( KABC::Addressee::businessAddressCountryLabel(), 109 mTypeMap.insert( KABC::Addressee::businessAddressCountryLabel(),
106 BusinessAddressCountry ); 110 BusinessAddressCountry );
107 mTypeMap.insert( KABC::Addressee::businessAddressLabelLabel(), 111 mTypeMap.insert( KABC::Addressee::businessAddressLabelLabel(),
108 BusinessAddressLabel ); 112 BusinessAddressLabel );
109 113
110 mTypeMap.insert( KABC::Addressee::homePhoneLabel(), HomePhone ); 114 mTypeMap.insert( KABC::Addressee::homePhoneLabel(), HomePhone );
111 mTypeMap.insert( KABC::Addressee::businessPhoneLabel(), BusinessPhone ); 115 mTypeMap.insert( KABC::Addressee::businessPhoneLabel(), BusinessPhone );
112 mTypeMap.insert( KABC::Addressee::mobilePhoneLabel(), MobilePhone ); 116 mTypeMap.insert( KABC::Addressee::mobilePhoneLabel(), MobilePhone );
113 mTypeMap.insert( KABC::Addressee::homeFaxLabel(), HomeFax ); 117 mTypeMap.insert( KABC::Addressee::homeFaxLabel(), HomeFax );
114 mTypeMap.insert( KABC::Addressee::businessFaxLabel(), BusinessFax ); 118 mTypeMap.insert( KABC::Addressee::businessFaxLabel(), BusinessFax );
115 mTypeMap.insert( KABC::Addressee::mobileWorkPhoneLabel(), MobileWorkPhone ); 119 mTypeMap.insert( KABC::Addressee::mobileWorkPhoneLabel(), MobileWorkPhone );
116 mTypeMap.insert( KABC::Addressee::isdnLabel(), Isdn ); 120 mTypeMap.insert( KABC::Addressee::isdnLabel(), Isdn );
117 mTypeMap.insert( KABC::Addressee::pagerLabel(), Pager ); 121 mTypeMap.insert( KABC::Addressee::pagerLabel(), Pager );
118 mTypeMap.insert( KABC::Addressee::emailLabel(), Email ); 122 mTypeMap.insert( KABC::Addressee::emailLabel(), Email );
119 mTypeMap.insert( KABC::Addressee::mailerLabel(), Mailer ); 123 mTypeMap.insert( KABC::Addressee::mailerLabel(), Mailer );
120 mTypeMap.insert( KABC::Addressee::titleLabel(), Title ); 124 mTypeMap.insert( KABC::Addressee::titleLabel(), Title );
121 mTypeMap.insert( KABC::Addressee::roleLabel(), Role ); 125 mTypeMap.insert( KABC::Addressee::roleLabel(), Role );
122 mTypeMap.insert( KABC::Addressee::organizationLabel(), Organization ); 126 mTypeMap.insert( KABC::Addressee::organizationLabel(), Organization );
123 mTypeMap.insert( KABC::Addressee::noteLabel(), Note ); 127 mTypeMap.insert( KABC::Addressee::noteLabel(), Note );
124 mTypeMap.insert( KABC::Addressee::urlLabel(), URL ); 128 mTypeMap.insert( KABC::Addressee::urlLabel(), URL );
125 mTypeMap.insert( KABC::Addressee::categoryLabel(), Categories ); 129 mTypeMap.insert( KABC::Addressee::categoryLabel(), Categories );
126 130
127 mCustomCounter = mTypeMap.count(); 131 mCustomCounter = mTypeMap.count();
128 int count = mCustomCounter; 132 int count = mCustomCounter;
129 133
130 KABC::Field::List fields = mAddressBook->fields( KABC::Field::CustomCategory ); 134 KABC::Field::List fields = mAddressBook->fields( KABC::Field::CustomCategory );
131 KABC::Field::List::Iterator it; 135 KABC::Field::List::Iterator it;
132 for ( it = fields.begin(); it != fields.end(); ++it, ++count ) 136 for ( it = fields.begin(); it != fields.end(); ++it, ++count )
133 mTypeMap.insert( (*it)->label(), count ); 137 mTypeMap.insert( (*it)->label(), count );
134 138
135 connect( mDelimiterBox, SIGNAL( clicked( int ) ), 139 connect( mDelimiterBox, SIGNAL( clicked( int ) ),
136 this, SLOT( delimiterClicked( int ) ) ); 140 this, SLOT( delimiterClicked( int ) ) );
137 connect( mDelimiterEdit, SIGNAL( returnPressed() ), 141 connect( mDelimiterEdit, SIGNAL( returnPressed() ),
138 this, SLOT( returnPressed() ) ); 142 this, SLOT( returnPressed() ) );
139 connect( mDelimiterEdit, SIGNAL( textChanged ( const QString& ) ), 143 connect( mDelimiterEdit, SIGNAL( textChanged ( const QString& ) ),
140 this, SLOT( textChanged ( const QString& ) ) ); 144 this, SLOT( textChanged ( const QString& ) ) );
141 connect( mComboLine, SIGNAL( activated( const QString& ) ), 145 connect( mComboLine, SIGNAL( activated( const QString& ) ),
142 this, SLOT( lineSelected( const QString& ) ) ); 146 this, SLOT( lineSelected( const QString& ) ) );
143 connect( mComboCodec, SIGNAL( activated( const QString& ) ), 147 connect( mComboCodec, SIGNAL( activated( const QString& ) ),
144 this, SLOT( codecChanged( const QString& ) ) ); 148 this, SLOT( codecChanged( const QString& ) ) );
145 connect( mComboQuote, SIGNAL( activated( const QString& ) ), 149 connect( mComboQuote, SIGNAL( activated( const QString& ) ),
146 this, SLOT( textquoteSelected( const QString& ) ) ); 150 this, SLOT( textquoteSelected( const QString& ) ) );
147 connect( mIgnoreDuplicates, SIGNAL( stateChanged( int ) ), 151 connect( mIgnoreDuplicates, SIGNAL( stateChanged( int ) ),
148 this, SLOT( ignoreDuplicatesChanged( int ) ) ); 152 this, SLOT( ignoreDuplicatesChanged( int ) ) );
149 153
150 connect( mUrlRequester, SIGNAL( returnPressed( const QString& ) ), 154 connect( mUrlRequester, SIGNAL( returnPressed( const QString& ) ),
151 this, SLOT( setFile( const QString& ) ) ); 155 this, SLOT( setFile( const QString& ) ) );
152 connect( mUrlRequester, SIGNAL( urlSelected( const QString& ) ), 156 connect( mUrlRequester, SIGNAL( urlSelected( const QString& ) ),
153 this, SLOT( setFile( const QString& ) ) ); 157 this, SLOT( setFile( const QString& ) ) );
154 connect( mUrlRequester->lineEdit(), SIGNAL( textChanged ( const QString& ) ), 158 connect( mUrlRequester->lineEdit(), SIGNAL( textChanged ( const QString& ) ),
155 this, SLOT( urlChanged( const QString& ) ) ); 159 this, SLOT( urlChanged( const QString& ) ) );
156 160
157 connect( this, SIGNAL( user1Clicked() ), 161 connect( this, SIGNAL( user1Clicked() ),
158 this, SLOT( applyTemplate() ) ); 162 this, SLOT( applyTemplate() ) );
159 163
160 connect( this, SIGNAL( user2Clicked() ), 164 connect( this, SIGNAL( user2Clicked() ),
161 this, SLOT( saveTemplate() ) ); 165 this, SLOT( saveTemplate() ) );
162 166
163 // if ( QApplication::desktop()->width() < 321 ) 167 // if ( QApplication::desktop()->width() < 321 )
164 QIconSet icon = SmallIcon("filesave"); 168 QIcon icon = SmallIcon("filesave");
165 169
166 findButton( User2 )->setIconSet (icon ) ; 170 findButton( User2 )->setIconSet (icon ) ;
167 icon = SmallIcon("fileopen"); 171 icon = SmallIcon("fileopen");
168 findButton( User1 )->setIconSet (icon ) ; 172 findButton( User1 )->setIconSet (icon ) ;
169 int wid = findButton( User2 )->sizeHint().height(); 173 int wid = findButton( User2 )->sizeHint().height();
170 findButton( User2 )->setMaximumWidth( wid+4 ); 174 findButton( User2 )->setMaximumWidth( wid+4 );
171 findButton( User1 )->setMaximumWidth( wid+4 ); 175 findButton( User1 )->setMaximumWidth( wid+4 );
172} 176}
173 177
174CSVImportDialog::~CSVImportDialog() 178CSVImportDialog::~CSVImportDialog()
175{ 179{
176} 180}
177 181
178KABC::AddresseeList CSVImportDialog::contacts() const 182KABC::AddresseeList CSVImportDialog::contacts() const
179{ 183{
180 KABC::AddresseeList contacts; 184 KABC::AddresseeList contacts;
181 185
182 for ( int row = 1; row < mTable->numRows(); ++row ) { 186 for ( int row = 1; row < mTable->numRows(); ++row ) {
183 KABC::Addressee a; 187 KABC::Addressee a;
184 bool emptyRow = true; 188 bool emptyRow = true;
185 KABC::Address addrHome( KABC::Address::Home ); 189 KABC::Address addrHome( KABC::Address::Home );
186 KABC::Address addrWork( KABC::Address::Work ); 190 KABC::Address addrWork( KABC::Address::Work );
187 for ( int col = 0; col < mTable->numCols(); ++col ) { 191 for ( int col = 0; col < mTable->numCols(); ++col ) {
188 192
189 QComboTableItem *item = static_cast<QComboTableItem*>( mTable->item( 0, col ) ); 193 Q3ComboTableItem *item = static_cast<Q3ComboTableItem*>( mTable->item( 0, col ) );
190 194
191 if ( !item ) { 195 if ( !item ) {
192 qDebug( "ERROR: item cast failed" ); 196 qDebug( "ERROR: item cast failed" );
193 continue; 197 continue;
194 } 198 }
195 199
196 QString value = mTable->text( row, col ); 200 QString value = mTable->text( row, col );
197 if ( !value.isEmpty() ) 201 if ( !value.isEmpty() )
198 emptyRow = false; 202 emptyRow = false;
199 203
200 switch ( posToType( item->currentItem() ) ) 204 switch ( posToType( item->currentItem() ) )
201 { 205 {
202 case Undefined: 206 case Undefined:
203 continue; 207 continue;
204 break; 208 break;
205 case FormattedName: 209 case FormattedName:
206 a.setFormattedName( value ); 210 a.setFormattedName( value );
207 break; 211 break;
208 case GivenName: 212 case GivenName:
209 a.setGivenName( value ); 213 a.setGivenName( value );
210 break; 214 break;
211 case FamilyName: 215 case FamilyName:
212 a.setFamilyName( value ); 216 a.setFamilyName( value );
213 break; 217 break;
214 case AdditionalName: 218 case AdditionalName:
215 a.setAdditionalName( value ); 219 a.setAdditionalName( value );
216 break; 220 break;
217 case Prefix: 221 case Prefix:
218 a.setPrefix( value ); 222 a.setPrefix( value );
219 break; 223 break;
220 case Suffix: 224 case Suffix:
221 a.setSuffix( value ); 225 a.setSuffix( value );
222 break; 226 break;
223 case NickName: 227 case NickName:
224 a.setNickName( value ); 228 a.setNickName( value );
225 break; 229 break;
226 case Birthday: 230 case Birthday:
227//US 231//US
228//the generated code had the following format: a.setBirthday( QDate::fromString( value, Qt::ISODate ) ); 232//the generated code had the following format: a.setBirthday( QDate::fromString( value, Qt::ISODate ) );
229// But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ? 233// But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ?
230 { 234 {
231 QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate 235 QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate
232 a.setBirthday(dt); 236 a.setBirthday(QDateTime(dt));
233 } 237 }
234 break; 238 break;
235 case Email: 239 case Email:
236 if ( !value.isEmpty() ) 240 if ( !value.isEmpty() )
237 a.insertEmail( value, true ); 241 a.insertEmail( value, true );
238 break; 242 break;
239 case Role: 243 case Role:
240 a.setRole( value ); 244 a.setRole( value );
241 break; 245 break;
242 case Title: 246 case Title:
243 a.setTitle( value ); 247 a.setTitle( value );
244 break; 248 break;
245 case Mailer: 249 case Mailer:
246 a.setMailer( value ); 250 a.setMailer( value );
247 break; 251 break;
248 case URL: 252 case URL:
249 a.setUrl( value ); 253 a.setUrl( value );
250 break; 254 break;
251 case Organization: 255 case Organization:
252 a.setOrganization( value ); 256 a.setOrganization( value );
253 break; 257 break;
254 case Note: 258 case Note:
255 if ( a.note().isEmpty() ) 259 if ( a.note().isEmpty() )
256 a.setNote( value ); 260 a.setNote( value );
257 else { 261 else {
258 a.setNote( a.note()+"\n"+value ); 262 a.setNote( a.note()+"\n"+value );
259 } 263 }
260 break; 264 break;
261 case Categories: 265 case Categories:
262 a.insertCategory( value ); 266 a.insertCategory( value );
263 break; 267 break;
264 case HomePhone: 268 case HomePhone:
265 if ( !value.isEmpty() ) { 269 if ( !value.isEmpty() ) {
266 KABC::PhoneNumber number( value, KABC::PhoneNumber::Home ); 270 KABC::PhoneNumber number( value, KABC::PhoneNumber::Home );
267 a.insertPhoneNumber( number ); 271 a.insertPhoneNumber( number );
268 } 272 }
269 break; 273 break;
270 case BusinessPhone: 274 case BusinessPhone:
271 if ( !value.isEmpty() ) { 275 if ( !value.isEmpty() ) {
272 KABC::PhoneNumber number( value, KABC::PhoneNumber::Work ); 276 KABC::PhoneNumber number( value, KABC::PhoneNumber::Work );
273 a.insertPhoneNumber( number ); 277 a.insertPhoneNumber( number );
274 } 278 }
275 break; 279 break;
276 case MobilePhone: 280 case MobilePhone:
277 if ( !value.isEmpty() ) { 281 if ( !value.isEmpty() ) {
278 KABC::PhoneNumber number( value, KABC::PhoneNumber::Cell ); 282 KABC::PhoneNumber number( value, KABC::PhoneNumber::Cell );
279 a.insertPhoneNumber( number ); 283 a.insertPhoneNumber( number );
280 } 284 }
281 break; 285 break;
282 case HomeFax: 286 case HomeFax:
283 if ( !value.isEmpty() ) { 287 if ( !value.isEmpty() ) {
284 KABC::PhoneNumber number( value, KABC::PhoneNumber::Home | 288 KABC::PhoneNumber number( value, KABC::PhoneNumber::Home |
285 KABC::PhoneNumber::Fax ); 289 KABC::PhoneNumber::Fax );
286 a.insertPhoneNumber( number ); 290 a.insertPhoneNumber( number );
287 } 291 }
288 break; 292 break;
289 case BusinessFax: 293 case BusinessFax:
290 if ( !value.isEmpty() ) { 294 if ( !value.isEmpty() ) {
291 KABC::PhoneNumber number( value, KABC::PhoneNumber::Work | 295 KABC::PhoneNumber number( value, KABC::PhoneNumber::Work |
292 KABC::PhoneNumber::Fax ); 296 KABC::PhoneNumber::Fax );
293 a.insertPhoneNumber( number ); 297 a.insertPhoneNumber( number );
294 } 298 }
295 break; 299 break;
296 case MobileWorkPhone: 300 case MobileWorkPhone:
297 if ( !value.isEmpty() ) { 301 if ( !value.isEmpty() ) {
298 KABC::PhoneNumber number( value, KABC::PhoneNumber::Car ); 302 KABC::PhoneNumber number( value, KABC::PhoneNumber::Car );
299 a.insertPhoneNumber( number ); 303 a.insertPhoneNumber( number );
300 } 304 }
301 break; 305 break;
302 case Isdn: 306 case Isdn:
303 if ( !value.isEmpty() ) { 307 if ( !value.isEmpty() ) {
304 KABC::PhoneNumber number( value, KABC::PhoneNumber::Isdn ); 308 KABC::PhoneNumber number( value, KABC::PhoneNumber::Isdn );
305 a.insertPhoneNumber( number ); 309 a.insertPhoneNumber( number );
306 } 310 }
307 break; 311 break;
308 case Pager: 312 case Pager:
309 if ( !value.isEmpty() ) { 313 if ( !value.isEmpty() ) {
310 KABC::PhoneNumber number( value, KABC::PhoneNumber::Pager ); 314 KABC::PhoneNumber number( value, KABC::PhoneNumber::Pager );
311 a.insertPhoneNumber( number ); 315 a.insertPhoneNumber( number );
312 } 316 }
313 break; 317 break;
314 318
315 case HomeAddressStreet: 319 case HomeAddressStreet:
316 addrHome.setStreet( value ); 320 addrHome.setStreet( value );
317 break; 321 break;
318 case HomeAddressLocality: 322 case HomeAddressLocality:
319 addrHome.setLocality( value ); 323 addrHome.setLocality( value );
320 break; 324 break;
321 case HomeAddressRegion: 325 case HomeAddressRegion:
322 addrHome.setRegion( value ); 326 addrHome.setRegion( value );
323 break; 327 break;
324 case HomeAddressPostalCode: 328 case HomeAddressPostalCode:
325 addrHome.setPostalCode( value ); 329 addrHome.setPostalCode( value );
326 break; 330 break;
327 case HomeAddressCountry: 331 case HomeAddressCountry:
328 addrHome.setCountry( value ); 332 addrHome.setCountry( value );
329 break; 333 break;
330 case HomeAddressLabel: 334 case HomeAddressLabel:
331 addrHome.setLabel( value ); 335 addrHome.setLabel( value );
332 break; 336 break;
333 337
334 case BusinessAddressStreet: 338 case BusinessAddressStreet:
335 addrWork.setStreet( value ); 339 addrWork.setStreet( value );
336 break; 340 break;
337 case BusinessAddressLocality: 341 case BusinessAddressLocality:
338 addrWork.setLocality( value ); 342 addrWork.setLocality( value );
339 break; 343 break;
340 case BusinessAddressRegion: 344 case BusinessAddressRegion:
341 addrWork.setRegion( value ); 345 addrWork.setRegion( value );
342 break; 346 break;
343 case BusinessAddressPostalCode: 347 case BusinessAddressPostalCode:
344 addrWork.setPostalCode( value ); 348 addrWork.setPostalCode( value );
345 break; 349 break;
346 case BusinessAddressCountry: 350 case BusinessAddressCountry:
347 addrWork.setCountry( value ); 351 addrWork.setCountry( value );
348 break; 352 break;
349 case BusinessAddressLabel: 353 case BusinessAddressLabel:
350 addrWork.setLabel( value ); 354 addrWork.setLabel( value );
351 break; 355 break;
352 default: 356 default:
353 KABC::Field::List fields = mAddressBook->fields( KABC::Field::CustomCategory ); 357 KABC::Field::List fields = mAddressBook->fields( KABC::Field::CustomCategory );
354 KABC::Field::List::Iterator it; 358 KABC::Field::List::Iterator it;
355 359
356 int counter = 0; 360 int counter = 0;
357 for ( it = fields.begin(); it != fields.end(); ++it ) { 361 for ( it = fields.begin(); it != fields.end(); ++it ) {
358 if ( counter == (int)( posToType( item->currentItem() ) - mCustomCounter ) ) 362 if ( counter == (int)( posToType( item->currentItem() ) - mCustomCounter ) )
359 { 363 {
360 (*it)->setValue( a, value ); 364 (*it)->setValue( a, value );
361 break; 365 break;
362 } 366 }
363 ++counter; 367 ++counter;
364 } 368 }
365 break; 369 break;
366 } 370 }
367 } 371 }
368 372
369 if ( !addrHome.isEmpty() ) 373 if ( !addrHome.isEmpty() )
370 a.insertAddress( addrHome ); 374 a.insertAddress( addrHome );
371 if ( !addrWork.isEmpty() ) 375 if ( !addrWork.isEmpty() )
372 a.insertAddress( addrWork ); 376 a.insertAddress( addrWork );
373 377
374 if ( !emptyRow && !a.isEmpty() ) 378 if ( !emptyRow && !a.isEmpty() )
375 contacts.append( a ); 379 contacts.append( a );
376 } 380 }
377 381
378 return contacts; 382 return contacts;
379} 383}
380 384
381void CSVImportDialog::initGUI() 385void CSVImportDialog::initGUI()
382{ 386{
383 QWidget* page = plainPage(); 387 QWidget* page = plainPage();
384 388
385 QGridLayout *layout = new QGridLayout( page, 1, 1, marginHintSmall(), 389 Q3GridLayout *layout = new Q3GridLayout( page, 1, 1, marginHintSmall(),
386 spacingHintSmall() ); 390 spacingHintSmall() );
387 QHBoxLayout *hbox = new QHBoxLayout(); 391 Q3HBoxLayout *hbox = new Q3HBoxLayout();
388 hbox->setSpacing( spacingHint() ); 392 hbox->setSpacing( spacingHint() );
389 393
390 QLabel *label = new QLabel( i18n( "File to import:" ), page ); 394 QLabel *label = new QLabel( i18n( "File to import:" ), page );
391 hbox->addWidget( label ); 395 hbox->addWidget( label );
392 396
393 mUrlRequester = new KURLRequester( page ); 397 mUrlRequester = new KURLRequester( page );
394 mUrlRequester->setFilter( "*.csv" ); 398 mUrlRequester->setFilter( "*.csv" );
395 hbox->addWidget( mUrlRequester ); 399 hbox->addWidget( mUrlRequester );
396 400
397 layout->addMultiCellLayout( hbox, 0, 0, 0, 2 ); 401 layout->addMultiCellLayout( hbox, 0, 0, 0, 2 );
398 402
399 // Delimiter: comma, semicolon, tab, space, other 403 // Delimiter: comma, semicolon, tab, space, other
400 mDelimiterBox = new QButtonGroup( i18n( "Delimiter" ), page ); 404 mDelimiterBox = new Q3ButtonGroup( i18n( "Delimiter" ), page );
401 mDelimiterBox->setColumnLayout( 0, Qt::Vertical ); 405 mDelimiterBox->setColumnLayout( 0, Qt::Vertical );
402 mDelimiterBox->layout()->setSpacing( spacingHint() ); 406 mDelimiterBox->layout()->setSpacing( spacingHint() );
403 mDelimiterBox->layout()->setMargin( marginHint() ); 407 mDelimiterBox->layout()->setMargin( marginHint() );
404 QGridLayout *delimiterLayout = new QGridLayout( mDelimiterBox->layout() ); 408 Q3GridLayout *delimiterLayout = new Q3GridLayout( mDelimiterBox->layout() );
405 delimiterLayout->setAlignment( Qt::AlignTop ); 409 delimiterLayout->setAlignment( Qt::AlignTop );
406 layout->addMultiCellWidget( mDelimiterBox, 1, 1, 0, 2 ); 410 layout->addMultiCellWidget( mDelimiterBox, 1, 1, 0, 2 );
407 411
408 mRadioComma = new QRadioButton( i18n( "Comma" ), mDelimiterBox ); 412 mRadioComma = new QRadioButton( i18n( "Comma" ), mDelimiterBox );
409 mRadioComma->setChecked( true ); 413 mRadioComma->setChecked( true );
410 delimiterLayout->addWidget( mRadioComma, 0, 0 ); 414 delimiterLayout->addWidget( mRadioComma, 0, 0 );
411 415
412 mRadioSemicolon = new QRadioButton( i18n( "Semicolon" ), mDelimiterBox ); 416 mRadioSemicolon = new QRadioButton( i18n( "Semicolon" ), mDelimiterBox );
413 delimiterLayout->addWidget( mRadioSemicolon, 0, 1 ); 417 delimiterLayout->addWidget( mRadioSemicolon, 0, 1 );
414 418
415 mRadioTab = new QRadioButton( i18n( "Tabulator" ), mDelimiterBox ); 419 mRadioTab = new QRadioButton( i18n( "Tabulator" ), mDelimiterBox );
416 delimiterLayout->addWidget( mRadioTab, 1, 0 ); 420 delimiterLayout->addWidget( mRadioTab, 1, 0 );
417 421
418 mRadioSpace = new QRadioButton( i18n( "Space" ), mDelimiterBox ); 422 mRadioSpace = new QRadioButton( i18n( "Space" ), mDelimiterBox );
419 delimiterLayout->addWidget( mRadioSpace, 1, 1 ); 423 delimiterLayout->addWidget( mRadioSpace, 1, 1 );
420 424
421 mRadioOther = new QRadioButton( i18n( "Other" ), mDelimiterBox ); 425 mRadioOther = new QRadioButton( i18n( "Other" ), mDelimiterBox );
422 delimiterLayout->addWidget( mRadioOther, 0, 2 ); 426 delimiterLayout->addWidget( mRadioOther, 0, 2 );
423 427
424 mDelimiterEdit = new QLineEdit( mDelimiterBox ); 428 mDelimiterEdit = new QLineEdit( mDelimiterBox );
425 delimiterLayout->addWidget( mDelimiterEdit, 1, 2 ); 429 delimiterLayout->addWidget( mDelimiterEdit, 1, 2 );
426 430
427 mComboLine = new QComboBox( false, page ); 431 mComboLine = new QComboBox( false, page );
428 mComboLine->insertItem( i18n( "1" ) ); 432 mComboLine->insertItem( i18n( "1" ) );
429 layout->addWidget( mComboLine, 3, 1 ); 433 layout->addWidget( mComboLine, 3, 1 );
430 434
431 mComboQuote = new QComboBox( false, page ); 435 mComboQuote = new QComboBox( false, page );
432 mComboQuote->insertItem( i18n( "\"" ), 0 ); 436 mComboQuote->insertItem( i18n( "\"" ), 0 );
433 mComboQuote->insertItem( i18n( "'" ), 1 ); 437 mComboQuote->insertItem( i18n( "'" ), 1 );
434 mComboQuote->insertItem( i18n( "None" ), 2 ); 438 mComboQuote->insertItem( i18n( "None" ), 2 );
435 layout->addWidget( mComboQuote, 3, 0 ); 439 layout->addWidget( mComboQuote, 3, 0 );
436 mComboCodec = new QComboBox( false, page ); 440 mComboCodec = new QComboBox( false, page );
437 mComboCodec->insertItem( i18n( "UTF8" ), 0 ); 441 mComboCodec->insertItem( i18n( "UTF8" ), 0 );
438 mComboCodec->insertItem( i18n( "LATIN1" ), 1 ); 442 mComboCodec->insertItem( i18n( "LATIN1" ), 1 );
439 mComboCodec->insertItem( i18n( "LOCALE" ), 2 ); 443 mComboCodec->insertItem( i18n( "LOCALE" ), 2 );
440 layout->addWidget( mComboCodec, 3, 2 ); 444 layout->addWidget( mComboCodec, 3, 2 );
441 label = new QLabel( i18n( "Start at line:" ), page ); 445 label = new QLabel( i18n( "Start at line:" ), page );
442 layout->addWidget( label, 2, 1 ); 446 layout->addWidget( label, 2, 1 );
443 447
444 label = new QLabel( i18n( "Textquote:" ), page ); 448 label = new QLabel( i18n( "Textquote:" ), page );
445 layout->addWidget( label, 2, 0 ); 449 layout->addWidget( label, 2, 0 );
446 label = new QLabel( i18n( "Codec:" ), page ); 450 label = new QLabel( i18n( "Codec:" ), page );
447 layout->addWidget( label, 2, 2 ); 451 layout->addWidget( label, 2, 2 );
448 452
449 mIgnoreDuplicates = new QCheckBox( page ); 453 mIgnoreDuplicates = new QCheckBox( page );
450 mIgnoreDuplicates->setText( i18n( "Ignore duplicate delimiters" ) ); 454 mIgnoreDuplicates->setText( i18n( "Ignore duplicate delimiters" ) );
451 layout->addMultiCellWidget( mIgnoreDuplicates, 4, 4, 0, 2 ); 455 layout->addMultiCellWidget( mIgnoreDuplicates, 4, 4, 0, 2 );
452 456
453 mTable = new QTable( 0, 0, page ); 457 mTable = new Q3Table( 0, 0, page );
454 mTable->setSelectionMode( QTable::NoSelection ); 458 mTable->setSelectionMode( Q3Table::NoSelection );
455 //mTable->horizontalHeader()->hide(); 459 //mTable->horizontalHeader()->hide();
456 layout->addMultiCellWidget( mTable, 5, 5, 0, 2 ); 460 layout->addMultiCellWidget( mTable, 5, 5, 0, 2 );
457/*US 461/*US
458 setButtonText( User1, i18n( "Apply Template" ) ); 462 setButtonText( User1, i18n( "Apply Template" ) );
459 setButtonText( User2, i18n( "Save Template" ) ); 463 setButtonText( User2, i18n( "Save Template" ) );
460*/ 464*/
461 465
462 enableButtonOK( false ); 466 enableButtonOK( false );
463 467
464 findButton( User1 )->setEnabled( false ); 468 findButton( User1 )->setEnabled( false );
465 findButton( User2 )->setEnabled( false ); 469 findButton( User2 )->setEnabled( false );
466 470
467#ifdef DESKTOP_VERSION 471#ifdef DESKTOP_VERSION
468 resize( 640, 480 ); 472 resize( 640, 480 );
469#else 473#else
470 showMaximized(); 474 showMaximized();
471#endif 475#endif
472} 476}
473 477
474void CSVImportDialog::fillTable() 478void CSVImportDialog::fillTable()
475{ 479{
476 int row, column; 480 int row, column;
477 bool lastCharDelimiter = false; 481 bool lastCharDelimiter = false;
478 bool ignoreDups = mIgnoreDuplicates->isChecked(); 482 bool ignoreDups = mIgnoreDuplicates->isChecked();
479 enum { S_START, S_QUOTED_FIELD, S_MAYBE_END_OF_QUOTED_FIELD, S_END_OF_QUOTED_FIELD, 483 enum { S_START, S_QUOTED_FIELD, S_MAYBE_END_OF_QUOTED_FIELD, S_END_OF_QUOTED_FIELD,
480 S_MAYBE_NORMAL_FIELD, S_NORMAL_FIELD } state = S_START; 484 S_MAYBE_NORMAL_FIELD, S_NORMAL_FIELD } state = S_START;
481 485
482 QChar x; 486 QChar x;
483 QString field = ""; 487 QString field = "";
484 488
485 // store previous assignment 489 // store previous assignment
486 QValueList<int> mTypeOld = mTypeStore; 490 Q3ValueList<int> mTypeOld = mTypeStore;
487 491
488 mTypeStore.clear(); 492 mTypeStore.clear();
489 for ( column = 0; column < mTable->numCols(); ++column ) { 493 for ( column = 0; column < mTable->numCols(); ++column ) {
490 QComboTableItem *item = static_cast<QComboTableItem*>( mTable->item( 0, column ) ); 494 Q3ComboTableItem *item = static_cast<Q3ComboTableItem*>( mTable->item( 0, column ) );
491 495
492 if ( !item || mClearTypeStore ) 496 if ( !item || mClearTypeStore )
493 mTypeStore.append( typeToPos( Undefined ) ); 497 mTypeStore.append( typeToPos( Undefined ) );
494 else if ( item ) 498 else if ( item )
495 mTypeStore.append( item->currentItem() ); 499 mTypeStore.append( item->currentItem() );
496 } 500 }
497 501
498 clearTable(); 502 clearTable();
499 503
500 row = column = 1; 504 row = column = 1;
501 if ( mComboCodec->currentItem () == 0 ) { 505 if ( mComboCodec->currentItem () == 0 ) {
502 mData = QString::fromUtf8( mFileArray.data() ); 506 mData = QString::fromUtf8( mFileArray.data() );
503 } else if ( mComboCodec->currentItem () == 1 ) { 507 } else if ( mComboCodec->currentItem () == 1 ) {
504 mData = QString::fromLatin1( mFileArray.data() ); 508 mData = QString::fromLatin1( mFileArray.data() );
505 } else { 509 } else {
506 mData = QString::fromLocal8Bit( mFileArray.data() ); 510 mData = QString::fromLocal8Bit( mFileArray.data() );
507 } 511 }
508 512
509 QTextStream inputStream( mData, IO_ReadOnly ); 513 Q3TextStream inputStream( mData, QIODevice::ReadOnly );
510 514
511 if ( mComboCodec->currentItem () == 0 ) { 515 if ( mComboCodec->currentItem () == 0 ) {
512 inputStream.setEncoding( QTextStream::UnicodeUTF8 ); 516 inputStream.setEncoding( Q3TextStream::UnicodeUTF8 );
513 } else if ( mComboCodec->currentItem () == 1 ) { 517 } else if ( mComboCodec->currentItem () == 1 ) {
514 inputStream.setEncoding( QTextStream::Latin1 ); 518 inputStream.setEncoding( Q3TextStream::Latin1 );
515 } else { 519 } else {
516 inputStream.setEncoding( QTextStream::Locale ); 520 inputStream.setEncoding( Q3TextStream::Locale );
517 } 521 }
518 522
519 int maxColumn = 0; 523 int maxColumn = 0;
520 while ( !inputStream.atEnd() ) { 524 while ( !inputStream.atEnd() ) {
521 inputStream >> x; // read one char 525 inputStream >> x; // read one char
522 526
523 if ( x == '\r' ) inputStream >> x; // eat '\r', to handle DOS/LOSEDOWS files correctly 527 if ( x == '\r' ) inputStream >> x; // eat '\r', to handle DOS/LOSEDOWS files correctly
524 528
525 switch ( state ) { 529 switch ( state ) {
526 case S_START : 530 case S_START :
527 if ( x == mTextQuote ) { 531 if ( x == mTextQuote ) {
528 state = S_QUOTED_FIELD; 532 state = S_QUOTED_FIELD;
529 } else if ( x == mDelimiter ) { 533 } else if ( QString(x) == mDelimiter ) {
530 if ( ( ignoreDups == false ) || ( lastCharDelimiter == false ) ) 534 if ( ( ignoreDups == false ) || ( lastCharDelimiter == false ) )
531 ++column; 535 ++column;
532 lastCharDelimiter = true; 536 lastCharDelimiter = true;
533 } else if ( x == '\n' ) { 537 } else if ( x == '\n' ) {
534 ++row; 538 ++row;
535 column = 1; 539 column = 1;
536 } else { 540 } else {
537 field += x; 541 field += x;
538 state = S_MAYBE_NORMAL_FIELD; 542 state = S_MAYBE_NORMAL_FIELD;
539 } 543 }
540 break; 544 break;
541 case S_QUOTED_FIELD : 545 case S_QUOTED_FIELD :
542 if ( x == mTextQuote ) { 546 if ( x == mTextQuote ) {
543 state = S_MAYBE_END_OF_QUOTED_FIELD; 547 state = S_MAYBE_END_OF_QUOTED_FIELD;
544 } else if ( x == '\n' && mTextQuote.isNull() ) { 548 } else if ( x == '\n' && mTextQuote.isNull() ) {
545 setText( row - mStartLine + 1, column, field ); 549 setText( row - mStartLine + 1, column, field );
546 field = ""; 550 field = "";
547 if ( x == '\n' ) { 551 if ( x == '\n' ) {
548 ++row; 552 ++row;
549 column = 1; 553 column = 1;
550 } else { 554 } else {
551 if ( ( ignoreDups == false ) || ( lastCharDelimiter == false ) ) 555 if ( ( ignoreDups == false ) || ( lastCharDelimiter == false ) )
552 ++column; 556 ++column;
553 lastCharDelimiter = true; 557 lastCharDelimiter = true;
554 } 558 }
555 state = S_START; 559 state = S_START;
556 } else { 560 } else {
557 field += x; 561 field += x;
558 } 562 }
559 break; 563 break;
560 case S_MAYBE_END_OF_QUOTED_FIELD : 564 case S_MAYBE_END_OF_QUOTED_FIELD :
561 if ( x == mTextQuote ) { 565 if ( x == mTextQuote ) {
562 field += x; 566 field += x;
563 state = S_QUOTED_FIELD; 567 state = S_QUOTED_FIELD;
564 } else if ( x == mDelimiter || x == '\n' ) { 568 } else if ( QString(x) == mDelimiter || x == '\n' ) {
565 setText( row - mStartLine + 1, column, field ); 569 setText( row - mStartLine + 1, column, field );
566 field = ""; 570 field = "";
567 if ( x == '\n' ) { 571 if ( x == '\n' ) {
568 ++row; 572 ++row;
569 column = 1; 573 column = 1;
570 } else { 574 } else {
571 if ( ( ignoreDups == false ) || ( lastCharDelimiter == false ) ) 575 if ( ( ignoreDups == false ) || ( lastCharDelimiter == false ) )
572 ++column; 576 ++column;
573 lastCharDelimiter = true; 577 lastCharDelimiter = true;
574 } 578 }
575 state = S_START; 579 state = S_START;
576 } else { 580 } else {
577 state = S_END_OF_QUOTED_FIELD; 581 state = S_END_OF_QUOTED_FIELD;
578 } 582 }
579 break; 583 break;
580 case S_END_OF_QUOTED_FIELD : 584 case S_END_OF_QUOTED_FIELD :
581 if ( x == mDelimiter || x == '\n' ) { 585 if ( QString(x) == mDelimiter || x == '\n' ) {
582 setText( row - mStartLine + 1, column, field ); 586 setText( row - mStartLine + 1, column, field );
583 field = ""; 587 field = "";
584 if ( x == '\n' ) { 588 if ( x == '\n' ) {
585 ++row; 589 ++row;
586 column = 1; 590 column = 1;
587 } else { 591 } else {
588 if ( ( ignoreDups == false ) || ( lastCharDelimiter == false ) ) 592 if ( ( ignoreDups == false ) || ( lastCharDelimiter == false ) )
589 ++column; 593 ++column;
590 lastCharDelimiter = true; 594 lastCharDelimiter = true;
591 } 595 }
592 state = S_START; 596 state = S_START;
593 } else { 597 } else {
594 state = S_END_OF_QUOTED_FIELD; 598 state = S_END_OF_QUOTED_FIELD;
595 } 599 }
596 break; 600 break;
597 case S_MAYBE_NORMAL_FIELD : 601 case S_MAYBE_NORMAL_FIELD :
598 if ( x == mTextQuote ) { 602 if ( x == mTextQuote ) {
599 field = ""; 603 field = "";
600 state = S_QUOTED_FIELD; 604 state = S_QUOTED_FIELD;
601 break; 605 break;
602 } 606 }
603 case S_NORMAL_FIELD : 607 case S_NORMAL_FIELD :
604 if ( x == mDelimiter || x == '\n' ) { 608 if ( QString(x) == mDelimiter || x == '\n' ) {
605 setText( row - mStartLine + 1, column, field ); 609 setText( row - mStartLine + 1, column, field );
606 field = ""; 610 field = "";
607 if ( x == '\n' ) { 611 if ( x == '\n' ) {
608 ++row; 612 ++row;
609 column = 1; 613 column = 1;
610 } else { 614 } else {
611 if ( ( ignoreDups == false ) || ( lastCharDelimiter == false ) ) 615 if ( ( ignoreDups == false ) || ( lastCharDelimiter == false ) )
612 ++column; 616 ++column;
613 lastCharDelimiter = true; 617 lastCharDelimiter = true;
614 } 618 }
615 state = S_START; 619 state = S_START;
616 } else { 620 } else {
617 field += x; 621 field += x;
618 } 622 }
619 } 623 }
620 if ( x != mDelimiter ) 624 if ( QString(x) != mDelimiter )
621 lastCharDelimiter = false; 625 lastCharDelimiter = false;
622 626
623 if ( column > maxColumn ) 627 if ( column > maxColumn )
624 maxColumn = column; 628 maxColumn = column;
625 } 629 }
626 630
627 // file with only one line without '\n' 631 // file with only one line without '\n'
628 if ( field.length() > 0 ) { 632 if ( field.length() > 0 ) {
629 setText( row - mStartLine + 1, column, field ); 633 setText( row - mStartLine + 1, column, field );
630 ++row; 634 ++row;
631 field = ""; 635 field = "";
632 } 636 }
633 637
634 adjustRows( row - mStartLine ); 638 adjustRows( row - mStartLine );
635 mTable->setNumCols( maxColumn ); 639 mTable->setNumCols( maxColumn );
636 640
637//US begin 641//US begin
638 QStringList keys; 642 QStringList keys;
639 uint iii = 0, count = mTypeMap.count(); 643 uint iii = 0, count = mTypeMap.count();
640 while ( iii < count ) { 644 while ( iii < count ) {
641 keys << "dummy"; 645 keys << "dummy";
642 ++iii; 646 ++iii;
643 } 647 }
644 QMap<QString, uint>::ConstIterator it; 648 QMap<QString, uint>::ConstIterator it;
645 for ( it = mTypeMap.begin(); it != mTypeMap.end(); ++it) 649 for ( it = mTypeMap.begin(); it != mTypeMap.end(); ++it)
646 keys[( it.data() )] = it.key(); 650 keys[( it.data() )] = it.key();
647//US end 651//US end
648 652
649 for ( column = 0; column < mTable->numCols(); ++column ) { 653 for ( column = 0; column < mTable->numCols(); ++column ) {
650 654
651//US QComboTableItem *item = new QComboTableItem( mTable, mTypeMap.keys() ); 655//US QComboTableItem *item = new QComboTableItem( mTable, mTypeMap.keys() );
652 QComboTableItem *item = new QComboTableItem( mTable, keys ); 656 Q3ComboTableItem *item = new Q3ComboTableItem( mTable, keys );
653 mTable->setItem( 0, column, item ); 657 mTable->setItem( 0, column, item );
654 if ( column < mTypeStore.count() ) 658 if ( column < mTypeStore.count() )
655 item->setCurrentItem( mTypeStore[ column ] ); 659 item->setCurrentItem( mTypeStore[ column ] );
656 else 660 else
657 item->setCurrentItem( typeToPos( Undefined ) ); 661 item->setCurrentItem( typeToPos( Undefined ) );
658 662
659 mTable->adjustColumn( column ); 663 mTable->adjustColumn( column );
660 } 664 }
661} 665}
662 666
663void CSVImportDialog::clearTable() 667void CSVImportDialog::clearTable()
664{ 668{
665 for ( int row = 0; row < mTable->numRows(); ++row ) 669 for ( int row = 0; row < mTable->numRows(); ++row )
666 for ( int column = 0; column < mTable->numCols(); ++column ) 670 for ( int column = 0; column < mTable->numCols(); ++column )
667 mTable->clearCell( row, column ); 671 mTable->clearCell( row, column );
668} 672}
669 673
670void CSVImportDialog::fillComboBox() 674void CSVImportDialog::fillComboBox()
671{ 675{
672 mComboLine->clear(); 676 mComboLine->clear();
673 for ( int row = 1; row < mTable->numRows() + 1; ++row ) 677 for ( int row = 1; row < mTable->numRows() + 1; ++row )
674 mComboLine->insertItem( QString::number( row ), row - 1 ); 678 mComboLine->insertItem( QString::number( row ), row - 1 );
675} 679}
676 680
677void CSVImportDialog::setText( int row, int col, const QString& text ) 681void CSVImportDialog::setText( int row, int col, const QString& text )
678{ 682{
679 if ( row < 1 ) // skipped by the user 683 if ( row < 1 ) // skipped by the user
680 return; 684 return;
681 685
682 if ( mTable->numRows() < row ) { 686 if ( mTable->numRows() < row ) {
683 mTable->setNumRows( row + 5000 ); // We add 5000 at a time to limit recalculations 687 mTable->setNumRows( row + 5000 ); // We add 5000 at a time to limit recalculations
684 mAdjustRows = true; 688 mAdjustRows = true;
685 } 689 }
686 690
687 if ( mTable->numCols() < col ) 691 if ( mTable->numCols() < col )
688 mTable->setNumCols( col + 50 ); // We add 50 at a time to limit recalculation 692 mTable->setNumCols( col + 50 ); // We add 50 at a time to limit recalculation
689 693
690 mTable->setText( row - 1, col - 1, text ); 694 mTable->setText( row - 1, col - 1, text );
691} 695}
692 696
693/* 697/*
694 * Called after the first fillTable() when number of rows are unknown. 698 * Called after the first fillTable() when number of rows are unknown.
695 */ 699 */
696void CSVImportDialog::adjustRows( int rows ) 700void CSVImportDialog::adjustRows( int rows )
697{ 701{
698 if ( mAdjustRows ) { 702 if ( mAdjustRows ) {
699 mTable->setNumRows( rows ); 703 mTable->setNumRows( rows );
700 mAdjustRows = false; 704 mAdjustRows = false;
701 } 705 }
702} 706}
703 707
704void CSVImportDialog::returnPressed() 708void CSVImportDialog::returnPressed()
705{ 709{
706 if ( mDelimiterBox->id( mDelimiterBox->selected() ) != 4 ) 710 if ( mDelimiterBox->id( mDelimiterBox->selected() ) != 4 )
707 return; 711 return;
708 712
709 mDelimiter = mDelimiterEdit->text(); 713 mDelimiter = mDelimiterEdit->text();
710 fillTable(); 714 fillTable();
711} 715}
712 716
713void CSVImportDialog::textChanged ( const QString& ) 717void CSVImportDialog::textChanged ( const QString& )
714{ 718{
715 mRadioOther->setChecked ( true ); 719 mRadioOther->setChecked ( true );
716 delimiterClicked( 4 ); // other 720 delimiterClicked( 4 ); // other
717} 721}
718void CSVImportDialog::codecChanged ( const QString& ) 722void CSVImportDialog::codecChanged ( const QString& )
719{ 723{
720 fillTable(); 724 fillTable();
721} 725}
722 726
723void CSVImportDialog::delimiterClicked( int id ) 727void CSVImportDialog::delimiterClicked( int id )
724{ 728{
725 switch ( id ) { 729 switch ( id ) {
726 case 0: // comma 730 case 0: // comma
727 mDelimiter = ","; 731 mDelimiter = ",";
728 break; 732 break;
729 case 4: // other 733 case 4: // other
730 mDelimiter = mDelimiterEdit->text(); 734 mDelimiter = mDelimiterEdit->text();
731 break; 735 break;
732 case 2: // tab 736 case 2: // tab
733 mDelimiter = "\t"; 737 mDelimiter = "\t";
734 break; 738 break;
735 case 3: // space 739 case 3: // space
736 mDelimiter = " "; 740 mDelimiter = " ";
737 break; 741 break;
738 case 1: // semicolon 742 case 1: // semicolon
739 mDelimiter = ";"; 743 mDelimiter = ";";
740 break; 744 break;
741 } 745 }
742 746
743 fillTable(); 747 fillTable();
744} 748}
745 749
746void CSVImportDialog::textquoteSelected( const QString& mark ) 750void CSVImportDialog::textquoteSelected( const QString& mark )
747{ 751{
748 if ( mComboQuote->currentItem() == 2 ) 752 if ( mComboQuote->currentItem() == 2 )
749 mTextQuote = 0; 753 mTextQuote = 0;
750 else 754 else
751 mTextQuote = mark[ 0 ]; 755 mTextQuote = mark[ 0 ];
752 756
753 fillTable(); 757 fillTable();
754} 758}
755 759
756void CSVImportDialog::lineSelected( const QString& line ) 760void CSVImportDialog::lineSelected( const QString& line )
757{ 761{
758 mStartLine = line.toInt() - 1; 762 mStartLine = line.toInt() - 1;
759 fillTable(); 763 fillTable();
760} 764}
761 765
762void CSVImportDialog::slotOk() 766void CSVImportDialog::slotOk()
763{ 767{
764 bool assigned = false; 768 bool assigned = false;
765 769
766 for ( int column = 0; column < mTable->numCols(); ++column ) { 770 for ( int column = 0; column < mTable->numCols(); ++column ) {
767 QComboTableItem *item = static_cast<QComboTableItem*>( mTable->item( 0, 771 Q3ComboTableItem *item = static_cast<Q3ComboTableItem*>( mTable->item( 0,
768 column ) ); 772 column ) );
769 if ( item && posToType( item->currentItem() ) != Undefined ) 773 if ( item && posToType( item->currentItem() ) != Undefined )
770 assigned = true; 774 assigned = true;
771 } 775 }
772 776
773 if ( assigned ) 777 if ( assigned )
774 KDialogBase::slotOk(); 778 KDialogBase::slotOk();
775 else 779 else
776 KMessageBox::sorry( this, i18n( "You have to assign at least one column." ) ); 780 KMessageBox::sorry( this, i18n( "You have to assign at least one column." ) );
777} 781}
778 782
779void CSVImportDialog::applyTemplate() 783void CSVImportDialog::applyTemplate()
780{ 784{
781 QMap<uint,int> columnMap; 785 QMap<uint,int> columnMap;
782 QMap<QString, QString> fileMap; 786 QMap<QString, QString> fileMap;
783 QStringList templates; 787 QStringList templates;
784 788
785 // load all template files 789 // load all template files
786/*US QStringList list = KGlobal::dirs()->findAllResources( "data" , QString( kapp->name() ) + 790/*US QStringList list = KGlobal::dirs()->findAllResources( "data" , QString( kapp->name() ) +
787 "/csv-templates/*.desktop", true, true ); 791 "/csv-templates/*.desktop", true, true );
788*/ 792*/
789 QStringList list = KGlobal::dirs()->findAllResources( "data" , KGlobal::getAppName() + 793 QStringList list = KGlobal::dirs()->findAllResources( "data" , KGlobal::getAppName() +
790 "/csv-templates/*.desktop", true, true ); 794 "/csv-templates/*.desktop", true, true );
791 795
792 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 796 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
793 { 797 {
794 798
795//US KSimpleConfig config( *it, true ); 799//US KSimpleConfig config( *it, true );
796 KConfig config( *it ); 800 KConfig config( *it );
797 801
798 if ( !config.hasGroup( "csv column map" ) ) 802 if ( !config.hasGroup( "csv column map" ) )
799 continue; 803 continue;
800 804
801 config.setGroup( "Misc" ); 805 config.setGroup( "Misc" );
802 templates.append( config.readEntry( "Name" ) ); 806 templates.append( config.readEntry( "Name" ) );
803 fileMap.insert( config.readEntry( "Name" ), *it ); 807 fileMap.insert( config.readEntry( "Name" ), *it );
804 } 808 }
805 809
806 // let the user chose, what to take 810 // let the user chose, what to take
807 bool ok = false; 811 bool ok = false;
808 QString tmp; 812 QString tmp;
809 tmp = QInputDialog::getItem( i18n( "Template Selection" ), 813 tmp = QInputDialog::getItem( i18n( "Template Selection" ),
810 i18n( "Please select a template\nthat matches the CSV file." ), 814 i18n( "Please select a template\nthat matches the CSV file." ),
811 templates, 0, false, &ok, this ); 815 templates, 0, false, &ok, this );
812 816
813 if ( !ok ) 817 if ( !ok )
814 return; 818 return;
815 819
816//US KSimpleConfig config( fileMap[ tmp ], true ); 820//US KSimpleConfig config( fileMap[ tmp ], true );
817 KConfig config( fileMap[ tmp ] ); 821 KConfig config( fileMap[ tmp ] );
818 config.setGroup( "General" ); 822 config.setGroup( "General" );
819//US uint numColumns = config.readUnsignedNumEntry( "Columns" ); 823//US uint numColumns = config.readUnsignedNumEntry( "Columns" );
820 uint numColumns = (uint)config.readNumEntry( "Columns" ); 824 uint numColumns = (uint)config.readNumEntry( "Columns" );
821 825
822 mDelimiterEdit->setText( config.readEntry( "DelimiterOther" ) ); 826 mDelimiterEdit->setText( config.readEntry( "DelimiterOther" ) );
823 mDelimiterBox->setButton( config.readNumEntry( "DelimiterType" ) ); 827 mDelimiterBox->setButton( config.readNumEntry( "DelimiterType" ) );
824 delimiterClicked( config.readNumEntry( "DelimiterType" ) ); 828 delimiterClicked( config.readNumEntry( "DelimiterType" ) );
825 int quoteType = config.readNumEntry( "QuoteType" ); 829 int quoteType = config.readNumEntry( "QuoteType" );
826 mComboQuote->setCurrentItem( quoteType ); 830 mComboQuote->setCurrentItem( quoteType );
827 textquoteSelected( mComboQuote->currentText() ); 831 textquoteSelected( mComboQuote->currentText() );
828 832
829 // create the column map 833 // create the column map
830 config.setGroup( "csv column map" ); 834 config.setGroup( "csv column map" );
831 for ( uint i = 0; i < numColumns; ++i ) { 835 for ( uint i = 0; i < numColumns; ++i ) {
832 int col = config.readNumEntry( QString::number( i ) ); 836 int col = config.readNumEntry( QString::number( i ) );
833 columnMap.insert( i, col ); 837 columnMap.insert( i, col );
834 } 838 }
835 839
836 // apply the column map 840 // apply the column map
837 for ( uint column = 0; column < columnMap.count(); ++column ) { 841 for ( uint column = 0; column < columnMap.count(); ++column ) {
838 int type = columnMap[ column ]; 842 int type = columnMap[ column ];
839 QComboTableItem *item = static_cast<QComboTableItem*>( mTable->item( 0, 843 Q3ComboTableItem *item = static_cast<Q3ComboTableItem*>( mTable->item( 0,
840 column ) ); 844 column ) );
841 if ( item ) 845 if ( item )
842 item->setCurrentItem( typeToPos( type ) ); 846 item->setCurrentItem( typeToPos( type ) );
843 } 847 }
844} 848}
845 849
846void CSVImportDialog::saveTemplate() 850void CSVImportDialog::saveTemplate()
847{ 851{
848/*US 852/*US
849 QString fileName = KFileDialog::getSaveFileName( 853 QString fileName = KFileDialog::getSaveFileName(
850 locateLocal( "data", QString( kapp->name() ) + "/csv-templates/" ), 854 locateLocal( "data", QString( kapp->name() ) + "/csv-templates/" ),
851 "*.desktop", this ); 855 "*.desktop", this );
852*/ 856*/
853 QString fileName = KFileDialog::getSaveFileName( 857 QString fileName = KFileDialog::getSaveFileName(
854 locateLocal( "data", KGlobal::getAppName() + "/csv-templates/" )+ 858 locateLocal( "data", KGlobal::getAppName() + "/csv-templates/" )+
855 "*.desktop",i18n("Save file name") , this ); 859 "*.desktop",i18n("Save file name") , this );
856 860
857 if ( fileName.isEmpty() ) 861 if ( fileName.isEmpty() )
858 return; 862 return;
859 863
860 if ( !fileName.contains( ".desktop" ) ) 864 if ( !fileName.contains( ".desktop" ) )
861 fileName += ".desktop"; 865 fileName += ".desktop";
862 866
863 QString name = QInputDialog::getText( i18n( "Template name" ), i18n( "Please enter a name for the template" ) ); 867 QString name = QInputDialog::getText( i18n( "Template name" ), i18n( "Please enter a name for the template" ) );
864 868
865 if ( name.isEmpty() ) 869 if ( name.isEmpty() )
866 return; 870 return;
867 871
868 KConfig config( fileName ); 872 KConfig config( fileName );
869 config.setGroup( "General" ); 873 config.setGroup( "General" );
870 config.writeEntry( "Columns", mTable->numCols() ); 874 config.writeEntry( "Columns", mTable->numCols() );
871 config.writeEntry( "DelimiterType", mDelimiterBox->id( mDelimiterBox->selected() ) ); 875 config.writeEntry( "DelimiterType", mDelimiterBox->id( mDelimiterBox->selected() ) );
872 config.writeEntry( "DelimiterOther", mDelimiterEdit->text() ); 876 config.writeEntry( "DelimiterOther", mDelimiterEdit->text() );
873 config.writeEntry( "QuoteType", mComboQuote->currentItem() ); 877 config.writeEntry( "QuoteType", mComboQuote->currentItem() );
874 878
875 config.setGroup( "Misc" ); 879 config.setGroup( "Misc" );
876 config.writeEntry( "Name", name ); 880 config.writeEntry( "Name", name );
877 881
878 config.setGroup( "csv column map" ); 882 config.setGroup( "csv column map" );
879 883
880 for ( uint column = 0; column < mTable->numCols(); ++column ) { 884 for ( uint column = 0; column < mTable->numCols(); ++column ) {
881 QComboTableItem *item = static_cast<QComboTableItem*>( mTable->item( 0, 885 Q3ComboTableItem *item = static_cast<Q3ComboTableItem*>( mTable->item( 0,
882 column ) ); 886 column ) );
883 if ( item ) 887 if ( item )
884 config.writeEntry( QString::number( column ), posToType( 888 config.writeEntry( QString::number( column ), posToType(
885 item->currentItem() ) ); 889 item->currentItem() ) );
886 else 890 else
887 config.writeEntry( QString::number( column ), 0 ); 891 config.writeEntry( QString::number( column ), 0 );
888 } 892 }
889 893
890 config.sync(); 894 config.sync();
891} 895}
892 896
893QString CSVImportDialog::getText( int row, int col ) 897QString CSVImportDialog::getText( int row, int col )
894{ 898{
895 return mTable->text( row, col ); 899 return mTable->text( row, col );
896} 900}
897 901
898uint CSVImportDialog::posToType( int pos ) const 902uint CSVImportDialog::posToType( int pos ) const
899{ 903{
900 return pos; 904 return pos;
901#if 0 905#if 0
902 uint counter = 0; 906 uint counter = 0;
903 QMap<QString, uint>::ConstIterator it; 907 QMap<QString, uint>::ConstIterator it;
904 for ( it = mTypeMap.begin(); it != mTypeMap.end(); ++it, ++counter ) 908 for ( it = mTypeMap.begin(); it != mTypeMap.end(); ++it, ++counter )
905 if ( counter == (uint)pos ) 909 if ( counter == (uint)pos )
906 return it.data(); 910 return it.data();
907 911
908 return 0; 912 return 0;
909#endif 913#endif
910} 914}
911 915
912int CSVImportDialog::typeToPos( uint type ) const 916int CSVImportDialog::typeToPos( uint type ) const
913{ 917{
914 return type; 918 return type;
915#if 0 919#if 0
916 uint counter = 0; 920 uint counter = 0;
917 QMap<QString, uint>::ConstIterator it; 921 QMap<QString, uint>::ConstIterator it;
918 for ( it = mTypeMap.begin(); it != mTypeMap.end(); ++it, ++counter ) 922 for ( it = mTypeMap.begin(); it != mTypeMap.end(); ++it, ++counter )
919 if ( it.data() == type ) 923 if ( it.data() == type )
920 return counter; 924 return counter;
921 925
922 return -1; 926 return -1;
923#endif 927#endif
924} 928}
925 929
926void CSVImportDialog::ignoreDuplicatesChanged( int ) 930void CSVImportDialog::ignoreDuplicatesChanged( int )
927{ 931{
928 fillTable(); 932 fillTable();
929} 933}
930 934
931void CSVImportDialog::setFile( const QString &fileName ) 935void CSVImportDialog::setFile( const QString &fileName )
932{ 936{
933 if ( fileName.isEmpty() ) 937 if ( fileName.isEmpty() )
934 return; 938 return;
935 939
936 QFile file( fileName ); 940 QFile file( fileName );
937 if ( !file.open( IO_ReadOnly ) ) { 941 if ( !file.open( QIODevice::ReadOnly ) ) {
938 KMessageBox::sorry( this, i18n( "Cannot open input file!" ) ); 942 KMessageBox::sorry( this, i18n( "Cannot open input file!" ) );
939 file.close(); 943 file.close();
940 return; 944 return;
941 } 945 }
942 946
943 mFileArray = file.readAll(); 947 mFileArray = file.readAll();
944 file.close(); 948 file.close();
945 949
946 mClearTypeStore = true; 950 mClearTypeStore = true;
947 clearTable(); 951 clearTable();
948 mTable->setNumCols( 0 ); 952 mTable->setNumCols( 0 );
949 mTable->setNumRows( 0 ); 953 mTable->setNumRows( 0 );
950 fillTable(); 954 fillTable();
951 mClearTypeStore = false; 955 mClearTypeStore = false;
952 956
953 fillComboBox(); 957 fillComboBox();
954} 958}
955 959
956void CSVImportDialog::urlChanged( const QString &file ) 960void CSVImportDialog::urlChanged( const QString &file )
957{ 961{
958 bool state = !file.isEmpty(); 962 bool state = !file.isEmpty();
959 963
960 enableButtonOK( state ); 964 enableButtonOK( state );
961 965
962 findButton( User1 )->setEnabled( state ); 966 findButton( User1 )->setEnabled( state );
963 findButton( User2 )->setEnabled( state ); 967 findButton( User2 )->setEnabled( state );
964 968
965} 969}
966 970
967#ifndef KAB_EMBEDDED 971#ifndef KAB_EMBEDDED_
968#include <csvimportdialog.moc> 972#include <moc_csvimportdialog.cpp>
969#endif //KAB_EMBEDDED 973#endif //KAB_EMBEDDED
diff --git a/kaddressbook/xxport/csvimportdialog.h b/kaddressbook/xxport/csvimportdialog.h
index 2661420..520f3fa 100644
--- a/kaddressbook/xxport/csvimportdialog.h
+++ b/kaddressbook/xxport/csvimportdialog.h
@@ -1,126 +1,126 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (C) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (C) 2003 Tobias Koenig <tokoe@kde.org>
4 based on the code of KSpread's CSV Import Dialog 4 based on the code of KSpread's CSV Import Dialog
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#ifndef CSV_IMPORT_DLG_H 29#ifndef CSV_IMPORT_DLG_H
30#define CSV_IMPORT_DLG_H 30#define CSV_IMPORT_DLG_H
31 31
32#include <kabc/addressbook.h> 32#include <kabc/addressbook.h>
33#include <kabc/addresseelist.h> 33#include <kabc/addresseelist.h>
34#include <kdialogbase.h> 34#include <kdialogbase.h>
35 35
36#include <qvaluelist.h> 36#include <q3valuelist.h>
37 37
38class KURLRequester; 38class KURLRequester;
39 39
40class QButtonGroup; 40class Q3ButtonGroup;
41class QComboBox; 41class QComboBox;
42class QCheckBox; 42class QCheckBox;
43class QLineEdit; 43class QLineEdit;
44class QPushButton; 44class QPushButton;
45class QRadioButton; 45class QRadioButton;
46class QTable; 46class Q3Table;
47 47
48class CSVImportDialog : public KDialogBase 48class CSVImportDialog : public KDialogBase
49{ 49{
50 Q_OBJECT 50 Q_OBJECT
51 51
52 public: 52 public:
53 CSVImportDialog( KABC::AddressBook *ab, QWidget *parent, 53 CSVImportDialog( KABC::AddressBook *ab, QWidget *parent,
54 const char *name = 0 ); 54 const char *name = 0 );
55 ~CSVImportDialog(); 55 ~CSVImportDialog();
56 56
57 KABC::AddresseeList contacts() const; 57 KABC::AddresseeList contacts() const;
58 58
59 protected slots: 59 protected slots:
60 virtual void slotOk(); 60 virtual void slotOk();
61 61
62 private slots: 62 private slots:
63 void returnPressed(); 63 void returnPressed();
64 void delimiterClicked( int id ); 64 void delimiterClicked( int id );
65 void lineSelected( const QString& line ); 65 void lineSelected( const QString& line );
66 void textquoteSelected( const QString& mark ); 66 void textquoteSelected( const QString& mark );
67 void textChanged ( const QString & ); 67 void textChanged ( const QString & );
68 void ignoreDuplicatesChanged( int ); 68 void ignoreDuplicatesChanged( int );
69 void setFile( const QString& ); 69 void setFile( const QString& );
70 void urlChanged( const QString& ); 70 void urlChanged( const QString& );
71 void codecChanged ( const QString& ); 71 void codecChanged ( const QString& );
72 72
73 void applyTemplate(); 73 void applyTemplate();
74 void saveTemplate(); 74 void saveTemplate();
75 75
76 private: 76 private:
77 enum { Undefined, FormattedName, FamilyName, GivenName, AdditionalName, 77 enum { Undefined, FormattedName, FamilyName, GivenName, AdditionalName,
78 Prefix, Suffix, NickName, Birthday, 78 Prefix, Suffix, NickName, Birthday,
79 HomeAddressStreet, HomeAddressLocality, HomeAddressRegion, 79 HomeAddressStreet, HomeAddressLocality, HomeAddressRegion,
80 HomeAddressPostalCode, HomeAddressCountry, HomeAddressLabel, 80 HomeAddressPostalCode, HomeAddressCountry, HomeAddressLabel,
81 BusinessAddressStreet, BusinessAddressLocality, BusinessAddressRegion, 81 BusinessAddressStreet, BusinessAddressLocality, BusinessAddressRegion,
82 BusinessAddressPostalCode, BusinessAddressCountry, 82 BusinessAddressPostalCode, BusinessAddressCountry,
83 BusinessAddressLabel, 83 BusinessAddressLabel,
84 HomePhone, BusinessPhone, MobilePhone, HomeFax, BusinessFax, MobileWorkPhone, 84 HomePhone, BusinessPhone, MobilePhone, HomeFax, BusinessFax, MobileWorkPhone,
85 Isdn, Pager, Email, Mailer, Title, Role, Organization, Note, URL, Categories 85 Isdn, Pager, Email, Mailer, Title, Role, Organization, Note, URL, Categories
86 }; 86 };
87 87
88 QTable* mTable; 88 Q3Table* mTable;
89 QButtonGroup* mDelimiterBox; 89 Q3ButtonGroup* mDelimiterBox;
90 QRadioButton* mRadioComma; 90 QRadioButton* mRadioComma;
91 QRadioButton* mRadioSemicolon; 91 QRadioButton* mRadioSemicolon;
92 QRadioButton* mRadioTab; 92 QRadioButton* mRadioTab;
93 QRadioButton* mRadioSpace; 93 QRadioButton* mRadioSpace;
94 QRadioButton* mRadioOther; 94 QRadioButton* mRadioOther;
95 QLineEdit* mDelimiterEdit; 95 QLineEdit* mDelimiterEdit;
96 QComboBox* mComboLine; 96 QComboBox* mComboLine;
97 QComboBox* mComboQuote; 97 QComboBox* mComboQuote;
98 QComboBox* mComboCodec; 98 QComboBox* mComboCodec;
99 QCheckBox* mIgnoreDuplicates; 99 QCheckBox* mIgnoreDuplicates;
100 KURLRequester* mUrlRequester; 100 KURLRequester* mUrlRequester;
101 101
102 void initGUI(); 102 void initGUI();
103 void fillTable(); 103 void fillTable();
104 void clearTable(); 104 void clearTable();
105 void fillComboBox(); 105 void fillComboBox();
106 void setText( int row, int col, const QString& text ); 106 void setText( int row, int col, const QString& text );
107 void adjustRows( int rows ); 107 void adjustRows( int rows );
108 QString getText( int row, int col ); 108 QString getText( int row, int col );
109 uint posToType( int pos ) const; 109 uint posToType( int pos ) const;
110 int typeToPos( uint type ) const; 110 int typeToPos( uint type ) const;
111 111
112 bool mAdjustRows; 112 bool mAdjustRows;
113 int mStartLine; 113 int mStartLine;
114 QChar mTextQuote; 114 QChar mTextQuote;
115 QString mDelimiter; 115 QString mDelimiter;
116 QString mData; 116 QString mData;
117 QByteArray mFileArray; 117 QByteArray mFileArray;
118 QMap<QString, uint> mTypeMap; 118 QMap<QString, uint> mTypeMap;
119 KABC::AddressBook *mAddressBook; 119 KABC::AddressBook *mAddressBook;
120 int mCustomCounter; 120 int mCustomCounter;
121 bool mClearTypeStore; 121 bool mClearTypeStore;
122 QValueList<int> mTypeStore; 122 Q3ValueList<int> mTypeStore;
123 123
124}; 124};
125 125
126#endif 126#endif
diff --git a/kaddressbook/xxport/kde2_xxport.cpp b/kaddressbook/xxport/kde2_xxport.cpp
index 03efc1b..72d3fc2 100644
--- a/kaddressbook/xxport/kde2_xxport.cpp
+++ b/kaddressbook/xxport/kde2_xxport.cpp
@@ -1,121 +1,121 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 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/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <qfile.h> 31#include <qfile.h>
32 32
33#include <kdebug.h> 33#include <kdebug.h>
34#include <kfiledialog.h> 34#include <kfiledialog.h>
35#ifndef KAB_EMBEDDED 35#ifndef KAB_EMBEDDED
36#include <kio/netaccess.h> 36#include <kio/netaccess.h>
37#endif //KAB_EMBEDDED 37#endif //KAB_EMBEDDED
38#include <klocale.h> 38#include <klocale.h>
39#include <kmessagebox.h> 39#include <kmessagebox.h>
40#include <kprocess.h> 40#include <kprocess.h>
41#include <kstandarddirs.h> 41#include <kstandarddirs.h>
42#include <ktempfile.h> 42#include <ktempfile.h>
43#include <kurl.h> 43#include <kurl.h>
44 44
45#include "xxportmanager.h" 45#include "xxportmanager.h"
46 46
47#include "kde2_xxport.h" 47#include "kde2_xxport.h"
48 48
49#ifndef KAB_EMBEDDED 49#ifndef KAB_EMBEDDED
50 50
51class KDE2XXPortFactory : public XXPortFactory 51class KDE2XXPortFactory : public XXPortFactory
52{ 52{
53 public: 53 public:
54 XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) 54 XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name )
55 { 55 {
56 return new KDE2XXPort( ab, parent, name ); 56 return new KDE2XXPort( ab, parent, name );
57 } 57 }
58}; 58};
59 59
60#endif //KAB_EMBEDDED 60#endif //KAB_EMBEDDED
61 61
62 62
63extern "C" 63extern "C"
64{ 64{
65#ifndef KAB_EMBEDDED 65#ifndef KAB_EMBEDDED
66 void *init_libkaddrbk_kde2_xxport() 66 void *init_libkaddrbk_kde2_xxport()
67#else //KAB_EMBEDDED 67#else //KAB_EMBEDDED
68 void *init_microkaddrbk_kde2_xxport() 68 void *init_microkaddrbk_kde2_xxport()
69#endif //KAB_EMBEDDED 69#endif //KAB_EMBEDDED
70 { 70 {
71 return ( new KDE2XXPortFactory() ); 71 return ( new KDE2XXPortFactory() );
72 } 72 }
73} 73}
74 74
75 75
76KDE2XXPort::KDE2XXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) 76KDE2XXPort::KDE2XXPort( KABC::AddressBook *ab, QWidget *parent, const char *name )
77 : XXPortObject( ab, parent, name ) 77 : XXPortObject( ab, parent, name )
78{ 78{
79 createImportAction( i18n( "Import KDE 2 Addressbook..." ) ); 79 createImportAction( i18n( "Import KDE 2 Addressbook..." ) );
80} 80}
81 81
82KABC::AddresseeList KDE2XXPort::importContacts( const QString& ) const 82KABC::AddresseeList KDE2XXPort::importContacts( const QString& ) const
83{ 83{
84 QString fileName = locateLocal( "data", "kabc/std.vcf" ); 84 QString fileName = locateLocal( "data", "kabc/std.vcf" );
85 if ( !QFile::exists( fileName ) ) { 85 if ( !QFile::exists( fileName ) ) {
86 KMessageBox::sorry( parentWidget(), i18n( "<qt>Couldn't find a KDE 2 address book <b>%1</b>.</qt>" ).arg( fileName ) ); 86 KMessageBox::sorry( parentWidget(), i18n( "<qt>Couldn't find a KDE 2 address book <b>%1</b>.</qt>" ).arg( fileName ) );
87 return KABC::AddresseeList(); 87 return KABC::AddresseeList();
88 } 88 }
89 89
90#ifndef KAB_EMBEDDED 90#ifndef KAB_EMBEDDED
91 int result = KMessageBox::questionYesNoCancel( parentWidget(), 91 int result = KMessageBox::questionYesNoCancel( parentWidget(),
92 i18n( "Override previously imported entries?" ), 92 i18n( "Override previously imported entries?" ),
93 i18n( "Import KDE 2 Addressbook" ) ); 93 i18n( "Import KDE 2 Addressbook" ) );
94#else //KAB_EMBEDDED 94#else //KAB_EMBEDDED
95 int result = KMessageBox::warningYesNoCancel( parentWidget(), 95 int result = KMessageBox::warningYesNoCancel( parentWidget(),
96 i18n( "Override previously imported entries?" ), 96 i18n( "Override previously imported entries?" ),
97 i18n( "Import KDE 2 Addressbook" ) ); 97 i18n( "Import KDE 2 Addressbook" ) );
98#endif //KAB_EMBEDDED 98#endif //KAB_EMBEDDED
99 99
100 if ( !result ) return KABC::AddresseeList(); 100 if ( !result ) return KABC::AddresseeList();
101 101
102 KProcess proc; 102 KProcess proc;
103 103
104 if ( result == KMessageBox::Yes ) { 104 if ( result == KMessageBox::Yes ) {
105 proc << "kab2kabc"; 105 proc << "kab2kabc";
106 proc << "--override"; 106 proc << "--override";
107 } else if ( result == KMessageBox::No ) 107 } else if ( result == KMessageBox::No )
108 proc << "kab2kabc"; 108 proc << "kab2kabc";
109 else 109 else
110 kdDebug(5720) << "KAddressBook::importKDE2(): Unknow return value." << endl; 110 kdDebug(5720) << "KAddressBook::importKDE2(): Unknow return value." << endl;
111 111
112 proc.start( KProcess::Block ); 112 proc.start( KProcess::Block );
113 113
114 addressBook()->load(); 114 addressBook()->load();
115 115
116 return KABC::AddresseeList(); 116 return KABC::AddresseeList();
117} 117}
118 118
119#ifndef KAB_EMBEDDED 119#ifndef KAB_EMBEDDED_
120#include "kde2_xxport.moc" 120#include "moc_kde2_xxport.cpp"
121#endif //KAB_EMBEDDED 121#endif //KAB_EMBEDDED
diff --git a/kaddressbook/xxport/vcard_xxport.cpp b/kaddressbook/xxport/vcard_xxport.cpp
index 9a8fa68..64b9071 100644
--- a/kaddressbook/xxport/vcard_xxport.cpp
+++ b/kaddressbook/xxport/vcard_xxport.cpp
@@ -1,272 +1,274 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 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/* 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#include <qfile.h> 31#include <qfile.h>
32#include <qtextstream.h> 32#include <q3textstream.h>
33#include <qfileinfo.h> 33#include <qfileinfo.h>
34//Added by qt3to4:
35#include <Q3CString>
34 36
35#include <kabc/vcardconverter.h> 37#include <kabc/vcardconverter.h>
36#include <kabc/vcardparser/vcardtool.h> 38#include <kabc/vcardparser/vcardtool.h>
37#include <kfiledialog.h> 39#include <kfiledialog.h>
38#ifndef KAB_EMBEDDED 40#ifndef KAB_EMBEDDED
39#include <kio/netaccess.h> 41#include <kio/netaccess.h>
40#endif //KAB_EMBEDDED 42#endif //KAB_EMBEDDED
41 43
42#include <klocale.h> 44#include <klocale.h>
43#include <kmessagebox.h> 45#include <kmessagebox.h>
44#include <ktempfile.h> 46#include <ktempfile.h>
45#include <kurl.h> 47#include <kurl.h>
46 48
47#include "xxportmanager.h" 49#include "xxportmanager.h"
48 50
49#include "vcard_xxport.h" 51#include "vcard_xxport.h"
50 52
51#ifndef KAB_EMBEDDED 53#ifndef KAB_EMBEDDED
52 54
53class VCardXXPortFactory : public XXPortFactory 55class VCardXXPortFactory : public XXPortFactory
54{ 56{
55public: 57public:
56 XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) 58 XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name )
57 { 59 {
58 return new VCardXXPort( ab, parent, name ); 60 return new VCardXXPort( ab, parent, name );
59 } 61 }
60}; 62};
61#endif //KAB_EMBEDDED 63#endif //KAB_EMBEDDED
62 64
63 65
64extern "C" 66extern "C"
65{ 67{
66#ifndef KAB_EMBEDDED 68#ifndef KAB_EMBEDDED
67 void *init_libkaddrbk_vcard_xxport() 69 void *init_libkaddrbk_vcard_xxport()
68#else //KAB_EMBEDDED 70#else //KAB_EMBEDDED
69 void *init_microkaddrbk_vcard_xxport() 71 void *init_microkaddrbk_vcard_xxport()
70#endif //KAB_EMBEDDED 72#endif //KAB_EMBEDDED
71 { 73 {
72 return ( new VCardXXPortFactory() ); 74 return ( new VCardXXPortFactory() );
73 } 75 }
74} 76}
75 77
76 78
77VCardXXPort::VCardXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) 79VCardXXPort::VCardXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name )
78 : XXPortObject( ab, parent, name ) 80 : XXPortObject( ab, parent, name )
79{ 81{
80 createImportAction( i18n( "Import vCard..." ) ); 82 createImportAction( i18n( "Import vCard..." ) );
81 //US KABC::VCardConverter does not support the export of 2.1 addressbooks. 83 //US KABC::VCardConverter does not support the export of 2.1 addressbooks.
82 //US createExportAction( i18n( "Export vCard 2.1..." ), "v21" ); 84 //US createExportAction( i18n( "Export vCard 2.1..." ), "v21" );
83 createExportAction( i18n( "Export vCard 3.0..." ), "v30" ); 85 createExportAction( i18n( "Export vCard 3.0..." ), "v30" );
84} 86}
85 87
86bool VCardXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data ) 88bool VCardXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data )
87{ 89{
88 QString name; 90 QString name;
89 91
90 if ( list.count() == 1 ) 92 if ( list.count() == 1 )
91 name = list[ 0 ].givenName() + "_" + list[ 0 ].familyName() + ".vcf"; 93 name = list[ 0 ].givenName() + "_" + list[ 0 ].familyName() + ".vcf";
92 else 94 else
93 name = "addressbook.vcf"; 95 name = "addressbook.vcf";
94 96
95#ifndef KAB_EMBEDDED 97#ifndef KAB_EMBEDDED
96 QString fileName = KFileDialog::getSaveFileName( name ); 98 QString fileName = KFileDialog::getSaveFileName( name );
97#else //KAB_EMBEDDED 99#else //KAB_EMBEDDED
98 QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); 100 QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() );
99#endif //KAB_EMBEDDED 101#endif //KAB_EMBEDDED
100 102
101 if ( fileName.isEmpty() ) 103 if ( fileName.isEmpty() )
102 return false; 104 return false;
103 105
104 QFile outFile( fileName ); 106 QFile outFile( fileName );
105 if ( !outFile.open( IO_WriteOnly ) ) { 107 if ( !outFile.open( QIODevice::WriteOnly ) ) {
106 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); 108 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
107 KMessageBox::error( parentWidget(), text.arg( fileName ) ); 109 KMessageBox::error( parentWidget(), text.arg( fileName ) );
108 return false; 110 return false;
109 } 111 }
110 112
111 QTextStream t( &outFile ); 113 Q3TextStream t( &outFile );
112 t.setEncoding( QTextStream::UnicodeUTF8 ); 114 t.setEncoding( Q3TextStream::UnicodeUTF8 );
113 115
114 KABC::Addressee::List::ConstIterator it; 116 KABC::Addressee::List::ConstIterator it;
115 for ( it = list.begin(); it != list.end(); ++it ) { 117 for ( it = list.begin(); it != list.end(); ++it ) {
116 KABC::VCardConverter converter; 118 KABC::VCardConverter converter;
117 QString vcard; 119 QString vcard;
118 120
119 KABC::VCardConverter::Version version; 121 KABC::VCardConverter::Version version;
120 if ( data == "v21" ) 122 if ( data == "v21" )
121 version = KABC::VCardConverter::v2_1; 123 version = KABC::VCardConverter::v2_1;
122 else 124 else
123 version = KABC::VCardConverter::v3_0; 125 version = KABC::VCardConverter::v3_0;
124 126
125 converter.addresseeToVCard( *it, vcard, version ); 127 converter.addresseeToVCard( *it, vcard, version );
126 t << vcard << "\r\n\r\n"; 128 t << vcard << "\r\n\r\n";
127 } 129 }
128 130
129 outFile.close(); 131 outFile.close();
130 132
131 return true; 133 return true;
132} 134}
133 135
134KABC::AddresseeList VCardXXPort::importContacts( const QString& ) const 136KABC::AddresseeList VCardXXPort::importContacts( const QString& ) const
135{ 137{
136 QString fileName; 138 QString fileName;
137 KABC::AddresseeList addrList; 139 KABC::AddresseeList addrList;
138 KURL url; 140 KURL url;
139 141
140#ifndef KAB_EMBEDDED 142#ifndef KAB_EMBEDDED
141 if ( !XXPortManager::importData.isEmpty() ) 143 if ( !XXPortManager::importData.isEmpty() )
142 addrList = parseVCard( XXPortManager::importData ); 144 addrList = parseVCard( XXPortManager::importData );
143 else { 145 else {
144 if ( XXPortManager::importURL.isEmpty() ) 146 if ( XXPortManager::importURL.isEmpty() )
145 { 147 {
146 url = KFileDialog::getLoadFileName( QString::null, i18n("Select vCard to Import"), parentWidget() ); 148 url = KFileDialog::getLoadFileName( QString::null, i18n("Select vCard to Import"), parentWidget() );
147 } 149 }
148 else 150 else
149 url = XXPortManager::importURL; 151 url = XXPortManager::importURL;
150 if ( url.isEmpty() ) 152 if ( url.isEmpty() )
151 return addrList; 153 return addrList;
152 QString caption( i18n( "vCard Import Failed" ) ); 154 QString caption( i18n( "vCard Import Failed" ) );
153 if ( KIO::NetAccess::download( url, fileName ) ) { 155 if ( KIO::NetAccess::download( url, fileName ) ) {
154 QFile file( fileName ); 156 QFile file( fileName );
155 157
156 file.open( IO_ReadOnly ); 158 file.open( QIODevice::ReadOnly );
157 QByteArray rawData = file.readAll(); 159 QByteArray rawData = file.readAll();
158 file.close(); 160 file.close();
159 161
160 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 162 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
161 addrList = parseVCard( data ); 163 addrList = parseVCard( data );
162 164
163 if ( !url.isLocalFile() ) 165 if ( !url.isLocalFile() )
164 KIO::NetAccess::removeTempFile( fileName ); 166 KIO::NetAccess::removeTempFile( fileName );
165 167
166 } else { 168 } else {
167 QString text = i18n( "<qt>Unable to access <b>%1</b>.</qt>" ); 169 QString text = i18n( "<qt>Unable to access <b>%1</b>.</qt>" );
168 KMessageBox::error( parentWidget(), text.arg( url.url() ), caption ); 170 KMessageBox::error( parentWidget(), text.arg( url.url() ), caption );
169 } 171 }
170 172
171 } 173 }
172 174
173 175
174#else //KAB_EMBEDDED 176#else //KAB_EMBEDDED
175 177
176 178
177 if ( !XXPortManager::importData.isEmpty() ) 179 if ( !XXPortManager::importData.isEmpty() )
178 addrList = parseVCard( XXPortManager::importData ); 180 addrList = parseVCard( XXPortManager::importData );
179 else { 181 else {
180 if ( XXPortManager::importURL.isEmpty() ) 182 if ( XXPortManager::importURL.isEmpty() )
181 { 183 {
182 fileName = KFileDialog::getOpenFileName( QString::null, i18n("Select vCard to Import"), parentWidget() ); 184 fileName = KFileDialog::getOpenFileName( QString::null, i18n("Select vCard to Import"), parentWidget() );
183 185
184 if ( fileName.isEmpty() ) 186 if ( fileName.isEmpty() )
185 return addrList; 187 return addrList;
186 QFileInfo fi ( fileName ); 188 QFileInfo fi ( fileName );
187 if ( !fi.isFile() ) 189 if ( !fi.isFile() )
188 return addrList; 190 return addrList;
189 } 191 }
190 else 192 else
191 { 193 {
192 //US url = XXPortManager::importURL; 194 //US url = XXPortManager::importURL;
193 qDebug("VCardXXPort::importContacts Urls at the moment not supported"); 195 qDebug("VCardXXPort::importContacts Urls at the moment not supported");
194 if ( url.isEmpty() ) 196 if ( url.isEmpty() )
195 return addrList; 197 return addrList;
196 198
197 } 199 }
198 QFile file( fileName ); 200 QFile file( fileName );
199 if ( file.open( IO_ReadOnly ) ) { 201 if ( file.open( QIODevice::ReadOnly ) ) {
200 QCString rawData ( file.readAll().data(),file.size()+1); 202 Q3CString rawData ( file.readAll().data(),file.size()+1);
201 file.close(); 203 file.close();
202 int start = 0; 204 int start = 0;
203#ifndef DESKTOP_VERSION 205#ifndef DESKTOP_VERSION
204 while ( start < rawData.size()-2 ) { 206 while ( start < rawData.size()-2 ) {
205 if ( rawData.at( start ) == '\r' ) 207 if ( rawData.at( start ) == '\r' )
206 if ( rawData.at( start+1 ) == '\n' ) 208 if ( rawData.at( start+1 ) == '\n' )
207 if ( rawData.at( start+2 ) == ' ' ) { 209 if ( rawData.at( start+2 ) == ' ' ) {
208 rawData.remove(start,3); 210 rawData.remove(start,3);
209 --start; 211 --start;
210 } 212 }
211 ++start; 213 ++start;
212 } 214 }
213#endif 215#endif
214 int ret = KMessageBox::warningYesNoCancel( 0, i18n("Select import format!\nDefault and standard is Utf8.\nLatin1 may be the right\nfor some West Europian languages."), i18n("Import Format"), i18n("Utf8"), i18n("Latin1") ); 216 int ret = KMessageBox::warningYesNoCancel( 0, i18n("Select import format!\nDefault and standard is Utf8.\nLatin1 may be the right\nfor some West Europian languages."), i18n("Import Format"), i18n("Utf8"), i18n("Latin1") );
215 if ( ret == KMessageBox::Cancel ) 217 if ( ret == KMessageBox::Cancel )
216 return addrList; 218 return addrList;
217 if ( ret == KMessageBox::Yes ) 219 if ( ret == KMessageBox::Yes )
218 addrList = parseVCard( QString::fromUtf8( rawData.data() ) ); 220 addrList = parseVCard( QString::fromUtf8( rawData.data() ) );
219 else 221 else
220 addrList = parseVCard( QString::fromLatin1( rawData.data() ) ); 222 addrList = parseVCard( QString::fromLatin1( rawData.data() ) );
221 } 223 }
222 224
223 } 225 }
224#endif //KAB_EMBEDDED 226#endif //KAB_EMBEDDED
225 227
226 return addrList; 228 return addrList;
227} 229}
228 230
229KABC::AddresseeList VCardXXPort::parseVCard( const QString &data ) const 231KABC::AddresseeList VCardXXPort::parseVCard( const QString &data ) const
230{ 232{
231 233
232 KABC::VCardTool tool; 234 KABC::VCardTool tool;
233 KABC::AddresseeList addrList; 235 KABC::AddresseeList addrList;
234 addrList = tool.parseVCards( data ); 236 addrList = tool.parseVCards( data );
235 // LR : I switched to the code, which is in current cvs HEAD 237 // LR : I switched to the code, which is in current cvs HEAD
236 /* 238 /*
237 uint numVCards = data.contains( "BEGIN:VCARD", false ); 239 uint numVCards = data.contains( "BEGIN:VCARD", false );
238 QStringList dataList = QStringList::split( "\r\n\r\n", data ); 240 QStringList dataList = QStringList::split( "\r\n\r\n", data );
239 241
240 for ( uint i = 0; i < numVCards && i < dataList.count(); ++i ) { 242 for ( uint i = 0; i < numVCards && i < dataList.count(); ++i ) {
241 KABC::Addressee addr; 243 KABC::Addressee addr;
242 bool ok = false; 244 bool ok = false;
243 245
244 if ( dataList[ i ].contains( "VERSION:3.0" ) ) 246 if ( dataList[ i ].contains( "VERSION:3.0" ) )
245 ok = converter.vCardToAddressee( dataList[ i ], addr, KABC::VCardConverter::v3_0 ); 247 ok = converter.vCardToAddressee( dataList[ i ], addr, KABC::VCardConverter::v3_0 );
246 else if ( dataList[ i ].contains( "VERSION:2.1" ) ) 248 else if ( dataList[ i ].contains( "VERSION:2.1" ) )
247 ok = converter.vCardToAddressee( dataList[ i ], addr, KABC::VCardConverter::v2_1 ); 249 ok = converter.vCardToAddressee( dataList[ i ], addr, KABC::VCardConverter::v2_1 );
248 else { 250 else {
249 KMessageBox::sorry( parentWidget(), i18n( "Not supported vCard version." ) ); 251 KMessageBox::sorry( parentWidget(), i18n( "Not supported vCard version." ) );
250 continue; 252 continue;
251 } 253 }
252 254
253 if ( !addr.isEmpty() && ok ) 255 if ( !addr.isEmpty() && ok )
254 addrList.append( addr ); 256 addrList.append( addr );
255 else { 257 else {
256 QString text = i18n( "The selected file does not include a valid vCard. " 258 QString text = i18n( "The selected file does not include a valid vCard. "
257 "Please check the file and try again." ); 259 "Please check the file and try again." );
258 KMessageBox::sorry( parentWidget(), text ); 260 KMessageBox::sorry( parentWidget(), text );
259 } 261 }
260 } 262 }
261 */ 263 */
262 if ( addrList.isEmpty() ) { 264 if ( addrList.isEmpty() ) {
263 QString text = i18n( "The selected file does not\ninclude a valid vCard.\nPlease check the file and try again.\n" ); 265 QString text = i18n( "The selected file does not\ninclude a valid vCard.\nPlease check the file and try again.\n" );
264 KMessageBox::sorry( parentWidget(), text ); 266 KMessageBox::sorry( parentWidget(), text );
265 } 267 }
266 return addrList; 268 return addrList;
267} 269}
268 270
269 271
270#ifndef KAB_EMBEDDED 272#ifndef KAB_EMBEDDED_
271#include "vcard_xxport.moc" 273#include "moc_vcard_xxport.cpp"
272#endif //KAB_EMBEDDED 274#endif //KAB_EMBEDDED
diff --git a/kaddressbook/xxportmanager.cpp b/kaddressbook/xxportmanager.cpp
index 405f7ec..95b240d 100644
--- a/kaddressbook/xxportmanager.cpp
+++ b/kaddressbook/xxportmanager.cpp
@@ -1,270 +1,269 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 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/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <qlayout.h> 31#include <qlayout.h>
32#include <qlist.h> 32#include <qlist.h>
33//Added by qt3to4:
34#include <Q3VBoxLayout>
33 35
34#include <kabc/addressbook.h> 36#include <kabc/addressbook.h>
35#include <kabc/resource.h> 37#include <kabc/resource.h>
36#include <kdebug.h> 38#include <kdebug.h>
37#include <kdialogbase.h> 39#include <kdialogbase.h>
38#include <klocale.h> 40#include <klocale.h>
39#include <kmessagebox.h> 41#include <kmessagebox.h>
40 42
41#ifndef KAB_EMBEDDED 43#ifndef KAB_EMBEDDED
42#include <ktrader.h> 44#include <ktrader.h>
43#else //KAB_EMBEDDED 45#else //KAB_EMBEDDED
44extern "C" 46extern "C"
45{ 47{
46 void* init_microkaddrbk_csv_xxport(); 48 void* init_microkaddrbk_csv_xxport();
47 void* init_microkaddrbk_kde2_xxport(); 49 void* init_microkaddrbk_kde2_xxport();
48 void* init_microkaddrbk_vcard_xxport(); 50 void* init_microkaddrbk_vcard_xxport();
49 // void* init_microkaddrbk_opie_xxport(); 51 // void* init_microkaddrbk_opie_xxport();
50 void* init_microkaddrbk_qtopia_xxport(); 52 void* init_microkaddrbk_qtopia_xxport();
51 void* init_microkaddrbk_sharpdtm_xxport(); 53 void* init_microkaddrbk_sharpdtm_xxport();
52} 54}
53#endif //KAB_EMBEDDED 55#endif //KAB_EMBEDDED
54 56
55#include <addresseeview.h> 57#include <addresseeview.h>
56 58
57#include "kabcore.h" 59#include "kabcore.h"
58#include "undocmds.h" 60#include "undocmds.h"
59#include "xxportselectdialog.h" 61#include "xxportselectdialog.h"
60 62
61#include "xxportmanager.h" 63#include "xxportmanager.h"
62#include "nameeditdialog.h" 64#include "nameeditdialog.h"
63 65
64KURL XXPortManager::importURL = KURL(); 66KURL XXPortManager::importURL = KURL();
65QString XXPortManager::importData = QString::null; 67QString XXPortManager::importData = QString::null;
66 68
67class PreviewDialog : public KDialogBase 69class PreviewDialog : public KDialogBase
68{ 70{
69 public: 71 public:
70 PreviewDialog( const KABC::Addressee &addr, 72 PreviewDialog( const KABC::Addressee &addr,
71 QWidget *parent, const char *name = 0 ); 73 QWidget *parent, const char *name = 0 );
72}; 74};
73 75
74XXPortManager::XXPortManager( KABCore *core, QObject *parent, const char *name ) 76XXPortManager::XXPortManager( KABCore *core, QObject *parent, const char *name )
75 : QObject( parent, name ), mCore( core ), mShowPreview( false ) 77 : QObject( parent, name ), mCore( core ), mShowPreview( false )
76{ 78{
77 loadPlugins(); 79 loadPlugins();
78} 80}
79 81
80XXPortManager::~XXPortManager() 82XXPortManager::~XXPortManager()
81{ 83{
82} 84}
83 85
84void XXPortManager::restoreSettings() 86void XXPortManager::restoreSettings()
85{ 87{
86} 88}
87 89
88void XXPortManager::saveSettings() 90void XXPortManager::saveSettings()
89{ 91{
90} 92}
91 93
92void XXPortManager::importVCard( const KURL &url ) 94void XXPortManager::importVCard( const KURL &url )
93{ 95{
94 importVCard( url, false ); 96 importVCard( url, false );
95} 97}
96 98
97void XXPortManager::importVCard( const KURL &url, bool showPreview ) 99void XXPortManager::importVCard( const KURL &url, bool showPreview )
98{ 100{
99 importURL = url; 101 importURL = url;
100 mShowPreview = showPreview; 102 mShowPreview = showPreview;
101 slotImport( "vcard", "<empty>" ); 103 slotImport( "vcard", "<empty>" );
102 mShowPreview = false; 104 mShowPreview = false;
103 importURL = KURL(); 105 importURL = KURL();
104} 106}
105 107
106void XXPortManager::importVCard( const QString &vCard, bool showPreview ) 108void XXPortManager::importVCard( const QString &vCard, bool showPreview )
107{ 109{
108 importData = vCard; 110 importData = vCard;
109 mShowPreview = showPreview; 111 mShowPreview = showPreview;
110 slotImport( "vcard", "<empty>" ); 112 slotImport( "vcard", "<empty>" );
111 mShowPreview = false; 113 mShowPreview = false;
112 importData = ""; 114 importData = "";
113} 115}
114 116
115void XXPortManager::slotImport( const QString &identifier, const QString &data ) 117void XXPortManager::slotImport( const QString &identifier, const QString &data )
116{ 118{
117 XXPortObject *obj = mXXPortObjects[ identifier ]; 119 XXPortObject *obj = mXXPortObjects[ identifier ];
118 if ( !obj ) { 120 if ( !obj ) {
119 KMessageBox::error( mCore, i18n( "<qt>No import plugin available for <b>%1</b>.</qt>" ).arg( identifier ) ); 121 KMessageBox::error( mCore, i18n( "<qt>No import plugin available for <b>%1</b>.</qt>" ).arg( identifier ) );
120 return; 122 return;
121 } 123 }
122 124
123 KABC::Resource *resource = mCore->requestResource( mCore ); 125 KABC::Resource *resource = mCore->requestResource( mCore );
124 if ( !resource ) 126 if ( !resource )
125 return; 127 return;
126 128
127 KABC::AddresseeList list = obj->importContacts( data ); 129 KABC::AddresseeList list = obj->importContacts( data );
128 bool useUndo = ( list.count() < 25 ); 130 bool useUndo = ( list.count() < 25 );
129#ifdef DESKTOP_VERSION 131#ifdef DESKTOP_VERSION
130 useUndo = true; 132 useUndo = true;
131#endif 133#endif
132 mShowPreview = true; 134 mShowPreview = true;
133 KABC::AddresseeList::Iterator it; 135 KABC::AddresseeList::Iterator it;
134 bool imported = false; 136 bool imported = false;
135 int count = 0; 137 int count = 0;
136 138
137 KConfig config( locateLocal("config", "kabcrc") ); 139 KConfig config( locateLocal("config", "kabcrc") );
138 config.setGroup( "General" ); 140 config.setGroup( "General" );
139 int FormattedNameType = config.readNumEntry( "FormattedNameType", 1 ); 141 int FormattedNameType = config.readNumEntry( "FormattedNameType", 1 );
140 142
141 143
142 for ( it = list.begin(); it != list.end(); ++it ) { 144 for ( it = list.begin(); it != list.end(); ++it ) {
143 if ( mShowPreview ) { 145 if ( mShowPreview ) {
144 PreviewDialog dlg( *it, mCore ); 146 PreviewDialog dlg( *it, mCore );
145 connect( &dlg, SIGNAL( closeClicked() ), this, SLOT ( noPreview()) ); 147 connect( &dlg, SIGNAL( closeClicked() ), this, SLOT ( noPreview()) );
146 if ( !dlg.exec() ) { 148 if ( !dlg.exec() ) {
147 if ( mShowPreview ) 149 if ( mShowPreview )
148 continue; 150 continue;
149 } 151 }
150 } 152 }
151 (*it).setResource( resource ); 153 (*it).setResource( resource );
152 if ( (*it).formattedName().isEmpty() ) 154 if ( (*it).formattedName().isEmpty() )
153 (*it).setFormattedName( NameEditDialog::formattedName( (*it), FormattedNameType ) ); 155 (*it).setFormattedName( NameEditDialog::formattedName( (*it), FormattedNameType ) );
154 if ( useUndo ) { 156 if ( useUndo ) {
155 ++count; 157 ++count;
156 // We use a PwNewCommand so the user can undo it. 158 // We use a PwNewCommand so the user can undo it.
157 PwNewCommand *command = new PwNewCommand( mCore->addressBook(), *it ); 159 PwNewCommand *command = new PwNewCommand( mCore->addressBook(), *it );
158 UndoStack::instance()->push( command ); 160 UndoStack::instance()->push( command );
159 RedoStack::instance()->clear(); 161 RedoStack::instance()->clear();
160 } else { 162 } else {
161 ++count; 163 ++count;
162 mCore->addressBook()->insertAddressee( (*it), true, true ); 164 mCore->addressBook()->insertAddressee( (*it), true, true );
163 } 165 }
164 imported = true; 166 imported = true;
165 } 167 }
166 if ( imported ) { 168 if ( imported ) {
167 KMessageBox::information( mCore, i18n( "%1 contacts\nsuccessfully\nimported.").arg( count) ); 169 KMessageBox::information( mCore, i18n( "%1 contacts\nsuccessfully\nimported.").arg( count) );
168 emit modified(); 170 emit modified();
169 } 171 }
170} 172}
171void XXPortManager::noPreview() 173void XXPortManager::noPreview()
172{ 174{
173 mShowPreview = false; 175 mShowPreview = false;
174} 176}
175void XXPortManager::slotExport( const QString &identifier, const QString &data ) 177void XXPortManager::slotExport( const QString &identifier, const QString &data )
176{ 178{
177 XXPortObject *obj = mXXPortObjects[ identifier ]; 179 XXPortObject *obj = mXXPortObjects[ identifier ];
178 if ( !obj ) { 180 if ( !obj ) {
179 KMessageBox::error( mCore, i18n( "<qt>No export plugin available for <b>%1</b>.</qt>" ).arg( identifier ) ); 181 KMessageBox::error( mCore, i18n( "<qt>No export plugin available for <b>%1</b>.</qt>" ).arg( identifier ) );
180 return; 182 return;
181 } 183 }
182 184
183 KABC::AddresseeList addrList; 185 KABC::AddresseeList addrList;
184 XXPortSelectDialog dlg( mCore, obj->requiresSorting(), mCore ); 186 XXPortSelectDialog dlg( mCore, obj->requiresSorting(), mCore );
185 if ( dlg.exec() ) 187 if ( dlg.exec() )
186 addrList = dlg.contacts(); 188 addrList = dlg.contacts();
187 else 189 else
188 return; 190 return;
189 if ( !obj->exportContacts( addrList, data ) ) 191 if ( !obj->exportContacts( addrList, data ) )
190 KMessageBox::error( mCore, i18n( "Unable to export contacts." ) ); 192 KMessageBox::error( mCore, i18n( "Unable to export contacts." ) );
191 else 193 else
192 KMessageBox::information( mCore, i18n( "contacts successfully exported." ) ); 194 KMessageBox::information( mCore, i18n( "contacts successfully exported." ) );
193} 195}
194 196
195void XXPortManager::loadPlugins() 197void XXPortManager::loadPlugins()
196{ 198{
197 mXXPortObjects.clear(); 199 mXXPortObjects.clear();
198 200
199#ifndef KAB_EMBEDDED 201#ifndef KAB_EMBEDDED
200 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/XXPort" ); 202 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/XXPort" );
201 KTrader::OfferList::ConstIterator it; 203 KTrader::OfferList::ConstIterator it;
202 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 204 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
203 if ( !(*it)->hasServiceType( "KAddressBook/XXPort" ) ) 205 if ( !(*it)->hasServiceType( "KAddressBook/XXPort" ) )
204 continue; 206 continue;
205 207
206 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); 208 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() );
207 if ( !factory ) { 209 if ( !factory ) {
208 kdDebug(5720) << "XXPortManager::loadExtensions(): Factory creation failed" << endl; 210 kdDebug(5720) << "XXPortManager::loadExtensions(): Factory creation failed" << endl;
209 continue; 211 continue;
210 } 212 }
211 213
212 XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory ); 214 XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory );
213 215
214 if ( !xxportFactory ) { 216 if ( !xxportFactory ) {
215 kdDebug(5720) << "XXPortManager::loadExtensions(): Cast failed" << endl; 217 kdDebug(5720) << "XXPortManager::loadExtensions(): Cast failed" << endl;
216 continue; 218 continue;
217 } 219 }
218 220
219#else //KAB_EMBEDDED 221#else //KAB_EMBEDDED
220 QList<XXPortFactory> factorylist; 222 QList<XXPortFactory*> factorylist;
221 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_csv_xxport())); 223 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_csv_xxport()));
222 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_kde2_xxport())); 224 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_kde2_xxport()));
223 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_vcard_xxport())); 225 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_vcard_xxport()));
224 //US factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_opie_xxport())); 226 //US factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_opie_xxport()));
225 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_qtopia_xxport())); 227 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_qtopia_xxport()));
226 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_sharpdtm_xxport())); 228 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_sharpdtm_xxport()));
227 229
228 QListIterator<XXPortFactory> it(factorylist); 230 for(QList<XXPortFactory*>::iterator it=factorylist.begin();it!=factorylist.end();++it) {
229 for ( ; it.current(); ++it ) 231 XXPortFactory *xxportFactory = *it;
230 {
231 XXPortFactory *xxportFactory = it.current();
232#endif //KAB_EMBEDDED 232#endif //KAB_EMBEDDED
233 233
234 XXPortObject *obj = xxportFactory->xxportObject( mCore->addressBook(), mCore ); 234 XXPortObject *obj = xxportFactory->xxportObject( mCore->addressBook(), mCore );
235 if ( obj ) { 235 if ( obj ) {
236 mCore->addGUIClient( obj ); 236 mCore->addGUIClient( obj );
237 mXXPortObjects.insert( obj->identifier(), obj ); 237 mXXPortObjects.insert( obj->identifier(), obj );
238 connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ), 238 connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ),
239 this, SLOT( slotExport( const QString&, const QString& ) ) ); 239 this, SLOT( slotExport( const QString&, const QString& ) ) );
240 connect( obj, SIGNAL( importActivated( const QString&, const QString& ) ), 240 connect( obj, SIGNAL( importActivated( const QString&, const QString& ) ),
241 this, SLOT( slotImport( const QString&, const QString& ) ) ); 241 this, SLOT( slotImport( const QString&, const QString& ) ) );
242 } 242 }
243 } 243 }
244} 244}
245 245
246 246
247PreviewDialog::PreviewDialog( const KABC::Addressee &addr, QWidget *parent, 247PreviewDialog::PreviewDialog( const KABC::Addressee &addr, QWidget *parent,
248 const char *name ) 248 const char *name )
249 : KDialogBase( Plain, i18n( "Import this contact?" ), Ok | User1| User2, Ok, parent, 249 : KDialogBase( Plain, i18n( "Import this contact?" ), Ok | User1| User2, Ok, parent,
250 name, true, true ,i18n( "Import all!" ),i18n( "No" ) ) 250 name, true, true ,i18n( "Import all!" ),i18n( "No" ) )
251{ 251{
252 QWidget *page = plainPage(); 252 QWidget *page = plainPage();
253 QVBoxLayout *layout = new QVBoxLayout( page, marginHint(), spacingHint() ); 253 Q3VBoxLayout *layout = new Q3VBoxLayout( page, marginHint(), spacingHint() );
254 connect( this, SIGNAL( user1Clicked() ), this, SLOT ( slotClose() ) ); 254 connect( this, SIGNAL( user1Clicked() ), this, SLOT ( slotClose() ) );
255 connect( this, SIGNAL( user2Clicked() ), this, SLOT ( slotCancel() ) ); 255 connect( this, SIGNAL( user2Clicked() ), this, SLOT ( slotCancel() ) );
256 256
257 KABC::AddresseeView *view = new KABC::AddresseeView( page ); 257 KABC::AddresseeView *view = new KABC::AddresseeView( page );
258 view->setAddressee( addr ); 258 view->setAddressee( addr );
259 layout->addWidget( view ); 259 layout->addWidget( view );
260#ifdef DESKTOP_VERSION 260#ifdef DESKTOP_VERSION
261 resize( 640, 480 ); 261 resize( 640, 480 );
262#else 262#else
263 showMaximized(); 263 showMaximized();
264#endif 264#endif
265} 265}
266 266
267#ifndef KAB_EMBEDDED 267#ifndef KAB_EMBEDDED_
268#include "xxportmanager.moc" 268#include "moc_xxportmanager.cpp"
269#endif //KAB_EMBEDDED 269#endif //KAB_EMBEDDED
270
diff --git a/kaddressbook/xxportmanager.h b/kaddressbook/xxportmanager.h
index e801d9b..0528922 100644
--- a/kaddressbook/xxportmanager.h
+++ b/kaddressbook/xxportmanager.h
@@ -1,80 +1,80 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 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/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31 31
32#ifndef XXPORTMANAGER_H 32#ifndef XXPORTMANAGER_H
33#define XXPORTMANAGER_H 33#define XXPORTMANAGER_H
34 34
35#include <qdict.h> 35#include <q3dict.h>
36#include <qobject.h> 36#include <qobject.h>
37 37
38#include <kurl.h> 38#include <kurl.h>
39 39
40#include "xxportobject.h" 40#include "xxportobject.h"
41 41
42class KABCore; 42class KABCore;
43 43
44class XXPortManager : public QObject 44class XXPortManager : public QObject
45{ 45{
46 Q_OBJECT 46 Q_OBJECT
47 47
48 public: 48 public:
49 XXPortManager( KABCore *core, QObject *parent, const char *name = 0 ); 49 XXPortManager( KABCore *core, QObject *parent, const char *name = 0 );
50 ~XXPortManager(); 50 ~XXPortManager();
51 51
52 void restoreSettings(); 52 void restoreSettings();
53 void saveSettings(); 53 void saveSettings();
54 54
55 static KURL importURL; 55 static KURL importURL;
56 static QString importData; 56 static QString importData;
57 57
58 public slots: 58 public slots:
59 void importVCard( const KURL &url ); 59 void importVCard( const KURL &url );
60 void importVCard( const KURL &url, bool showPreview ); 60 void importVCard( const KURL &url, bool showPreview );
61 void importVCard( const QString &vCard, bool showPreview ); 61 void importVCard( const QString &vCard, bool showPreview );
62 62
63 signals: 63 signals:
64 void modified(); 64 void modified();
65 65
66 protected slots: 66 protected slots:
67 void noPreview(); 67 void noPreview();
68 void slotImport( const QString&, const QString& ); 68 void slotImport( const QString&, const QString& );
69 void slotExport( const QString&, const QString& ); 69 void slotExport( const QString&, const QString& );
70 70
71 private: 71 private:
72 void loadPlugins(); 72 void loadPlugins();
73 73
74 QDict<XXPortObject> mXXPortObjects; 74 Q3Dict<XXPortObject> mXXPortObjects;
75 75
76 KABCore *mCore; 76 KABCore *mCore;
77 bool mShowPreview; 77 bool mShowPreview;
78}; 78};
79 79
80#endif 80#endif
diff --git a/kaddressbook/xxportobject.cpp b/kaddressbook/xxportobject.cpp
index bd9d986..2d8d0ff 100644
--- a/kaddressbook/xxportobject.cpp
+++ b/kaddressbook/xxportobject.cpp
@@ -1,276 +1,276 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 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/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <qmap.h> 31#include <qmap.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qsignalmapper.h> 33#include <qsignalmapper.h>
34 34
35#include <kaction.h> 35#include <kaction.h>
36#include <kmessagebox.h> 36#include <kmessagebox.h>
37#include <factory.h> 37#include <factory.h>
38 38
39#include "kabcore.h" 39#include "kabcore.h"
40#include "addressee.h" 40#include "addressee.h"
41#include "tmpaddressbook.h" 41#include "tmpaddressbook.h"
42#include "xxportobject.h" 42#include "xxportobject.h"
43 43
44 44
45class XXPortObject::XXPortObjectPrivate 45class XXPortObject::XXPortObjectPrivate
46{ 46{
47 public: 47 public:
48 QSignalMapper *mExportMapper; 48 QSignalMapper *mExportMapper;
49 QSignalMapper *mImportMapper; 49 QSignalMapper *mImportMapper;
50}; 50};
51 51
52XXPortObject::XXPortObject( KABC::AddressBook *ab, QWidget *parent, 52XXPortObject::XXPortObject( KABC::AddressBook *ab, QWidget *parent,
53 const char *name ) 53 const char *name )
54 : QObject( parent, name ), mAddressBook( ab ), mParentWidget( parent ), 54 : QObject( parent, name ), mAddressBook( ab ), mParentWidget( parent ),
55 d( new XXPortObjectPrivate ) 55 d( new XXPortObjectPrivate )
56{ 56{
57 d->mExportMapper = new QSignalMapper( this ); 57 d->mExportMapper = new QSignalMapper( this );
58 d->mImportMapper = new QSignalMapper( this ); 58 d->mImportMapper = new QSignalMapper( this );
59 59
60 connect( d->mExportMapper, SIGNAL( mapped( const QString& ) ), 60 connect( d->mExportMapper, SIGNAL( mapped( const QString& ) ),
61 SLOT( slotExportActivated( const QString& ) ) ); 61 SLOT( slotExportActivated( const QString& ) ) );
62 connect( d->mImportMapper, SIGNAL( mapped( const QString& ) ), 62 connect( d->mImportMapper, SIGNAL( mapped( const QString& ) ),
63 SLOT( slotImportActivated( const QString& ) ) ); 63 SLOT( slotImportActivated( const QString& ) ) );
64} 64}
65 65
66XXPortObject::~XXPortObject() 66XXPortObject::~XXPortObject()
67{ 67{
68 delete d; 68 delete d;
69 d = 0; 69 d = 0;
70} 70}
71 71
72bool XXPortObject::exportContacts( const KABC::AddresseeList&, const QString& ) 72bool XXPortObject::exportContacts( const KABC::AddresseeList&, const QString& )
73{ 73{
74 // do nothing 74 // do nothing
75 return false; 75 return false;
76} 76}
77 77
78KABC::AddresseeList XXPortObject::importContacts( const QString& ) const 78KABC::AddresseeList XXPortObject::importContacts( const QString& ) const
79{ 79{
80 // do nothing 80 // do nothing
81 return KABC::AddresseeList(); 81 return KABC::AddresseeList();
82} 82}
83 83
84void XXPortObject::createImportAction( const QString &label, const QString &data ) 84void XXPortObject::createImportAction( const QString &label, const QString &data )
85{ 85{
86#ifdef KAB_EMBEDDED 86#ifdef KAB_EMBEDDED
87 KABCore* kabcore = (KABCore*)mParentWidget; 87 KABCore* kabcore = (KABCore*)mParentWidget;
88#endif //KAB_EMBEDDED 88#endif //KAB_EMBEDDED
89 89
90 QString id = "file_import_" + identifier() + ( data.isEmpty() ? QString( "" ) : "_" + data ); 90 QString id = "file_import_" + identifier() + ( data.isEmpty() ? QString( "" ) : "_" + data );
91#ifndef KAB_EMBEDDED 91#ifndef KAB_EMBEDDED
92 KAction *action = new KAction( label, 0, d->mImportMapper, SLOT( map() ), actionCollection(), id.latin1() ); 92 KAction *action = new KAction( label, 0, d->mImportMapper, SLOT( map() ), actionCollection(), id.latin1() );
93#else //KAB_EMBEDDED 93#else //KAB_EMBEDDED
94 KAction *action = new KAction( label, 0, d->mImportMapper, SLOT( map() ), kabcore->actionCollection(), id.latin1() ); 94 KAction *action = new KAction( label, 0, d->mImportMapper, SLOT( map() ), kabcore->actionCollection(), id.latin1() );
95#endif //KAB_EMBEDDED 95#endif //KAB_EMBEDDED
96 96
97 d->mImportMapper->setMapping( action, ( data.isEmpty() ? QString( "<empty>" ) : data ) ); 97 d->mImportMapper->setMapping( action, ( data.isEmpty() ? QString( "<empty>" ) : data ) );
98 98
99#ifndef KAB_EMBEDDED 99#ifndef KAB_EMBEDDED
100 setXMLFile( identifier() + "_xxportui.rc" ); 100 setXMLFile( identifier() + "_xxportui.rc" );
101#endif //KAB_EMBEDDED 101#endif //KAB_EMBEDDED
102 102
103#ifdef KAB_EMBEDDED 103#ifdef KAB_EMBEDDED
104 action->plug((QWidget*)kabcore->getImportMenu()); 104 action->plug((QWidget*)kabcore->getImportMenu());
105#endif //KAB_EMBEDDED 105#endif //KAB_EMBEDDED
106 106
107} 107}
108 108
109void XXPortObject::createExportAction( const QString &label, const QString &data ) 109void XXPortObject::createExportAction( const QString &label, const QString &data )
110{ 110{
111#ifdef KAB_EMBEDDED 111#ifdef KAB_EMBEDDED
112 KABCore* kabcore = (KABCore*)mParentWidget; 112 KABCore* kabcore = (KABCore*)mParentWidget;
113#endif //KAB_EMBEDDED 113#endif //KAB_EMBEDDED
114 114
115 QString id = "file_export_" + identifier() + ( data.isEmpty() ? QString( "" ) : "_" + data ); 115 QString id = "file_export_" + identifier() + ( data.isEmpty() ? QString( "" ) : "_" + data );
116#ifndef KAB_EMBEDDED 116#ifndef KAB_EMBEDDED
117 KAction *action = new KAction( label, 0, d->mExportMapper, SLOT( map() ), actionCollection(), id.latin1() ); 117 KAction *action = new KAction( label, 0, d->mExportMapper, SLOT( map() ), actionCollection(), id.latin1() );
118#else //KAB_EMBEDDED 118#else //KAB_EMBEDDED
119 KAction *action = new KAction( label, 0, d->mExportMapper, SLOT( map() ), kabcore->actionCollection(), id.latin1() ); 119 KAction *action = new KAction( label, 0, d->mExportMapper, SLOT( map() ), kabcore->actionCollection(), id.latin1() );
120#endif //KAB_EMBEDDED 120#endif //KAB_EMBEDDED
121 121
122 d->mExportMapper->setMapping( action, ( data.isEmpty() ? QString( "<empty>" ) : data ) ); 122 d->mExportMapper->setMapping( action, ( data.isEmpty() ? QString( "<empty>" ) : data ) );
123 123
124#ifndef KAB_EMBEDDED 124#ifndef KAB_EMBEDDED
125 setXMLFile( identifier() + "_xxportui.rc" ); 125 setXMLFile( identifier() + "_xxportui.rc" );
126#endif //KAB_EMBEDDED 126#endif //KAB_EMBEDDED
127 127
128#ifdef KAB_EMBEDDED 128#ifdef KAB_EMBEDDED
129 action->plug((QWidget*)kabcore->getExportMenu()); 129 action->plug((QWidget*)kabcore->getExportMenu());
130#endif //KAB_EMBEDDED 130#endif //KAB_EMBEDDED
131 131
132} 132}
133 133
134KABC::AddressBook *XXPortObject::addressBook() const 134KABC::AddressBook *XXPortObject::addressBook() const
135{ 135{
136 return mAddressBook; 136 return mAddressBook;
137} 137}
138 138
139QWidget *XXPortObject::parentWidget() const 139QWidget *XXPortObject::parentWidget() const
140{ 140{
141 return mParentWidget; 141 return mParentWidget;
142} 142}
143 143
144void XXPortObject::slotExportActivated( const QString &data ) 144void XXPortObject::slotExportActivated( const QString &data )
145{ 145{
146 emit exportActivated( identifier(), ( data == "<empty>" ? QString::null : data ) ); 146 emit exportActivated( identifier(), ( data == "<empty>" ? QString::null : data ) );
147} 147}
148 148
149void XXPortObject::slotImportActivated( const QString &data ) 149void XXPortObject::slotImportActivated( const QString &data )
150{ 150{
151 emit importActivated( identifier(), ( data == "<empty>" ? QString::null : data ) ); 151 emit importActivated( identifier(), ( data == "<empty>" ? QString::null : data ) );
152} 152}
153 153
154/******************************************************************** 154/********************************************************************
155 * 155 *
156 *******************************************************************/ 156 *******************************************************************/
157 157
158 158
159XXPortResourceObject::XXPortResourceObject( KABC::AddressBook *ab, QWidget *parent, 159XXPortResourceObject::XXPortResourceObject( KABC::AddressBook *ab, QWidget *parent,
160 const char *name ) 160 const char *name )
161 : XXPortObject( ab, parent, name ), mFactory(0) 161 : XXPortObject( ab, parent, name ), mFactory(0)
162{ 162{
163 mFactory = KRES::Factory::self( "tmpcontact" ); 163 mFactory = KRES::Factory::self( "tmpcontact" );
164} 164}
165 165
166XXPortResourceObject::~XXPortResourceObject() 166XXPortResourceObject::~XXPortResourceObject()
167{ 167{
168 //do not delete the factory. It is a singleton, and selfcontained 168 //do not delete the factory. It is a singleton, and selfcontained
169} 169}
170 170
171bool XXPortResourceObject::isAvailable() 171bool XXPortResourceObject::isAvailable()
172{ 172{
173 return (mFactory != 0); 173 return (mFactory != 0);
174} 174}
175 175
176 176
177bool XXPortResourceObject::_exportContacts( const KABC::AddresseeList &list, const QString& identifier, const QString& fileName ) 177bool XXPortResourceObject::_exportContacts( const KABC::AddresseeList &list, const QString& identifier, const QString& fileName )
178{ 178{
179 //create new resource 179 //create new resource
180 KABC::Resource* mResource = (KABC::Resource*)(mFactory->resource( this->identifier(), 0 )); 180 KABC::Resource* mResource = (KABC::Resource*)(mFactory->resource( this->identifier(), 0 ));
181 181
182 if (mResource == 0) 182 if (mResource == 0)
183 return false; 183 return false;
184 184
185 if (fileName != QString::null) { 185 if (fileName != QString::null) {
186 mResource->setFileName( fileName ); 186 mResource->setFileName( fileName );
187 } else 187 } else
188 return false; 188 return false;
189 189
190 190
191 KABC::TmpAddressBook tmpAB; 191 KABC::TmpAddressBook tmpAB;
192 192
193 bool res = tmpAB.addResource( mResource ); 193 bool res = tmpAB.addResource( mResource );
194 if (res == false) 194 if (res == false)
195 { 195 {
196 delete mResource; 196 delete mResource;
197 return false; 197 return false;
198 } 198 }
199 if ( QFile::exists ( fileName ) ) { 199 if ( QFile::exists ( fileName ) ) {
200 res = tmpAB.load(); 200 res = tmpAB.load();
201 if (res == false) 201 if (res == false)
202 { 202 {
203 //removeResource deletes also the resource object, if the linkcount is 0 203 //removeResource deletes also the resource object, if the linkcount is 0
204 tmpAB.removeResource( mResource ); 204 tmpAB.removeResource( mResource );
205 return false; 205 return false;
206 } 206 }
207 207
208 208
209 //Now check if the file has already entries, and ask the user if he wants to delete them first. 209 //Now check if the file has already entries, and ask the user if he wants to delete them first.
210 if (tmpAB.begin() != tmpAB.end()) 210 if (tmpAB.begin() != tmpAB.end())
211 { 211 {
212 QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) ); 212 QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) );
213 if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) { 213 if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) {
214 // Clean the database.. 214 // Clean the database..
215 tmpAB.clear(); 215 tmpAB.clear();
216 } 216 }
217 } 217 }
218 } 218 }
219 219
220 KABC::Addressee::List::ConstIterator it; 220 KABC::Addressee::List::ConstIterator it;
221 for ( it = list.begin(); it != list.end(); ++it ) { 221 for ( it = list.begin(); it != list.end(); ++it ) {
222 tmpAB.insertAddressee(*it); 222 tmpAB.insertAddressee(*it);
223 } 223 }
224 224
225 KABC::Ticket * ticket = tmpAB.requestSaveTicket(mResource); 225 KABC::Ticket * ticket = tmpAB.requestSaveTicket(mResource);
226 226
227 res = false; 227 res = false;
228 if (ticket != 0) 228 if (ticket != 0)
229 res = tmpAB.save( ticket ); 229 res = tmpAB.save( ticket );
230 230
231 //removeResource deletes also the resource object, if the linkcount is 0 231 //removeResource deletes also the resource object, if the linkcount is 0
232 tmpAB.removeResource( mResource ); 232 tmpAB.removeResource( mResource );
233 233
234 return res; 234 return res;
235} 235}
236 236
237 237
238KABC::AddresseeList XXPortResourceObject::_importContacts( const QString& identifier, const QString& fileName ) const 238KABC::AddresseeList XXPortResourceObject::_importContacts( const QString& identifier, const QString& fileName ) const
239{ 239{
240 240
241 241
242 KABC::Resource* mResource = (KABC::Resource*)(mFactory->resource( this->identifier(), 0 )); 242 KABC::Resource* mResource = (KABC::Resource*)(mFactory->resource( this->identifier(), 0 ));
243 243
244 if (mResource == 0) 244 if (mResource == 0)
245 return KABC::AddresseeList(); 245 return KABC::AddresseeList();
246 246
247 KABC::AddresseeList adrlst; 247 KABC::AddresseeList adrlst;
248 248
249 if (fileName != QString::null) 249 if (fileName != QString::null)
250 mResource->setFileName( fileName ); 250 mResource->setFileName( fileName );
251 251
252 252
253 KABC::TmpAddressBook tmpAB; 253 KABC::TmpAddressBook tmpAB;
254 254
255 bool res = tmpAB.addResource( mResource ); 255 bool res = tmpAB.addResource( mResource );
256 if (res == false) 256 if (res == false)
257 { 257 {
258 delete mResource; 258 delete mResource;
259 return KABC::AddresseeList(); 259 return KABC::AddresseeList();
260 } 260 }
261 261
262 res = tmpAB.load(); 262 res = tmpAB.load();
263 263
264 adrlst = tmpAB.allAddressees(); 264 adrlst = tmpAB.allAddressees();
265 265
266 //remove resource deletes also the Resourceobject, if the linkcount is 0 266 //remove resource deletes also the Resourceobject, if the linkcount is 0
267 tmpAB.removeResource( mResource ); 267 tmpAB.removeResource( mResource );
268 268
269 return adrlst; 269 return adrlst;
270} 270}
271 271
272 272
273 273
274#ifndef KAB_EMBEDDED 274#ifndef KAB_EMBEDDED_
275#include "xxportobject.moc" 275#include "moc_xxportobject.cpp"
276#endif //KAB_EMBEDDED 276#endif //KAB_EMBEDDED
diff --git a/kaddressbook/xxportselectdialog.cpp b/kaddressbook/xxportselectdialog.cpp
index 278cab0..088bffa 100644
--- a/kaddressbook/xxportselectdialog.cpp
+++ b/kaddressbook/xxportselectdialog.cpp
@@ -1,342 +1,345 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk> 3 Copyright (c) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
4 Tobias Koenig <tokoe@kde.org> 4 Tobias Koenig <tokoe@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25/* 25/*
26Enhanced Version of the file for platform independent KDE tools. 26Enhanced Version of the file for platform independent KDE tools.
27Copyright (c) 2004 Ulf Schenk 27Copyright (c) 2004 Ulf Schenk
28 28
29$Id$ 29$Id$
30*/ 30*/
31 31
32#include <kabc/addressbook.h> 32#include <kabc/addressbook.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <kcombobox.h> 34#include <kcombobox.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kglobal.h> 36#include <kglobal.h>
37 37
38#include <qapplication.h> 38#include <qapplication.h>
39#include <qbuttongroup.h> 39#include <QDesktopWidget>
40#include <q3buttongroup.h>
40#include <qcombobox.h> 41#include <qcombobox.h>
41#include <qheader.h> 42#include <q3header.h>
42#include <qlabel.h> 43#include <qlabel.h>
43#include <qlayout.h> 44#include <qlayout.h>
44#include <qlistview.h> 45#include <q3listview.h>
45#include <qpushbutton.h> 46#include <qpushbutton.h>
46#include <qradiobutton.h> 47#include <qradiobutton.h>
47#include <qstringlist.h> 48#include <qstringlist.h>
48#include <qwhatsthis.h> 49#include <q3whatsthis.h>
50//Added by qt3to4:
51#include <Q3GridLayout>
52#include <Q3Frame>
53#include <Q3VBoxLayout>
49 54
50#include "kabcore.h" 55#include "kabcore.h"
51#include "kabprefs.h" 56#include "kabprefs.h"
52 57
53#include "xxportselectdialog.h" 58#include "xxportselectdialog.h"
54 59
55XXPortSelectDialog::XXPortSelectDialog( KABCore *core, bool sort, 60XXPortSelectDialog::XXPortSelectDialog( KABCore *core, bool sort,
56 QWidget* parent, const char* name ) 61 QWidget* parent, const char* name )
57 : KDialogBase( Plain, i18n( "Choose contact selection" ), Help | Ok | Cancel, 62 : KDialogBase( Plain, i18n( "Choose contact selection" ), Help | Ok | Cancel,
58 Ok, parent, name, true, true ), mCore( core ), 63 Ok, parent, name, true, true ), mCore( core ),
59 mUseSorting( sort ) 64 mUseSorting( sort )
60{ 65{
61 initGUI(); 66 initGUI();
62 67
63 connect( mFiltersCombo, SIGNAL( activated( int ) ), 68 connect( mFiltersCombo, SIGNAL( activated( int ) ),
64 SLOT( filterChanged( int ) ) ); 69 SLOT( filterChanged( int ) ) );
65 connect( mCategoriesView, SIGNAL( clicked( QListViewItem* ) ), 70 connect( mCategoriesView, SIGNAL( clicked( Q3ListViewItem* ) ),
66 SLOT( categoryClicked( QListViewItem* ) ) ); 71 SLOT( categoryClicked( Q3ListViewItem* ) ) );
67 72
68 // setup filters 73 // setup filters
69#ifndef KAB_EMBEDDED 74#ifndef KAB_EMBEDDED
70 mFilters = Filter::restore( kapp->config(), "Filter" ); 75 mFilters = Filter::restore( kapp->config(), "Filter" );
71 Filter::List::iterator filterIt; 76 Filter::List::iterator filterIt;
72#else //KAB_EMBEDDED 77#else //KAB_EMBEDDED
73 mFilters = Filter::restore( KGlobal::config(), "Filter" ); 78 mFilters = Filter::restore( KGlobal::config(), "Filter" );
74 Filter::List::Iterator filterIt; 79 Filter::List::Iterator filterIt;
75#endif //KAB_EMBEDDED 80#endif //KAB_EMBEDDED
76 QStringList filters; 81 QStringList filters;
77 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt ) 82 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt )
78 filters.append( (*filterIt).name() ); 83 filters.append( (*filterIt).name() );
79 84
80 mFiltersCombo->insertStringList( filters ); 85 mFiltersCombo->insertStringList( filters );
81 mUseFilters->setEnabled( filters.count() > 0 ); 86 mUseFilters->setEnabled( filters.count() > 0 );
82 87
83 // setup categories 88 // setup categories
84 QStringList categories = KABPrefs::instance()->mCustomCategories; 89 QStringList categories = KABPrefs::instance()->mCustomCategories;
85 QStringList::Iterator it; 90 QStringList::Iterator it;
86 for ( it = categories.begin(); it != categories.end(); ++it ) 91 for ( it = categories.begin(); it != categories.end(); ++it )
87 new QCheckListItem( mCategoriesView, *it, QCheckListItem::CheckBox ); 92 new Q3CheckListItem( mCategoriesView, *it, Q3CheckListItem::CheckBox );
88 mUseCategories->setEnabled( categories.count() > 0 ); 93 mUseCategories->setEnabled( categories.count() > 0 );
89 94
90 int count = mCore->selectedUIDs().count(); 95 int count = mCore->selectedUIDs().count();
91 mUseSelection->setEnabled( count != 0 ); 96 mUseSelection->setEnabled( count != 0 );
92 mUseSelection->setChecked( count > 1 ); 97 mUseSelection->setChecked( count > 1 );
93 98
94 mSortTypeCombo->insertItem( i18n( "Ascending" ) ); 99 mSortTypeCombo->insertItem( i18n( "Ascending" ) );
95 mSortTypeCombo->insertItem( i18n( "Descending" ) ); 100 mSortTypeCombo->insertItem( i18n( "Descending" ) );
96 101
97 mFields = mCore->addressBook()->fields( KABC::Field::All ); 102 mFields = mCore->addressBook()->fields( KABC::Field::All );
98 KABC::Field::List::Iterator fieldIt; 103 KABC::Field::List::Iterator fieldIt;
99 for ( fieldIt = mFields.begin(); fieldIt != mFields.end(); ++fieldIt ) 104 for ( fieldIt = mFields.begin(); fieldIt != mFields.end(); ++fieldIt )
100 mFieldCombo->insertItem( (*fieldIt)->label() ); 105 mFieldCombo->insertItem( (*fieldIt)->label() );
101} 106}
102 107
103QStringList XXPortSelectDialog::uids() 108QStringList XXPortSelectDialog::uids()
104{ 109{
105 QStringList uidlist; 110 QStringList uidlist;
106 KABC::AddresseeList list = contacts(); 111 KABC::AddresseeList list = contacts();
107 KABC::Addressee::List::Iterator it; 112 KABC::Addressee::List::Iterator it;
108 for ( it = list.begin(); it != list.end(); ++it ) 113 for ( it = list.begin(); it != list.end(); ++it )
109 uidlist.append((*it).uid()); 114 uidlist.append((*it).uid());
110 return uidlist; 115 return uidlist;
111} 116}
112void XXPortSelectDialog::tagSelected() 117void XXPortSelectDialog::tagSelected()
113{ 118{
114 if ( mUseSelection->isChecked() ) { 119 if ( mUseSelection->isChecked() ) {
115 120
116 QStringList selection = mCore->selectedUIDs(); 121 QStringList selection = mCore->selectedUIDs();
117 KABC::AddressBook::Iterator it; 122 KABC::AddressBook::Iterator it;
118 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { 123 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) {
119 if ( selection.findIndex((*it).uid()) >= 0 ) 124 if ( selection.findIndex((*it).uid()) >= 0 )
120 (*it).setTagged( true ); 125 (*it).setTagged( true );
121 } 126 }
122 } else if ( mUseFilters->isChecked() ) { 127 } else if ( mUseFilters->isChecked() ) {
123 // find contacts that can pass selected filter 128 // find contacts that can pass selected filter
124 Filter::List::Iterator filterIt; 129 Filter::List::Iterator filterIt;
125 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt ) 130 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt )
126 if ( (*filterIt).name() == mFiltersCombo->currentText() ) 131 if ( (*filterIt).name() == mFiltersCombo->currentText() )
127 break; 132 break;
128 KABC::AddressBook::Iterator it; 133 KABC::AddressBook::Iterator it;
129 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { 134 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) {
130 if ( (*filterIt).filterAddressee( *it ) ) 135 if ( (*filterIt).filterAddressee( *it ) )
131 (*it).setTagged( true ); 136 (*it).setTagged( true );
132 } 137 }
133 } else if ( mUseCategories->isChecked() ) { 138 } else if ( mUseCategories->isChecked() ) {
134 QStringList categorieList = categories(); 139 QStringList categorieList = categories();
135 KABC::AddressBook::Iterator it; 140 KABC::AddressBook::Iterator it;
136 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { 141 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) {
137 QStringList tmp( (*it).categories() ); 142 QStringList tmp( (*it).categories() );
138 QStringList::Iterator tmpIt; 143 QStringList::Iterator tmpIt;
139 for ( tmpIt = tmp.begin(); tmpIt != tmp.end(); ++tmpIt ) 144 for ( tmpIt = tmp.begin(); tmpIt != tmp.end(); ++tmpIt )
140 if ( categorieList.contains( *tmpIt ) ) { 145 if ( categorieList.contains( *tmpIt ) ) {
141 (*it).setTagged( true ); 146 (*it).setTagged( true );
142 break; 147 break;
143 } 148 }
144 } 149 }
145 } else { 150 } else {
146 // create a string list of all entries: 151 // create a string list of all entries:
147 KABC::AddressBook::Iterator it; 152 KABC::AddressBook::Iterator it;
148 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) 153 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it )
149 (*it).setTagged( true ); 154 (*it).setTagged( true );
150 } 155 }
151} 156}
152KABC::AddresseeList XXPortSelectDialog::contacts() 157KABC::AddresseeList XXPortSelectDialog::contacts()
153{ 158{
154 159
155 KABC::AddresseeList list; 160 KABC::AddresseeList list;
156 if ( mUseSelection->isChecked() ) { 161 if ( mUseSelection->isChecked() ) {
157 QStringList::Iterator it; 162 QStringList::Iterator it;
158 QStringList selection = mCore->selectedUIDs(); 163 QStringList selection = mCore->selectedUIDs();
159 for ( it = selection.begin(); it != selection.end(); ++it ) { 164 for ( it = selection.begin(); it != selection.end(); ++it ) {
160 KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); 165 KABC::Addressee addr = mCore->addressBook()->findByUid( *it );
161 if ( !addr.isEmpty() ) 166 if ( !addr.isEmpty() )
162 if ( addr.uid().left( 19 ) != QString("last-syncAddressee-") ) 167 if ( addr.uid().left( 19 ) != QString("last-syncAddressee-") )
163 list.append( addr ); 168 list.append( addr );
164 } 169 }
165 } else if ( mUseFilters->isChecked() ) { 170 } else if ( mUseFilters->isChecked() ) {
166 // find contacts that can pass selected filter 171 // find contacts that can pass selected filter
167 Filter::List::Iterator filterIt; 172 Filter::List::Iterator filterIt;
168 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt ) 173 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt )
169 if ( (*filterIt).name() == mFiltersCombo->currentText() ) 174 if ( (*filterIt).name() == mFiltersCombo->currentText() )
170 break; 175 break;
171 176
172 KABC::AddressBook::Iterator it; 177 KABC::AddressBook::Iterator it;
173 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { 178 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) {
174 if ( (*filterIt).filterAddressee( *it ) ) 179 if ( (*filterIt).filterAddressee( *it ) )
175 if ((*it).uid().left( 19 ) != QString("last-syncAddressee-") ) 180 if ((*it).uid().left( 19 ) != QString("last-syncAddressee-") )
176 list.append( *it ); 181 list.append( *it );
177 } 182 }
178 } else if ( mUseCategories->isChecked() ) { 183 } else if ( mUseCategories->isChecked() ) {
179 QStringList categorieList = categories(); 184 QStringList categorieList = categories();
180 KABC::AddressBook::Iterator it; 185 KABC::AddressBook::Iterator it;
181 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { 186 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) {
182 QStringList tmp( (*it).categories() ); 187 QStringList tmp( (*it).categories() );
183 QStringList::Iterator tmpIt; 188 QStringList::Iterator tmpIt;
184 for ( tmpIt = tmp.begin(); tmpIt != tmp.end(); ++tmpIt ) 189 for ( tmpIt = tmp.begin(); tmpIt != tmp.end(); ++tmpIt )
185 if ( categorieList.contains( *tmpIt ) ) { 190 if ( categorieList.contains( *tmpIt ) ) {
186 if ((*it).uid().left( 19 ) != QString("last-syncAddressee-") ) 191 if ((*it).uid().left( 19 ) != QString("last-syncAddressee-") )
187 list.append( *it ); 192 list.append( *it );
188 break; 193 break;
189 } 194 }
190 } 195 }
191 } else { 196 } else {
192 // create a string list of all entries: 197 // create a string list of all entries:
193 KABC::AddressBook::Iterator it; 198 KABC::AddressBook::Iterator it;
194 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) 199 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it )
195 if ((*it).uid().left( 19 ) != QString("last-syncAddressee-") ) 200 if ((*it).uid().left( 19 ) != QString("last-syncAddressee-") )
196 list.append( *it ); 201 list.append( *it );
197 } 202 }
198 203
199 if ( mUseSorting ) { 204 if ( mUseSorting ) {
200 list.setReverseSorting( mSortTypeCombo->currentItem() == 1 ); 205 list.setReverseSorting( mSortTypeCombo->currentItem() == 1 );
201 uint pos = mFieldCombo->currentItem(); 206 uint pos = mFieldCombo->currentItem();
202 if ( pos < mFields.count() ) 207 if ( pos < mFields.count() )
203 list.sortByField( mFields[ pos ] ); 208 list.sortByField( mFields[ pos ] );
204 } 209 }
205 210
206 return list; 211 return list;
207} 212}
208 213
209QStringList XXPortSelectDialog::categories() const 214QStringList XXPortSelectDialog::categories() const
210{ 215{
211 QStringList list; 216 QStringList list;
212 217
213 QListViewItemIterator it( mCategoriesView ); 218 Q3ListViewItemIterator it( mCategoriesView );
214 for ( ; it.current(); ++it ) { 219 for ( ; it.current(); ++it ) {
215 QCheckListItem* qcli = static_cast<QCheckListItem*>(it.current()); 220 Q3CheckListItem* qcli = static_cast<Q3CheckListItem*>(it.current());
216 if ( qcli->isOn() ) 221 if ( qcli->isOn() )
217 list.append( it.current()->text( 0 ) ); 222 list.append( it.current()->text( 0 ) );
218 } 223 }
219 224
220 return list; 225 return list;
221} 226}
222 227
223void XXPortSelectDialog::filterChanged( int ) 228void XXPortSelectDialog::filterChanged( int )
224{ 229{
225 mUseFilters->setChecked( true ); 230 mUseFilters->setChecked( true );
226} 231}
227 232
228void XXPortSelectDialog::categoryClicked( QListViewItem *i ) 233void XXPortSelectDialog::categoryClicked( Q3ListViewItem *i )
229{ 234{
230 QCheckListItem *qcli = static_cast<QCheckListItem*>( i ); 235 Q3CheckListItem *qcli = static_cast<Q3CheckListItem*>( i );
231 if ( qcli->isOn() ) 236 if ( qcli->isOn() )
232 mUseCategories->setChecked( true ); 237 mUseCategories->setChecked( true );
233} 238}
234 239
235void XXPortSelectDialog::slotHelp() 240void XXPortSelectDialog::slotHelp()
236{ 241{
237#ifndef KAB_EMBEDDED 242#ifndef KAB_EMBEDDED
238 kapp->invokeHelp( "import-and-export" ); 243 kapp->invokeHelp( "import-and-export" );
239#else //KAB_EMBEDDED 244#else //KAB_EMBEDDED
240 qDebug("XXPortSelectDialog::slotHelp is not implemented yet"); 245 qDebug("XXPortSelectDialog::slotHelp is not implemented yet");
241#endif //KAB_EMBEDDED 246#endif //KAB_EMBEDDED
242 247
243} 248}
244 249
245void XXPortSelectDialog::initGUI() 250void XXPortSelectDialog::initGUI()
246{ 251{
247 QFrame *page = plainPage(); 252 Q3Frame *page = plainPage();
248 253
249 QVBoxLayout *topLayout = new QVBoxLayout( page, KDialog::marginHintSmall(), 254 Q3VBoxLayout *topLayout = new Q3VBoxLayout( page, KDialog::marginHintSmall(),
250 KDialog::spacingHintSmall() ); 255 KDialog::spacingHintSmall() );
251 256
252 QLabel *label = new QLabel( i18n( "Which contacts do you want to select?" ), page ); 257 QLabel *label = new QLabel( i18n( "Which contacts do you want to select?" ), page );
253 topLayout->addWidget( label ); 258 topLayout->addWidget( label );
254 259
255 mButtonGroup = new QButtonGroup( i18n( "Contact Selection" ), page ); 260 mButtonGroup = new Q3ButtonGroup( i18n( "Contact Selection" ), page );
256 mButtonGroup->setColumnLayout( 0, Qt::Vertical ); 261 mButtonGroup->setColumnLayout( 0, Qt::Vertical );
257 mButtonGroup->layout()->setSpacing( KDialog::spacingHint() ); 262 mButtonGroup->layout()->setSpacing( KDialog::spacingHint() );
258 mButtonGroup->layout()->setMargin( KDialog::marginHint() ); 263 mButtonGroup->layout()->setMargin( KDialog::marginHint() );
259 264
260 QGridLayout *groupLayout = new QGridLayout( mButtonGroup->layout() ); 265 Q3GridLayout *groupLayout = new Q3GridLayout( mButtonGroup->layout() );
261 groupLayout->setAlignment( Qt::AlignTop ); 266 groupLayout->setAlignment( Qt::AlignTop );
262 267
263 mUseWholeBook = new QRadioButton( i18n( "&All" ), mButtonGroup ); 268 mUseWholeBook = new QRadioButton( i18n( "&All" ), mButtonGroup );
264 mUseWholeBook->setChecked( true ); 269 mUseWholeBook->setChecked( true );
265 QWhatsThis::add( mUseWholeBook, i18n( "Select the entire address book" ) ); 270 Q3WhatsThis::add( mUseWholeBook, i18n( "Select the entire address book" ) );
266 groupLayout->addWidget( mUseWholeBook, 0, 0 ); 271 groupLayout->addWidget( mUseWholeBook, 0, 0 );
267 272
268 mUseSelection = new QRadioButton( i18n( "&Selected" ), mButtonGroup ); 273 mUseSelection = new QRadioButton( i18n( "&Selected" ), mButtonGroup );
269 QWhatsThis::add( mUseSelection, i18n( "Only contacts selected in KAddressBook.\n" 274 Q3WhatsThis::add( mUseSelection, i18n( "Only contacts selected in KAddressBook.\n"
270 "This option is disabled if no contacts are selected." ) ); 275 "This option is disabled if no contacts are selected." ) );
271 groupLayout->addWidget( mUseSelection, 1, 0 ); 276 groupLayout->addWidget( mUseSelection, 1, 0 );
272 277
273 mUseFilters = new QRadioButton( i18n( "By matching &filter" ), mButtonGroup ); 278 mUseFilters = new QRadioButton( i18n( "By matching &filter" ), mButtonGroup );
274 QWhatsThis::add( mUseFilters, i18n( "Only contacts matching the selected filter.\n" 279 Q3WhatsThis::add( mUseFilters, i18n( "Only contacts matching the selected filter.\n"
275 "This option is disabled if you haven't defined any filters" ) ); 280 "This option is disabled if you haven't defined any filters" ) );
276 groupLayout->addWidget( mUseFilters, 2, 0 ); 281 groupLayout->addWidget( mUseFilters, 2, 0 );
277 282
278 mUseCategories = new QRadioButton( i18n( "By Cate&gories" ), mButtonGroup ); 283 mUseCategories = new QRadioButton( i18n( "By Cate&gories" ), mButtonGroup );
279 QWhatsThis::add( mUseCategories, i18n( "Only contacts who are members of a category that is checked on the list to the left.\n" 284 Q3WhatsThis::add( mUseCategories, i18n( "Only contacts who are members of a category that is checked on the list to the left.\n"
280 "This option is disabled if you have no categories." ) ); 285 "This option is disabled if you have no categories." ) );
281 groupLayout->addWidget( mUseCategories, 3, 0 ); 286 groupLayout->addWidget( mUseCategories, 3, 0 );
282 287
283 mFiltersCombo = new QComboBox( false, mButtonGroup ); 288 mFiltersCombo = new QComboBox( false, mButtonGroup );
284 mFiltersCombo->setSizePolicy(QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); 289 mFiltersCombo->setSizePolicy(QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
285 QWhatsThis::add( mFiltersCombo, i18n( "Select a filter to decide which contacts to select." ) ); 290 Q3WhatsThis::add( mFiltersCombo, i18n( "Select a filter to decide which contacts to select." ) );
286 groupLayout->addWidget( mFiltersCombo, 2, 1 ); 291 groupLayout->addWidget( mFiltersCombo, 2, 1 );
287 292
288 mCategoriesView = new QListView( mButtonGroup ); 293 mCategoriesView = new Q3ListView( mButtonGroup );
289 mCategoriesView->addColumn( "" ); 294 mCategoriesView->addColumn( "" );
290 mCategoriesView->header()->hide(); 295 mCategoriesView->header()->hide();
291 QWhatsThis::add( mCategoriesView, i18n( "Check the categories whose members you want to select." ) ); 296 Q3WhatsThis::add( mCategoriesView, i18n( "Check the categories whose members you want to select." ) );
292 groupLayout->addWidget( mCategoriesView, 3, 1 ); 297 groupLayout->addWidget( mCategoriesView, 3, 1 );
293 mCategoriesView->setSizePolicy(QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); 298 mCategoriesView->setSizePolicy(QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
294 //if (QApplication::desktop()->height() == 480 ) 299 //if (QApplication::desktop()->height() == 480 )
295 // mCategoriesView->setMaximumHeight( 240 ); 300 // mCategoriesView->setMaximumHeight( 240 );
296 topLayout->addWidget( mButtonGroup ); 301 topLayout->addWidget( mButtonGroup );
297 302
298 QButtonGroup *sortingGroup = new QButtonGroup( i18n( "Sorting" ), page ); 303 Q3ButtonGroup *sortingGroup = new Q3ButtonGroup( i18n( "Sorting" ), page );
299 sortingGroup->setColumnLayout( 0, Qt::Vertical ); 304 sortingGroup->setColumnLayout( 0, Qt::Vertical );
300 QGridLayout *sortLayout = new QGridLayout( sortingGroup->layout(), 2, 2, 305 Q3GridLayout *sortLayout = new Q3GridLayout( sortingGroup->layout(), 2, 2,
301 KDialog::spacingHint() ); 306 KDialog::spacingHint() );
302 sortLayout->setAlignment( Qt::AlignTop ); 307 sortLayout->setAlignment( Qt::AlignTop );
303 308
304 label = new QLabel( i18n( "Criterion:" ), sortingGroup ); 309 label = new QLabel( i18n( "Criterion:" ), sortingGroup );
305 sortLayout->addWidget( label, 0, 0 ); 310 sortLayout->addWidget( label, 0, 0 );
306 311
307#ifndef KAB_EMBEDDED 312#ifndef KAB_EMBEDDED
308 mFieldCombo = new KComboBox( false, sortingGroup ); 313 mFieldCombo = new KComboBox( false, sortingGroup );
309#else //KAB_EMBEDDED 314#else //KAB_EMBEDDED
310 //US Combobox is not editable anyway 315 //US Combobox is not editable anyway
311 mFieldCombo = new KComboBox( sortingGroup ); 316 mFieldCombo = new KComboBox( sortingGroup );
312#endif //KAB_EMBEDDED 317#endif //KAB_EMBEDDED
313 sortLayout->addWidget( mFieldCombo, 0, 1 ); 318 sortLayout->addWidget( mFieldCombo, 0, 1 );
314 319
315 label = new QLabel( i18n( "Order:" ), sortingGroup ); 320 label = new QLabel( i18n( "Order:" ), sortingGroup );
316 sortLayout->addWidget( label, 1, 0 ); 321 sortLayout->addWidget( label, 1, 0 );
317 322
318#ifndef KAB_EMBEDDED 323#ifndef KAB_EMBEDDED
319 mSortTypeCombo = new KComboBox( false, sortingGroup ); 324 mSortTypeCombo = new KComboBox( false, sortingGroup );
320#else //KAB_EMBEDDED 325#else //KAB_EMBEDDED
321 //US Combobox is not editable anyway 326 //US Combobox is not editable anyway
322 mSortTypeCombo = new KComboBox( sortingGroup ); 327 mSortTypeCombo = new KComboBox( sortingGroup );
323#endif //KAB_EMBEDDED 328#endif //KAB_EMBEDDED
324 sortLayout->addWidget( mSortTypeCombo, 1, 1 ); 329 sortLayout->addWidget( mSortTypeCombo, 1, 1 );
325 330
326 topLayout->addWidget( sortingGroup ); 331 topLayout->addWidget( sortingGroup );
327 332
328 if ( !mUseSorting ) 333 if ( !mUseSorting )
329 sortingGroup->hide(); 334 sortingGroup->hide();
330 if (QApplication::desktop()->width() <= 640 ) { 335 if (QApplication::desktop()->width() <= 640 ) {
331 showMaximized(); 336 showMaximized();
332#ifndef DESKTOP_VERSION 337#ifndef DESKTOP_VERSION
333 hideButtons(); 338 hideButtons();
334#endif 339#endif
335 } 340 }
336} 341}
337 342
338#ifndef KAB_EMBEDDED 343#ifndef KAB_EMBEDDED_
339#include "xxportselectdialog.moc" 344#include "moc_xxportselectdialog.cpp"
340#endif //KAB_EMBEDDED 345#endif //KAB_EMBEDDED
341
342
diff --git a/kaddressbook/xxportselectdialog.h b/kaddressbook/xxportselectdialog.h
index 28b1fef..208f4f9 100644
--- a/kaddressbook/xxportselectdialog.h
+++ b/kaddressbook/xxportselectdialog.h
@@ -1,83 +1,83 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk> 3 Copyright (c) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
4 Tobias Koenig <tokoe@kde.org> 4 Tobias Koenig <tokoe@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef XXPORTSELECTDIALOG_H 24#ifndef XXPORTSELECTDIALOG_H
25#define XXPORTSELECTDIALOG_H 25#define XXPORTSELECTDIALOG_H
26 26
27#include <kabc/addresseelist.h> 27#include <kabc/addresseelist.h>
28#include <kabc/field.h> 28#include <kabc/field.h>
29#include <kdialogbase.h> 29#include <kdialogbase.h>
30 30
31#include "filter.h" 31#include "filter.h"
32 32
33class QButtonGroup; 33class Q3ButtonGroup;
34class QComboBox; 34class QComboBox;
35class QListView; 35class Q3ListView;
36class QListViewItem; 36class Q3ListViewItem;
37class QRadioButton; 37class QRadioButton;
38 38
39class KABCore; 39class KABCore;
40class KComboBox; 40class KComboBox;
41 41
42class XXPortSelectDialog : public KDialogBase 42class XXPortSelectDialog : public KDialogBase
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45 45
46 public: 46 public:
47 XXPortSelectDialog( KABCore *core, bool sort, QWidget* parent, 47 XXPortSelectDialog( KABCore *core, bool sort, QWidget* parent,
48 const char* name = 0 ); 48 const char* name = 0 );
49 49
50 KABC::AddresseeList contacts(); 50 KABC::AddresseeList contacts();
51 void tagSelected(); 51 void tagSelected();
52 QStringList uids(); 52 QStringList uids();
53 53
54 private slots: 54 private slots:
55 void filterChanged( int ); 55 void filterChanged( int );
56 void categoryClicked( QListViewItem * i ); 56 void categoryClicked( Q3ListViewItem * i );
57 57
58 protected slots: 58 protected slots:
59 void slotHelp(); 59 void slotHelp();
60 60
61 private: 61 private:
62 void initGUI(); 62 void initGUI();
63 QStringList categories() const; 63 QStringList categories() const;
64 64
65 QButtonGroup* mButtonGroup; 65 Q3ButtonGroup* mButtonGroup;
66 QRadioButton* mUseCategories; 66 QRadioButton* mUseCategories;
67 QRadioButton* mUseFilters; 67 QRadioButton* mUseFilters;
68 QRadioButton* mUseWholeBook; 68 QRadioButton* mUseWholeBook;
69 QRadioButton* mUseSelection; 69 QRadioButton* mUseSelection;
70 QComboBox* mFiltersCombo; 70 QComboBox* mFiltersCombo;
71 QListView* mCategoriesView; 71 Q3ListView* mCategoriesView;
72 72
73 KComboBox *mFieldCombo; 73 KComboBox *mFieldCombo;
74 KComboBox *mSortTypeCombo; 74 KComboBox *mSortTypeCombo;
75 75
76 KABCore *mCore; 76 KABCore *mCore;
77 KABC::AddresseeList mAddresseeList; 77 KABC::AddresseeList mAddresseeList;
78 Filter::List mFilters; 78 Filter::List mFilters;
79 KABC::Field::List mFields; 79 KABC::Field::List mFields;
80 bool mUseSorting; 80 bool mUseSorting;
81}; 81};
82 82
83#endif 83#endif