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,216 +1,223 @@ | |||
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 | ||
65 | AddressEditWidget::AddressEditWidget( QWidget *parent, const char *name ) | 72 | AddressEditWidget::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 | ||
102 | AddressEditWidget::~AddressEditWidget() | 109 | AddressEditWidget::~AddressEditWidget() |
103 | { | 110 | { |
104 | 111 | ||
105 | } | 112 | } |
106 | 113 | ||
107 | KABC::Address::List AddressEditWidget::addresses() | 114 | KABC::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 | ||
119 | void AddressEditWidget::setAddresses( const KABC::Addressee &addr, | 126 | void 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 | ||
163 | void AddressEditWidget::edit() | 170 | void 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 | ||
200 | void AddressEditWidget::updateAddressEdit() | 207 | void 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 { |
@@ -226,128 +233,128 @@ void AddressEditWidget::updateAddressEdit() | |||
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 | ||
247 | AddressEditDialog::AddressEditDialog( const KABC::Address::List &list, | 254 | AddressEditDialog::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 |
@@ -554,69 +561,69 @@ void AddressEditDialog::fillCountryCombo() | |||
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 | ||
581 | AddressTypeDialog::AddressTypeDialog( int type, QWidget *parent ) | 588 | AddressTypeDialog::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 | ||
604 | AddressTypeDialog::~AddressTypeDialog() | 611 | AddressTypeDialog::~AddressTypeDialog() |
605 | { | 612 | { |
606 | } | 613 | } |
607 | 614 | ||
608 | int AddressTypeDialog::type() const | 615 | int 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 | |||
@@ -4,156 +4,156 @@ | |||
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 | ||
36 | class QButtonGroup; | 36 | class Q3ButtonGroup; |
37 | class QCheckBox; | 37 | class QCheckBox; |
38 | class QListView; | 38 | class Q3ListView; |
39 | #ifndef KAB_EMBEDDED | 39 | #ifndef KAB_EMBEDDED |
40 | class QTextEdit; | 40 | class Q3TextEdit; |
41 | #else //KAB_EMBEDDED | 41 | #else //KAB_EMBEDDED |
42 | class QMultiLineEdit; | 42 | class Q3MultiLineEdit; |
43 | #endif //KAB_EMBEDDED | 43 | #endif //KAB_EMBEDDED |
44 | class QToolButton; | 44 | class QToolButton; |
45 | 45 | ||
46 | class KComboBox; | 46 | class KComboBox; |
47 | class KLineEdit; | 47 | class KLineEdit; |
48 | class KListView; | 48 | class KListView; |
49 | 49 | ||
50 | typedef TypeCombo<KABC::Address> AddressTypeCombo; | 50 | typedef TypeCombo<KABC::Address> AddressTypeCombo; |
51 | 51 | ||
52 | /** | 52 | /** |
53 | Editor widget for addresses. | 53 | Editor widget for addresses. |
54 | */ | 54 | */ |
55 | class AddressEditWidget : public QWidget | 55 | class 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 | */ |
97 | class AddressEditDialog : public KDialogBase | 97 | class 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 | */ |
145 | class AddressTypeDialog : public KDialogBase | 145 | class 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 | ||
30 | using namespace KABC; | 32 | using namespace KABC; |
31 | 33 | ||
32 | static AddresseeConfig* extern_AddresseeConfig = 0; | 34 | static AddresseeConfig* extern_AddresseeConfig = 0; |
33 | static KConfig * extern_Config = 0; | 35 | static KConfig * extern_Config = 0; |
34 | 36 | ||
35 | AddresseeConfig::AddresseeConfig() | 37 | AddresseeConfig::AddresseeConfig() |
36 | { | 38 | { |
37 | 39 | ||
38 | 40 | ||
39 | } | 41 | } |
40 | AddresseeConfig::~AddresseeConfig() | 42 | AddresseeConfig::~AddresseeConfig() |
41 | { | 43 | { |
42 | delete AddresseeConfig::config(); | 44 | delete AddresseeConfig::config(); |
43 | } | 45 | } |
44 | 46 | ||
45 | 47 | ||
46 | AddresseeConfig* AddresseeConfig::instance() | 48 | AddresseeConfig* 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 | } |
52 | KConfig* AddresseeConfig::config() | 54 | KConfig* 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 | ||
62 | void AddresseeConfig::setUid( const QString & uid ) | 64 | void 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 | ||
68 | void AddresseeConfig::setAutomaticNameParsing( bool value ) | 70 | void 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 | ||
80 | void AddresseeConfig::setNoDefaultAddrTypes( const QValueList<int> &types ) | 82 | void 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 | ||
91 | void AddresseeConfig::remove( const QString & uid ) | 93 | void 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 | ||
30 | using namespace KABC; | 32 | using namespace KABC; |
31 | 33 | ||
32 | class AddresseeConfig | 34 | class 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,78 +1,81 @@ | |||
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 | ||
36 | AddresseeEditorDialog::AddresseeEditorDialog( KABCore *core, QWidget *parent, | 39 | AddresseeEditorDialog::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 | ||
59 | AddresseeEditorDialog::~AddresseeEditorDialog() | 62 | AddresseeEditorDialog::~AddresseeEditorDialog() |
60 | { | 63 | { |
61 | //emit editorDestroyed( mEditorWidget->addressee().uid() ); | 64 | //emit editorDestroyed( mEditorWidget->addressee().uid() ); |
62 | } | 65 | } |
63 | 66 | ||
64 | void AddresseeEditorDialog::setAddressee( const KABC::Addressee &addr ) | 67 | void 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 | ||
73 | KABC::Addressee AddresseeEditorDialog::addressee() | 76 | KABC::Addressee AddresseeEditorDialog::addressee() |
74 | { | 77 | { |
75 | return mEditorWidget->addressee(); | 78 | return mEditorWidget->addressee(); |
76 | } | 79 | } |
77 | 80 | ||
78 | bool AddresseeEditorDialog::dirty() | 81 | bool AddresseeEditorDialog::dirty() |
@@ -89,35 +92,35 @@ void AddresseeEditorDialog::slotApply() | |||
89 | 92 | ||
90 | enableButton( KDialogBase::Apply, false ); | 93 | enableButton( KDialogBase::Apply, false ); |
91 | 94 | ||
92 | KDialogBase::slotApply(); | 95 | KDialogBase::slotApply(); |
93 | } | 96 | } |
94 | 97 | ||
95 | void AddresseeEditorDialog:: accept () | 98 | void AddresseeEditorDialog:: accept () |
96 | { | 99 | { |
97 | slotOk(); | 100 | slotOk(); |
98 | 101 | ||
99 | } | 102 | } |
100 | void AddresseeEditorDialog::slotOk() | 103 | void 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 | ||
109 | void AddresseeEditorDialog::widgetModified() | 112 | void AddresseeEditorDialog::widgetModified() |
110 | { | 113 | { |
111 | enableButton( KDialogBase::Apply, true ); | 114 | enableButton( KDialogBase::Apply, true ); |
112 | } | 115 | } |
113 | 116 | ||
114 | void AddresseeEditorDialog::slotCancel() | 117 | void 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,73 +1,77 @@ | |||
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 | ||
@@ -101,95 +105,95 @@ AddresseeEditorWidget::AddresseeEditorWidget( KABCore *core, bool isExtension, | |||
101 | 105 | ||
102 | AddresseeEditorWidget::~AddresseeEditorWidget() | 106 | AddresseeEditorWidget::~AddresseeEditorWidget() |
103 | { | 107 | { |
104 | kdDebug(5720) << "~AddresseeEditorWidget()" << endl; | 108 | kdDebug(5720) << "~AddresseeEditorWidget()" << endl; |
105 | } | 109 | } |
106 | 110 | ||
107 | void AddresseeEditorWidget::contactsSelectionChanged() | 111 | void 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 | ||
115 | void AddresseeEditorWidget::setAddressee( const KABC::Addressee &addr ) | 119 | void AddresseeEditorWidget::setAddressee( const KABC::Addressee &addr ) |
116 | { | 120 | { |
117 | mAddressee = addr; | 121 | mAddressee = addr; |
118 | load(); | 122 | load(); |
119 | } | 123 | } |
120 | 124 | ||
121 | const KABC::Addressee &AddresseeEditorWidget::addressee() | 125 | const KABC::Addressee &AddresseeEditorWidget::addressee() |
122 | { | 126 | { |
123 | return mAddressee; | 127 | return mAddressee; |
124 | } | 128 | } |
125 | 129 | ||
126 | void AddresseeEditorWidget::textChanged( const QString& ) | 130 | void AddresseeEditorWidget::textChanged( const QString& ) |
127 | { | 131 | { |
128 | emitModified(); | 132 | emitModified(); |
129 | } | 133 | } |
130 | 134 | ||
131 | void AddresseeEditorWidget::initGUI() | 135 | void 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 | ||
151 | void AddresseeEditorWidget::setupTab1() | 155 | void 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 ); |
@@ -298,75 +302,75 @@ void AddresseeEditorWidget::setupTab1() | |||
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 | ||
359 | void AddresseeEditorWidget::showCatPopup() | 363 | void 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 | } |
@@ -382,65 +386,65 @@ void AddresseeEditorWidget::selectedCatPopup( int index ) | |||
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 | } |
391 | void AddresseeEditorWidget::setRole2FN() | 395 | void 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 | } |
399 | void AddresseeEditorWidget::setCompany2FN() | 403 | void 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 | ||
408 | void AddresseeEditorWidget::setupTab1_1() | 412 | void 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 |
445 | qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); | 449 | qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); |
446 | #endif //KAB_EMBEDDED | 450 | #endif //KAB_EMBEDDED |
@@ -583,65 +587,65 @@ qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); | |||
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 | ||
610 | void AddresseeEditorWidget::setupTab2() | 614 | void 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 | ||
@@ -662,109 +666,109 @@ void AddresseeEditorWidget::setupTab2() | |||
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; |
@@ -775,65 +779,65 @@ void AddresseeEditorWidget::setupTab2() | |||
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 | ||
802 | void AddresseeEditorWidget::setupTab2_1() | 806 | void 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 ); |
@@ -897,144 +901,144 @@ void AddresseeEditorWidget::setupTab2_1() | |||
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 | ||
951 | void AddresseeEditorWidget::setupTab3() | 955 | void 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 |
976 | qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); | 980 | qDebug("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 | ||
1002 | void AddresseeEditorWidget::setupTab3_1() | 1006 | void 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 |
@@ -1401,35 +1405,35 @@ void 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 |
1406 | void AddresseeEditorWidget::invalidDate() | 1410 | void 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 | ||
1412 | void AddresseeEditorWidget::pageChanged( QWidget *wdg ) | 1416 | void 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 | ||
1423 | QString AddresseeEditorWidget::title() const | 1427 | QString AddresseeEditorWidget::title() const |
1424 | { | 1428 | { |
1425 | return i18n( "Contact Editor" ); | 1429 | return i18n( "Contact Editor" ); |
1426 | } | 1430 | } |
1427 | 1431 | ||
1428 | QString AddresseeEditorWidget::identifier() const | 1432 | QString 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,77 +1,77 @@ | |||
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 | ||
37 | class AddresseeConfig; | 37 | class AddresseeConfig; |
38 | class QCheckBox; | 38 | class QCheckBox; |
39 | class QSpinBox; | 39 | class QSpinBox; |
40 | class QTabWidget; | 40 | class QTabWidget; |
41 | 41 | ||
42 | #ifndef KAB_EMBEDDED | 42 | #ifndef KAB_EMBEDDED |
43 | class QTextEdit; | 43 | class Q3TextEdit; |
44 | #else //KAB_EMBEDDED | 44 | #else //KAB_EMBEDDED |
45 | class QMultiLineEdit; | 45 | class Q3MultiLineEdit; |
46 | #endif //KAB_EMBEDDED | 46 | #endif //KAB_EMBEDDED |
47 | 47 | ||
48 | class KComboBox; | 48 | class KComboBox; |
49 | class KDateEdit; | 49 | class KDateEdit; |
50 | class KLineEdit; | 50 | class KLineEdit; |
51 | class KSqueezedTextLabel; | 51 | class KSqueezedTextLabel; |
52 | 52 | ||
53 | class AddressEditWidget; | 53 | class AddressEditWidget; |
54 | class EmailEditWidget; | 54 | class EmailEditWidget; |
55 | class GeoWidget; | 55 | class GeoWidget; |
56 | class ImageWidget; | 56 | class ImageWidget; |
57 | class KABCore; | 57 | class KABCore; |
58 | class KeyWidget; | 58 | class KeyWidget; |
59 | class PhoneEditWidget; | 59 | class PhoneEditWidget; |
60 | class SecrecyWidget; | 60 | class SecrecyWidget; |
61 | class SoundWidget; | 61 | class SoundWidget; |
62 | 62 | ||
63 | namespace KPIM | 63 | namespace KPIM |
64 | { | 64 | { |
65 | class CategorySelectDialog; | 65 | class CategorySelectDialog; |
66 | class CategoryEditDialog; | 66 | class CategoryEditDialog; |
67 | } | 67 | } |
68 | 68 | ||
69 | namespace KABC { class AddressBook; } | 69 | namespace KABC { class AddressBook; } |
70 | 70 | ||
71 | class AddresseeEditorWidget : public ExtensionWidget | 71 | class 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 ); |
@@ -126,68 +126,68 @@ class AddresseeEditorWidget : public ExtensionWidget | |||
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 | |||
@@ -17,50 +17,50 @@ | |||
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 | ||
32 | QString AddresseeUtil::addresseesToClipboard( const KABC::Addressee::List &list ) | 32 | QString 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 | ||
47 | KABC::Addressee::List AddresseeUtil::clipboardToAddressees( const QString &data ) | 47 | KABC::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 | ||
38 | AddViewDialog::AddViewDialog( QDict<ViewFactory> *viewFactoryDict, | 40 | AddViewDialog::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 | ||
92 | AddViewDialog::~AddViewDialog() | 94 | AddViewDialog::~AddViewDialog() |
93 | { | 95 | { |
94 | } | 96 | } |
95 | 97 | ||
96 | QString AddViewDialog::viewName()const | 98 | QString AddViewDialog::viewName()const |
97 | { | 99 | { |
98 | return mViewNameEdit->text(); | 100 | return mViewNameEdit->text(); |
99 | } | 101 | } |
100 | 102 | ||
101 | QString AddViewDialog::viewType()const | 103 | QString AddViewDialog::viewType()const |
102 | { | 104 | { |
103 | return mTypeGroup->find( mTypeId )->text(); | 105 | return mTypeGroup->find( mTypeId )->text(); |
104 | } | 106 | } |
105 | 107 | ||
106 | void AddViewDialog::clicked( int id ) | 108 | void AddViewDialog::clicked( int id ) |
107 | { | 109 | { |
108 | mTypeId = id; | 110 | mTypeId = id; |
109 | } | 111 | } |
110 | 112 | ||
111 | void AddViewDialog::textChanged( const QString &text ) | 113 | void 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 | ||
31 | class ViewFactory; | 31 | class ViewFactory; |
32 | class QButtonGroup; | 32 | class Q3ButtonGroup; |
33 | class QLineEdit; | 33 | class 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 | */ |
41 | class AddViewDialog : public KDialogBase | 41 | class 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,99 +1,102 @@ | |||
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 | ||
45 | ViewContainer::ViewContainer( QWidget *parent, const char* name ) | 48 | ViewContainer::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 | ||
81 | void ViewContainer::printView() | 84 | void ViewContainer::printView() |
82 | { | 85 | { |
83 | mCurrentLook->printView(); | 86 | mCurrentLook->printView(); |
84 | } | 87 | } |
85 | KABBasicLook *ViewContainer::currentLook() | 88 | KABBasicLook *ViewContainer::currentLook() |
86 | { | 89 | { |
87 | return mCurrentLook; | 90 | return mCurrentLook; |
88 | } | 91 | } |
89 | 92 | ||
90 | void ViewContainer::registerLooks() | 93 | void 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() ) |
@@ -130,35 +133,35 @@ void ViewContainer::slotStyleSelected( int index ) | |||
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 | ||
137 | void ViewContainer::setAddressee( const KABC::Addressee& addressee ) | 140 | void 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 | ||
146 | KABC::Addressee ViewContainer::addressee() | 149 | KABC::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 | ||
156 | void ViewContainer::setReadOnly( bool state ) | 159 | void 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 | ||
31 | class QComboBox; | 31 | class QComboBox; |
32 | class QWidgetStack; | 32 | class Q3WidgetStack; |
33 | 33 | ||
34 | class ViewContainer : public QWidget | 34 | class 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 | ||
28 | KABBasicLook::KABBasicLook( QWidget *parent, const char *name ) | 28 | KABBasicLook::KABBasicLook( QWidget *parent, const char *name ) |
29 | : QVBox( parent, name ), mReadOnly( false ) | 29 | : Q3VBox( parent, name ), mReadOnly( false ) |
30 | { | 30 | { |
31 | } | 31 | } |
32 | 32 | ||
33 | void KABBasicLook::setReadOnly( bool state ) | 33 | void KABBasicLook::setReadOnly( bool state ) |
34 | { | 34 | { |
35 | mReadOnly = state; | 35 | mReadOnly = state; |
36 | } | 36 | } |
37 | 37 | ||
38 | bool KABBasicLook::isReadOnly() const | 38 | bool KABBasicLook::isReadOnly() const |
39 | { | 39 | { |
40 | return mReadOnly; | 40 | return mReadOnly; |
41 | } | 41 | } |
42 | 42 | ||
43 | void KABBasicLook::setAddressee( const KABC::Addressee &addr ) | 43 | void 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 | ||
52 | KABC::Addressee KABBasicLook::addressee() | 52 | KABC::Addressee KABBasicLook::addressee() |
53 | { | 53 | { |
54 | return mAddressee; | 54 | return mAddressee; |
55 | } | 55 | } |
56 | 56 | ||
57 | void KABBasicLook::restoreSettings( KConfig* ) | 57 | void KABBasicLook::restoreSettings( KConfig* ) |
58 | { | 58 | { |
59 | } | 59 | } |
60 | 60 | ||
61 | void KABBasicLook::saveSettings( KConfig* ) | 61 | void KABBasicLook::saveSettings( KConfig* ) |
62 | { | 62 | { |
63 | } | 63 | } |
64 | 64 | ||
65 | KABLookFactory::KABLookFactory( QWidget *parent, const char *name ) | 65 | KABLookFactory::KABLookFactory( QWidget *parent, const char *name ) |
66 | : mParent( parent ), mName( name ) | 66 | : mParent( parent ), mName( name ) |
67 | { | 67 | { |
68 | } | 68 | } |
69 | 69 | ||
70 | KABLookFactory::~KABLookFactory() | 70 | KABLookFactory::~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,76 +1,76 @@ | |||
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 | ||
30 | class KConfig; | 30 | class 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 | */ |
44 | class KABBasicLook : public QVBox | 44 | class 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 | */ |
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 | |||
@@ -160,68 +160,68 @@ void KABDetailedView::paintEvent( QPaintEvent* ) | |||
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 | ||
167 | void KABDetailedView::mouseMoveEvent( QMouseEvent *e ) | 167 | void 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 | ||
190 | void KABDetailedView::mousePressEvent( QMouseEvent *e ) | 190 | void 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 ] ); |
@@ -385,35 +385,35 @@ void KABDetailedView::restoreSettings( KConfig *config ) | |||
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 | |||
@@ -101,57 +101,57 @@ class KABDetailedView : public KABBasicLook | |||
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 | ||
140 | class KABDetailedViewFactory : public KABLookFactory | 140 | class 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> |
30 | KABHtmlView::KABHtmlView( QWidget *parent, const char *name ) | 30 | KABHtmlView::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 | ||
39 | KABHtmlView::~KABHtmlView() | 39 | KABHtmlView::~KABHtmlView() |
40 | { | 40 | { |
41 | } | 41 | } |
42 | void KABHtmlView::printMe() | 42 | void KABHtmlView::printMe() |
43 | { | 43 | { |
44 | mView->printMe(); | 44 | mView->printMe(); |
45 | 45 | ||
46 | } | 46 | } |
47 | 47 | ||
48 | void KABHtmlView::setAddressee( const KABC::Addressee &addr ) | 48 | void 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,90 +1,92 @@ | |||
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 | ||
48 | EmailEditWidget::EmailEditWidget( QWidget *parent, const char *name ) | 50 | EmailEditWidget::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 | ||
78 | EmailEditWidget::~EmailEditWidget() | 80 | EmailEditWidget::~EmailEditWidget() |
79 | { | 81 | { |
80 | } | 82 | } |
81 | 83 | ||
82 | void EmailEditWidget::setEmails( const QStringList &list ) | 84 | void 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 |
@@ -108,82 +110,82 @@ QStringList EmailEditWidget::emails() | |||
108 | } | 110 | } |
109 | 111 | ||
110 | void EmailEditWidget::edit() | 112 | void 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 | ||
123 | void EmailEditWidget::textChanged( const QString &text ) | 125 | void 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 | ||
132 | EmailEditDialog::EmailEditDialog( const QStringList &list, QWidget *parent, | 134 | EmailEditDialog::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 | ||
180 | qDebug("EmailEditDialog::EmailEditDialog has to be changed (lowPrio)"); | 182 | qDebug("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 ); |
@@ -243,35 +245,35 @@ void EmailEditDialog::remove() | |||
243 | } | 245 | } |
244 | } | 246 | } |
245 | 247 | ||
246 | bool EmailEditDialog::changed() const | 248 | bool EmailEditDialog::changed() const |
247 | { | 249 | { |
248 | return mChanged; | 250 | return mChanged; |
249 | } | 251 | } |
250 | 252 | ||
251 | void EmailEditDialog::standard() | 253 | void 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 | ||
261 | void EmailEditDialog::selectionChanged( int index ) | 263 | void 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 | ||
270 | void EmailEditDialog::emailChanged() | 272 | void 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 | ||
32 | class QButtonGroup; | 32 | class Q3ButtonGroup; |
33 | class QCheckBox; | 33 | class QCheckBox; |
34 | class QListView; | 34 | class Q3ListView; |
35 | class QListBox; | 35 | class Q3ListBox; |
36 | class QTextEdit; | 36 | class Q3TextEdit; |
37 | class QToolButton; | 37 | class QToolButton; |
38 | 38 | ||
39 | class KComboBox; | 39 | class KComboBox; |
40 | class KLineEdit; | 40 | class KLineEdit; |
41 | class KListView; | 41 | class 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 | */ |
47 | class EmailEditWidget : public QWidget | 47 | class 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 | ||
70 | class EmailEditDialog : public KDialogBase | 70 | class 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,93 +1,95 @@ | |||
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 | ||
43 | ExtensionManager::ExtensionManager( KABCore *core, QWidget *parent, | 45 | ExtensionManager::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 | ||
68 | ExtensionManager::~ExtensionManager() | 70 | ExtensionManager::~ExtensionManager() |
69 | { | 71 | { |
70 | } | 72 | } |
71 | 73 | ||
72 | void ExtensionManager::restoreSettings() | 74 | void 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 | ||
86 | void ExtensionManager::saveSettings() | 88 | void ExtensionManager::saveSettings() |
87 | { | 89 | { |
88 | KABPrefs::instance()->mCurrentExtension = mActionExtensions->currentItem(); | 90 | KABPrefs::instance()->mCurrentExtension = mActionExtensions->currentItem(); |
89 | } | 91 | } |
90 | 92 | ||
91 | void ExtensionManager::reconfigure() | 93 | void ExtensionManager::reconfigure() |
92 | { | 94 | { |
93 | saveSettings(); | 95 | saveSettings(); |
@@ -119,76 +121,76 @@ void ExtensionManager::setActiveExtension( int id ) | |||
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 | ||
147 | void ExtensionManager::createExtensionWidgets() | 149 | void 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 | ||
@@ -215,35 +217,35 @@ void ExtensionManager::createExtensionWidgets() | |||
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 | ||
33 | class KABCore; | 33 | class KABCore; |
34 | class KSelectAction; | 34 | class KSelectAction; |
35 | 35 | ||
36 | 36 | ||
37 | class ExtensionManager : public QScrollView | 37 | class 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 | |||
@@ -49,36 +49,35 @@ bool ExtensionWidget::contactsSelected() const | |||
49 | KABC::Addressee::List ExtensionWidget::selectedContacts() | 49 | KABC::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 | ||
61 | void ExtensionWidget::contactsSelectionChanged() | 61 | void ExtensionWidget::contactsSelectionChanged() |
62 | { | 62 | { |
63 | // do nothing | 63 | // do nothing |
64 | } | 64 | } |
65 | 65 | ||
66 | QString ExtensionWidget::title() const | 66 | QString ExtensionWidget::title() const |
67 | { | 67 | { |
68 | return "<bug!!!>"; | 68 | return "<bug!!!>"; |
69 | } | 69 | } |
70 | 70 | ||
71 | QString ExtensionWidget::identifier() const | 71 | QString ExtensionWidget::identifier() const |
72 | { | 72 | { |
73 | return "<bug!!!>"; | 73 | return "<bug!!!>"; |
74 | } | 74 | } |
75 | 75 | ||
76 | ConfigureWidget *ExtensionFactory::configureWidget( QWidget*, const char* ) | 76 | ConfigureWidget *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 | |||
@@ -57,63 +57,63 @@ class ExtensionWidget : public QWidget | |||
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 |
90 | class ExtensionFactory : public KLibFactory | 90 | class ExtensionFactory : public KLibFactory |
91 | //MOC_SKIP_END | 91 | #endif |
92 | #else //KAB_EMBEDDED | 92 | #else //KAB_EMBEDDED |
93 | class ExtensionFactory | 93 | class 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,202 +1,209 @@ | |||
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 | ||
58 | class DistributionListFactory : public ExtensionFactory | 65 | class 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 | ||
72 | extern "C" { | 79 | extern "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 | ||
80 | class ContactItem : public QListViewItem | 87 | class 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 | ||
120 | DistributionListWidget::DistributionListWidget( KABCore *core, QWidget *parent, | 127 | DistributionListWidget::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 | ||
197 | DistributionListWidget::~DistributionListWidget() | 204 | DistributionListWidget::~DistributionListWidget() |
198 | { | 205 | { |
199 | delete mManager; | 206 | delete mManager; |
200 | } | 207 | } |
201 | 208 | ||
202 | void DistributionListWidget::save() | 209 | void DistributionListWidget::save() |
@@ -381,121 +388,121 @@ void DistributionListWidget::dropEvent( QDropEvent *e ) | |||
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 | ||
398 | void DistributionListWidget::contactsSelectionChanged() | 405 | void DistributionListWidget::contactsSelectionChanged() |
399 | { | 406 | { |
400 | mAddContactButton->setEnabled( contactsSelected() && mNameCombo->count() > 0 ); | 407 | mAddContactButton->setEnabled( contactsSelected() && mNameCombo->count() > 0 ); |
401 | } | 408 | } |
402 | 409 | ||
403 | QString DistributionListWidget::title() const | 410 | QString DistributionListWidget::title() const |
404 | { | 411 | { |
405 | return i18n( "Distribution List Editor" ); | 412 | return i18n( "Distribution List Editor" ); |
406 | } | 413 | } |
407 | 414 | ||
408 | QString DistributionListWidget::identifier() const | 415 | QString DistributionListWidget::identifier() const |
409 | { | 416 | { |
410 | return "distribution_list_editor"; | 417 | return "distribution_list_editor"; |
411 | } | 418 | } |
412 | 419 | ||
413 | void DistributionListWidget::dropped( QDropEvent *e, QListViewItem* ) | 420 | void DistributionListWidget::dropped( QDropEvent *e, Q3ListViewItem* ) |
414 | { | 421 | { |
415 | dropEvent( e ); | 422 | dropEvent( e ); |
416 | } | 423 | } |
417 | 424 | ||
418 | void DistributionListWidget::changed() | 425 | void DistributionListWidget::changed() |
419 | { | 426 | { |
420 | save(); | 427 | save(); |
421 | } | 428 | } |
422 | 429 | ||
423 | 430 | ||
424 | DistributionListView::DistributionListView( QWidget *parent, const char* name ) | 431 | DistributionListView::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 | ||
432 | void DistributionListView::dragEnterEvent( QDragEnterEvent* e ) | 439 | void 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 | ||
440 | void DistributionListView::viewportDragMoveEvent( QDragMoveEvent *e ) | 447 | void 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 | ||
448 | void DistributionListView::viewportDropEvent( QDropEvent *e ) | 455 | void DistributionListView::viewportDropEvent( QDropEvent *e ) |
449 | { | 456 | { |
450 | emit dropped( e, 0 ); | 457 | emit dropped( e, 0 ); |
451 | } | 458 | } |
452 | 459 | ||
453 | void DistributionListView::dropEvent( QDropEvent *e ) | 460 | void DistributionListView::dropEvent( QDropEvent *e ) |
454 | { | 461 | { |
455 | emit dropped( e, 0 ); | 462 | emit dropped( e, 0 ); |
456 | } | 463 | } |
457 | 464 | ||
458 | 465 | ||
459 | EmailSelector::EmailSelector( const QStringList &emails, | 466 | EmailSelector::EmailSelector( const QStringList &emails, |
460 | const QString ¤t, QWidget *parent ) | 467 | const QString ¤t, 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 | ||
480 | QString EmailSelector::selected() | 487 | QString 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 | ||
489 | QString EmailSelector::getEmail( const QStringList &emails, | 496 | QString EmailSelector::getEmail( const QStringList &emails, |
490 | const QString ¤t, QWidget *parent ) | 497 | const QString ¤t, 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 | ||
32 | class QButtonGroup; | 37 | class Q3ButtonGroup; |
33 | class QComboBox; | 38 | class QComboBox; |
34 | class QLabel; | 39 | class QLabel; |
35 | class QListView; | 40 | class Q3ListView; |
36 | 41 | ||
37 | class DistributionListView; | 42 | class DistributionListView; |
38 | class KABCore; | 43 | class KABCore; |
39 | 44 | ||
40 | namespace KABC { | 45 | namespace KABC { |
41 | class AddressBook; | 46 | class AddressBook; |
42 | class DistributionListManager; | 47 | class DistributionListManager; |
43 | } | 48 | } |
44 | 49 | ||
45 | class DistributionListWidget : public ExtensionWidget | 50 | class 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 | */ |
94 | class DistributionListView : public KListView | 99 | class 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 | */ |
111 | class EmailSelector : public KDialogBase | 116 | class EmailSelector : public KDialogBase |
112 | { | 117 | { |
113 | public: | 118 | public: |
114 | EmailSelector( const QStringList &emails, const QString ¤t, | 119 | EmailSelector( const QStringList &emails, const QString ¤t, |
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 ¤t, | 124 | static QString getEmail( const QStringList &emails, const QString ¤t, |
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 |
128 | class DistributionListFactory : public ExtensionFactory | 133 | class 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,129 +1,131 @@ | |||
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 |
44 | class MergeFactory : public ExtensionFactory | 46 | class 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 | ||
58 | extern "C" { | 60 | extern "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 | ||
66 | class ContactItem : public QListViewItem | 68 | class 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 | ||
89 | MergeWidget::MergeWidget( KABCore *core, QWidget *parent, const char *name ) | 91 | MergeWidget::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 | ||
129 | MergeWidget::~MergeWidget() | 131 | MergeWidget::~MergeWidget() |
@@ -185,65 +187,65 @@ void MergeWidget::updateView() | |||
185 | new ContactItem( mContactView, *it ); | 187 | new ContactItem( mContactView, *it ); |
186 | } | 188 | } |
187 | 189 | ||
188 | QString MergeWidget::title() const | 190 | QString MergeWidget::title() const |
189 | { | 191 | { |
190 | return i18n( "Merge Contacts Editor" ); | 192 | return i18n( "Merge Contacts Editor" ); |
191 | } | 193 | } |
192 | 194 | ||
193 | QString MergeWidget::identifier() const | 195 | QString MergeWidget::identifier() const |
194 | { | 196 | { |
195 | return "merge"; | 197 | return "merge"; |
196 | } | 198 | } |
197 | 199 | ||
198 | void MergeWidget::mergeAndRemove() | 200 | void 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 | ||
224 | void MergeWidget::merge() | 226 | void 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 | ||
247 | void MergeWidget::doMerge( const KABC::Addressee &addr ) | 249 | void MergeWidget::doMerge( const KABC::Addressee &addr ) |
248 | { | 250 | { |
249 | // ADR + LABEL | 251 | // ADR + LABEL |
@@ -340,35 +342,35 @@ void MergeWidget::doMerge( const KABC::Addressee &addr ) | |||
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,64 +1,64 @@ | |||
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 | ||
32 | class QListView; | 32 | class Q3ListView; |
33 | 33 | ||
34 | class KABCore; | 34 | class KABCore; |
35 | 35 | ||
36 | namespace KABC { | 36 | namespace KABC { |
37 | class AddressBook; | 37 | class AddressBook; |
38 | } | 38 | } |
39 | 39 | ||
40 | class MergeWidget : public ExtensionWidget | 40 | class 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; |
diff --git a/kaddressbook/filter.cpp b/kaddressbook/filter.cpp index 12ab1e3..6462310 100644 --- a/kaddressbook/filter.cpp +++ b/kaddressbook/filter.cpp | |||
@@ -189,50 +189,50 @@ void Filter::save( KConfig *config, QString baseGroup, Filter::List &list ) | |||
189 | 189 | ||
190 | config->writeEntry( "Count", index ); | 190 | config->writeEntry( "Count", index ); |
191 | 191 | ||
192 | } | 192 | } |
193 | 193 | ||
194 | Filter::List Filter::restore( KConfig *config, QString baseGroup ) | 194 | Filter::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 | ||
230 | void Filter::setMatchRule( MatchRule rule ) | 230 | void Filter::setMatchRule( MatchRule rule ) |
231 | { | 231 | { |
232 | mMatchRule = rule; | 232 | mMatchRule = rule; |
233 | } | 233 | } |
234 | 234 | ||
235 | Filter::MatchRule Filter::matchRule() const | 235 | Filter::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,77 +1,77 @@ | |||
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 | */ |
39 | class Filter | 39 | class 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 | /** |
diff --git a/kaddressbook/filtereditdialog.cpp b/kaddressbook/filtereditdialog.cpp index ef9b979..40698a7 100644 --- a/kaddressbook/filtereditdialog.cpp +++ b/kaddressbook/filtereditdialog.cpp | |||
@@ -1,199 +1,201 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #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 | ||
57 | FilterEditDialog::FilterEditDialog( QWidget *parent, const char *name ) | 59 | FilterEditDialog::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 | ||
71 | FilterEditDialog::~FilterEditDialog() | 73 | FilterEditDialog::~FilterEditDialog() |
72 | { | 74 | { |
73 | } | 75 | } |
74 | 76 | ||
75 | void FilterEditDialog::setFilter( const Filter &filter ) | 77 | void 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 | ||
101 | Filter FilterEditDialog::filter() | 103 | Filter 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 | ||
132 | void FilterEditDialog::initGUI() | 134 | void 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 | ||
178 | void FilterEditDialog::filterNameTextChanged( const QString &text ) | 180 | void FilterEditDialog::filterNameTextChanged( const QString &text ) |
179 | { | 181 | { |
180 | enableButtonOK( !text.isEmpty() ); | 182 | enableButtonOK( !text.isEmpty() ); |
181 | } | 183 | } |
182 | 184 | ||
183 | void FilterEditDialog::slotHelp() | 185 | void 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 | ||
190 | FilterDialog::FilterDialog( QWidget *parent, const char *name ) | 192 | FilterDialog::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 | ||
197 | FilterDialog::~FilterDialog() | 199 | FilterDialog::~FilterDialog() |
198 | { | 200 | { |
199 | } | 201 | } |
@@ -243,73 +245,73 @@ void FilterDialog::edit() | |||
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 | ||
257 | void FilterDialog::remove() | 259 | void 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 | ||
266 | void FilterDialog::refresh() | 268 | void 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 | ||
275 | void FilterDialog::selectionChanged( QListBoxItem *item ) | 277 | void 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 | ||
283 | void FilterDialog::initGUI() | 285 | void 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 | |||
@@ -2,108 +2,107 @@ | |||
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #ifndef FILTEREDITDIALOG_H | 31 | #ifndef FILTEREDITDIALOG_H |
32 | #define FILTEREDITDIALOG_H | 32 | #define FILTEREDITDIALOG_H |
33 | 33 | ||
34 | class QButtonGroup; | 34 | #include <Q3HButtonGroup> |
35 | class QString; | 35 | class QString; |
36 | class QToolButton; | 36 | class QToolButton; |
37 | class QWidget; | 37 | class QWidget; |
38 | class QListBoxItem; | 38 | class Q3ListBoxItem; |
39 | class QCheckBox; | 39 | class QCheckBox; |
40 | 40 | ||
41 | class KLineEdit; | 41 | class KLineEdit; |
42 | class KListBox; | 42 | class KListBox; |
43 | class KListView; | 43 | class 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 | ||
50 | class FilterDialog : public KDialogBase | 49 | class 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 | ||
80 | class FilterEditDialog : public KDialogBase | 79 | class 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,104 +1,111 @@ | |||
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 | ||
57 | GeoWidget::GeoWidget( QWidget *parent, const char *name ) | 64 | GeoWidget::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 | ||
@@ -138,74 +145,74 @@ KABC::Geo GeoWidget::geo() const | |||
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 | ||
148 | void GeoWidget::editGeoData() | 155 | void 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 | ||
165 | GeoDialog::GeoDialog( QWidget *parent, const char *name ) | 172 | GeoDialog::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 ); |
@@ -400,66 +407,66 @@ void GeoDialog::updateInputs() | |||
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 | ||
413 | void GeoDialog::loadCityList() | 420 | void 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(); |
@@ -523,65 +530,65 @@ double GeoDialog::calculateCoordinate( const QString &coordinate ) | |||
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 | ||
537 | int GeoDialog::nearestCity( double x, double y ) | 544 | int 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 | ||
552 | GeoMapWidget::GeoMapWidget( QWidget *parent, const char *name ) | 559 | GeoMapWidget::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 | ||
562 | GeoMapWidget::~GeoMapWidget() | 569 | GeoMapWidget::~GeoMapWidget() |
563 | { | 570 | { |
564 | } | 571 | } |
565 | 572 | ||
566 | void GeoMapWidget::setLatitude( double latitude ) | 573 | void GeoMapWidget::setLatitude( double latitude ) |
567 | { | 574 | { |
568 | mLatitude = latitude; | 575 | mLatitude = latitude; |
569 | } | 576 | } |
570 | 577 | ||
571 | double GeoMapWidget::latitude()const | 578 | double GeoMapWidget::latitude()const |
572 | { | 579 | { |
573 | return mLatitude; | 580 | return mLatitude; |
574 | } | 581 | } |
575 | 582 | ||
576 | void GeoMapWidget::setLongitude( double longitude ) | 583 | void GeoMapWidget::setLongitude( double longitude ) |
577 | { | 584 | { |
578 | mLongitude = longitude; | 585 | mLongitude = longitude; |
579 | } | 586 | } |
580 | 587 | ||
581 | double GeoMapWidget::longitude()const | 588 | double GeoMapWidget::longitude()const |
582 | { | 589 | { |
583 | return mLongitude; | 590 | return mLongitude; |
584 | } | 591 | } |
585 | 592 | ||
586 | void GeoMapWidget::mousePressEvent( QMouseEvent *event ) | 593 | void GeoMapWidget::mousePressEvent( QMouseEvent *event ) |
587 | { | 594 | { |
@@ -595,35 +602,35 @@ void GeoMapWidget::mousePressEvent( QMouseEvent *event ) | |||
595 | mLongitude = ( longOffset * 180 ) / longMid; | 602 | mLongitude = ( longOffset * 180 ) / longMid; |
596 | 603 | ||
597 | emit changed(); | 604 | emit changed(); |
598 | } | 605 | } |
599 | 606 | ||
600 | void GeoMapWidget::paintEvent( QPaintEvent* ) | 607 | void 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,61 +1,65 @@ | |||
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 | ||
32 | namespace KABC { | 36 | namespace KABC { |
33 | class Geo; | 37 | class Geo; |
34 | } | 38 | } |
35 | 39 | ||
36 | class GeoMapWidget; | 40 | class GeoMapWidget; |
37 | 41 | ||
38 | class KComboBox; | 42 | class KComboBox; |
39 | class KDoubleSpinBox; | 43 | class KDoubleSpinBox; |
40 | 44 | ||
41 | class QCheckBox; | 45 | class QCheckBox; |
42 | class QLabel; | 46 | class QLabel; |
43 | class QSpinBox; | 47 | class QSpinBox; |
44 | class QPushButton; | 48 | class QPushButton; |
45 | 49 | ||
46 | typedef struct { | 50 | typedef 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 | ||
52 | class GeoWidget : public QWidget | 56 | class 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. |
diff --git a/kaddressbook/imagewidget.cpp b/kaddressbook/imagewidget.cpp index eec5e08..6ecf66d 100644 --- a/kaddressbook/imagewidget.cpp +++ b/kaddressbook/imagewidget.cpp | |||
@@ -8,132 +8,136 @@ | |||
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 | ||
49 | ImageWidget::ImageWidget( QWidget *parent, const char *name ) | 53 | ImageWidget::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 |
@@ -151,147 +155,147 @@ void ImageWidget::setPhoto( const KABC::Picture &photo ) | |||
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 | ||
176 | KABC::Picture ImageWidget::photo() const | 180 | KABC::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 | ||
203 | void ImageWidget::setLogo( const KABC::Picture &logo ) | 207 | void 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 | ||
228 | KABC::Picture ImageWidget::logo() const | 232 | KABC::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 | } |
253 | void ImageWidget::removePhoto() | 257 | void ImageWidget::removePhoto() |
254 | { | 258 | { |
255 | setPhoto(KABC::Picture() ); | 259 | setPhoto(KABC::Picture() ); |
256 | } | 260 | } |
257 | 261 | ||
258 | void ImageWidget::removeLogo() | 262 | void ImageWidget::removeLogo() |
259 | { | 263 | { |
260 | setLogo(KABC::Picture() ); | 264 | setLogo(KABC::Picture() ); |
261 | } | 265 | } |
262 | 266 | ||
263 | void ImageWidget::loadPhoto() | 267 | void ImageWidget::loadPhoto() |
264 | { | 268 | { |
265 | mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) ); | 269 | mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) ); |
266 | } | 270 | } |
267 | 271 | ||
268 | void ImageWidget::loadLogo() | 272 | void ImageWidget::loadLogo() |
269 | { | 273 | { |
270 | mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) ); | 274 | mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) ); |
271 | } | 275 | } |
272 | 276 | ||
273 | void ImageWidget::updateGUI() | 277 | void 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 | ||
284 | QPixmap ImageWidget::loadPixmap( const QString &url ) | 288 | QPixmap 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,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 | #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 | ||
32 | class KURL; | 35 | class KURL; |
33 | class KURLRequester; | 36 | class KURLRequester; |
34 | 37 | ||
35 | class QCheckBox; | 38 | class QCheckBox; |
36 | class QLabel; | 39 | class QLabel; |
37 | 40 | ||
38 | class ImageWidget : public QWidget | 41 | class 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 ); |
diff --git a/kaddressbook/incsearchwidget.cpp b/kaddressbook/incsearchwidget.cpp index 5f8b83d..a54d1cd 100644 --- a/kaddressbook/incsearchwidget.cpp +++ b/kaddressbook/incsearchwidget.cpp | |||
@@ -1,82 +1,86 @@ | |||
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 | ||
39 | IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name ) | 42 | IncSearchWidget::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() ) ); |
@@ -147,35 +151,35 @@ void IncSearchWidget::setFields( const KABC::Field::List &list ) | |||
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 | ||
155 | KABC::Field::List IncSearchWidget::fields() const | 159 | KABC::Field::List IncSearchWidget::fields() const |
156 | { | 160 | { |
157 | return mFieldList; | 161 | return mFieldList; |
158 | } | 162 | } |
159 | 163 | ||
160 | KABC::Field *IncSearchWidget::currentField()const | 164 | KABC::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 | ||
168 | void IncSearchWidget::setCurrentItem( int pos ) | 172 | void IncSearchWidget::setCurrentItem( int pos ) |
169 | { | 173 | { |
170 | mFieldCombo->setCurrentItem( pos ); | 174 | mFieldCombo->setCurrentItem( pos ); |
171 | announceFieldChanged(); | 175 | announceFieldChanged(); |
172 | } | 176 | } |
173 | 177 | ||
174 | int IncSearchWidget::currentItem() const | 178 | int 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,110 +1,113 @@ | |||
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 | ||
40 | class JumpButton : public QPushButton | 43 | class 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 | ||
53 | JumpButton::JumpButton( const QString &text, QWidget *parent, | 56 | JumpButton::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 | ||
60 | void JumpButton::setCharacter( const QString &character ) | 63 | void 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 | ||
66 | QString JumpButton::character() const | 69 | QString JumpButton::character() const |
67 | { | 70 | { |
68 | return mCharacter; | 71 | return mCharacter; |
69 | } | 72 | } |
70 | 73 | ||
71 | JumpButtonBar::JumpButtonBar( KABCore *core, QWidget *parent, const char *name ) | 74 | JumpButtonBar::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 | ||
84 | JumpButtonBar::~JumpButtonBar() | 87 | JumpButtonBar::~JumpButtonBar() |
85 | { | 88 | { |
86 | } | 89 | } |
87 | 90 | ||
88 | QSizePolicy JumpButtonBar::sizePolicy() const | 91 | QSizePolicy 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 | ||
98 | void JumpButtonBar::letterClicked() | 101 | void 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 | ||
109 | void JumpButtonBar::recreateButtons() | 112 | void JumpButtonBar::recreateButtons() |
110 | { | 113 | { |
@@ -223,35 +226,35 @@ void JumpButtonBar::recreateButtons() | |||
223 | } | 226 | } |
224 | 227 | ||
225 | void JumpButtonBar::sortListLocaleAware( QStringList &list ) | 228 | void 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 | ||
32 | class QChar; | 35 | class QChar; |
33 | class QGridLayout; | 36 | class Q3GridLayout; |
34 | class QResizeEvent; | 37 | class QResizeEvent; |
35 | class QPushButton; | 38 | class QPushButton; |
36 | class JumpButton; | 39 | class JumpButton; |
37 | 40 | ||
38 | namespace KABC { | 41 | namespace KABC { |
39 | class Field; | 42 | class Field; |
40 | } | 43 | } |
41 | 44 | ||
42 | class KABCore; | 45 | class 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 | */ |
47 | class JumpButtonBar : public QWidget | 50 | class 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 | |||
@@ -10,293 +10,303 @@ | |||
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 |
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 "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 | ||
171 | class KABCatPrefs : public QDialog | 181 | class 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(); } |
199 | private: | 209 | private: |
200 | QRadioButton* addCatBut; | 210 | QRadioButton* addCatBut; |
201 | }; | 211 | }; |
202 | 212 | ||
203 | class KABFormatPrefs : public QDialog | 213 | class 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 | } |
234 | public: | 244 | public: |
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 | ||
241 | class KAex2phonePrefs : public QDialog | 251 | class 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 | ||
281 | public: | 291 | public: |
282 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 292 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
283 | QCheckBox* mWriteToSim; | 293 | QCheckBox* mWriteToSim; |
284 | }; | 294 | }; |
285 | 295 | ||
286 | 296 | ||
287 | bool pasteWithNewUid = true; | 297 | bool pasteWithNewUid = true; |
288 | 298 | ||
289 | #ifdef KAB_EMBEDDED | 299 | #ifdef KAB_EMBEDDED |
290 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 300 | KABCore::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 |
295 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 305 | KABCore::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); |
@@ -378,138 +388,138 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const | |||
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 | } |
410 | void KABCore::receiveStart( const QCString& cmsg, const QByteArray& data ) | 420 | void 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 | ||
417 | void KABCore::loadDataAfterStart() | 427 | void 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 | } |
433 | void KABCore::updateToolBar() | 443 | void 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 | } |
441 | KABCore::~KABCore() | 451 | KABCore::~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 | } |
456 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) | 466 | void 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 | } |
467 | void KABCore::toggleBeamReceive( ) | 477 | void 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 | ||
488 | void KABCore::disableBR(bool b) | 498 | void 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 | } |
505 | void KABCore::recieve( QString fn ) | 515 | void 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 | } |
@@ -531,65 +541,65 @@ void KABCore::restoreSettings() | |||
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 |
@@ -621,68 +631,68 @@ KABC::AddressBook *KABCore::addressBook() const | |||
621 | return mAddressBook; | 631 | return mAddressBook; |
622 | } | 632 | } |
623 | 633 | ||
624 | KConfig *KABCore::config() | 634 | KConfig *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 | ||
633 | KActionCollection *KABCore::actionCollection() const | 643 | KActionCollection *KABCore::actionCollection() const |
634 | { | 644 | { |
635 | return mGUIClient->actionCollection(); | 645 | return mGUIClient->actionCollection(); |
636 | } | 646 | } |
637 | 647 | ||
638 | KABC::Field *KABCore::currentSearchField() const | 648 | KABC::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 | ||
646 | QStringList KABCore::selectedUIDs() const | 656 | QStringList KABCore::selectedUIDs() const |
647 | { | 657 | { |
648 | return mViewManager->selectedUids(); | 658 | return mViewManager->selectedUids(); |
649 | } | 659 | } |
650 | 660 | ||
651 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 661 | KABC::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 |
672 | KAboutData *KABCore::createAboutData() | 682 | KAboutData *KABCore::createAboutData() |
673 | #else //KAB_EMBEDDED | 683 | #else //KAB_EMBEDDED |
674 | void KABCore::createAboutData() | 684 | void 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" |
@@ -766,72 +776,72 @@ void KABCore::sendMail( const QString& emaillist ) | |||
766 | 776 | ||
767 | void KABCore::mailVCard() | 777 | void 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 | ||
774 | void KABCore::mailVCard( const QStringList& uids ) | 784 | void 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 | */ |
830 | void KABCore::beamMySelf() | 840 | void 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 | ||
@@ -987,69 +997,69 @@ void KABCore::beamVCard(const QStringList& uids) | |||
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 | ||
1037 | void KABCore::beamDone( Ir *ir ) | 1047 | void 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 | ||
1047 | void KABCore::browse( const QString& url ) | 1057 | void 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 | ||
@@ -1268,68 +1278,68 @@ void KABCore::contactModified( const KABC::Addressee &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 | ||
1274 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) | 1284 | void 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 | ||
1296 | void KABCore::newContact() | 1306 | void 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 | ||
1332 | void KABCore::addEmail( QString aStr ) | 1342 | void KABCore::addEmail( QString aStr ) |
1333 | { | 1343 | { |
1334 | #ifndef KAB_EMBEDDED | 1344 | #ifndef KAB_EMBEDDED |
1335 | QString fullName, email; | 1345 | QString fullName, email; |
@@ -1827,138 +1837,138 @@ void KABCore::addressBookChanged() | |||
1827 | } | 1837 | } |
1828 | mViewManager->refreshView(); | 1838 | mViewManager->refreshView(); |
1829 | 1839 | ||
1830 | 1840 | ||
1831 | } | 1841 | } |
1832 | 1842 | ||
1833 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1843 | AddresseeEditorDialog *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 | ||
1851 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1861 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1852 | { | 1862 | { |
1853 | //mEditorDict.remove( uid ); | 1863 | //mEditorDict.remove( uid ); |
1854 | } | 1864 | } |
1855 | 1865 | ||
1856 | void KABCore::initGUI() | 1866 | void 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 ); |
@@ -2005,142 +2015,142 @@ void KABCore::initGUI() | |||
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 | } |
2024 | void KABCore::initActions() | 2034 | void 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" ); |
@@ -2217,95 +2227,95 @@ void KABCore::initActions() | |||
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. |
2244 | void KABCore::addActionsManually() | 2254 | void 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 ); |
@@ -2602,65 +2612,65 @@ void KABCore::clipboardDataChanged() | |||
2602 | void KABCore::updateActionMenu() | 2612 | void 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 | ||
2622 | void KABCore::configureKeyBindings() | 2632 | void 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 |
2632 | void KABCore::configureResources() | 2642 | void 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 | */ |
2646 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2656 | void 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 | */ |
@@ -2698,65 +2708,65 @@ void KABCore::callContactdialog() | |||
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 | */ |
2714 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2724 | void 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"; |
@@ -2879,65 +2889,65 @@ void KABCore::synchowto() | |||
2879 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2889 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2880 | } | 2890 | } |
2881 | void KABCore::kdesynchowto() | 2891 | void 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 | } |
2885 | void KABCore::multisynchowto() | 2895 | void 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 | } |
2889 | void KABCore::faq() | 2899 | void 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 | ||
2896 | KABC::Addressee KABCore::getLastSyncAddressee() | 2906 | KABC::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 | } |
2916 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2926 | int 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 "); |
@@ -3070,65 +3080,65 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
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 ); |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index ec6a9ec..4351720 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -1,171 +1,175 @@ | |||
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 | ||
41 | namespace KABC { | 45 | namespace KABC { |
42 | class AddressBook; | 46 | class AddressBook; |
43 | } | 47 | } |
44 | 48 | ||
45 | #ifndef KAB_EMBEDDED | 49 | #ifndef KAB_EMBEDDED |
46 | class KAboutData; | 50 | class KAboutData; |
47 | class KConfig; | 51 | class KConfig; |
48 | 52 | ||
49 | class KAddressBookService; | 53 | class KAddressBookService; |
50 | class LDAPSearchDialog; | 54 | class LDAPSearchDialog; |
51 | #else //KAB_EMBEDDED | 55 | #else //KAB_EMBEDDED |
52 | class KAddressBookMain; | 56 | class KAddressBookMain; |
53 | //US class QAction; | 57 | //US class QAction; |
54 | #endif //KAB_EMBEDDED | 58 | #endif //KAB_EMBEDDED |
55 | class KCMultiDialog; | 59 | class KCMultiDialog; |
56 | class KXMLGUIClient; | 60 | class KXMLGUIClient; |
57 | class ExtensionManager; | 61 | class ExtensionManager; |
58 | class XXPortManager; | 62 | class XXPortManager; |
59 | class JumpButtonBar; | 63 | class JumpButtonBar; |
60 | class IncSearchWidget; | 64 | class IncSearchWidget; |
61 | class KDGanttMinimizeSplitter; | 65 | class KDGanttMinimizeSplitter; |
62 | class KAction; | 66 | class KAction; |
63 | class KActionCollection; | 67 | class KActionCollection; |
64 | class KToggleAction; | 68 | class KToggleAction; |
65 | class KSyncProfile; | 69 | class KSyncProfile; |
66 | 70 | ||
67 | class QAction; | 71 | class QAction; |
68 | class QMenuBar; | 72 | class QMenuBar; |
69 | class QSplitter; | 73 | class QSplitter; |
70 | class ViewContainer; | 74 | class ViewContainer; |
71 | class ViewManager; | 75 | class ViewManager; |
72 | class AddresseeEditorDialog; | 76 | class AddresseeEditorDialog; |
73 | class Ir; | 77 | class Ir; |
74 | 78 | ||
75 | class KABCore : public QWidget, public KSyncInterface | 79 | class 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 | */ |
@@ -337,93 +341,93 @@ class KABCore : public QWidget, public KSyncInterface | |||
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 | ||
@@ -457,84 +461,84 @@ class KABCore : public QWidget, public KSyncInterface | |||
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,60 +1,60 @@ | |||
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 | ||
46 | KABPrefs *KABPrefs::sInstance = 0; | 46 | KABPrefs *KABPrefs::sInstance = 0; |
47 | static KStaticDeleter<KABPrefs> staticDeleterAB; | 47 | static KStaticDeleter<KABPrefs> staticDeleterAB; |
48 | 48 | ||
49 | KABPrefs::KABPrefs() | 49 | KABPrefs::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); |
@@ -62,65 +62,65 @@ KABPrefs::KABPrefs() | |||
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 | ||
101 | KABPrefs::~KABPrefs() | 101 | KABPrefs::~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 | ||
108 | KABPrefs *KABPrefs::instance() | 108 | KABPrefs *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 | ||
123 | void KABPrefs::setCategoryDefaults() | 123 | void KABPrefs::setCategoryDefaults() |
124 | { | 124 | { |
125 | mCustomCategories.clear(); | 125 | mCustomCategories.clear(); |
126 | 126 | ||
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 | ||
32 | class KConfig; | 34 | class KConfig; |
33 | 35 | ||
34 | class KABPrefs : public KPimPrefs | 36 | class 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,81 +1,81 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG = qt warn_on | 2 | CONFIG = qt warn_on |
3 | TARGET = kapi | 3 | TARGET = kapi |
4 | DESTDIR= ../bin | 4 | DESTDIR= ../bin |
5 | 5 | ||
6 | include( ../variables.pri ) | 6 | include( ../variables.pri ) |
7 | 7 | ||
8 | 8 | ||
9 | INCLUDEPATH += . ./details ./features ./xxport ../libkdepim ../microkde ../microkde/kdecore ../microkde/kutils ../microkde/kio/kfile ../microkde/kio/kio ../microkde/kdeui ../microkde/kresources ../kabc ../ interfaces | 9 | INCLUDEPATH += . ./details ./features ./xxport ../libkdepim ../microkde ../microkde/kdecore ../microkde/kutils ../microkde/kio/kfile ../microkde/kio/kio ../microkde/kdeui ../microkde/kresources ../kabc ../ interfaces |
10 | DEFINES += KAB_EMBEDDED KAB_NOSPLITTER DESKTOP_VERSION | 10 | DEFINES += KAB_EMBEDDED KAB_NOSPLITTER DESKTOP_VERSION |
11 | 11 | ||
12 | unix : { | 12 | unix : { |
13 | 13 | ||
14 | staticlib: { | 14 | staticlib: { |
15 | TARGET = kapi_linux | 15 | TARGET = kapi_linux |
16 | LIBS += ../bin/libmicrokabc_qtopia.a | 16 | LIBS += ../bin/libxmicrokabc_qtopia.a |
17 | LIBS += ../bin/libmicrokabc_file.a | 17 | LIBS += ../bin/libxmicrokabc_file.a |
18 | LIBS += ../bin/libmicrokabc_dir.a | 18 | LIBS += ../bin/libxmicrokabc_dir.a |
19 | LIBS += ../bin/libmicrokdepim.a | 19 | LIBS += ../bin/libxmicrokdepim.a |
20 | LIBS += ../bin/libmicrokcal.a | 20 | LIBS += ../bin/libxmicrokcal.a |
21 | LIBS += ../bin/libmicrokabc.a | 21 | LIBS += ../bin/libxmicrokabc.a |
22 | LIBS += ../bin/libmicrokde.a | 22 | LIBS += ../bin/libxmicrokde.a |
23 | LIBS += ../bin/libmicrokabc_qtopia.a | 23 | LIBS += ../bin/libxmicrokabc_qtopia.a |
24 | LIBS += ../bin/libmicrokabc_file.a | 24 | LIBS += ../bin/libxmicrokabc_file.a |
25 | LIBS += ../bin/libmicrokabc_dir.a | 25 | LIBS += ../bin/libxmicrokabc_dir.a |
26 | LIBS += ../bin/libmicrokdepim.a | 26 | LIBS += ../bin/libxmicrokdepim.a |
27 | LIBS += ../bin/libmicrokcal.a | 27 | LIBS += ../bin/libxmicrokcal.a |
28 | LIBS += ../bin/libmicrokabc.a | 28 | LIBS += ../bin/libxmicrokabc.a |
29 | LIBS += ../bin/libmicrokde.a | 29 | LIBS += ../bin/libxmicrokde.a |
30 | LIBS += ../libical/lib/libical.a | 30 | LIBS += ../libical/lib/libical.a |
31 | LIBS += ../libical/lib/libicalss.a | 31 | LIBS += ../libical/lib/libicalss.a |
32 | 32 | ||
33 | } else { | 33 | } else { |
34 | LIBS += ../bin/libmicrokdepim.so | 34 | LIBS += ../bin/libxmicrokdepim.so |
35 | LIBS += ../bin/libmicrokde.so | 35 | LIBS += ../bin/libxmicrokde.so |
36 | LIBS += ../bin/libmicrokabc.so | 36 | LIBS += ../bin/libxmicrokabc.so |
37 | LIBS += ../bin/libmicrokcal.so | 37 | LIBS += ../bin/libxmicrokcal.so |
38 | #LIBS += -lldap | 38 | #LIBS += -lldap |
39 | } | 39 | } |
40 | OBJECTS_DIR = obj/unix | 40 | OBJECTS_DIR = obj/unix |
41 | MOC_DIR = moc/unix | 41 | MOC_DIR = moc/unix |
42 | } | 42 | } |
43 | win32: { | 43 | win32: { |
44 | RC_FILE = winicons.rc | 44 | RC_FILE = winicons.rc |
45 | DEFINES += _WIN32_ | 45 | DEFINES += _WIN32_ |
46 | LIBS += ../bin/microkdepim.lib | 46 | LIBS += ../bin/xmicrokdepim.lib |
47 | LIBS += ../bin/microkcal.lib | 47 | LIBS += ../bin/xmicrokcal.lib |
48 | LIBS += ../bin/microkde.lib | 48 | LIBS += ../bin/xmicrokde.lib |
49 | LIBS += ../bin/microkabc.lib | 49 | LIBS += ../bin/xmicrokabc.lib |
50 | QMAKE_LINK += /NODEFAULTLIB:LIBC | 50 | QMAKE_LINK += /NODEFAULTLIB:LIBC |
51 | OBJECTS_DIR = obj/win | 51 | OBJECTS_DIR = obj/win |
52 | MOC_DIR = moc/win | 52 | MOC_DIR = moc/win |
53 | #olimport section | 53 | #olimport section |
54 | importol { | 54 | importol { |
55 | debug: { | 55 | debug: { |
56 | LIBS += mfc71ud.lib | 56 | LIBS += mfc71ud.lib |
57 | } | 57 | } |
58 | release: { | 58 | release: { |
59 | LIBS += mfc71u.lib | 59 | LIBS += mfc71u.lib |
60 | } | 60 | } |
61 | DEFINES += _OL_IMPORT_ | 61 | DEFINES += _OL_IMPORT_ |
62 | HEADERS = ../outport/msoutl9.h \ | 62 | HEADERS = ../outport/msoutl9.h \ |
63 | kaimportoldialog.h | 63 | kaimportoldialog.h |
64 | SOURCES = ../outport/msoutl9.cpp \ | 64 | SOURCES = ../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 | ||
73 | INTERFACES = \ | 73 | INTERFACES = \ |
74 | # filteredit_base.ui \ | 74 | # filteredit_base.ui \ |
75 | # kofilterview_base.ui \ | 75 | # kofilterview_base.ui \ |
76 | 76 | ||
77 | HEADERS += \ | 77 | HEADERS += \ |
78 | features/mergewidget.h \ | 78 | features/mergewidget.h \ |
79 | features/distributionlistwidget.h \ | 79 | features/distributionlistwidget.h \ |
80 | kcmconfigs/addresseewidget.h \ | 80 | kcmconfigs/addresseewidget.h \ |
81 | kcmconfigs/extensionconfigdialog.h \ | 81 | kcmconfigs/extensionconfigdialog.h \ |
@@ -175,32 +175,34 @@ addviewdialog.cpp \ | |||
175 | configurewidget.cpp \ | 175 | configurewidget.cpp \ |
176 | viewconfigurewidget.cpp \ | 176 | viewconfigurewidget.cpp \ |
177 | viewconfigurefieldspage.cpp \ | 177 | viewconfigurefieldspage.cpp \ |
178 | viewconfigurefilterpage.cpp \ | 178 | viewconfigurefilterpage.cpp \ |
179 | undo.cpp \ | 179 | undo.cpp \ |
180 | undocmds.cpp \ | 180 | undocmds.cpp \ |
181 | xxportmanager.cpp \ | 181 | xxportmanager.cpp \ |
182 | xxportobject.cpp \ | 182 | xxportobject.cpp \ |
183 | xxportselectdialog.cpp \ | 183 | xxportselectdialog.cpp \ |
184 | details/detailsviewcontainer.cpp \ | 184 | details/detailsviewcontainer.cpp \ |
185 | details/look_basic.cpp \ | 185 | details/look_basic.cpp \ |
186 | details/look_html.cpp \ | 186 | details/look_html.cpp \ |
187 | views/kaddressbookiconview.cpp \ | 187 | views/kaddressbookiconview.cpp \ |
188 | views/kaddressbooktableview.cpp \ | 188 | views/kaddressbooktableview.cpp \ |
189 | views/kaddressbookcardview.cpp \ | 189 | views/kaddressbookcardview.cpp \ |
190 | views/configuretableviewdialog.cpp \ | 190 | views/configuretableviewdialog.cpp \ |
191 | views/configurecardviewdialog.cpp \ | 191 | views/configurecardviewdialog.cpp \ |
192 | views/cardview.cpp \ | 192 | views/cardview.cpp \ |
193 | views/contactlistview.cpp \ | 193 | views/contactlistview.cpp \ |
194 | views/colorlistbox.cpp \ | 194 | views/colorlistbox.cpp \ |
195 | xxport/vcard_xxport.cpp \ | 195 | xxport/vcard_xxport.cpp \ |
196 | xxport/kde2_xxport.cpp \ | 196 | xxport/kde2_xxport.cpp \ |
197 | xxport/csv_xxport.cpp \ | 197 | xxport/csv_xxport.cpp \ |
198 | xxport/csvimportdialog.cpp \ | 198 | xxport/csvimportdialog.cpp \ |
199 | xxport/opie_xxport.cpp \ | 199 | xxport/opie_xxport.cpp \ |
200 | xxport/qtopia_xxport.cpp \ | 200 | xxport/qtopia_xxport.cpp \ |
201 | xxport/sharpdtm_xxport.cpp \ | 201 | xxport/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 | ||
208 | QT += 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,50 +1,50 @@ | |||
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 |
6 | OBJECTS_DIR = obj/$(PLATFORM) | 6 | OBJECTS_DIR = obj/$(PLATFORM) |
7 | MOC_DIR = moc/$(PLATFORM) | 7 | MOC_DIR = moc/$(PLATFORM) |
8 | DESTDIR=$(QPEDIR)/bin | 8 | DESTDIR=$(QPEDIR)/bin |
9 | 9 | ||
10 | INCLUDEPATH += . ./details ./features ./xxport ../libkdepim ../microkde ../microkde/kdecore ../microkde/kutils ../microkde/kio/kfile ../microkde/kio/kio ../microkde/kdeui ../microkde/kresources ../kabc ../qtcompat ../ interfaces $(QPEDIR)/include | 10 | INCLUDEPATH += . ./details ./features ./xxport ../libkdepim ../microkde ../microkde/kdecore ../microkde/kutils ../microkde/kio/kfile ../microkde/kio/kio ../microkde/kdeui ../microkde/kresources ../kabc ../qtcompat ../ interfaces $(QPEDIR)/include |
11 | DEFINES += KAB_EMBEDDED KAB_NOSPLITTER | 11 | DEFINES += 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 |
15 | LIBS += -lmicrokdepim | 15 | LIBS += -lxmicrokdepim |
16 | LIBS += -lmicrokde | 16 | LIBS += -lxmicrokde |
17 | LIBS += -lmicroqtcompat | 17 | LIBS += -lmicroqtcompat |
18 | LIBS += -lmicrokabc | 18 | LIBS += -lxmicrokabc |
19 | LIBS += -lqpe | 19 | LIBS += -lqpe |
20 | LIBS += -ljpeg | 20 | LIBS += -ljpeg |
21 | LIBS += $(QTOPIALIB) | 21 | LIBS += $(QTOPIALIB) |
22 | LIBS += -L$(QPEDIR)/lib | 22 | LIBS += -L$(QPEDIR)/lib |
23 | LIBS += -Wl,-export-dynamic | 23 | LIBS += -Wl,-export-dynamic |
24 | LIBS += $(GCC3EXTRALIB1) | 24 | LIBS += $(GCC3EXTRALIB1) |
25 | LIBS += $(GCC3EXTRALIB2) | 25 | LIBS += $(GCC3EXTRALIB2) |
26 | 26 | ||
27 | INTERFACES = \ | 27 | INTERFACES = \ |
28 | # filteredit_base.ui \ | 28 | # filteredit_base.ui \ |
29 | # kofilterview_base.ui \ | 29 | # kofilterview_base.ui \ |
30 | 30 | ||
31 | HEADERS = \ | 31 | HEADERS = \ |
32 | features/mergewidget.h \ | 32 | features/mergewidget.h \ |
33 | features/distributionlistwidget.h \ | 33 | features/distributionlistwidget.h \ |
34 | kcmconfigs/addresseewidget.h \ | 34 | kcmconfigs/addresseewidget.h \ |
35 | kcmconfigs/extensionconfigdialog.h \ | 35 | kcmconfigs/extensionconfigdialog.h \ |
36 | kcmconfigs/kcmkabconfig.h \ | 36 | kcmconfigs/kcmkabconfig.h \ |
37 | kcmconfigs/kabconfigwidget.h \ | 37 | kcmconfigs/kabconfigwidget.h \ |
38 | addresseeeditordialog.h \ | 38 | addresseeeditordialog.h \ |
39 | addresseeeditorwidget.h \ | 39 | addresseeeditorwidget.h \ |
40 | addresseditwidget.h \ | 40 | addresseditwidget.h \ |
41 | addresseeconfig.h \ | 41 | addresseeconfig.h \ |
42 | addresseeutil.h \ | 42 | addresseeutil.h \ |
43 | emaileditwidget.h \ | 43 | emaileditwidget.h \ |
44 | filtereditdialog.h \ | 44 | filtereditdialog.h \ |
45 | kaddressbookmain.h \ | 45 | kaddressbookmain.h \ |
46 | kabprefs.h \ | 46 | kabprefs.h \ |
47 | kabcore.h \ | 47 | kabcore.h \ |
48 | viewmanager.h \ | 48 | viewmanager.h \ |
49 | extensionmanager.h \ | 49 | extensionmanager.h \ |
50 | extensionwidget.h \ | 50 | extensionwidget.h \ |
diff --git a/kaddressbook/kaddressbookmain.cpp b/kaddressbook/kaddressbookmain.cpp index c417226..b317974 100644 --- a/kaddressbook/kaddressbookmain.cpp +++ b/kaddressbook/kaddressbookmain.cpp | |||
@@ -1,120 +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 | #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 |
43 | KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "abmain" ) | 46 | KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "abmain" ) |
44 | #else //KAB_EMBEDDED | 47 | #else //KAB_EMBEDDED |
45 | //MOC_SKIP_BEGIN | 48 | #ifndef Q_MOC_RUN |
46 | KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 ) | 49 | KAddressBookMain::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 | ||
92 | KAddressBookMain::~KAddressBookMain() | 95 | KAddressBookMain::~KAddressBookMain() |
93 | { | 96 | { |
94 | // mCore->saveSettings(); | 97 | // mCore->saveSettings(); |
95 | } | 98 | } |
96 | 99 | ||
97 | void KAddressBookMain::showMinimized () | 100 | void KAddressBookMain::showMinimized () |
98 | { | 101 | { |
99 | QWidget::showMinimized () ; | 102 | QWidget::showMinimized () ; |
100 | } | 103 | } |
101 | void KAddressBookMain::addEmail( QString addr ) | 104 | void 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 |
107 | ASYNC KAddressBookMain::showContactEditor( QString uid ) | 110 | ASYNC KAddressBookMain::showContactEditor( QString uid ) |
108 | { | 111 | { |
109 | mCore->editContact( uid ); | 112 | mCore->editContact( uid ); |
110 | } | 113 | } |
111 | #endif //KAB_EMBEDDED | 114 | #endif //KAB_EMBEDDED |
112 | void KAddressBookMain::newContact() | 115 | void KAddressBookMain::newContact() |
113 | { | 116 | { |
114 | mCore->newContact(); | 117 | mCore->newContact(); |
115 | } | 118 | } |
116 | 119 | ||
117 | QString KAddressBookMain::getNameByPhone( QString phone ) | 120 | QString KAddressBookMain::getNameByPhone( QString phone ) |
118 | { | 121 | { |
119 | return mCore->getNameByPhone( phone ); | 122 | return mCore->getNameByPhone( phone ); |
120 | } | 123 | } |
@@ -206,36 +209,35 @@ void KAddressBookMain::closeEvent( QCloseEvent* ce ) | |||
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,110 +1,112 @@ | |||
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 |
30 | class QToolBar; | 32 | class 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 | ||
41 | class KABCore; | 43 | class KABCore; |
42 | class KConfig; | 44 | class 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 |
53 | class KAddressBookMain : public KMainWindow | 55 | class KAddressBookMain : public KMainWindow |
54 | #else //KAB_EMBEDDED | 56 | #else //KAB_EMBEDDED |
55 | //MOC_SKIP_BEGIN | 57 | #ifndef Q_MOC_RUN |
56 | class KAddressBookMain : public KMainWindow, virtual public KAddressBookIface | 58 | class 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(); |
diff --git a/kaddressbook/kaddressbookview.cpp b/kaddressbook/kaddressbookview.cpp index 86898e2..4823b37 100644 --- a/kaddressbook/kaddressbookview.cpp +++ b/kaddressbook/kaddressbookview.cpp | |||
@@ -3,64 +3,66 @@ | |||
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 | ||
42 | KAddressBookView::KAddressBookView( KABC::AddressBook *ab, QWidget *parent, | 44 | KAddressBookView::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 | ||
50 | KAddressBookView::~KAddressBookView() | 52 | KAddressBookView::~KAddressBookView() |
51 | { | 53 | { |
52 | 54 | ||
53 | } | 55 | } |
54 | 56 | ||
55 | QRegExp KAddressBookView::getRegExp( const QString s ) | 57 | QRegExp 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); |
@@ -104,85 +106,85 @@ QString KAddressBookView::selectedEmails() | |||
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 | ||
120 | KABC::Addressee::List KAddressBookView::addressees() | 122 | KABC::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 | ||
133 | void KAddressBookView::initGUI() | 135 | void 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 | ||
143 | KABC::Field::List KAddressBookView::fields() const | 145 | KABC::Field::List KAddressBookView::fields() const |
144 | { | 146 | { |
145 | return mFieldList; | 147 | return mFieldList; |
146 | } | 148 | } |
147 | KABC::Field::List KAddressBookView::allFields() const | 149 | KABC::Field::List KAddressBookView::allFields() const |
148 | { | 150 | { |
149 | return KABC::Field::allFields(); | 151 | return KABC::Field::allFields(); |
150 | } | 152 | } |
151 | 153 | ||
152 | void KAddressBookView::setFilter( const Filter &filter ) | 154 | void KAddressBookView::setFilter( const Filter &filter ) |
153 | { | 155 | { |
154 | mFilter = filter; | 156 | mFilter = filter; |
155 | } | 157 | } |
156 | 158 | ||
157 | KAddressBookView::DefaultFilterType KAddressBookView::defaultFilterType() const | 159 | KAddressBookView::DefaultFilterType KAddressBookView::defaultFilterType() const |
158 | { | 160 | { |
159 | return mDefaultFilterType; | 161 | return mDefaultFilterType; |
160 | } | 162 | } |
161 | 163 | ||
162 | const QString &KAddressBookView::defaultFilterName() const | 164 | const QString &KAddressBookView::defaultFilterName() const |
163 | { | 165 | { |
164 | return mDefaultFilterName; | 166 | return mDefaultFilterName; |
165 | } | 167 | } |
166 | 168 | ||
167 | KABC::AddressBook *KAddressBookView::addressBook() const | 169 | KABC::AddressBook *KAddressBookView::addressBook() const |
168 | { | 170 | { |
169 | return mAddressBook; | 171 | return mAddressBook; |
170 | } | 172 | } |
171 | 173 | ||
172 | QWidget *KAddressBookView::viewWidget() | 174 | QWidget *KAddressBookView::viewWidget() |
173 | { | 175 | { |
174 | return mViewWidget; | 176 | return mViewWidget; |
175 | } | 177 | } |
176 | 178 | ||
177 | ViewConfigureWidget *ViewFactory::configureWidget( KABC::AddressBook *ab, | 179 | ViewConfigureWidget *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,75 +1,77 @@ | |||
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 | ||
31 | class KConfig; | 33 | class KConfig; |
32 | class QDropEvent; | 34 | class 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 | ||
48 | namespace KABC { class AddressBook; } | 50 | namespace 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 | */ |
59 | class KAddressBookView : public QWidget | 61 | class 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; |
@@ -146,67 +148,67 @@ class KAddressBookView : public QWidget | |||
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 | ||
@@ -233,67 +235,67 @@ class KAddressBookView : public QWidget | |||
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 |
266 | class ViewFactory : public KLibFactory | 268 | class ViewFactory : public KLibFactory |
267 | //MOC_SKIP_END | 269 | #endif |
268 | #else //KAB_EMBEDDED | 270 | #else //KAB_EMBEDDED |
269 | class ViewFactory | 271 | class 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, |
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 | ||
42 | NamePartWidget::NamePartWidget( const QString &title, QWidget *parent, | 46 | NamePartWidget::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 | ||
108 | NamePartWidget::~NamePartWidget() | 112 | NamePartWidget::~NamePartWidget() |
109 | { | 113 | { |
110 | } | 114 | } |
111 | 115 | ||
112 | void NamePartWidget::setNameParts( const QStringList &list ) | 116 | void 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 | ||
118 | QStringList NamePartWidget::nameParts() const | 122 | QStringList 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 | ||
127 | void NamePartWidget::add() | 131 | void 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 | ||
137 | void NamePartWidget::remove() | 141 | void 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 | ||
146 | void NamePartWidget::selectionChanged( QListBoxItem *item ) | 150 | void NamePartWidget::selectionChanged( Q3ListBoxItem *item ) |
147 | { | 151 | { |
148 | mRemoveButton->setEnabled( item != 0 ); | 152 | mRemoveButton->setEnabled( item != 0 ); |
149 | } | 153 | } |
150 | 154 | ||
151 | void NamePartWidget::textChanged( const QString& text ) | 155 | void NamePartWidget::textChanged( const QString& text ) |
152 | { | 156 | { |
153 | mAddButton->setEnabled( !text.isEmpty() ); | 157 | mAddButton->setEnabled( !text.isEmpty() ); |
154 | } | 158 | } |
155 | 159 | ||
156 | 160 | ||
157 | AddresseeWidget::AddresseeWidget( QWidget *parent, const char *name ) | 161 | AddresseeWidget::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 | ||
209 | AddresseeWidget::~AddresseeWidget() | 213 | AddresseeWidget::~AddresseeWidget() |
210 | { | 214 | { |
211 | } | 215 | } |
212 | 216 | ||
213 | void AddresseeWidget::restoreSettings() | 217 | void 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 | ||
224 | void AddresseeWidget::saveSettings() | 228 | void 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 | ||
29 | class KComboBox; | 29 | class KComboBox; |
30 | class KLineEdit; | 30 | class KLineEdit; |
31 | 31 | ||
32 | class QListBox; | 32 | class Q3ListBox; |
33 | class QListBoxItem; | 33 | class Q3ListBoxItem; |
34 | class QPushButton; | 34 | class QPushButton; |
35 | 35 | ||
36 | class NamePartWidget : public QWidget | 36 | class 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 | ||
66 | class AddresseeWidget : public QWidget | 66 | class 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 | ||
32 | ExtensionConfigDialog::ExtensionConfigDialog( ExtensionFactory *factory, KConfig *config, | 35 | ExtensionConfigDialog::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 | ||
46 | ExtensionConfigDialog::~ExtensionConfigDialog() | 49 | ExtensionConfigDialog::~ExtensionConfigDialog() |
47 | { | 50 | { |
48 | } | 51 | } |
49 | 52 | ||
50 | void ExtensionConfigDialog::slotOk() | 53 | void 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,227 +1,231 @@ | |||
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 | ||
60 | class ExtensionItem : public QCheckListItem | 64 | class 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 | ||
89 | KABConfigWidget::KABConfigWidget( KABPrefs* prefs, QWidget *parent, const char *name ) | 93 | KABConfigWidget::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 | ||
208 | void KABConfigWidget::usrReadConfig() | 212 | void 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 | ||
@@ -266,159 +270,158 @@ void KABConfigWidget::restoreExtensionSettings() | |||
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 | ||
294 | void KABConfigWidget::saveExtensionSettings() | 298 | void 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 | ||
312 | void KABConfigWidget::configureExtension() | 316 | void 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 | ||
331 | void KABConfigWidget::selectionChanged( QListViewItem *i ) | 335 | void 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 | ||
340 | void KABConfigWidget::itemClicked( QListViewItem *item ) | 344 | void 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 |
347 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text ) | 351 | ExtensionItem::ExtensionItem( Q3ListView *parent, const QString &text ) |
348 | : QCheckListItem( parent, text, CheckBox ) | 352 | : Q3CheckListItem( parent, text, CheckBox ) |
349 | { | 353 | { |
350 | } | 354 | } |
351 | 355 | ||
352 | void ExtensionItem::setService( const KService::Ptr &ptr ) | 356 | void ExtensionItem::setService( const KService::Ptr &ptr ) |
353 | { | 357 | { |
354 | mPtr = ptr; | 358 | mPtr = ptr; |
355 | } | 359 | } |
356 | #else //KAB_EMBEDDED | 360 | #else //KAB_EMBEDDED |
357 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ) | 361 | ExtensionItem::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 | ||
365 | void ExtensionItem::setFactory( ExtensionFactory* fac ) | 369 | void ExtensionItem::setFactory( ExtensionFactory* fac ) |
366 | { | 370 | { |
367 | mFactory = fac; | 371 | mFactory = fac; |
368 | } | 372 | } |
369 | #endif //KAB_EMBEDDED | 373 | #endif //KAB_EMBEDDED |
370 | 374 | ||
371 | bool ExtensionItem::configWidgetAvailable() const | 375 | bool 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 | ||
389 | ExtensionFactory *ExtensionItem::factory() const | 393 | ExtensionFactory *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 | ||
402 | QString ExtensionItem::text( int column ) const | 406 | QString 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 | ||
29 | class QCheckBox; | 29 | class QCheckBox; |
30 | class QListViewItem; | 30 | class Q3ListViewItem; |
31 | class QPushButton; | 31 | class QPushButton; |
32 | class QComboBox; | 32 | class QComboBox; |
33 | class QLineEdit; | 33 | class QLineEdit; |
34 | class KListView; | 34 | class KListView; |
35 | class KABPrefs; | 35 | class KABPrefs; |
36 | 36 | ||
37 | class AddresseeWidget; | 37 | class AddresseeWidget; |
38 | 38 | ||
39 | class KABConfigWidget : public KPrefsWidget | 39 | class 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 | ||
40 | extern "C" | 42 | extern "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 | ||
47 | KCMKabConfig::KCMKabConfig( QWidget *parent, const char *name ) | 49 | KCMKabConfig::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 | ||
60 | void KCMKabConfig::load() | 62 | void KCMKabConfig::load() |
61 | { | 63 | { |
62 | mConfigWidget->readConfig(); | 64 | mConfigWidget->readConfig(); |
63 | } | 65 | } |
64 | 66 | ||
65 | void KCMKabConfig::save() | 67 | void KCMKabConfig::save() |
66 | { | 68 | { |
67 | mConfigWidget->writeConfig(); | 69 | mConfigWidget->writeConfig(); |
68 | } | 70 | } |
69 | 71 | ||
70 | void KCMKabConfig::defaults() | 72 | void KCMKabConfig::defaults() |
71 | { | 73 | { |
72 | mConfigWidget->setDefaults(); | 74 | mConfigWidget->setDefaults(); |
73 | } | 75 | } |
74 | 76 | ||
75 | #ifndef KAB_EMBEDDED | 77 | #ifndef KAB_EMBEDDED |
76 | const KAboutData* KCMKabConfig::aboutData() const | 78 | const 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,87 +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 | #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 | ||
52 | KeyWidget::KeyWidget( QWidget *parent, const char *name ) | 54 | KeyWidget::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 | ||
80 | KeyWidget::~KeyWidget() | 82 | KeyWidget::~KeyWidget() |
81 | { | 83 | { |
82 | } | 84 | } |
83 | 85 | ||
84 | void KeyWidget::setKeys( const KABC::Key::List &list ) | 86 | void KeyWidget::setKeys( const KABC::Key::List &list ) |
85 | { | 87 | { |
86 | mKeyList = list; | 88 | mKeyList = list; |
87 | 89 | ||
@@ -107,171 +109,171 @@ void KeyWidget::addKey() | |||
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 | ||
189 | void KeyWidget::removeKey() | 191 | void 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 | ||
216 | void KeyWidget::exportKey() | 218 | void 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 | ||
255 | void KeyWidget::updateKeyCombo() | 257 | void 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,64 +1,63 @@ | |||
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> |
24 | void dumpMissing(); | 23 | void dumpMissing(); |
25 | int main( int argc, char **argv ) | 24 | int 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 |
diff --git a/kaddressbook/nameeditdialog.cpp b/kaddressbook/nameeditdialog.cpp index 199f3d6..96822d8 100644 --- a/kaddressbook/nameeditdialog.cpp +++ b/kaddressbook/nameeditdialog.cpp | |||
@@ -1,92 +1,94 @@ | |||
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 | ||
53 | NameEditDialog::NameEditDialog( const KABC::Addressee &addr, int type, | 55 | NameEditDialog::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 ); |
@@ -266,35 +268,35 @@ void NameEditDialog::modified() | |||
266 | mChanged = true; | 268 | mChanged = true; |
267 | } | 269 | } |
268 | 270 | ||
269 | void NameEditDialog::updateTypeCombo() | 271 | void 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 | ||
289 | void NameEditDialog::slotHelp() | 291 | void 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 |
294 | qDebug("NameEditDialog::slotHelp Help is not supported yet"); | 296 | qDebug("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 | |||
@@ -287,71 +287,71 @@ void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | |||
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 | ||
297 | QPixmap MainWindow::loadPixmap( QString name ) | 297 | QPixmap 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 | ||
314 | void MainWindow::initActions() | 314 | void 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 ); |
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp index df3b551..3661677 100644 --- a/kaddressbook/phoneeditwidget.cpp +++ b/kaddressbook/phoneeditwidget.cpp | |||
@@ -1,125 +1,131 @@ | |||
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 | ||
57 | PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name ) | 63 | PhoneEditWidget::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 | ||
105 | PhoneEditWidget::~PhoneEditWidget() | 111 | PhoneEditWidget::~PhoneEditWidget() |
106 | { | 112 | { |
107 | } | 113 | } |
108 | void PhoneEditWidget::setDefaults() | 114 | void 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 | } |
125 | void PhoneEditWidget::addNumberInt( int index ) | 131 | void PhoneEditWidget::addNumberInt( int index ) |
@@ -197,75 +203,75 @@ void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &li ) | |||
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 | } |
210 | KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() | 216 | KABC::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 |
226 | PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name ) | 232 | PhoneEditWidget::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 ); |
@@ -298,75 +304,75 @@ PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name ) | |||
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 | ||
319 | PhoneEditWidget::~PhoneEditWidget() | 325 | PhoneEditWidget::~PhoneEditWidget() |
320 | { | 326 | { |
321 | } | 327 | } |
322 | 328 | ||
323 | void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &list ) | 329 | void 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 | ||
356 | void PhoneEditWidget::updateLineEdits() | 362 | void PhoneEditWidget::updateLineEdits() |
357 | { | 363 | { |
358 | updatePrefEdit(); | 364 | updatePrefEdit(); |
359 | updateSecondEdit(); | 365 | updateSecondEdit(); |
360 | updateThirdEdit(); | 366 | updateThirdEdit(); |
361 | updateFourthEdit(); | 367 | updateFourthEdit(); |
362 | } | 368 | } |
363 | 369 | ||
364 | void PhoneEditWidget::updateCombos() | 370 | void 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 | ||
372 | KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() | 378 | KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() |
@@ -458,274 +464,274 @@ void PhoneEditWidget::slotFourthEditChanged() | |||
458 | } | 464 | } |
459 | 465 | ||
460 | void PhoneEditWidget::updatePhoneNumber( PhoneTypeCombo *combo ) | 466 | void 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 | ||
478 | void PhoneEditWidget::updateOtherEdit( PhoneTypeCombo *combo, PhoneTypeCombo *otherCombo ) | 484 | void 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 | ||
490 | class PhoneViewItem : public QListViewItem | 496 | class PhoneViewItem : public Q3ListViewItem |
491 | { | 497 | { |
492 | public: | 498 | public: |
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 | ||
508 | private: | 514 | private: |
509 | void makeText(); | 515 | void makeText(); |
510 | 516 | ||
511 | KABC::PhoneNumber mPhoneNumber; | 517 | KABC::PhoneNumber mPhoneNumber; |
512 | }; | 518 | }; |
513 | 519 | ||
514 | PhoneViewItem::PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number ) | 520 | PhoneViewItem::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 | ||
523 | void PhoneViewItem::makeText() | 529 | void 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 | ||
538 | PhoneEditDialog::PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget *parent, const char *name ) | 544 | PhoneEditDialog::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 | ||
580 | PhoneEditDialog::~PhoneEditDialog() | 586 | PhoneEditDialog::~PhoneEditDialog() |
581 | { | 587 | { |
582 | qDebug("PhoneEditDialog::~PhoneEditDialog() "); | 588 | qDebug("PhoneEditDialog::~PhoneEditDialog() "); |
583 | } | 589 | } |
584 | 590 | ||
585 | void PhoneEditDialog::slotAddPhoneNumber() | 591 | void 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 | ||
616 | void PhoneEditDialog::slotRemovePhoneNumber() | 622 | void 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 | ||
630 | void PhoneEditDialog::slotEditPhoneNumber() | 636 | void 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 | ||
648 | void PhoneEditDialog::slotSelectionChanged() | 654 | void 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 | ||
656 | const KABC::PhoneNumber::List &PhoneEditDialog::phoneNumbers() | 662 | const KABC::PhoneNumber::List &PhoneEditDialog::phoneNumbers() |
657 | { | 663 | { |
658 | return mPhoneNumberList; | 664 | return mPhoneNumberList; |
659 | } | 665 | } |
660 | 666 | ||
661 | bool PhoneEditDialog::changed() const | 667 | bool PhoneEditDialog::changed() const |
662 | { | 668 | { |
663 | return mChanged; | 669 | return mChanged; |
664 | } | 670 | } |
665 | 671 | ||
666 | /////////////////////////////////////////// | 672 | /////////////////////////////////////////// |
667 | // PhoneTypeDialog | 673 | // PhoneTypeDialog |
668 | PhoneTypeDialog::PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber, | 674 | PhoneTypeDialog::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 | ||
710 | KABC::PhoneNumber PhoneTypeDialog::phoneNumber() | 716 | KABC::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,137 +1,141 @@ | |||
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 | ||
39 | class QButtonGroup; | 43 | class Q3ButtonGroup; |
40 | class QCheckBox; | 44 | class QCheckBox; |
41 | class PhoneTypeNumberEdit; | 45 | class 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 | ||
47 | typedef TypeCombo<KABC::PhoneNumber> PhoneTypeCombo; | 51 | typedef TypeCombo<KABC::PhoneNumber> PhoneTypeCombo; |
48 | 52 | ||
49 | /** | 53 | /** |
50 | Widget for editing phone numbers. | 54 | Widget for editing phone numbers. |
51 | */ | 55 | */ |
52 | class PhoneEditWidget : public QWidget | 56 | class 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 | ||
92 | class PhoneTypeNumberEdit : public QWidget | 96 | class PhoneTypeNumberEdit : public QWidget |
93 | { | 97 | { |
94 | Q_OBJECT | 98 | Q_OBJECT |
95 | public: | 99 | public: |
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 | { |
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 | ||
32 | SecrecyWidget::SecrecyWidget( QWidget *parent, const char *name ) | 34 | SecrecyWidget::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 | ||
49 | SecrecyWidget::~SecrecyWidget() | 51 | SecrecyWidget::~SecrecyWidget() |
50 | { | 52 | { |
51 | } | 53 | } |
52 | 54 | ||
53 | void SecrecyWidget::setSecrecy( const KABC::Secrecy &secrecy ) | 55 | void 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 | ||
60 | KABC::Secrecy SecrecyWidget::secrecy() const | 62 | KABC::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 | |||
@@ -85,35 +85,35 @@ void UndoStack::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 | ||
92 | RedoStack* RedoStack::instance_ = 0; | 92 | RedoStack* RedoStack::instance_ = 0; |
93 | 93 | ||
94 | RedoStack::RedoStack() | 94 | RedoStack::RedoStack() |
95 | { | 95 | { |
96 | mCommandStack.setAutoDelete( true ); | 96 | mCommandStack.setAutoDelete( true ); |
97 | } | 97 | } |
98 | 98 | ||
99 | RedoStack* RedoStack::instance() | 99 | RedoStack* 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 | ||
106 | void RedoStack::redo() | 106 | void 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 | ||
31 | class Command | 31 | class Command |
32 | { | 32 | { |
33 | public: | 33 | public: |
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 | */ |
49 | class StackBase : public QObject | 49 | class 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 | ||
73 | class UndoStack : public StackBase | 73 | class UndoStack : public StackBase |
74 | { | 74 | { |
75 | public: | 75 | public: |
76 | static UndoStack *instance(); | 76 | static UndoStack *instance(); |
77 | void undo(); | 77 | void undo(); |
78 | 78 | ||
79 | protected: | 79 | protected: |
80 | UndoStack(); | 80 | UndoStack(); |
81 | static UndoStack* instance_; | 81 | static UndoStack* instance_; |
82 | }; | 82 | }; |
83 | 83 | ||
84 | class RedoStack : public StackBase | 84 | class RedoStack : public StackBase |
85 | { | 85 | { |
86 | public: | 86 | public: |
87 | static RedoStack *instance(); | 87 | static RedoStack *instance(); |
88 | void redo(); | 88 | void redo(); |
89 | 89 | ||
90 | protected: | 90 | protected: |
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,56 +1,56 @@ | |||
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" |
39 | extern bool pasteWithNewUid; | 39 | extern bool pasteWithNewUid; |
40 | ///////////////////////////////// | 40 | ///////////////////////////////// |
41 | // PwDelete Methods | 41 | // PwDelete Methods |
42 | 42 | ||
43 | PwDeleteCommand::PwDeleteCommand(KABC::AddressBook *doc, | 43 | PwDeleteCommand::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 | ||
50 | PwDeleteCommand::~PwDeleteCommand() | 50 | PwDeleteCommand::~PwDeleteCommand() |
51 | { | 51 | { |
52 | } | 52 | } |
53 | 53 | ||
54 | QString PwDeleteCommand::name() | 54 | QString PwDeleteCommand::name() |
55 | { | 55 | { |
56 | return i18n( "Delete" ); | 56 | return i18n( "Delete" ); |
diff --git a/kaddressbook/viewconfigurefieldspage.cpp b/kaddressbook/viewconfigurefieldspage.cpp index 5daae1a..7366a0b 100644 --- a/kaddressbook/viewconfigurefieldspage.cpp +++ b/kaddressbook/viewconfigurefieldspage.cpp | |||
@@ -7,135 +7,139 @@ | |||
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 | ||
45 | class FieldItem : public QListBoxText | 49 | class 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 | ||
62 | ViewConfigureFieldsPage::ViewConfigureFieldsPage( KABC::AddressBook *ab, | 66 | ViewConfigureFieldsPage::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 | ||
70 | void ViewConfigureFieldsPage::restoreSettings( KConfig *config ) | 74 | void 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 | ||
84 | void ViewConfigureFieldsPage::saveSettings( KConfig *config ) | 88 | void 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 | ||
96 | void ViewConfigureFieldsPage::slotShowFields( int index ) | 100 | void 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 | ||
125 | void ViewConfigureFieldsPage::slotSelect() | 129 | void 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 | ||
@@ -160,192 +164,192 @@ void ViewConfigureFieldsPage::slotButtonsEnabled() | |||
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 | ||
188 | void ViewConfigureFieldsPage::slotMoveUp() | 192 | void 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 | ||
200 | void ViewConfigureFieldsPage::slotMoveDown() | 204 | void 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 | ||
212 | void ViewConfigureFieldsPage::initGUI() | 216 | void 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 | |||
@@ -6,76 +6,76 @@ | |||
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 |
33 | class KComboBox; | 33 | class KComboBox; |
34 | #else //KAB_EMBEDDED | 34 | #else //KAB_EMBEDDED |
35 | class QComboBox; | 35 | class QComboBox; |
36 | #endif //KAB_EMBEDDED | 36 | #endif //KAB_EMBEDDED |
37 | 37 | ||
38 | class QListBox; | 38 | class Q3ListBox; |
39 | class QListBoxItem; | 39 | class Q3ListBoxItem; |
40 | class QPushButton; | 40 | class QPushButton; |
41 | class QToolButton; | 41 | class QToolButton; |
42 | 42 | ||
43 | class ViewConfigureFieldsPage : public QWidget | 43 | class 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 | ||
43 | ViewConfigureFilterPage::ViewConfigureFilterPage( QWidget *parent, | 46 | ViewConfigureFilterPage::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 | ||
86 | ViewConfigureFilterPage::~ViewConfigureFilterPage() | 89 | ViewConfigureFilterPage::~ViewConfigureFilterPage() |
87 | { | 90 | { |
88 | delete mFilterGroup; | 91 | delete mFilterGroup; |
89 | } | 92 | } |
90 | 93 | ||
91 | void ViewConfigureFilterPage::restoreSettings( KConfig *config ) | 94 | void 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 | ||
124 | void ViewConfigureFilterPage::saveSettings( KConfig *config ) | 127 | void 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 | ||
130 | void ViewConfigureFilterPage::buttonClicked( int id ) | 133 | void 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 | ||
29 | class QButtonGroup; | 29 | class Q3ButtonGroup; |
30 | 30 | ||
31 | #ifndef KAB_EMBEDDED | 31 | #ifndef KAB_EMBEDDED |
32 | class KComboBox; | 32 | class KComboBox; |
33 | #else //KAB_EMBEDDED | 33 | #else //KAB_EMBEDDED |
34 | class QComboBox; | 34 | class QComboBox; |
35 | #endif //KAB_EMBEDDED | 35 | #endif //KAB_EMBEDDED |
36 | 36 | ||
37 | class KConfig; | 37 | class KConfig; |
38 | 38 | ||
39 | class ViewConfigureFilterPage : public QWidget | 39 | class 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 | ||
49 | ViewConfigureWidget::ViewConfigureWidget( KABC::AddressBook *ab, QWidget *parent, | 52 | ViewConfigureWidget::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 | ||
79 | ViewConfigureWidget::~ViewConfigureWidget() | 82 | ViewConfigureWidget::~ViewConfigureWidget() |
80 | { | 83 | { |
81 | //qDebug("-----ViewConfigureWidget::~ViewConfigureWidget() "); | 84 | //qDebug("-----ViewConfigureWidget::~ViewConfigureWidget() "); |
82 | } | 85 | } |
83 | 86 | ||
84 | void ViewConfigureWidget::restoreSettings( KConfig *config ) | 87 | void 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 | ||
90 | void ViewConfigureWidget::saveSettings( KConfig *config ) | 93 | void 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 | ||
96 | QVBox *ViewConfigureWidget::addPage( const QString &item, const QString &header, | 99 | Q3VBox *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 | ||
107 | ViewConfigureDialog::ViewConfigureDialog( ViewConfigureWidget *wdg, const QString &viewName, | 110 | ViewConfigureDialog::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 | ||
126 | ViewConfigureDialog::~ViewConfigureDialog() | 129 | ViewConfigureDialog::~ViewConfigureDialog() |
127 | { | 130 | { |
128 | } | 131 | } |
129 | void ViewConfigureDialog::setWidget( ViewConfigureWidget *wdg ) | 132 | void ViewConfigureDialog::setWidget( ViewConfigureWidget *wdg ) |
130 | { | 133 | { |
131 | mConfigWidget = wdg ; | 134 | mConfigWidget = wdg ; |
132 | setMainWidget( mConfigWidget ); | 135 | setMainWidget( mConfigWidget ); |
133 | 136 | ||
134 | } | 137 | } |
135 | 138 | ||
136 | void ViewConfigureDialog::restoreSettings( KConfig *config ) | 139 | void ViewConfigureDialog::restoreSettings( KConfig *config ) |
137 | { | 140 | { |
138 | mConfigWidget->restoreSettings( config ); | 141 | mConfigWidget->restoreSettings( config ); |
139 | } | 142 | } |
140 | 143 | ||
141 | void ViewConfigureDialog::saveSettings( KConfig *config ) | 144 | void ViewConfigureDialog::saveSettings( KConfig *config ) |
142 | { | 145 | { |
143 | mConfigWidget->saveSettings( config ); | 146 | mConfigWidget->saveSettings( config ); |
144 | } | 147 | } |
145 | 148 | ||
146 | void ViewConfigureDialog::slotHelp() | 149 | void 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 | ||
31 | class QVBox; | 31 | class Q3VBox; |
32 | 32 | ||
33 | #include <kdialogbase.h> | 33 | #include <kdialogbase.h> |
34 | #include <qpixmap.h> | 34 | #include <qpixmap.h> |
35 | 35 | ||
36 | class KJanusWidget; | 36 | class KJanusWidget; |
37 | class QString; | 37 | class QString; |
38 | class ViewConfigureFieldsPage; | 38 | class ViewConfigureFieldsPage; |
39 | class ViewConfigureFilterPage; | 39 | class ViewConfigureFilterPage; |
40 | class ViewConfigureDialog; | 40 | class 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 | */ |
48 | class ViewConfigureWidget : public ConfigureWidget | 48 | class 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 | ||
87 | class ViewConfigureDialog : public KDialogBase | 87 | class 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 | |||
@@ -21,176 +21,180 @@ | |||
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | 31 | ||
32 | #ifndef KAB_EMBEDDED | 32 | #ifndef KAB_EMBEDDED |
33 | #include <libkdepim/kvcarddrag.h> | 33 | #include <libkdepim/kvcarddrag.h> |
34 | #include <kabc/vcardconverter.h> | 34 | #include <kabc/vcardconverter.h> |
35 | #include <kconfig.h> | 35 | #include <kconfig.h> |
36 | #include <kdeversion.h> | 36 | #include <kdeversion.h> |
37 | #include <kiconloader.h> | 37 | #include <kiconloader.h> |
38 | #include <klocale.h> | 38 | #include <klocale.h> |
39 | #include <kmessagebox.h> | 39 | #include <kmessagebox.h> |
40 | #include <kmultipledrag.h> | 40 | #include <kmultipledrag.h> |
41 | #include <ktrader.h> | 41 | #include <ktrader.h> |
42 | #include <kurldrag.h> | 42 | #include <kurldrag.h> |
43 | 43 | ||
44 | #include "addresseeutil.h" | 44 | #include "addresseeutil.h" |
45 | #else //KAB_EMBEDDED | 45 | #else //KAB_EMBEDDED |
46 | #include "views/kaddressbookiconview.h" | 46 | #include "views/kaddressbookiconview.h" |
47 | #include "views/kaddressbooktableview.h" | 47 | #include "views/kaddressbooktableview.h" |
48 | #include "views/kaddressbookcardview.h" | 48 | #include "views/kaddressbookcardview.h" |
49 | #include "kaddressbookview.h" | 49 | #include "kaddressbookview.h" |
50 | 50 | ||
51 | #include <qaction.h> | 51 | #include <qaction.h> |
52 | #include <qmessagebox.h> | 52 | #include <qmessagebox.h> |
53 | #include <qpopupmenu.h> | 53 | #include <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 | ||
73 | ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) | 77 | ViewManager::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 | ||
84 | ViewManager::~ViewManager() | 88 | ViewManager::~ViewManager() |
85 | { | 89 | { |
86 | unloadViews(); | 90 | unloadViews(); |
87 | mViewFactoryDict.clear(); | 91 | mViewFactoryDict.clear(); |
88 | } | 92 | } |
89 | void ViewManager::scrollUP() | 93 | void ViewManager::scrollUP() |
90 | { | 94 | { |
91 | if ( mActiveView ) | 95 | if ( mActiveView ) |
92 | mActiveView->scrollUP(); | 96 | mActiveView->scrollUP(); |
93 | } | 97 | } |
94 | void ViewManager::scrollDOWN() | 98 | void ViewManager::scrollDOWN() |
95 | { | 99 | { |
96 | if ( mActiveView ) | 100 | if ( mActiveView ) |
97 | mActiveView->scrollDOWN(); | 101 | mActiveView->scrollDOWN(); |
98 | } | 102 | } |
99 | void ViewManager::restoreSettings() | 103 | void 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 | ||
130 | void ViewManager::saveSettings() | 134 | void 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 | ||
153 | QStringList ViewManager::selectedUids() const | 157 | QStringList 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 | ||
161 | QStringList ViewManager::selectedEmails() const | 165 | QStringList 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 | ||
169 | KABC::Addressee::List ViewManager::selectedAddressees() const | 173 | KABC::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. |
185 | void ViewManager::setSelected() | 189 | void ViewManager::setSelected() |
186 | { | 190 | { |
187 | setSelected( QString::null, true ); | 191 | setSelected( QString::null, true ); |
188 | } | 192 | } |
189 | 193 | ||
190 | void ViewManager::setSelected( const QString &uid, bool selected ) | 194 | void 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 | ||
196 | void ViewManager::setListSelected(QStringList list) | 200 | void ViewManager::setListSelected(QStringList list) |
@@ -527,65 +531,65 @@ void ViewManager::dropped( QDropEvent *e ) | |||
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 |
540 | qDebug("ViewManager::dropped() has to be changed!!" ); | 544 | qDebug("ViewManager::dropped() has to be changed!!" ); |
541 | #endif //KAB_EMBEDDED | 545 | #endif //KAB_EMBEDDED |
542 | 546 | ||
543 | } | 547 | } |
544 | 548 | ||
545 | void ViewManager::startDrag() | 549 | void 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 |
574 | qDebug("ViewManager::startDrag() has to be changed!!" ); | 578 | qDebug("ViewManager::startDrag() has to be changed!!" ); |
575 | #endif //KAB_EMBEDDED | 579 | #endif //KAB_EMBEDDED |
576 | 580 | ||
577 | } | 581 | } |
578 | void ViewManager::doSearch( const QString& s,KABC::Field *field ) | 582 | void 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 | } |
584 | void ViewManager::setActiveFilter( int index ) | 588 | void 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 ]; |
@@ -630,67 +634,67 @@ QStringList ViewManager::filterNames() const | |||
630 | names.append( (*it).name() ); | 634 | names.append( (*it).name() ); |
631 | 635 | ||
632 | return names; | 636 | return names; |
633 | } | 637 | } |
634 | Filter ViewManager::getFilterByName( const QString &name ) const | 638 | Filter 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 | ||
644 | int ViewManager::filterPosition( const QString &name ) const | 648 | int 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 | ||
656 | void ViewManager::initActions() | 660 | void 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 |
@@ -709,40 +713,40 @@ void ViewManager::initActions() | |||
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 | ||
739 | void ViewManager::initGUI() | 743 | void 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,69 +1,71 @@ | |||
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 | ||
33 | class KAction; | 35 | class KAction; |
34 | class KSelectAction; | 36 | class KSelectAction; |
35 | 37 | ||
36 | class KABCore; | 38 | class KABCore; |
37 | class QWidgetStack; | 39 | class Q3WidgetStack; |
38 | class QDropEvent; | 40 | class QDropEvent; |
39 | 41 | ||
40 | namespace KABC { class AddressBook; } | 42 | namespace 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 | */ |
50 | class ViewManager : public QWidget | 52 | class 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(); |
@@ -116,46 +118,46 @@ class ViewManager : public QWidget | |||
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 | |||
@@ -5,106 +5,114 @@ | |||
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 |
48 | class CardViewTip : public QLabel { | 56 | class 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 | // |
74 | class CardViewItemList : public QPtrList<CardViewItem> | 82 | class 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 |
107 | class CardViewSeparator | 115 | class CardViewSeparator |
108 | { | 116 | { |
109 | friend class CardView; | 117 | friend class CardView; |
110 | 118 | ||
@@ -132,112 +140,112 @@ class CardViewSeparator | |||
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 | ||
140 | class CardViewPrivate | 148 | class 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 | ||
201 | class CardViewItemPrivate | 209 | class 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 | ||
222 | CardViewItem::CardViewItem(CardView *parent, QString caption) | 230 | CardViewItem::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 | ||
230 | CardViewItem::~CardViewItem() | 238 | CardViewItem::~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 | ||
240 | void CardViewItem::initialize() | 248 | void CardViewItem::initialize() |
241 | { | 249 | { |
242 | d->mSelected = false; | 250 | d->mSelected = false; |
243 | d->mFieldList.setAutoDelete(true); | 251 | d->mFieldList.setAutoDelete(true); |
@@ -284,65 +292,65 @@ void CardViewItem::paintCard(QPainter *p, QColorGroup &cg) | |||
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++) |
@@ -379,107 +387,107 @@ void CardViewItem::paintCard(QPainter *p, QColorGroup &cg) | |||
379 | } | 387 | } |
380 | 388 | ||
381 | const QString &CardViewItem::caption() const | 389 | const QString &CardViewItem::caption() const |
382 | { | 390 | { |
383 | return d->mCaption; | 391 | return d->mCaption; |
384 | } | 392 | } |
385 | 393 | ||
386 | 394 | ||
387 | int CardViewItem::height( bool allowCache ) const | 395 | int 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 | ||
426 | bool CardViewItem::isSelected() const | 434 | bool CardViewItem::isSelected() const |
427 | { | 435 | { |
428 | return d->mSelected; | 436 | return d->mSelected; |
429 | } | 437 | } |
430 | 438 | ||
431 | void CardViewItem::setSelected(bool selected) | 439 | void CardViewItem::setSelected(bool selected) |
432 | { | 440 | { |
433 | d->mSelected = selected; | 441 | d->mSelected = selected; |
434 | } | 442 | } |
435 | 443 | ||
436 | void CardViewItem::insertField(const QString &label, const QString &value) | 444 | void 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 | ||
449 | void CardViewItem::removeField(const QString &label) | 457 | void 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 | ||
469 | void CardViewItem::clearFields() | 477 | void 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 | ||
478 | QString CardViewItem::trimString(const QString &text, int width, | 486 | QString 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); |
@@ -494,204 +502,204 @@ QString CardViewItem::trimString(const QString &text, int width, | |||
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 | ||
502 | CardViewItem *CardViewItem::nextItem() | 510 | CardViewItem *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 | ||
512 | void CardViewItem::repaintCard() | 520 | void CardViewItem::repaintCard() |
513 | { | 521 | { |
514 | if (mView) | 522 | if (mView) |
515 | mView->repaintItem(this); | 523 | mView->repaintItem(this); |
516 | } | 524 | } |
517 | 525 | ||
518 | void CardViewItem::setCaption(const QString &caption) | 526 | void CardViewItem::setCaption(const QString &caption) |
519 | { | 527 | { |
520 | d->mCaption = caption; | 528 | d->mCaption = caption; |
521 | repaintCard(); | 529 | repaintCard(); |
522 | } | 530 | } |
523 | 531 | ||
524 | QString CardViewItem::fieldValue(const QString &label) | 532 | QString 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 | ||
535 | void CardViewItem::showFullString( const QPoint &itempos, CardViewTip *tip ) | 543 | void 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 | ||
614 | CardViewItem::Field *CardViewItem::fieldAt( const QPoint & itempos ) const | 622 | CardViewItem::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 | ||
639 | CardView::CardView(QWidget *parent, const char *name) | 647 | CardView::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 | ||
671 | CardView::~CardView() | 679 | CardView::~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 | ||
679 | void CardView::insertItem(CardViewItem *item) | 687 | void 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 | ||
685 | void CardView::takeItem(CardViewItem *item) | 693 | void 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 | ||
694 | void CardView::clear() | 702 | void CardView::clear() |
695 | { | 703 | { |
696 | d->mItemList.clear(); | 704 | d->mItemList.clear(); |
697 | 705 | ||
@@ -710,113 +718,113 @@ void CardView::setCurrentItem( CardViewItem *item ) | |||
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 | ||
739 | CardViewItem *CardView::itemAt(const QPoint &viewPos) | 747 | CardViewItem *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 | ||
758 | QRect CardView::itemRect(const CardViewItem *item) | 766 | QRect 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 | ||
764 | void CardView::ensureItemVisible(const CardViewItem *item) | 772 | void 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 | ||
770 | void CardView::repaintItem(const CardViewItem *item) | 778 | void 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 | ||
776 | void CardView::setSelectionMode(CardView::SelectionMode mode) | 784 | void 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 | ||
783 | CardView::SelectionMode CardView::selectionMode() const | 791 | CardView::SelectionMode CardView::selectionMode() const |
784 | { | 792 | { |
785 | return d->mSelectionMode; | 793 | return d->mSelectionMode; |
786 | } | 794 | } |
787 | 795 | ||
788 | void CardView::selectAll(bool state) | 796 | void 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 | ||
821 | void CardView::setSelected(CardViewItem *item, bool selected) | 829 | void CardView::setSelected(CardViewItem *item, bool selected) |
822 | { | 830 | { |
@@ -849,65 +857,65 @@ void CardView::setSelected(CardViewItem *item, bool selected) | |||
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 | ||
873 | bool CardView::isSelected(CardViewItem *item) const | 881 | bool CardView::isSelected(CardViewItem *item) const |
874 | { | 882 | { |
875 | return (item && item->isSelected()); | 883 | return (item && item->isSelected()); |
876 | } | 884 | } |
877 | 885 | ||
878 | CardViewItem *CardView::selectedItem() const | 886 | CardViewItem *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 | ||
891 | CardViewItem *CardView::firstItem() const | 899 | CardViewItem *CardView::firstItem() const |
892 | { | 900 | { |
893 | return d->mItemList.first(); | 901 | return d->mItemList.first(); |
894 | } | 902 | } |
895 | 903 | ||
896 | int CardView::childCount() const | 904 | int CardView::childCount() const |
897 | { | 905 | { |
898 | return d->mItemList.count(); | 906 | return d->mItemList.count(); |
899 | } | 907 | } |
900 | /*US | 908 | /*US |
901 | CardViewItem *CardView::findItem(const QString &text, const QString &label, | 909 | CardViewItem *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) |
@@ -926,211 +934,211 @@ CardViewItem *CardView::findItem(const QString &text, const QString &label, | |||
926 | } | 934 | } |
927 | */ | 935 | */ |
928 | 936 | ||
929 | uint CardView::columnWidth() | 937 | uint 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 | ||
936 | void CardView::drawContents(QPainter *p, int clipx, int clipy, | 944 | void 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 | ||
994 | void CardView::resizeEvent(QResizeEvent *e) | 1002 | void 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 | ||
1001 | void CardView::calcLayout() | 1009 | void 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 | ||
1068 | CardViewItem *CardView::itemAfter(CardViewItem *item) | 1076 | CardViewItem *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 | ||
1074 | uint CardView::itemMargin() | 1082 | uint CardView::itemMargin() |
1075 | { | 1083 | { |
1076 | return d->mItemMargin; | 1084 | return d->mItemMargin; |
1077 | } | 1085 | } |
1078 | 1086 | ||
1079 | void CardView::setItemMargin( uint margin ) | 1087 | void 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 | ||
1088 | uint CardView::itemSpacing() | 1096 | uint CardView::itemSpacing() |
1089 | { | 1097 | { |
1090 | return d->mItemSpacing; | 1098 | return d->mItemSpacing; |
1091 | } | 1099 | } |
1092 | 1100 | ||
1093 | void CardView::setItemSpacing( uint spacing ) | 1101 | void 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 | ||
1102 | void CardView::contentsMousePressEvent(QMouseEvent *e) | 1110 | void 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 | ||
@@ -1142,413 +1150,413 @@ void CardView::contentsMousePressEvent(QMouseEvent *e) | |||
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 | ||
1220 | void CardView::contentsMouseReleaseEvent(QMouseEvent *e) | 1228 | void 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 | ||
1258 | void CardView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 1266 | void 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 | ||
1276 | void CardView::contentsMouseMoveEvent( QMouseEvent *e ) | 1284 | void 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 | ||
1316 | void CardView::enterEvent( QEvent * ) | 1324 | void CardView::enterEvent( QEvent * ) |
1317 | { | 1325 | { |
1318 | d->mTimer->start( 500 ); | 1326 | d->mTimer->start( 500 ); |
1319 | } | 1327 | } |
1320 | 1328 | ||
1321 | void CardView::leaveEvent( QEvent * ) | 1329 | void 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 | ||
1331 | void CardView::focusInEvent( QFocusEvent * ) | 1339 | void 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 | ||
1343 | void CardView::focusOutEvent( QFocusEvent * ) | 1351 | void 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 | ||
1349 | void CardView::keyPressEvent( QKeyEvent *e ) | 1357 | void 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 | ||
1541 | void CardView::contentsWheelEvent( QWheelEvent * e ) | 1549 | void CardView::contentsWheelEvent( QWheelEvent * e ) |
1542 | { | 1550 | { |
1543 | scrollBy(2*e->delta()/-3, 0); | 1551 | scrollBy(2*e->delta()/-3, 0); |
1544 | } | 1552 | } |
1545 | 1553 | ||
1546 | void CardView::setLayoutDirty(bool dirty) | 1554 | void 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 | ||
@@ -1609,142 +1617,142 @@ bool CardView::showEmptyFields() const | |||
1609 | } | 1617 | } |
1610 | 1618 | ||
1611 | void CardView::startDrag() | 1619 | void 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 | } |
1616 | void CardView::tryShowFullText() | 1624 | void 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 | ||
1632 | void CardView::drawRubberBands( int pos ) | 1640 | void 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 | ||
1666 | int CardView::itemWidth() const | 1674 | int CardView::itemWidth() const |
1667 | { | 1675 | { |
1668 | return d->mItemWidth; | 1676 | return d->mItemWidth; |
1669 | } | 1677 | } |
1670 | 1678 | ||
1671 | void CardView::setItemWidth( int w ) | 1679 | void 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() ); |
1683 | qDebug("CardView::setItemWidth has to be verified"); | 1691 | qDebug("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 | ||
1688 | void CardView::setHeaderFont( const QFont &fnt ) | 1696 | void 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 | ||
1695 | QFont CardView::headerFont() const | 1703 | QFont CardView::headerFont() const |
1696 | { | 1704 | { |
1697 | return d->mHeaderFont; | 1705 | return d->mHeaderFont; |
1698 | } | 1706 | } |
1699 | 1707 | ||
1700 | void CardView::setFont( const QFont &fnt ) | 1708 | void 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 | ||
1707 | int CardView::separatorWidth() | 1715 | int CardView::separatorWidth() |
1708 | { | 1716 | { |
1709 | return d->mSepWidth; | 1717 | return d->mSepWidth; |
1710 | } | 1718 | } |
1711 | 1719 | ||
1712 | void CardView::setSeparatorWidth( int width ) | 1720 | void 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 | ||
1718 | int CardView::maxFieldLines() const | 1726 | int CardView::maxFieldLines() const |
1719 | { | 1727 | { |
1720 | return d->mMaxFieldLines; | 1728 | return d->mMaxFieldLines; |
1721 | } | 1729 | } |
1722 | 1730 | ||
1723 | void CardView::setMaxFieldLines( int howmany ) | 1731 | void 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 | ||
1729 | void CardView::keyReleaseEvent ( QKeyEvent * e ) | 1737 | void 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,41 +1,49 @@ | |||
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 | ||
11 | class QLabel; | 19 | class QLabel; |
12 | class QPainter; | 20 | class QPainter; |
13 | class QResizeEvent; | 21 | class QResizeEvent; |
14 | class QMouseEvent; | 22 | class QMouseEvent; |
15 | class CardView; | 23 | class CardView; |
16 | class CardViewPrivate; | 24 | class CardViewPrivate; |
17 | class CardViewItemPrivate; | 25 | class CardViewItemPrivate; |
18 | class CardViewTip; | 26 | class 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 | */ |
24 | class CardViewItem | 32 | class 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); |
@@ -119,65 +127,65 @@ class CardViewItem | |||
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 | */ |
151 | class CardView : public QScrollView | 159 | class 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(); |
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,113 +1,118 @@ | |||
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 | ||
34 | ColorListBox::ColorListBox( QWidget *parent, const char *name, WFlags f ) | 39 | ColorListBox::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 | ||
43 | void ColorListBox::setEnabled( bool state ) | 48 | void 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 | ||
58 | void ColorListBox::setColor( uint index, const QColor &color ) | 63 | void 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 | ||
69 | QColor ColorListBox::color( uint index ) const | 74 | QColor 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 | } |
81 | void ColorListBox::slotNewColor(QListBoxItem * i) | 86 | void ColorListBox::slotNewColor(Q3ListBoxItem * i) |
82 | { | 87 | { |
83 | if ( i ) | 88 | if ( i ) |
84 | newColor( index( i ) ); | 89 | newColor( index( i ) ); |
85 | } | 90 | } |
86 | 91 | ||
87 | void ColorListBox::newColor( int index ) | 92 | void 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() ); |
@@ -169,77 +174,77 @@ void ColorListBox::dragMoveEvent( QDragMoveEvent *e ) | |||
169 | #else //KAB_EMBEDDED | 174 | #else //KAB_EMBEDDED |
170 | qDebug("ColorListBox::dragMoveEvent drag&drop currently not supported"); | 175 | qDebug("ColorListBox::dragMoveEvent drag&drop currently not supported"); |
171 | #endif //KAB_EMBEDDED | 176 | #endif //KAB_EMBEDDED |
172 | 177 | ||
173 | } | 178 | } |
174 | 179 | ||
175 | 180 | ||
176 | void ColorListBox::dropEvent( QDropEvent *e ) | 181 | void 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 |
193 | qDebug("ColorListBox::dropEvent drag&drop currently not supported"); | 198 | qDebug("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 | ||
200 | ColorListItem::ColorListItem( const QString &text, const QColor &color ) | 205 | ColorListItem::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 | ||
207 | const QColor &ColorListItem::color( void ) | 212 | const QColor &ColorListItem::color( void ) |
208 | { | 213 | { |
209 | return( mColor ); | 214 | return( mColor ); |
210 | } | 215 | } |
211 | 216 | ||
212 | 217 | ||
213 | void ColorListItem::setColor( const QColor &color ) | 218 | void ColorListItem::setColor( const QColor &color ) |
214 | { | 219 | { |
215 | mColor = color; | 220 | mColor = color; |
216 | } | 221 | } |
217 | 222 | ||
218 | 223 | ||
219 | void ColorListItem::paint( QPainter *p ) | 224 | void 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 | ||
232 | int ColorListItem::height(const QListBox *lb ) const | 237 | int 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 | ||
238 | int ColorListItem::width(const QListBox *lb ) const | 243 | int 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 | ||
26 | class QDragEnterEvent; | 31 | class QDragEnterEvent; |
27 | class QDragLeaveEvent; | 32 | class QDragLeaveEvent; |
28 | class QDragMoveEvent; | 33 | class QDragMoveEvent; |
29 | class QDropEvent; | 34 | class QDropEvent; |
30 | 35 | ||
31 | class ColorListBox : public KListBox | 36 | class 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 | ||
59 | class ColorListItem : public QListBoxItem | 64 | class 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,124 +1,127 @@ | |||
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 | ||
55 | ConfigureCardViewWidget::ConfigureCardViewWidget( KABC::AddressBook *ab, QWidget *parent, | 58 | ConfigureCardViewWidget::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 | ||
71 | ConfigureCardViewWidget::~ConfigureCardViewWidget() | 74 | ConfigureCardViewWidget::~ConfigureCardViewWidget() |
72 | { | 75 | { |
73 | } | 76 | } |
74 | 77 | ||
75 | void ConfigureCardViewWidget::restoreSettings( KConfig *config ) | 78 | void 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 | ||
82 | void ConfigureCardViewWidget::saveSettings( KConfig *config ) | 85 | void 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 |
91 | CardViewLookNFeelPage::CardViewLookNFeelPage( QWidget *parent, const char *name ) | 94 | CardViewLookNFeelPage::CardViewLookNFeelPage( QWidget *parent, const char *name ) |
92 | : QVBox( parent, name ) | 95 | : Q3VBox( parent, name ) |
93 | { | 96 | { |
94 | initGUI(); | 97 | initGUI(); |
95 | } | 98 | } |
96 | 99 | ||
97 | CardViewLookNFeelPage::~CardViewLookNFeelPage() | 100 | CardViewLookNFeelPage::~CardViewLookNFeelPage() |
98 | { | 101 | { |
99 | } | 102 | } |
100 | 103 | ||
101 | void CardViewLookNFeelPage::restoreSettings( KConfig *config ) | 104 | void 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; |
106 | qDebug("CardViewLookNFeelPage::restoreSettings make base color configurable"); | 109 | qDebug("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"), |
@@ -205,165 +208,165 @@ void CardViewLookNFeelPage::setHeaderFont() | |||
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 | ||
215 | void CardViewLookNFeelPage::enableFonts() | 218 | void 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 | ||
222 | void CardViewLookNFeelPage::enableColors() | 225 | void 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 | ||
229 | void CardViewLookNFeelPage::initGUI() | 232 | void 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 | ||
361 | void CardViewLookNFeelPage::updateFontLabel( QFont fnt, QLabel *l ) | 364 | void 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,112 +1,114 @@ | |||
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 | ||
33 | class QString; | 35 | class QString; |
34 | class QWidget; | 36 | class QWidget; |
35 | class QCheckBox; | 37 | class QCheckBox; |
36 | class QLabel; | 38 | class QLabel; |
37 | class KConfig; | 39 | class KConfig; |
38 | 40 | ||
39 | namespace KABC { class AddressBook; } | 41 | namespace KABC { class AddressBook; } |
40 | 42 | ||
41 | class CardViewLookAndFeelPage; | 43 | class 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 | */ |
48 | class ConfigureCardViewWidget : public ViewConfigureWidget | 50 | class 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 | ||
80 | class CardViewLookNFeelPage : public QVBox { | 82 | class 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; |
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,119 +1,122 @@ | |||
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 | ||
54 | ConfigureTableViewWidget::ConfigureTableViewWidget( KABC::AddressBook *ab, | 57 | ConfigureTableViewWidget::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 | ||
66 | ConfigureTableViewWidget::~ConfigureTableViewWidget() | 69 | ConfigureTableViewWidget::~ConfigureTableViewWidget() |
67 | { | 70 | { |
68 | } | 71 | } |
69 | 72 | ||
70 | void ConfigureTableViewWidget::restoreSettings( KConfig *config ) | 73 | void 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 | ||
77 | void ConfigureTableViewWidget::saveSettings( KConfig *config ) | 80 | void 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 | ||
86 | LookAndFeelPage::LookAndFeelPage(QWidget *parent, const char *name) | 89 | LookAndFeelPage::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 | ||
95 | void LookAndFeelPage::restoreSettings( KConfig *config ) | 98 | void 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"), |
@@ -200,146 +203,146 @@ void LookAndFeelPage::setHeaderFont() | |||
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 | ||
210 | void LookAndFeelPage::enableFonts() | 213 | void 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 | ||
217 | void LookAndFeelPage::enableColors() | 220 | void 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 | ||
224 | void LookAndFeelPage::initGUI() | 227 | void 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 | ||
331 | void LookAndFeelPage::enableBackgroundToggled(bool enabled) | 334 | void LookAndFeelPage::enableBackgroundToggled(bool enabled) |
332 | { | 335 | { |
333 | mBackgroundName->setEnabled(enabled); | 336 | mBackgroundName->setEnabled(enabled); |
334 | } | 337 | } |
335 | 338 | ||
336 | 339 | ||
337 | void LookAndFeelPage::updateFontLabel( QFont fnt, QLabel *l ) | 340 | void 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,98 +1,100 @@ | |||
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 | ||
31 | class QString; | 33 | class QString; |
32 | class QWidget; | 34 | class QWidget; |
33 | class QRadioButton; | 35 | class QRadioButton; |
34 | class QCheckBox; | 36 | class QCheckBox; |
35 | class KURLRequester; | 37 | class KURLRequester; |
36 | class KConfig; | 38 | class KConfig; |
37 | class QLabel; | 39 | class QLabel; |
38 | 40 | ||
39 | namespace KABC { class AddressBook; } | 41 | namespace KABC { class AddressBook; } |
40 | 42 | ||
41 | class LookAndFeelPage; | 43 | class 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 | */ |
48 | class ConfigureTableViewWidget : public ViewConfigureWidget | 50 | class 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 | */ |
66 | class LookAndFeelPage : public QVBox | 68 | class 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; |
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,98 +1,104 @@ | |||
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 | ||
49 | DynamicTip::DynamicTip( ContactListView *parent) | 54 | DynamicTip::DynamicTip( ContactListView *parent) |
50 | : QToolTip( parent ) | 55 | /* TODO:hacker:: QToolTip( parent ) */ |
51 | { | 56 | { |
52 | } | 57 | } |
53 | 58 | ||
54 | void DynamicTip::maybeTip( const QPoint &pos ) | 59 | void 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(); |
@@ -122,111 +128,111 @@ void DynamicTip::maybeTip( const QPoint &pos ) | |||
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 | ||
160 | ContactListViewItem::ContactListViewItem(const KABC::Addressee &a, | 166 | ContactListViewItem::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 | ||
170 | QString ContactListViewItem::key(int column, bool ascending) const | 176 | QString 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 | ||
203 | void ContactListViewItem::paintCell(QPainter * p, | 209 | void 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 | ||
221 | ContactListView *ContactListViewItem::parent() | 227 | ContactListView *ContactListViewItem::parent() |
222 | { | 228 | { |
223 | return parentListView; | 229 | return parentListView; |
224 | } | 230 | } |
225 | 231 | ||
226 | 232 | ||
227 | void ContactListViewItem::refresh() | 233 | void 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; |
@@ -259,130 +265,130 @@ ContactListView::ContactListView(KAddressBookTableView *view, | |||
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 | } |
283 | void ContactListView::printMe() | 289 | void 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 | ||
311 | void ContactListView::setAlternateColor(const QColor &m_AlternateColor) | 317 | void ContactListView::setAlternateColor(const QColor &m_AlternateColor) |
312 | { | 318 | { |
313 | mAlternateColor = m_AlternateColor; | 319 | mAlternateColor = m_AlternateColor; |
314 | } | 320 | } |
315 | 321 | ||
316 | void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) | 322 | void 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 | ||
336 | void ContactListView::contentsMousePressEvent(QMouseEvent* e) | 342 | void 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 |
344 | void ContactListView::contentsMouseMoveEvent( QMouseEvent *e ) | 350 | void 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 | ||
353 | bool ContactListView::acceptDrag(QDropEvent *e) const | 359 | bool 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 |
358 | qDebug("ContactListView::acceptDrag has to be fixed"); | 364 | qDebug("ContactListView::acceptDrag has to be fixed"); |
359 | return false; | 365 | return false; |
360 | #endif //KAB_EMBEDDED | 366 | #endif //KAB_EMBEDDED |
361 | } | 367 | } |
362 | 368 | ||
363 | void ContactListView::itemDropped(QDropEvent *e) | 369 | void ContactListView::itemDropped(QDropEvent *e) |
364 | { | 370 | { |
365 | contentsDropEvent(e); | 371 | contentsDropEvent(e); |
366 | } | 372 | } |
367 | 373 | ||
368 | void ContactListView::contentsDropEvent( QDropEvent *e ) | 374 | void ContactListView::contentsDropEvent( QDropEvent *e ) |
369 | { | 375 | { |
370 | emit addresseeDropped(e); | 376 | emit addresseeDropped(e); |
371 | } | 377 | } |
372 | 378 | ||
373 | void ContactListView::setAlternateBackgroundEnabled(bool enabled) | 379 | void 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 | ||
387 | void ContactListView::setBackgroundPixmap(const QString &filename) | 393 | void ContactListView::setBackgroundPixmap(const QString &filename) |
388 | { | 394 | { |
@@ -395,35 +401,35 @@ void ContactListView::setBackgroundPixmap(const QString &filename) | |||
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 | ||
402 | void ContactListView::keyPressEvent ( QKeyEvent * e ) | 408 | void 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 | } |
415 | void ContactListView::keyReleaseEvent ( QKeyEvent * e ) | 421 | void 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,55 +1,59 @@ | |||
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 | ||
16 | class QDropEvent; | 20 | class QDropEvent; |
17 | class KAddressBookTableView; | 21 | class KAddressBookTableView; |
18 | class ContactListView; | 22 | class 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 | */ |
23 | class DynamicTip : public QToolTip | 27 | class 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 | ||
34 | class ContactListViewItem : public KListViewItem | 38 | class ContactListViewItem : public KListViewItem |
35 | { | 39 | { |
36 | 40 | ||
37 | public: | 41 | public: |
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 | ||
51 | private: | 55 | private: |
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; |
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,62 +1,67 @@ | |||
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 |
45 | extern "C" { | 50 | extern "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) |
55 | class AddresseeCardViewItem : public CardViewItem | 60 | class 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() ), |
@@ -96,116 +101,116 @@ class AddresseeCardViewItem : public CardViewItem | |||
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 | ||
111 | AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) | 116 | AddresseeCardView::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 | ||
117 | AddresseeCardView::~AddresseeCardView() | 122 | AddresseeCardView::~AddresseeCardView() |
118 | { | 123 | { |
119 | } | 124 | } |
120 | void AddresseeCardView::printMe() | 125 | void 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 | ||
148 | void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) | 153 | void 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 |
154 | qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); | 159 | qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); |
155 | #endif //KAB_EMBEDDED | 160 | #endif //KAB_EMBEDDED |
156 | } | 161 | } |
157 | 162 | ||
158 | void AddresseeCardView::dropEvent(QDropEvent *e) | 163 | void AddresseeCardView::dropEvent(QDropEvent *e) |
159 | { | 164 | { |
160 | emit addresseeDropped(e); | 165 | emit addresseeDropped(e); |
161 | } | 166 | } |
162 | 167 | ||
163 | void AddresseeCardView::startDrag() | 168 | void AddresseeCardView::startDrag() |
164 | { | 169 | { |
165 | emit startAddresseeDrag(); | 170 | emit startAddresseeDrag(); |
166 | } | 171 | } |
167 | 172 | ||
168 | 173 | ||
169 | /////////////////////////////// | 174 | /////////////////////////////// |
170 | // KAddressBookCardView | 175 | // KAddressBookCardView |
171 | 176 | ||
172 | KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, | 177 | KAddressBookCardView::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 | ||
198 | KAddressBookCardView::~KAddressBookCardView() | 203 | KAddressBookCardView::~KAddressBookCardView() |
199 | { | 204 | { |
200 | } | 205 | } |
201 | void KAddressBookCardView::setFocusAV() | 206 | void KAddressBookCardView::setFocusAV() |
202 | { | 207 | { |
203 | if ( mCardView ) | 208 | if ( mCardView ) |
204 | mCardView->setFocus(); | 209 | mCardView->setFocus(); |
205 | 210 | ||
206 | } | 211 | } |
207 | void KAddressBookCardView::scrollUP() | 212 | void 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 ); |
@@ -491,35 +496,35 @@ void KAddressBookCardView::addresseeExecuted(CardViewItem *item) | |||
491 | emit executed(aItem->addressee().uid()); | 496 | emit executed(aItem->addressee().uid()); |
492 | } | 497 | } |
493 | } | 498 | } |
494 | 499 | ||
495 | void KAddressBookCardView::addresseeSelected() | 500 | void 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,59 +1,62 @@ | |||
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 | ||
38 | class QDragEnterEvent; | 41 | class QDragEnterEvent; |
39 | class QDragEntryEvent; | 42 | class QDragEntryEvent; |
40 | class QDropEvent; | 43 | class QDropEvent; |
41 | class KConfig; | 44 | class KConfig; |
42 | class AddresseeCardView; | 45 | class 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 | */ |
49 | class KAddressBookCardView : public KAddressBookView | 52 | class 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"; } |
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,165 +1,173 @@ | |||
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 |
47 | class IconViewFactory : public ViewFactory | 55 | class 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 | ||
62 | extern "C" { | 70 | extern "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 |
72 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) | 80 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) |
73 | : KIconView(parent, name) | 81 | : KIconView(parent, name) |
74 | #else //KAB_EMBEDDED | 82 | #else //KAB_EMBEDDED |
75 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) | 83 | AddresseeIconView::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 | ||
97 | AddresseeIconView::~AddresseeIconView() | 105 | AddresseeIconView::~AddresseeIconView() |
98 | { | 106 | { |
99 | } | 107 | } |
100 | 108 | ||
101 | 109 | ||
102 | void AddresseeIconView::itemDropped(QDropEvent *e, | 110 | void 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 | ||
108 | QDragObject *AddresseeIconView::dragObject() | 116 | Q3DragObject *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 |
118 | class AddresseeIconViewItem : public KIconViewItem | 126 | class AddresseeIconViewItem : public KIconViewItem |
119 | #else //KAB_EMBEDDED | 127 | #else //KAB_EMBEDDED |
120 | class AddresseeIconViewItem : public QIconViewItem | 128 | class 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 |
@@ -171,126 +179,126 @@ class AddresseeIconViewItem : public QIconViewItem | |||
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 | ||
198 | KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, | 206 | KAddressBookIconView::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 | ||
224 | KAddressBookIconView::~KAddressBookIconView() | 232 | KAddressBookIconView::~KAddressBookIconView() |
225 | { | 233 | { |
226 | } | 234 | } |
227 | void KAddressBookIconView::setFocusAV() | 235 | void KAddressBookIconView::setFocusAV() |
228 | { | 236 | { |
229 | if ( mIconView ) | 237 | if ( mIconView ) |
230 | mIconView->setFocus(); | 238 | mIconView->setFocus(); |
231 | } | 239 | } |
232 | 240 | ||
233 | 241 | ||
234 | void KAddressBookIconView::scrollUP() | 242 | void 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 | } |
239 | void KAddressBookIconView::scrollDOWN() | 247 | void 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 | } |
244 | void KAddressBookIconView::readConfig(KConfig *config) | 252 | void 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 | } |
267 | void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) | 275 | void 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 ) { |
@@ -307,175 +315,175 @@ void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) | |||
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 | } |
336 | QStringList KAddressBookIconView::selectedUids() | 344 | QStringList 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 | ||
359 | void KAddressBookIconView::refresh(QString uid) | 367 | void 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 | ||
407 | void KAddressBookIconView::setSelected(QString uid, bool selected) | 415 | void 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 | ||
438 | void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) | 446 | void 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 | ||
451 | void KAddressBookIconView::addresseeSelected() | 459 | void 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 | ||
37 | class QIconViewItem; | 40 | class Q3IconViewItem; |
38 | class KConfig; | 41 | class KConfig; |
39 | class AddresseeIconView; | 42 | class AddresseeIconView; |
40 | class AddresseeIconViewItem; | 43 | class AddresseeIconViewItem; |
41 | class QIconDragItem; | 44 | class Q3IconDragItem; |
42 | class KAddressBookIconView; | 45 | class KAddressBookIconView; |
43 | 46 | ||
44 | namespace KABC { class AddressBook; } | 47 | namespace 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 | */ |
50 | class KAddressBookIconView : public KAddressBookView | 53 | class 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 |
91 | class AddresseeIconView : public KIconView | 94 | class AddresseeIconView : public KIconView |
92 | //MOC_SKIP_END | 95 | #endif |
93 | #else //KAB_EMBEDDED | 96 | #else //KAB_EMBEDDED |
94 | class AddresseeIconView : public QIconView | 97 | class 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 | ||
114 | class IconViewFactory : public ViewFactory | 117 | class 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 | /* |
127 | extern "C" { | 130 | extern "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,162 +1,166 @@ | |||
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 | ||
41 | KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, | 45 | KAddressBookTableView::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 | ||
51 | KAddressBookTableView::~KAddressBookTableView() | 55 | KAddressBookTableView::~KAddressBookTableView() |
52 | { | 56 | { |
53 | } | 57 | } |
54 | void KAddressBookTableView::setFocusAV() | 58 | void KAddressBookTableView::setFocusAV() |
55 | { | 59 | { |
56 | if ( mListView ) | 60 | if ( mListView ) |
57 | mListView->setFocus(); | 61 | mListView->setFocus(); |
58 | 62 | ||
59 | } | 63 | } |
60 | void KAddressBookTableView::scrollUP() | 64 | void 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 | } |
67 | void KAddressBookTableView::scrollDOWN() | 71 | void 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 | } |
74 | void KAddressBookTableView::reconstructListView() | 78 | void 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 | ||
143 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) | 147 | void 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) |
@@ -315,178 +319,178 @@ void KAddressBookTableView::refresh(QString uid) | |||
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 | ||
366 | QStringList KAddressBookTableView::selectedUids() | 370 | QStringList 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 | ||
395 | void KAddressBookTableView::setSelected(QString uid, bool selected) | 399 | void 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 | ||
426 | void KAddressBookTableView::addresseeSelected() | 430 | void 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 | ||
456 | void KAddressBookTableView::addresseeExecuted(QListViewItem *item) | 460 | void 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 | ||
479 | void KAddressBookTableView::addresseeDeleted() | 483 | void 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,117 +1,119 @@ | |||
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 | ||
29 | class QListViewItem; | 31 | class Q3ListViewItem; |
30 | class QListBox; | 32 | class Q3ListBox; |
31 | class QVBoxLayout; | 33 | class Q3VBoxLayout; |
32 | class KConfig; | 34 | class KConfig; |
33 | 35 | ||
34 | class ContactListViewItem; | 36 | class ContactListViewItem; |
35 | class ContactListView; | 37 | class ContactListView; |
36 | 38 | ||
37 | 39 | ||
38 | namespace KABC { class AddressBook; } | 40 | namespace 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 | */ |
48 | class KAddressBookTableView : public KAddressBookView | 50 | class KAddressBookTableView : public KAddressBookView |
49 | { | 51 | { |
50 | friend class ContactListView; | 52 | friend 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 | ||
90 | class TableViewFactory : public ViewFactory | 92 | class 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 |
110 | extern "C" { | 112 | extern "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 | ||
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,65 +1,65 @@ | |||
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 <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 | ||
53 | class CSVXXPortFactory : public XXPortFactory | 53 | class 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 | ||
65 | extern "C" | 65 | extern "C" |
@@ -75,120 +75,118 @@ extern "C" | |||
75 | } | 75 | } |
76 | 76 | ||
77 | 77 | ||
78 | CSVXXPort::CSVXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 78 | CSVXXPort::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 | ||
85 | bool CSVXXPort::exportContacts( const KABC::AddresseeList &list, const QString& ) | 85 | bool 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 | ||
143 | KABC::AddresseeList CSVXXPort::importContacts( const QString& ) const | 143 | KABC::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 | ||
152 | void CSVXXPort::doExport( QFile *fp, const KABC::AddresseeList &list ) | 152 | void 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,91 +1,95 @@ | |||
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 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (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 | ||
65 | CSVImportDialog::CSVImportDialog( KABC::AddressBook *ab, QWidget *parent, | 69 | CSVImportDialog::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(), |
@@ -132,133 +136,133 @@ CSVImportDialog::CSVImportDialog( KABC::AddressBook *ab, QWidget *parent, | |||
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 | ||
174 | CSVImportDialog::~CSVImportDialog() | 178 | CSVImportDialog::~CSVImportDialog() |
175 | { | 179 | { |
176 | } | 180 | } |
177 | 181 | ||
178 | KABC::AddresseeList CSVImportDialog::contacts() const | 182 | KABC::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: |
@@ -353,332 +357,332 @@ KABC::AddresseeList CSVImportDialog::contacts() const | |||
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 | ||
381 | void CSVImportDialog::initGUI() | 385 | void 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 | ||
474 | void CSVImportDialog::fillTable() | 478 | void 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 | ||
663 | void CSVImportDialog::clearTable() | 667 | void 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 | ||
670 | void CSVImportDialog::fillComboBox() | 674 | void 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 | ||
677 | void CSVImportDialog::setText( int row, int col, const QString& text ) | 681 | void 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; |
@@ -735,65 +739,65 @@ void CSVImportDialog::delimiterClicked( int id ) | |||
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 | ||
746 | void CSVImportDialog::textquoteSelected( const QString& mark ) | 750 | void 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 | ||
756 | void CSVImportDialog::lineSelected( const QString& line ) | 760 | void 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 | ||
762 | void CSVImportDialog::slotOk() | 766 | void 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 | ||
779 | void CSVImportDialog::applyTemplate() | 783 | void 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; |
@@ -807,163 +811,163 @@ void CSVImportDialog::applyTemplate() | |||
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 | ||
846 | void CSVImportDialog::saveTemplate() | 850 | void 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 | ||
893 | QString CSVImportDialog::getText( int row, int col ) | 897 | QString CSVImportDialog::getText( int row, int col ) |
894 | { | 898 | { |
895 | return mTable->text( row, col ); | 899 | return mTable->text( row, col ); |
896 | } | 900 | } |
897 | 901 | ||
898 | uint CSVImportDialog::posToType( int pos ) const | 902 | uint 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 | ||
912 | int CSVImportDialog::typeToPos( uint type ) const | 916 | int 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 | ||
926 | void CSVImportDialog::ignoreDuplicatesChanged( int ) | 930 | void CSVImportDialog::ignoreDuplicatesChanged( int ) |
927 | { | 931 | { |
928 | fillTable(); | 932 | fillTable(); |
929 | } | 933 | } |
930 | 934 | ||
931 | void CSVImportDialog::setFile( const QString &fileName ) | 935 | void 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 | ||
956 | void CSVImportDialog::urlChanged( const QString &file ) | 960 | void 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 | |||
@@ -4,123 +4,123 @@ | |||
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 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (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 | ||
38 | class KURLRequester; | 38 | class KURLRequester; |
39 | 39 | ||
40 | class QButtonGroup; | 40 | class Q3ButtonGroup; |
41 | class QComboBox; | 41 | class QComboBox; |
42 | class QCheckBox; | 42 | class QCheckBox; |
43 | class QLineEdit; | 43 | class QLineEdit; |
44 | class QPushButton; | 44 | class QPushButton; |
45 | class QRadioButton; | 45 | class QRadioButton; |
46 | class QTable; | 46 | class Q3Table; |
47 | 47 | ||
48 | class CSVImportDialog : public KDialogBase | 48 | class 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 | |||
@@ -87,35 +87,35 @@ KABC::AddresseeList KDE2XXPort::importContacts( const QString& ) const | |||
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,65 +1,67 @@ | |||
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 | ||
53 | class VCardXXPortFactory : public XXPortFactory | 55 | class VCardXXPortFactory : public XXPortFactory |
54 | { | 56 | { |
55 | public: | 57 | public: |
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 | ||
64 | extern "C" | 66 | extern "C" |
65 | { | 67 | { |
@@ -73,160 +75,160 @@ extern "C" | |||
73 | } | 75 | } |
74 | } | 76 | } |
75 | 77 | ||
76 | 78 | ||
77 | VCardXXPort::VCardXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 79 | VCardXXPort::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 | ||
86 | bool VCardXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data ) | 88 | bool 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 | ||
134 | KABC::AddresseeList VCardXXPort::importContacts( const QString& ) const | 136 | KABC::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 | ||
229 | KABC::AddresseeList VCardXXPort::parseVCard( const QString &data ) const | 231 | KABC::AddresseeList VCardXXPort::parseVCard( const QString &data ) const |
230 | { | 232 | { |
231 | 233 | ||
232 | KABC::VCardTool tool; | 234 | KABC::VCardTool tool; |
@@ -238,35 +240,35 @@ KABC::AddresseeList VCardXXPort::parseVCard( const QString &data ) const | |||
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,64 +1,66 @@ | |||
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 <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 |
44 | extern "C" | 46 | extern "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 | ||
64 | KURL XXPortManager::importURL = KURL(); | 66 | KURL XXPortManager::importURL = KURL(); |
@@ -188,83 +190,80 @@ void XXPortManager::slotExport( const QString &identifier, const QString &data ) | |||
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 | ||
195 | void XXPortManager::loadPlugins() | 197 | void 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 | ||
247 | PreviewDialog::PreviewDialog( const KABC::Addressee &addr, QWidget *parent, | 247 | PreviewDialog::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 | |||
@@ -3,78 +3,78 @@ | |||
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 | 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 | ||
42 | class KABCore; | 42 | class KABCore; |
43 | 43 | ||
44 | class XXPortManager : public QObject | 44 | class 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 | |||
@@ -242,35 +242,35 @@ KABC::AddresseeList XXPortResourceObject::_importContacts( const QString& identi | |||
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 | |||
@@ -7,113 +7,118 @@ | |||
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 | /* |
26 | Enhanced Version of the file for platform independent KDE tools. | 26 | Enhanced Version of the file for platform independent KDE tools. |
27 | Copyright (c) 2004 Ulf Schenk | 27 | Copyright (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 | ||
55 | XXPortSelectDialog::XXPortSelectDialog( KABCore *core, bool sort, | 60 | XXPortSelectDialog::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 | ||
103 | QStringList XXPortSelectDialog::uids() | 108 | QStringList 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 | } |
112 | void XXPortSelectDialog::tagSelected() | 117 | void 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 ) |
@@ -181,162 +186,160 @@ KABC::AddresseeList XXPortSelectDialog::contacts() | |||
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 | ||
209 | QStringList XXPortSelectDialog::categories() const | 214 | QStringList 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 | ||
223 | void XXPortSelectDialog::filterChanged( int ) | 228 | void XXPortSelectDialog::filterChanged( int ) |
224 | { | 229 | { |
225 | mUseFilters->setChecked( true ); | 230 | mUseFilters->setChecked( true ); |
226 | } | 231 | } |
227 | 232 | ||
228 | void XXPortSelectDialog::categoryClicked( QListViewItem *i ) | 233 | void 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 | ||
235 | void XXPortSelectDialog::slotHelp() | 240 | void 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 | ||
245 | void XXPortSelectDialog::initGUI() | 250 | void 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 | ||
33 | class QButtonGroup; | 33 | class Q3ButtonGroup; |
34 | class QComboBox; | 34 | class QComboBox; |
35 | class QListView; | 35 | class Q3ListView; |
36 | class QListViewItem; | 36 | class Q3ListViewItem; |
37 | class QRadioButton; | 37 | class QRadioButton; |
38 | 38 | ||
39 | class KABCore; | 39 | class KABCore; |
40 | class KComboBox; | 40 | class KComboBox; |
41 | 41 | ||
42 | class XXPortSelectDialog : public KDialogBase | 42 | class 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 |