author | zautrix <zautrix> | 2005-01-17 18:22:47 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-17 18:22:47 (UTC) |
commit | 32479683283fc9f20d369ac9671ba0f8a33d3381 (patch) (unidiff) | |
tree | 0d764657db915bd2d2bf2fb751800eb14515626b /kaddressbook/xxportselectdialog.cpp | |
parent | 11e05160cda1571a208edbabc71f6d94e394d829 (diff) | |
download | kdepimpi-32479683283fc9f20d369ac9671ba0f8a33d3381.zip kdepimpi-32479683283fc9f20d369ac9671ba0f8a33d3381.tar.gz kdepimpi-32479683283fc9f20d369ac9671ba0f8a33d3381.tar.bz2 |
fast set formatted name
Diffstat (limited to 'kaddressbook/xxportselectdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/xxportselectdialog.cpp | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/kaddressbook/xxportselectdialog.cpp b/kaddressbook/xxportselectdialog.cpp index 6282453..e7bc8c0 100644 --- a/kaddressbook/xxportselectdialog.cpp +++ b/kaddressbook/xxportselectdialog.cpp | |||
@@ -33,49 +33,49 @@ $Id$ | |||
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 <qbuttongroup.h> |
40 | #include <qcombobox.h> | 40 | #include <qcombobox.h> |
41 | #include <qheader.h> | 41 | #include <qheader.h> |
42 | #include <qlabel.h> | 42 | #include <qlabel.h> |
43 | #include <qlayout.h> | 43 | #include <qlayout.h> |
44 | #include <qlistview.h> | 44 | #include <qlistview.h> |
45 | #include <qpushbutton.h> | 45 | #include <qpushbutton.h> |
46 | #include <qradiobutton.h> | 46 | #include <qradiobutton.h> |
47 | #include <qstringlist.h> | 47 | #include <qstringlist.h> |
48 | #include <qwhatsthis.h> | 48 | #include <qwhatsthis.h> |
49 | 49 | ||
50 | #include "kabcore.h" | 50 | #include "kabcore.h" |
51 | #include "kabprefs.h" | 51 | #include "kabprefs.h" |
52 | 52 | ||
53 | #include "xxportselectdialog.h" | 53 | #include "xxportselectdialog.h" |
54 | 54 | ||
55 | XXPortSelectDialog::XXPortSelectDialog( KABCore *core, bool sort, | 55 | XXPortSelectDialog::XXPortSelectDialog( KABCore *core, bool sort, |
56 | QWidget* parent, const char* name ) | 56 | QWidget* parent, const char* name ) |
57 | : KDialogBase( Plain, i18n( "Choose which contacts to select" ), Help | Ok | Cancel, | 57 | : KDialogBase( Plain, i18n( "Choose contact selection" ), Help | Ok | Cancel, |
58 | Ok, parent, name, true, true ), mCore( core ), | 58 | Ok, parent, name, true, true ), mCore( core ), |
59 | mUseSorting( sort ) | 59 | mUseSorting( sort ) |
60 | { | 60 | { |
61 | initGUI(); | 61 | initGUI(); |
62 | 62 | ||
63 | connect( mFiltersCombo, SIGNAL( activated( int ) ), | 63 | connect( mFiltersCombo, SIGNAL( activated( int ) ), |
64 | SLOT( filterChanged( int ) ) ); | 64 | SLOT( filterChanged( int ) ) ); |
65 | connect( mCategoriesView, SIGNAL( clicked( QListViewItem* ) ), | 65 | connect( mCategoriesView, SIGNAL( clicked( QListViewItem* ) ), |
66 | SLOT( categoryClicked( QListViewItem* ) ) ); | 66 | SLOT( categoryClicked( QListViewItem* ) ) ); |
67 | 67 | ||
68 | // setup filters | 68 | // setup filters |
69 | #ifndef KAB_EMBEDDED | 69 | #ifndef KAB_EMBEDDED |
70 | mFilters = Filter::restore( kapp->config(), "Filter" ); | 70 | mFilters = Filter::restore( kapp->config(), "Filter" ); |
71 | Filter::List::iterator filterIt; | 71 | Filter::List::iterator filterIt; |
72 | #else //KAB_EMBEDDED | 72 | #else //KAB_EMBEDDED |
73 | mFilters = Filter::restore( KGlobal::config(), "Filter" ); | 73 | mFilters = Filter::restore( KGlobal::config(), "Filter" ); |
74 | Filter::List::Iterator filterIt; | 74 | Filter::List::Iterator filterIt; |
75 | #endif //KAB_EMBEDDED | 75 | #endif //KAB_EMBEDDED |
76 | QStringList filters; | 76 | QStringList filters; |
77 | for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt ) | 77 | for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt ) |
78 | filters.append( (*filterIt).name() ); | 78 | filters.append( (*filterIt).name() ); |
79 | 79 | ||
80 | mFiltersCombo->insertStringList( filters ); | 80 | mFiltersCombo->insertStringList( filters ); |
81 | mUseFilters->setEnabled( filters.count() > 0 ); | 81 | mUseFilters->setEnabled( filters.count() > 0 ); |
@@ -88,55 +88,95 @@ XXPortSelectDialog::XXPortSelectDialog( KABCore *core, bool sort, | |||
88 | mUseCategories->setEnabled( categories.count() > 0 ); | 88 | mUseCategories->setEnabled( categories.count() > 0 ); |
89 | 89 | ||
90 | int count = mCore->selectedUIDs().count(); | 90 | int count = mCore->selectedUIDs().count(); |
91 | mUseSelection->setEnabled( count != 0 ); | 91 | mUseSelection->setEnabled( count != 0 ); |
92 | mUseSelection->setChecked( count > 1 ); | 92 | mUseSelection->setChecked( count > 1 ); |
93 | 93 | ||
94 | mSortTypeCombo->insertItem( i18n( "Ascending" ) ); | 94 | mSortTypeCombo->insertItem( i18n( "Ascending" ) ); |
95 | mSortTypeCombo->insertItem( i18n( "Descending" ) ); | 95 | mSortTypeCombo->insertItem( i18n( "Descending" ) ); |
96 | 96 | ||
97 | mFields = mCore->addressBook()->fields( KABC::Field::All ); | 97 | mFields = mCore->addressBook()->fields( KABC::Field::All ); |
98 | KABC::Field::List::Iterator fieldIt; | 98 | KABC::Field::List::Iterator fieldIt; |
99 | for ( fieldIt = mFields.begin(); fieldIt != mFields.end(); ++fieldIt ) | 99 | for ( fieldIt = mFields.begin(); fieldIt != mFields.end(); ++fieldIt ) |
100 | mFieldCombo->insertItem( (*fieldIt)->label() ); | 100 | mFieldCombo->insertItem( (*fieldIt)->label() ); |
101 | } | 101 | } |
102 | 102 | ||
103 | QStringList XXPortSelectDialog::uids() | 103 | QStringList XXPortSelectDialog::uids() |
104 | { | 104 | { |
105 | QStringList uidlist; | 105 | QStringList uidlist; |
106 | KABC::AddresseeList list = contacts(); | 106 | KABC::AddresseeList list = contacts(); |
107 | KABC::Addressee::List::Iterator it; | 107 | KABC::Addressee::List::Iterator it; |
108 | for ( it = list.begin(); it != list.end(); ++it ) | 108 | for ( it = list.begin(); it != list.end(); ++it ) |
109 | uidlist.append((*it).uid()); | 109 | uidlist.append((*it).uid()); |
110 | return uidlist; | 110 | return uidlist; |
111 | } | 111 | } |
112 | void XXPortSelectDialog::tagSelected() | ||
113 | { | ||
114 | if ( mUseSelection->isChecked() ) { | ||
115 | |||
116 | QStringList selection = mCore->selectedUIDs(); | ||
117 | KABC::AddressBook::Iterator it; | ||
118 | for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { | ||
119 | if ( selection.findIndex((*it).uid()) >= 0 ) | ||
120 | (*it).setTagged( true ); | ||
121 | } | ||
122 | } else if ( mUseFilters->isChecked() ) { | ||
123 | // find contacts that can pass selected filter | ||
124 | Filter::List::Iterator filterIt; | ||
125 | for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt ) | ||
126 | if ( (*filterIt).name() == mFiltersCombo->currentText() ) | ||
127 | break; | ||
128 | KABC::AddressBook::Iterator it; | ||
129 | for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { | ||
130 | if ( (*filterIt).filterAddressee( *it ) ) | ||
131 | (*it).setTagged( true ); | ||
132 | } | ||
133 | } else if ( mUseCategories->isChecked() ) { | ||
134 | QStringList categorieList = categories(); | ||
135 | KABC::AddressBook::Iterator it; | ||
136 | for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { | ||
137 | QStringList tmp( (*it).categories() ); | ||
138 | QStringList::Iterator tmpIt; | ||
139 | for ( tmpIt = tmp.begin(); tmpIt != tmp.end(); ++tmpIt ) | ||
140 | if ( categorieList.contains( *tmpIt ) ) { | ||
141 | (*it).setTagged( true ); | ||
142 | break; | ||
143 | } | ||
144 | } | ||
145 | } else { | ||
146 | // create a string list of all entries: | ||
147 | KABC::AddressBook::Iterator it; | ||
148 | for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) | ||
149 | (*it).setTagged( true ); | ||
150 | } | ||
151 | } | ||
112 | KABC::AddresseeList XXPortSelectDialog::contacts() | 152 | KABC::AddresseeList XXPortSelectDialog::contacts() |
113 | { | 153 | { |
114 | QStringList selection = mCore->selectedUIDs(); | ||
115 | 154 | ||
116 | KABC::AddresseeList list; | 155 | KABC::AddresseeList list; |
117 | if ( mUseSelection->isChecked() ) { | 156 | if ( mUseSelection->isChecked() ) { |
118 | QStringList::Iterator it; | 157 | QStringList::Iterator it; |
158 | QStringList selection = mCore->selectedUIDs(); | ||
119 | for ( it = selection.begin(); it != selection.end(); ++it ) { | 159 | for ( it = selection.begin(); it != selection.end(); ++it ) { |
120 | KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); | 160 | KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); |
121 | if ( !addr.isEmpty() ) | 161 | if ( !addr.isEmpty() ) |
122 | list.append( addr ); | 162 | list.append( addr ); |
123 | } | 163 | } |
124 | } else if ( mUseFilters->isChecked() ) { | 164 | } else if ( mUseFilters->isChecked() ) { |
125 | // find contacts that can pass selected filter | 165 | // find contacts that can pass selected filter |
126 | Filter::List::Iterator filterIt; | 166 | Filter::List::Iterator filterIt; |
127 | for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt ) | 167 | for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt ) |
128 | if ( (*filterIt).name() == mFiltersCombo->currentText() ) | 168 | if ( (*filterIt).name() == mFiltersCombo->currentText() ) |
129 | break; | 169 | break; |
130 | 170 | ||
131 | KABC::AddressBook::Iterator it; | 171 | KABC::AddressBook::Iterator it; |
132 | for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { | 172 | for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { |
133 | if ( (*filterIt).filterAddressee( *it ) ) | 173 | if ( (*filterIt).filterAddressee( *it ) ) |
134 | list.append( *it ); | 174 | list.append( *it ); |
135 | } | 175 | } |
136 | } else if ( mUseCategories->isChecked() ) { | 176 | } else if ( mUseCategories->isChecked() ) { |
137 | QStringList categorieList = categories(); | 177 | QStringList categorieList = categories(); |
138 | KABC::AddressBook::Iterator it; | 178 | KABC::AddressBook::Iterator it; |
139 | for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { | 179 | for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { |
140 | QStringList tmp( (*it).categories() ); | 180 | QStringList tmp( (*it).categories() ); |
141 | QStringList::Iterator tmpIt; | 181 | QStringList::Iterator tmpIt; |
142 | for ( tmpIt = tmp.begin(); tmpIt != tmp.end(); ++tmpIt ) | 182 | for ( tmpIt = tmp.begin(); tmpIt != tmp.end(); ++tmpIt ) |
@@ -225,50 +265,50 @@ void XXPortSelectDialog::initGUI() | |||
225 | QWhatsThis::add( mUseSelection, i18n( "Only contacts selected in KAddressBook.\n" | 265 | QWhatsThis::add( mUseSelection, i18n( "Only contacts selected in KAddressBook.\n" |
226 | "This option is disabled if no contacts are selected." ) ); | 266 | "This option is disabled if no contacts are selected." ) ); |
227 | groupLayout->addWidget( mUseSelection, 1, 0 ); | 267 | groupLayout->addWidget( mUseSelection, 1, 0 ); |
228 | 268 | ||
229 | mUseFilters = new QRadioButton( i18n( "By matching &filter" ), mButtonGroup ); | 269 | mUseFilters = new QRadioButton( i18n( "By matching &filter" ), mButtonGroup ); |
230 | QWhatsThis::add( mUseFilters, i18n( "Only contacts matching the selected filter.\n" | 270 | QWhatsThis::add( mUseFilters, i18n( "Only contacts matching the selected filter.\n" |
231 | "This option is disabled if you haven't defined any filters" ) ); | 271 | "This option is disabled if you haven't defined any filters" ) ); |
232 | groupLayout->addWidget( mUseFilters, 2, 0 ); | 272 | groupLayout->addWidget( mUseFilters, 2, 0 ); |
233 | 273 | ||
234 | mUseCategories = new QRadioButton( i18n( "By Cate&gories" ), mButtonGroup ); | 274 | mUseCategories = new QRadioButton( i18n( "By Cate&gories" ), mButtonGroup ); |
235 | QWhatsThis::add( mUseCategories, i18n( "Only contacts who are members of a category that is checked on the list to the left.\n" | 275 | QWhatsThis::add( mUseCategories, i18n( "Only contacts who are members of a category that is checked on the list to the left.\n" |
236 | "This option is disabled if you have no categories." ) ); | 276 | "This option is disabled if you have no categories." ) ); |
237 | groupLayout->addWidget( mUseCategories, 3, 0 ); | 277 | groupLayout->addWidget( mUseCategories, 3, 0 ); |
238 | 278 | ||
239 | mFiltersCombo = new QComboBox( false, mButtonGroup ); | 279 | mFiltersCombo = new QComboBox( false, mButtonGroup ); |
240 | QWhatsThis::add( mFiltersCombo, i18n( "Select a filter to decide which contacts to select." ) ); | 280 | QWhatsThis::add( mFiltersCombo, i18n( "Select a filter to decide which contacts to select." ) ); |
241 | groupLayout->addWidget( mFiltersCombo, 2, 1 ); | 281 | groupLayout->addWidget( mFiltersCombo, 2, 1 ); |
242 | 282 | ||
243 | mCategoriesView = new QListView( mButtonGroup ); | 283 | mCategoriesView = new QListView( mButtonGroup ); |
244 | mCategoriesView->addColumn( "" ); | 284 | mCategoriesView->addColumn( "" ); |
245 | mCategoriesView->header()->hide(); | 285 | mCategoriesView->header()->hide(); |
246 | QWhatsThis::add( mCategoriesView, i18n( "Check the categories whose members you want to select." ) ); | 286 | QWhatsThis::add( mCategoriesView, i18n( "Check the categories whose members you want to select." ) ); |
247 | groupLayout->addWidget( mCategoriesView, 3, 1 ); | 287 | groupLayout->addWidget( mCategoriesView, 3, 1 ); |
248 | 288 | ||
249 | // if (QApplication::desktop()->height() == 480 ) | 289 | if (QApplication::desktop()->height() == 480 ) |
250 | // mCategoriesView->setMaximumHeight( 240 ); | 290 | mCategoriesView->setMaximumHeight( 240 ); |
251 | topLayout->addWidget( mButtonGroup ); | 291 | topLayout->addWidget( mButtonGroup ); |
252 | 292 | ||
253 | QButtonGroup *sortingGroup = new QButtonGroup( i18n( "Sorting" ), page ); | 293 | QButtonGroup *sortingGroup = new QButtonGroup( i18n( "Sorting" ), page ); |
254 | sortingGroup->setColumnLayout( 0, Qt::Vertical ); | 294 | sortingGroup->setColumnLayout( 0, Qt::Vertical ); |
255 | QGridLayout *sortLayout = new QGridLayout( sortingGroup->layout(), 2, 2, | 295 | QGridLayout *sortLayout = new QGridLayout( sortingGroup->layout(), 2, 2, |
256 | KDialog::spacingHint() ); | 296 | KDialog::spacingHint() ); |
257 | sortLayout->setAlignment( Qt::AlignTop ); | 297 | sortLayout->setAlignment( Qt::AlignTop ); |
258 | 298 | ||
259 | label = new QLabel( i18n( "Criterion:" ), sortingGroup ); | 299 | label = new QLabel( i18n( "Criterion:" ), sortingGroup ); |
260 | sortLayout->addWidget( label, 0, 0 ); | 300 | sortLayout->addWidget( label, 0, 0 ); |
261 | 301 | ||
262 | #ifndef KAB_EMBEDDED | 302 | #ifndef KAB_EMBEDDED |
263 | mFieldCombo = new KComboBox( false, sortingGroup ); | 303 | mFieldCombo = new KComboBox( false, sortingGroup ); |
264 | #else //KAB_EMBEDDED | 304 | #else //KAB_EMBEDDED |
265 | //US Combobox is not editable anyway | 305 | //US Combobox is not editable anyway |
266 | mFieldCombo = new KComboBox( sortingGroup ); | 306 | mFieldCombo = new KComboBox( sortingGroup ); |
267 | #endif //KAB_EMBEDDED | 307 | #endif //KAB_EMBEDDED |
268 | sortLayout->addWidget( mFieldCombo, 0, 1 ); | 308 | sortLayout->addWidget( mFieldCombo, 0, 1 ); |
269 | 309 | ||
270 | label = new QLabel( i18n( "Order:" ), sortingGroup ); | 310 | label = new QLabel( i18n( "Order:" ), sortingGroup ); |
271 | sortLayout->addWidget( label, 1, 0 ); | 311 | sortLayout->addWidget( label, 1, 0 ); |
272 | 312 | ||
273 | #ifndef KAB_EMBEDDED | 313 | #ifndef KAB_EMBEDDED |
274 | mSortTypeCombo = new KComboBox( false, sortingGroup ); | 314 | mSortTypeCombo = new KComboBox( false, sortingGroup ); |