summaryrefslogtreecommitdiffabout
path: root/kaddressbook/xxportselectdialog.cpp
Unidiff
Diffstat (limited to 'kaddressbook/xxportselectdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/xxportselectdialog.cpp59
1 files changed, 31 insertions, 28 deletions
diff --git a/kaddressbook/xxportselectdialog.cpp b/kaddressbook/xxportselectdialog.cpp
index 278cab0..088bffa 100644
--- a/kaddressbook/xxportselectdialog.cpp
+++ b/kaddressbook/xxportselectdialog.cpp
@@ -15,97 +15,102 @@
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25/* 25/*
26Enhanced Version of the file for platform independent KDE tools. 26Enhanced Version of the file for platform independent KDE tools.
27Copyright (c) 2004 Ulf Schenk 27Copyright (c) 2004 Ulf Schenk
28 28
29$Id$ 29$Id$
30*/ 30*/
31 31
32#include <kabc/addressbook.h> 32#include <kabc/addressbook.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <kcombobox.h> 34#include <kcombobox.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kglobal.h> 36#include <kglobal.h>
37 37
38#include <qapplication.h> 38#include <qapplication.h>
39#include <qbuttongroup.h> 39#include <QDesktopWidget>
40#include <q3buttongroup.h>
40#include <qcombobox.h> 41#include <qcombobox.h>
41#include <qheader.h> 42#include <q3header.h>
42#include <qlabel.h> 43#include <qlabel.h>
43#include <qlayout.h> 44#include <qlayout.h>
44#include <qlistview.h> 45#include <q3listview.h>
45#include <qpushbutton.h> 46#include <qpushbutton.h>
46#include <qradiobutton.h> 47#include <qradiobutton.h>
47#include <qstringlist.h> 48#include <qstringlist.h>
48#include <qwhatsthis.h> 49#include <q3whatsthis.h>
50//Added by qt3to4:
51#include <Q3GridLayout>
52#include <Q3Frame>
53#include <Q3VBoxLayout>
49 54
50#include "kabcore.h" 55#include "kabcore.h"
51#include "kabprefs.h" 56#include "kabprefs.h"
52 57
53#include "xxportselectdialog.h" 58#include "xxportselectdialog.h"
54 59
55XXPortSelectDialog::XXPortSelectDialog( KABCore *core, bool sort, 60XXPortSelectDialog::XXPortSelectDialog( KABCore *core, bool sort,
56 QWidget* parent, const char* name ) 61 QWidget* parent, const char* name )
57 : KDialogBase( Plain, i18n( "Choose contact selection" ), Help | Ok | Cancel, 62 : KDialogBase( Plain, i18n( "Choose contact selection" ), Help | Ok | Cancel,
58 Ok, parent, name, true, true ), mCore( core ), 63 Ok, parent, name, true, true ), mCore( core ),
59 mUseSorting( sort ) 64 mUseSorting( sort )
60{ 65{
61 initGUI(); 66 initGUI();
62 67
63 connect( mFiltersCombo, SIGNAL( activated( int ) ), 68 connect( mFiltersCombo, SIGNAL( activated( int ) ),
64 SLOT( filterChanged( int ) ) ); 69 SLOT( filterChanged( int ) ) );
65 connect( mCategoriesView, SIGNAL( clicked( QListViewItem* ) ), 70 connect( mCategoriesView, SIGNAL( clicked( Q3ListViewItem* ) ),
66 SLOT( categoryClicked( QListViewItem* ) ) ); 71 SLOT( categoryClicked( Q3ListViewItem* ) ) );
67 72
68 // setup filters 73 // setup filters
69#ifndef KAB_EMBEDDED 74#ifndef KAB_EMBEDDED
70 mFilters = Filter::restore( kapp->config(), "Filter" ); 75 mFilters = Filter::restore( kapp->config(), "Filter" );
71 Filter::List::iterator filterIt; 76 Filter::List::iterator filterIt;
72#else //KAB_EMBEDDED 77#else //KAB_EMBEDDED
73 mFilters = Filter::restore( KGlobal::config(), "Filter" ); 78 mFilters = Filter::restore( KGlobal::config(), "Filter" );
74 Filter::List::Iterator filterIt; 79 Filter::List::Iterator filterIt;
75#endif //KAB_EMBEDDED 80#endif //KAB_EMBEDDED
76 QStringList filters; 81 QStringList filters;
77 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt ) 82 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt )
78 filters.append( (*filterIt).name() ); 83 filters.append( (*filterIt).name() );
79 84
80 mFiltersCombo->insertStringList( filters ); 85 mFiltersCombo->insertStringList( filters );
81 mUseFilters->setEnabled( filters.count() > 0 ); 86 mUseFilters->setEnabled( filters.count() > 0 );
82 87
83 // setup categories 88 // setup categories
84 QStringList categories = KABPrefs::instance()->mCustomCategories; 89 QStringList categories = KABPrefs::instance()->mCustomCategories;
85 QStringList::Iterator it; 90 QStringList::Iterator it;
86 for ( it = categories.begin(); it != categories.end(); ++it ) 91 for ( it = categories.begin(); it != categories.end(); ++it )
87 new QCheckListItem( mCategoriesView, *it, QCheckListItem::CheckBox ); 92 new Q3CheckListItem( mCategoriesView, *it, Q3CheckListItem::CheckBox );
88 mUseCategories->setEnabled( categories.count() > 0 ); 93 mUseCategories->setEnabled( categories.count() > 0 );
89 94
90 int count = mCore->selectedUIDs().count(); 95 int count = mCore->selectedUIDs().count();
91 mUseSelection->setEnabled( count != 0 ); 96 mUseSelection->setEnabled( count != 0 );
92 mUseSelection->setChecked( count > 1 ); 97 mUseSelection->setChecked( count > 1 );
93 98
94 mSortTypeCombo->insertItem( i18n( "Ascending" ) ); 99 mSortTypeCombo->insertItem( i18n( "Ascending" ) );
95 mSortTypeCombo->insertItem( i18n( "Descending" ) ); 100 mSortTypeCombo->insertItem( i18n( "Descending" ) );
96 101
97 mFields = mCore->addressBook()->fields( KABC::Field::All ); 102 mFields = mCore->addressBook()->fields( KABC::Field::All );
98 KABC::Field::List::Iterator fieldIt; 103 KABC::Field::List::Iterator fieldIt;
99 for ( fieldIt = mFields.begin(); fieldIt != mFields.end(); ++fieldIt ) 104 for ( fieldIt = mFields.begin(); fieldIt != mFields.end(); ++fieldIt )
100 mFieldCombo->insertItem( (*fieldIt)->label() ); 105 mFieldCombo->insertItem( (*fieldIt)->label() );
101} 106}
102 107
103QStringList XXPortSelectDialog::uids() 108QStringList XXPortSelectDialog::uids()
104{ 109{
105 QStringList uidlist; 110 QStringList uidlist;
106 KABC::AddresseeList list = contacts(); 111 KABC::AddresseeList list = contacts();
107 KABC::Addressee::List::Iterator it; 112 KABC::Addressee::List::Iterator it;
108 for ( it = list.begin(); it != list.end(); ++it ) 113 for ( it = list.begin(); it != list.end(); ++it )
109 uidlist.append((*it).uid()); 114 uidlist.append((*it).uid());
110 return uidlist; 115 return uidlist;
111} 116}
@@ -189,154 +194,152 @@ KABC::AddresseeList XXPortSelectDialog::contacts()
189 } 194 }
190 } 195 }
191 } else { 196 } else {
192 // create a string list of all entries: 197 // create a string list of all entries:
193 KABC::AddressBook::Iterator it; 198 KABC::AddressBook::Iterator it;
194 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) 199 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it )
195 if ((*it).uid().left( 19 ) != QString("last-syncAddressee-") ) 200 if ((*it).uid().left( 19 ) != QString("last-syncAddressee-") )
196 list.append( *it ); 201 list.append( *it );
197 } 202 }
198 203
199 if ( mUseSorting ) { 204 if ( mUseSorting ) {
200 list.setReverseSorting( mSortTypeCombo->currentItem() == 1 ); 205 list.setReverseSorting( mSortTypeCombo->currentItem() == 1 );
201 uint pos = mFieldCombo->currentItem(); 206 uint pos = mFieldCombo->currentItem();
202 if ( pos < mFields.count() ) 207 if ( pos < mFields.count() )
203 list.sortByField( mFields[ pos ] ); 208 list.sortByField( mFields[ pos ] );
204 } 209 }
205 210
206 return list; 211 return list;
207} 212}
208 213
209QStringList XXPortSelectDialog::categories() const 214QStringList XXPortSelectDialog::categories() const
210{ 215{
211 QStringList list; 216 QStringList list;
212 217
213 QListViewItemIterator it( mCategoriesView ); 218 Q3ListViewItemIterator it( mCategoriesView );
214 for ( ; it.current(); ++it ) { 219 for ( ; it.current(); ++it ) {
215 QCheckListItem* qcli = static_cast<QCheckListItem*>(it.current()); 220 Q3CheckListItem* qcli = static_cast<Q3CheckListItem*>(it.current());
216 if ( qcli->isOn() ) 221 if ( qcli->isOn() )
217 list.append( it.current()->text( 0 ) ); 222 list.append( it.current()->text( 0 ) );
218 } 223 }
219 224
220 return list; 225 return list;
221} 226}
222 227
223void XXPortSelectDialog::filterChanged( int ) 228void XXPortSelectDialog::filterChanged( int )
224{ 229{
225 mUseFilters->setChecked( true ); 230 mUseFilters->setChecked( true );
226} 231}
227 232
228void XXPortSelectDialog::categoryClicked( QListViewItem *i ) 233void XXPortSelectDialog::categoryClicked( Q3ListViewItem *i )
229{ 234{
230 QCheckListItem *qcli = static_cast<QCheckListItem*>( i ); 235 Q3CheckListItem *qcli = static_cast<Q3CheckListItem*>( i );
231 if ( qcli->isOn() ) 236 if ( qcli->isOn() )
232 mUseCategories->setChecked( true ); 237 mUseCategories->setChecked( true );
233} 238}
234 239
235void XXPortSelectDialog::slotHelp() 240void XXPortSelectDialog::slotHelp()
236{ 241{
237#ifndef KAB_EMBEDDED 242#ifndef KAB_EMBEDDED
238 kapp->invokeHelp( "import-and-export" ); 243 kapp->invokeHelp( "import-and-export" );
239#else //KAB_EMBEDDED 244#else //KAB_EMBEDDED
240 qDebug("XXPortSelectDialog::slotHelp is not implemented yet"); 245 qDebug("XXPortSelectDialog::slotHelp is not implemented yet");
241#endif //KAB_EMBEDDED 246#endif //KAB_EMBEDDED
242 247
243} 248}
244 249
245void XXPortSelectDialog::initGUI() 250void XXPortSelectDialog::initGUI()
246{ 251{
247 QFrame *page = plainPage(); 252 Q3Frame *page = plainPage();
248 253
249 QVBoxLayout *topLayout = new QVBoxLayout( page, KDialog::marginHintSmall(), 254 Q3VBoxLayout *topLayout = new Q3VBoxLayout( page, KDialog::marginHintSmall(),
250 KDialog::spacingHintSmall() ); 255 KDialog::spacingHintSmall() );
251 256
252 QLabel *label = new QLabel( i18n( "Which contacts do you want to select?" ), page ); 257 QLabel *label = new QLabel( i18n( "Which contacts do you want to select?" ), page );
253 topLayout->addWidget( label ); 258 topLayout->addWidget( label );
254 259
255 mButtonGroup = new QButtonGroup( i18n( "Contact Selection" ), page ); 260 mButtonGroup = new Q3ButtonGroup( i18n( "Contact Selection" ), page );
256 mButtonGroup->setColumnLayout( 0, Qt::Vertical ); 261 mButtonGroup->setColumnLayout( 0, Qt::Vertical );
257 mButtonGroup->layout()->setSpacing( KDialog::spacingHint() ); 262 mButtonGroup->layout()->setSpacing( KDialog::spacingHint() );
258 mButtonGroup->layout()->setMargin( KDialog::marginHint() ); 263 mButtonGroup->layout()->setMargin( KDialog::marginHint() );
259 264
260 QGridLayout *groupLayout = new QGridLayout( mButtonGroup->layout() ); 265 Q3GridLayout *groupLayout = new Q3GridLayout( mButtonGroup->layout() );
261 groupLayout->setAlignment( Qt::AlignTop ); 266 groupLayout->setAlignment( Qt::AlignTop );
262 267
263 mUseWholeBook = new QRadioButton( i18n( "&All" ), mButtonGroup ); 268 mUseWholeBook = new QRadioButton( i18n( "&All" ), mButtonGroup );
264 mUseWholeBook->setChecked( true ); 269 mUseWholeBook->setChecked( true );
265 QWhatsThis::add( mUseWholeBook, i18n( "Select the entire address book" ) ); 270 Q3WhatsThis::add( mUseWholeBook, i18n( "Select the entire address book" ) );
266 groupLayout->addWidget( mUseWholeBook, 0, 0 ); 271 groupLayout->addWidget( mUseWholeBook, 0, 0 );
267 272
268 mUseSelection = new QRadioButton( i18n( "&Selected" ), mButtonGroup ); 273 mUseSelection = new QRadioButton( i18n( "&Selected" ), mButtonGroup );
269 QWhatsThis::add( mUseSelection, i18n( "Only contacts selected in KAddressBook.\n" 274 Q3WhatsThis::add( mUseSelection, i18n( "Only contacts selected in KAddressBook.\n"
270 "This option is disabled if no contacts are selected." ) ); 275 "This option is disabled if no contacts are selected." ) );
271 groupLayout->addWidget( mUseSelection, 1, 0 ); 276 groupLayout->addWidget( mUseSelection, 1, 0 );
272 277
273 mUseFilters = new QRadioButton( i18n( "By matching &filter" ), mButtonGroup ); 278 mUseFilters = new QRadioButton( i18n( "By matching &filter" ), mButtonGroup );
274 QWhatsThis::add( mUseFilters, i18n( "Only contacts matching the selected filter.\n" 279 Q3WhatsThis::add( mUseFilters, i18n( "Only contacts matching the selected filter.\n"
275 "This option is disabled if you haven't defined any filters" ) ); 280 "This option is disabled if you haven't defined any filters" ) );
276 groupLayout->addWidget( mUseFilters, 2, 0 ); 281 groupLayout->addWidget( mUseFilters, 2, 0 );
277 282
278 mUseCategories = new QRadioButton( i18n( "By Cate&gories" ), mButtonGroup ); 283 mUseCategories = new QRadioButton( i18n( "By Cate&gories" ), mButtonGroup );
279 QWhatsThis::add( mUseCategories, i18n( "Only contacts who are members of a category that is checked on the list to the left.\n" 284 Q3WhatsThis::add( mUseCategories, i18n( "Only contacts who are members of a category that is checked on the list to the left.\n"
280 "This option is disabled if you have no categories." ) ); 285 "This option is disabled if you have no categories." ) );
281 groupLayout->addWidget( mUseCategories, 3, 0 ); 286 groupLayout->addWidget( mUseCategories, 3, 0 );
282 287
283 mFiltersCombo = new QComboBox( false, mButtonGroup ); 288 mFiltersCombo = new QComboBox( false, mButtonGroup );
284 mFiltersCombo->setSizePolicy(QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); 289 mFiltersCombo->setSizePolicy(QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
285 QWhatsThis::add( mFiltersCombo, i18n( "Select a filter to decide which contacts to select." ) ); 290 Q3WhatsThis::add( mFiltersCombo, i18n( "Select a filter to decide which contacts to select." ) );
286 groupLayout->addWidget( mFiltersCombo, 2, 1 ); 291 groupLayout->addWidget( mFiltersCombo, 2, 1 );
287 292
288 mCategoriesView = new QListView( mButtonGroup ); 293 mCategoriesView = new Q3ListView( mButtonGroup );
289 mCategoriesView->addColumn( "" ); 294 mCategoriesView->addColumn( "" );
290 mCategoriesView->header()->hide(); 295 mCategoriesView->header()->hide();
291 QWhatsThis::add( mCategoriesView, i18n( "Check the categories whose members you want to select." ) ); 296 Q3WhatsThis::add( mCategoriesView, i18n( "Check the categories whose members you want to select." ) );
292 groupLayout->addWidget( mCategoriesView, 3, 1 ); 297 groupLayout->addWidget( mCategoriesView, 3, 1 );
293 mCategoriesView->setSizePolicy(QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); 298 mCategoriesView->setSizePolicy(QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
294 //if (QApplication::desktop()->height() == 480 ) 299 //if (QApplication::desktop()->height() == 480 )
295 // mCategoriesView->setMaximumHeight( 240 ); 300 // mCategoriesView->setMaximumHeight( 240 );
296 topLayout->addWidget( mButtonGroup ); 301 topLayout->addWidget( mButtonGroup );
297 302
298 QButtonGroup *sortingGroup = new QButtonGroup( i18n( "Sorting" ), page ); 303 Q3ButtonGroup *sortingGroup = new Q3ButtonGroup( i18n( "Sorting" ), page );
299 sortingGroup->setColumnLayout( 0, Qt::Vertical ); 304 sortingGroup->setColumnLayout( 0, Qt::Vertical );
300 QGridLayout *sortLayout = new QGridLayout( sortingGroup->layout(), 2, 2, 305 Q3GridLayout *sortLayout = new Q3GridLayout( sortingGroup->layout(), 2, 2,
301 KDialog::spacingHint() ); 306 KDialog::spacingHint() );
302 sortLayout->setAlignment( Qt::AlignTop ); 307 sortLayout->setAlignment( Qt::AlignTop );
303 308
304 label = new QLabel( i18n( "Criterion:" ), sortingGroup ); 309 label = new QLabel( i18n( "Criterion:" ), sortingGroup );
305 sortLayout->addWidget( label, 0, 0 ); 310 sortLayout->addWidget( label, 0, 0 );
306 311
307#ifndef KAB_EMBEDDED 312#ifndef KAB_EMBEDDED
308 mFieldCombo = new KComboBox( false, sortingGroup ); 313 mFieldCombo = new KComboBox( false, sortingGroup );
309#else //KAB_EMBEDDED 314#else //KAB_EMBEDDED
310 //US Combobox is not editable anyway 315 //US Combobox is not editable anyway
311 mFieldCombo = new KComboBox( sortingGroup ); 316 mFieldCombo = new KComboBox( sortingGroup );
312#endif //KAB_EMBEDDED 317#endif //KAB_EMBEDDED
313 sortLayout->addWidget( mFieldCombo, 0, 1 ); 318 sortLayout->addWidget( mFieldCombo, 0, 1 );
314 319
315 label = new QLabel( i18n( "Order:" ), sortingGroup ); 320 label = new QLabel( i18n( "Order:" ), sortingGroup );
316 sortLayout->addWidget( label, 1, 0 ); 321 sortLayout->addWidget( label, 1, 0 );
317 322
318#ifndef KAB_EMBEDDED 323#ifndef KAB_EMBEDDED
319 mSortTypeCombo = new KComboBox( false, sortingGroup ); 324 mSortTypeCombo = new KComboBox( false, sortingGroup );
320#else //KAB_EMBEDDED 325#else //KAB_EMBEDDED
321 //US Combobox is not editable anyway 326 //US Combobox is not editable anyway
322 mSortTypeCombo = new KComboBox( sortingGroup ); 327 mSortTypeCombo = new KComboBox( sortingGroup );
323#endif //KAB_EMBEDDED 328#endif //KAB_EMBEDDED
324 sortLayout->addWidget( mSortTypeCombo, 1, 1 ); 329 sortLayout->addWidget( mSortTypeCombo, 1, 1 );
325 330
326 topLayout->addWidget( sortingGroup ); 331 topLayout->addWidget( sortingGroup );
327 332
328 if ( !mUseSorting ) 333 if ( !mUseSorting )
329 sortingGroup->hide(); 334 sortingGroup->hide();
330 if (QApplication::desktop()->width() <= 640 ) { 335 if (QApplication::desktop()->width() <= 640 ) {
331 showMaximized(); 336 showMaximized();
332#ifndef DESKTOP_VERSION 337#ifndef DESKTOP_VERSION
333 hideButtons(); 338 hideButtons();
334#endif 339#endif
335 } 340 }
336} 341}
337 342
338#ifndef KAB_EMBEDDED 343#ifndef KAB_EMBEDDED_
339#include "xxportselectdialog.moc" 344#include "moc_xxportselectdialog.cpp"
340#endif //KAB_EMBEDDED 345#endif //KAB_EMBEDDED
341
342