summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/xxportselectdialog.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/kaddressbook/xxportselectdialog.cpp b/kaddressbook/xxportselectdialog.cpp
index e0da3b2..41c999b 100644
--- a/kaddressbook/xxportselectdialog.cpp
+++ b/kaddressbook/xxportselectdialog.cpp
@@ -1,279 +1,279 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk> 3 Copyright (c) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
4 Tobias Koenig <tokoe@kde.org> 4 Tobias Koenig <tokoe@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25/* 25/*
26Enhanced Version of the file for platform independent KDE tools. 26Enhanced Version of the file for platform independent KDE tools.
27Copyright (c) 2004 Ulf Schenk 27Copyright (c) 2004 Ulf Schenk
28 28
29$Id$ 29$Id$
30*/ 30*/
31 31
32#include <kabc/addressbook.h> 32#include <kabc/addressbook.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <kcombobox.h> 34#include <kcombobox.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kglobal.h> 36#include <kglobal.h>
37 37
38#include <qbuttongroup.h> 38#include <qbuttongroup.h>
39#include <qcombobox.h> 39#include <qcombobox.h>
40#include <qheader.h> 40#include <qheader.h>
41#include <qlabel.h> 41#include <qlabel.h>
42#include <qlayout.h> 42#include <qlayout.h>
43#include <qlistview.h> 43#include <qlistview.h>
44#include <qpushbutton.h> 44#include <qpushbutton.h>
45#include <qradiobutton.h> 45#include <qradiobutton.h>
46#include <qstringlist.h> 46#include <qstringlist.h>
47#include <qwhatsthis.h> 47#include <qwhatsthis.h>
48 48
49#include "kabcore.h" 49#include "kabcore.h"
50#include "kabprefs.h" 50#include "kabprefs.h"
51 51
52#include "xxportselectdialog.h" 52#include "xxportselectdialog.h"
53 53
54XXPortSelectDialog::XXPortSelectDialog( KABCore *core, bool sort, 54XXPortSelectDialog::XXPortSelectDialog( KABCore *core, bool sort,
55 QWidget* parent, const char* name ) 55 QWidget* parent, const char* name )
56 : KDialogBase( Plain, i18n( "Choose which contacts to export" ), Help | Ok | Cancel, 56 : KDialogBase( Plain, i18n( "Choose which contacts to export" ), Help | Ok | Cancel,
57 Ok, parent, name, true, true ), mCore( core ), 57 Ok, parent, name, true, true ), mCore( core ),
58 mUseSorting( sort ) 58 mUseSorting( sort )
59{ 59{
60 initGUI(); 60 initGUI();
61 61
62 connect( mFiltersCombo, SIGNAL( activated( int ) ), 62 connect( mFiltersCombo, SIGNAL( activated( int ) ),
63 SLOT( filterChanged( int ) ) ); 63 SLOT( filterChanged( int ) ) );
64 connect( mCategoriesView, SIGNAL( clicked( QListViewItem* ) ), 64 connect( mCategoriesView, SIGNAL( clicked( QListViewItem* ) ),
65 SLOT( categoryClicked( QListViewItem* ) ) ); 65 SLOT( categoryClicked( QListViewItem* ) ) );
66 66
67 // setup filters 67 // setup filters
68#ifndef KAB_EMBEDDED 68#ifndef KAB_EMBEDDED
69 mFilters = Filter::restore( kapp->config(), "Filter" ); 69 mFilters = Filter::restore( kapp->config(), "Filter" );
70 Filter::List::iterator filterIt; 70 Filter::List::iterator filterIt;
71#else //KAB_EMBEDDED 71#else //KAB_EMBEDDED
72 mFilters = Filter::restore( KGlobal::config(), "Filter" ); 72 mFilters = Filter::restore( KGlobal::config(), "Filter" );
73 Filter::List::Iterator filterIt; 73 Filter::List::Iterator filterIt;
74#endif //KAB_EMBEDDED 74#endif //KAB_EMBEDDED
75 QStringList filters; 75 QStringList filters;
76 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt ) 76 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt )
77 filters.append( (*filterIt).name() ); 77 filters.append( (*filterIt).name() );
78 78
79 mFiltersCombo->insertStringList( filters ); 79 mFiltersCombo->insertStringList( filters );
80 mUseFilters->setEnabled( filters.count() > 0 ); 80 mUseFilters->setEnabled( filters.count() > 0 );
81 81
82 // setup categories 82 // setup categories
83 QStringList categories = KABPrefs::instance()->mCustomCategories; 83 QStringList categories = KABPrefs::instance()->mCustomCategories;
84 QStringList::Iterator it; 84 QStringList::Iterator it;
85 for ( it = categories.begin(); it != categories.end(); ++it ) 85 for ( it = categories.begin(); it != categories.end(); ++it )
86 new QCheckListItem( mCategoriesView, *it, QCheckListItem::CheckBox ); 86 new QCheckListItem( mCategoriesView, *it, QCheckListItem::CheckBox );
87 mUseCategories->setEnabled( categories.count() > 0 ); 87 mUseCategories->setEnabled( categories.count() > 0 );
88 88
89 int count = mCore->selectedUIDs().count(); 89 int count = mCore->selectedUIDs().count();
90 mUseSelection->setEnabled( count != 0 ); 90 mUseSelection->setEnabled( count != 0 );
91 mUseSelection->setChecked( count > 1 ); 91 mUseSelection->setChecked( count > 1 );
92 92
93 mSortTypeCombo->insertItem( i18n( "Ascending" ) ); 93 mSortTypeCombo->insertItem( i18n( "Ascending" ) );
94 mSortTypeCombo->insertItem( i18n( "Descending" ) ); 94 mSortTypeCombo->insertItem( i18n( "Descending" ) );
95 95
96 mFields = mCore->addressBook()->fields( KABC::Field::All ); 96 mFields = mCore->addressBook()->fields( KABC::Field::All );
97 KABC::Field::List::Iterator fieldIt; 97 KABC::Field::List::Iterator fieldIt;
98 for ( fieldIt = mFields.begin(); fieldIt != mFields.end(); ++fieldIt ) 98 for ( fieldIt = mFields.begin(); fieldIt != mFields.end(); ++fieldIt )
99 mFieldCombo->insertItem( (*fieldIt)->label() ); 99 mFieldCombo->insertItem( (*fieldIt)->label() );
100} 100}
101 101
102KABC::AddresseeList XXPortSelectDialog::contacts() 102KABC::AddresseeList XXPortSelectDialog::contacts()
103{ 103{
104 QStringList selection = mCore->selectedUIDs(); 104 QStringList selection = mCore->selectedUIDs();
105 105
106 KABC::AddresseeList list; 106 KABC::AddresseeList list;
107 if ( mUseSelection->isChecked() ) { 107 if ( mUseSelection->isChecked() ) {
108 QStringList::Iterator it; 108 QStringList::Iterator it;
109 for ( it = selection.begin(); it != selection.end(); ++it ) { 109 for ( it = selection.begin(); it != selection.end(); ++it ) {
110 KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); 110 KABC::Addressee addr = mCore->addressBook()->findByUid( *it );
111 if ( !addr.isEmpty() ) 111 if ( !addr.isEmpty() )
112 list.append( addr ); 112 list.append( addr );
113 } 113 }
114 } else if ( mUseFilters->isChecked() ) { 114 } else if ( mUseFilters->isChecked() ) {
115 // find contacts that can pass selected filter 115 // find contacts that can pass selected filter
116 Filter::List::Iterator filterIt; 116 Filter::List::Iterator filterIt;
117 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt ) 117 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt )
118 if ( (*filterIt).name() == mFiltersCombo->currentText() ) 118 if ( (*filterIt).name() == mFiltersCombo->currentText() )
119 break; 119 break;
120 120
121 KABC::AddressBook::Iterator it; 121 KABC::AddressBook::Iterator it;
122 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { 122 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) {
123 if ( (*filterIt).filterAddressee( *it ) ) 123 if ( (*filterIt).filterAddressee( *it ) )
124 list.append( *it ); 124 list.append( *it );
125 } 125 }
126 } else if ( mUseCategories->isChecked() ) { 126 } else if ( mUseCategories->isChecked() ) {
127 QStringList categorieList = categories(); 127 QStringList categorieList = categories();
128 KABC::AddressBook::Iterator it; 128 KABC::AddressBook::Iterator it;
129 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { 129 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) {
130 QStringList tmp( (*it).categories() ); 130 QStringList tmp( (*it).categories() );
131 QStringList::Iterator tmpIt; 131 QStringList::Iterator tmpIt;
132 for ( tmpIt = tmp.begin(); tmpIt != tmp.end(); ++tmpIt ) 132 for ( tmpIt = tmp.begin(); tmpIt != tmp.end(); ++tmpIt )
133 if ( categorieList.contains( *tmpIt ) ) { 133 if ( categorieList.contains( *tmpIt ) ) {
134 list.append( *it ); 134 list.append( *it );
135 break; 135 break;
136 } 136 }
137 } 137 }
138 } else { 138 } else {
139 // create a string list of all entries: 139 // create a string list of all entries:
140 KABC::AddressBook::Iterator it; 140 KABC::AddressBook::Iterator it;
141 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) 141 for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it )
142 list.append( *it ); 142 list.append( *it );
143 } 143 }
144 144
145 if ( mUseSorting ) { 145 if ( mUseSorting ) {
146 list.setReverseSorting( mSortTypeCombo->currentItem() == 1 ); 146 list.setReverseSorting( mSortTypeCombo->currentItem() == 1 );
147 uint pos = mFieldCombo->currentItem(); 147 uint pos = mFieldCombo->currentItem();
148 if ( pos < mFields.count() ) 148 if ( pos < mFields.count() )
149 list.sortByField( mFields[ pos ] ); 149 list.sortByField( mFields[ pos ] );
150 } 150 }
151 151
152 return list; 152 return list;
153} 153}
154 154
155QStringList XXPortSelectDialog::categories() const 155QStringList XXPortSelectDialog::categories() const
156{ 156{
157 QStringList list; 157 QStringList list;
158 158
159 QListViewItemIterator it( mCategoriesView ); 159 QListViewItemIterator it( mCategoriesView );
160 for ( ; it.current(); ++it ) { 160 for ( ; it.current(); ++it ) {
161 QCheckListItem* qcli = static_cast<QCheckListItem*>(it.current()); 161 QCheckListItem* qcli = static_cast<QCheckListItem*>(it.current());
162 if ( qcli->isOn() ) 162 if ( qcli->isOn() )
163 list.append( it.current()->text( 0 ) ); 163 list.append( it.current()->text( 0 ) );
164 } 164 }
165 165
166 return list; 166 return list;
167} 167}
168 168
169void XXPortSelectDialog::filterChanged( int ) 169void XXPortSelectDialog::filterChanged( int )
170{ 170{
171 mUseFilters->setChecked( true ); 171 mUseFilters->setChecked( true );
172} 172}
173 173
174void XXPortSelectDialog::categoryClicked( QListViewItem *i ) 174void XXPortSelectDialog::categoryClicked( QListViewItem *i )
175{ 175{
176 QCheckListItem *qcli = static_cast<QCheckListItem*>( i ); 176 QCheckListItem *qcli = static_cast<QCheckListItem*>( i );
177 if ( qcli->isOn() ) 177 if ( qcli->isOn() )
178 mUseCategories->setChecked( true ); 178 mUseCategories->setChecked( true );
179} 179}
180 180
181void XXPortSelectDialog::slotHelp() 181void XXPortSelectDialog::slotHelp()
182{ 182{
183#ifndef KAB_EMBEDDED 183#ifndef KAB_EMBEDDED
184 kapp->invokeHelp( "import-and-export" ); 184 kapp->invokeHelp( "import-and-export" );
185#else //KAB_EMBEDDED 185#else //KAB_EMBEDDED
186 qDebug("XXPortSelectDialog::slotHelp is not implemented yet"); 186 qDebug("XXPortSelectDialog::slotHelp is not implemented yet");
187#endif //KAB_EMBEDDED 187#endif //KAB_EMBEDDED
188 188
189} 189}
190 190
191void XXPortSelectDialog::initGUI() 191void XXPortSelectDialog::initGUI()
192{ 192{
193 QFrame *page = plainPage(); 193 QFrame *page = plainPage();
194 194
195 QVBoxLayout *topLayout = new QVBoxLayout( page, KDialog::marginHint(), 195 QVBoxLayout *topLayout = new QVBoxLayout( page, KDialog::marginHint(),
196 KDialog::spacingHint() ); 196 KDialog::spacingHint() );
197 197
198 QLabel *label = new QLabel( i18n( "Which contacts do you want to export?" ), page ); 198 QLabel *label = new QLabel( i18n( "Which contacts do you want to export?" ), page );
199 topLayout->addWidget( label ); 199 topLayout->addWidget( label );
200 200
201 mButtonGroup = new QButtonGroup( i18n( "Selection" ), page ); 201 mButtonGroup = new QButtonGroup( i18n( "Contact Selection" ), page );
202 mButtonGroup->setColumnLayout( 0, Qt::Vertical ); 202 mButtonGroup->setColumnLayout( 0, Qt::Vertical );
203 mButtonGroup->layout()->setSpacing( KDialog::spacingHint() ); 203 mButtonGroup->layout()->setSpacing( KDialog::spacingHint() );
204 mButtonGroup->layout()->setMargin( KDialog::marginHint() ); 204 mButtonGroup->layout()->setMargin( KDialog::marginHint() );
205 205
206 QGridLayout *groupLayout = new QGridLayout( mButtonGroup->layout() ); 206 QGridLayout *groupLayout = new QGridLayout( mButtonGroup->layout() );
207 groupLayout->setAlignment( Qt::AlignTop ); 207 groupLayout->setAlignment( Qt::AlignTop );
208 208
209 mUseWholeBook = new QRadioButton( i18n( "&All contacts" ), mButtonGroup ); 209 mUseWholeBook = new QRadioButton( i18n( "&All" ), mButtonGroup );
210 mUseWholeBook->setChecked( true ); 210 mUseWholeBook->setChecked( true );
211 QWhatsThis::add( mUseWholeBook, i18n( "Export the entire address book" ) ); 211 QWhatsThis::add( mUseWholeBook, i18n( "Export the entire address book" ) );
212 groupLayout->addWidget( mUseWholeBook, 0, 0 ); 212 groupLayout->addWidget( mUseWholeBook, 0, 0 );
213 213
214 mUseSelection = new QRadioButton( i18n( "&Selected contacts" ), mButtonGroup ); 214 mUseSelection = new QRadioButton( i18n( "&Selected" ), mButtonGroup );
215 QWhatsThis::add( mUseSelection, i18n( "Only export contacts selected in KAddressBook.\n" 215 QWhatsThis::add( mUseSelection, i18n( "Only export contacts selected in KAddressBook.\n"
216 "This option is disabled if no contacts are selected." ) ); 216 "This option is disabled if no contacts are selected." ) );
217 groupLayout->addWidget( mUseSelection, 1, 0 ); 217 groupLayout->addWidget( mUseSelection, 1, 0 );
218 218
219 mUseFilters = new QRadioButton( i18n( "Contacts matching &filter" ), mButtonGroup ); 219 mUseFilters = new QRadioButton( i18n( "By matching &filter" ), mButtonGroup );
220 QWhatsThis::add( mUseFilters, i18n( "Only export contacts matching the selected filter.\n" 220 QWhatsThis::add( mUseFilters, i18n( "Only export contacts matching the selected filter.\n"
221 "This option is disabled if you haven't defined any filters" ) ); 221 "This option is disabled if you haven't defined any filters" ) );
222 groupLayout->addWidget( mUseFilters, 2, 0 ); 222 groupLayout->addWidget( mUseFilters, 2, 0 );
223 223
224 mUseCategories = new QRadioButton( i18n( "Category &members" ), mButtonGroup ); 224 mUseCategories = new QRadioButton( i18n( "By Cate&gories" ), mButtonGroup );
225 QWhatsThis::add( mUseCategories, i18n( "Only export contacts who are members of a category that is checked on the list to the left.\n" 225 QWhatsThis::add( mUseCategories, i18n( "Only export contacts who are members of a category that is checked on the list to the left.\n"
226 "This option is disabled if you have no categories." ) ); 226 "This option is disabled if you have no categories." ) );
227 groupLayout->addWidget( mUseCategories, 3, 0 ); 227 groupLayout->addWidget( mUseCategories, 3, 0 );
228 228
229 mFiltersCombo = new QComboBox( false, mButtonGroup ); 229 mFiltersCombo = new QComboBox( false, mButtonGroup );
230 QWhatsThis::add( mFiltersCombo, i18n( "Select a filter to decide which contacts to export." ) ); 230 QWhatsThis::add( mFiltersCombo, i18n( "Select a filter to decide which contacts to export." ) );
231 groupLayout->addWidget( mFiltersCombo, 2, 1 ); 231 groupLayout->addWidget( mFiltersCombo, 2, 1 );
232 232
233 mCategoriesView = new QListView( mButtonGroup ); 233 mCategoriesView = new QListView( mButtonGroup );
234 mCategoriesView->addColumn( "" ); 234 mCategoriesView->addColumn( "" );
235 mCategoriesView->header()->hide(); 235 mCategoriesView->header()->hide();
236 QWhatsThis::add( mCategoriesView, i18n( "Check the categories whose members you want to export." ) ); 236 QWhatsThis::add( mCategoriesView, i18n( "Check the categories whose members you want to export." ) );
237 groupLayout->addWidget( mCategoriesView, 3, 1 ); 237 groupLayout->addWidget( mCategoriesView, 3, 1 );
238 238
239 topLayout->addWidget( mButtonGroup ); 239 topLayout->addWidget( mButtonGroup );
240 240
241 QButtonGroup *sortingGroup = new QButtonGroup( i18n( "Sorting" ), page ); 241 QButtonGroup *sortingGroup = new QButtonGroup( i18n( "Sorting" ), page );
242 sortingGroup->setColumnLayout( 0, Qt::Vertical ); 242 sortingGroup->setColumnLayout( 0, Qt::Vertical );
243 QGridLayout *sortLayout = new QGridLayout( sortingGroup->layout(), 2, 2, 243 QGridLayout *sortLayout = new QGridLayout( sortingGroup->layout(), 2, 2,
244 KDialog::spacingHint() ); 244 KDialog::spacingHint() );
245 sortLayout->setAlignment( Qt::AlignTop ); 245 sortLayout->setAlignment( Qt::AlignTop );
246 246
247 label = new QLabel( i18n( "Criterion:" ), sortingGroup ); 247 label = new QLabel( i18n( "Criterion:" ), sortingGroup );
248 sortLayout->addWidget( label, 0, 0 ); 248 sortLayout->addWidget( label, 0, 0 );
249 249
250#ifndef KAB_EMBEDDED 250#ifndef KAB_EMBEDDED
251 mFieldCombo = new KComboBox( false, sortingGroup ); 251 mFieldCombo = new KComboBox( false, sortingGroup );
252#else //KAB_EMBEDDED 252#else //KAB_EMBEDDED
253 //US Combobox is not editable anyway 253 //US Combobox is not editable anyway
254 mFieldCombo = new KComboBox( sortingGroup ); 254 mFieldCombo = new KComboBox( sortingGroup );
255#endif //KAB_EMBEDDED 255#endif //KAB_EMBEDDED
256 sortLayout->addWidget( mFieldCombo, 0, 1 ); 256 sortLayout->addWidget( mFieldCombo, 0, 1 );
257 257
258 label = new QLabel( i18n( "Order:" ), sortingGroup ); 258 label = new QLabel( i18n( "Order:" ), sortingGroup );
259 sortLayout->addWidget( label, 1, 0 ); 259 sortLayout->addWidget( label, 1, 0 );
260 260
261#ifndef KAB_EMBEDDED 261#ifndef KAB_EMBEDDED
262 mSortTypeCombo = new KComboBox( false, sortingGroup ); 262 mSortTypeCombo = new KComboBox( false, sortingGroup );
263#else //KAB_EMBEDDED 263#else //KAB_EMBEDDED
264 //US Combobox is not editable anyway 264 //US Combobox is not editable anyway
265 mSortTypeCombo = new KComboBox( sortingGroup ); 265 mSortTypeCombo = new KComboBox( sortingGroup );
266#endif //KAB_EMBEDDED 266#endif //KAB_EMBEDDED
267 sortLayout->addWidget( mSortTypeCombo, 1, 1 ); 267 sortLayout->addWidget( mSortTypeCombo, 1, 1 );
268 268
269 topLayout->addWidget( sortingGroup ); 269 topLayout->addWidget( sortingGroup );
270 270
271 if ( !mUseSorting ) 271 if ( !mUseSorting )
272 sortingGroup->hide(); 272 sortingGroup->hide();
273} 273}
274 274
275#ifndef KAB_EMBEDDED 275#ifndef KAB_EMBEDDED
276#include "xxportselectdialog.moc" 276#include "xxportselectdialog.moc"
277#endif //KAB_EMBEDDED 277#endif //KAB_EMBEDDED
278 278
279 279