26 #include <tdelocale.h>
28 #include <tqbuttongroup.h>
29 #include <tqcombobox.h>
33 #include <tqlistview.h>
34 #include <tqpushbutton.h>
35 #include <tqradiobutton.h>
36 #include <tqstringlist.h>
37 #include <tqwhatsthis.h>
39 #include "selectionpage.h"
41 SelectionPage::SelectionPage( TQWidget* parent,
const char* name )
42 : TQWidget( parent, name )
44 setCaption( i18n(
"Choose Which Contacts to Print" ) );
46 TQVBoxLayout *topLayout =
new TQVBoxLayout(
this, KDialog::marginHint(),
47 KDialog::spacingHint() );
49 TQLabel *label =
new TQLabel( i18n(
"Which contacts do you want to print?" ),
this );
50 topLayout->addWidget( label );
52 mButtonGroup =
new TQButtonGroup(
this );
53 mButtonGroup->setFrameShape( TQButtonGroup::NoFrame );
54 mButtonGroup->setColumnLayout( 0, TQt::Vertical );
55 mButtonGroup->layout()->setSpacing( KDialog::spacingHint() );
56 mButtonGroup->layout()->setMargin( KDialog::marginHint() );
58 TQGridLayout *groupLayout =
new TQGridLayout( mButtonGroup->layout() );
59 groupLayout->setAlignment( TQt::AlignTop );
61 mUseWholeBook =
new TQRadioButton( i18n(
"&All contacts" ), mButtonGroup );
62 mUseWholeBook->setChecked(
true );
63 TQWhatsThis::add( mUseWholeBook, i18n(
"Print the entire address book" ) );
64 groupLayout->addWidget( mUseWholeBook, 0, 0 );
66 mUseSelection =
new TQRadioButton( i18n(
"&Selected contacts" ), mButtonGroup );
67 TQWhatsThis::add( mUseSelection, i18n(
"Only print contacts selected in KAddressBook.\n"
68 "This option is disabled if no contacts are selected." ) );
69 groupLayout->addWidget( mUseSelection, 1, 0 );
71 mUseFilters =
new TQRadioButton( i18n(
"Contacts matching &filter" ), mButtonGroup );
72 TQWhatsThis::add( mUseFilters, i18n(
"Only print contacts matching the selected filter.\n"
73 "This option is disabled if you have not defined any filters." ) );
74 groupLayout->addWidget( mUseFilters, 2, 0 );
76 mUseCategories =
new TQRadioButton( i18n(
"Category &members" ), mButtonGroup );
77 TQWhatsThis::add( mUseCategories, i18n(
"Only print contacts who are members of a category that is checked on the list to the left.\n"
78 "This option is disabled if you have no categories." ) );
79 groupLayout->addWidget( mUseCategories, 3, 0, TQt::AlignTop );
81 mFiltersCombo =
new TQComboBox(
false, mButtonGroup );
82 TQWhatsThis::add( mFiltersCombo, i18n(
"Select a filter to decide which contacts to print." ) );
83 groupLayout->addWidget( mFiltersCombo, 2, 1 );
85 mCategoriesView =
new TQListView( mButtonGroup );
86 mCategoriesView->addColumn(
"" );
87 mCategoriesView->header()->hide();
88 TQWhatsThis::add( mCategoriesView, i18n(
"Check the categories whose members you want to print." ) );
89 groupLayout->addWidget( mCategoriesView, 3, 1 );
91 topLayout->addWidget( mButtonGroup );
93 connect( mFiltersCombo, TQ_SIGNAL( activated(
int) ), TQ_SLOT( filterChanged(
int) ) );
94 connect( mCategoriesView, TQ_SIGNAL( clicked(TQListViewItem*) ), TQ_SLOT( categoryClicked(TQListViewItem*) ) );
97 SelectionPage::~SelectionPage()
101 void SelectionPage::setFilters(
const TQStringList& filters )
103 mFiltersCombo->clear();
104 mFiltersCombo->insertStringList( filters );
106 mUseFilters->setEnabled( filters.count() > 0 );
109 TQString SelectionPage::filter()
const
111 return mFiltersCombo->currentText();
114 bool SelectionPage::useFilters()
const
116 return mUseFilters->isChecked();
119 void SelectionPage::setCategories(
const TQStringList& list )
121 TQStringList::ConstIterator it;
122 for ( it = list.begin(); it != list.end(); ++it )
123 new TQCheckListItem( mCategoriesView, *it, TQCheckListItem::CheckBox );
125 mUseCategories->setEnabled( list.count() > 0 );
128 TQStringList SelectionPage::categories()
const
132 TQListViewItemIterator it( mCategoriesView );
133 for ( ; it.current(); ++it ) {
134 TQCheckListItem *qcli =
static_cast<TQCheckListItem*
>(it.current());
136 list.append( it.current()->text( 0 ) );
142 bool SelectionPage::useCategories()
144 return mUseCategories->isChecked();
147 void SelectionPage::setUseSelection(
bool value )
149 mUseSelection->setEnabled( value );
152 bool SelectionPage::useSelection()
const
154 return mUseSelection->isChecked();
157 void SelectionPage::filterChanged(
int )
159 mUseFilters->setChecked(
true );
162 void SelectionPage::categoryClicked( TQListViewItem *i )
164 TQCheckListItem *qcli =
static_cast<TQCheckListItem*
>( i );
165 if ( i && qcli->isOn() )
166 mUseCategories->setChecked(
true );
169 #include "selectionpage.moc"