00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <kdialog.h>
00026 #include <tdelocale.h>
00027
00028 #include <tqbuttongroup.h>
00029 #include <tqcombobox.h>
00030 #include <tqheader.h>
00031 #include <tqlabel.h>
00032 #include <tqlayout.h>
00033 #include <tqlistview.h>
00034 #include <tqpushbutton.h>
00035 #include <tqradiobutton.h>
00036 #include <tqstringlist.h>
00037 #include <tqwhatsthis.h>
00038
00039 #include "selectionpage.h"
00040
00041 SelectionPage::SelectionPage( TQWidget* parent, const char* name )
00042 : TQWidget( parent, name )
00043 {
00044 setCaption( i18n( "Choose Which Contacts to Print" ) );
00045
00046 TQVBoxLayout *topLayout = new TQVBoxLayout( this, KDialog::marginHint(),
00047 KDialog::spacingHint() );
00048
00049 TQLabel *label = new TQLabel( i18n( "Which contacts do you want to print?" ), this );
00050 topLayout->addWidget( label );
00051
00052 mButtonGroup = new TQButtonGroup( this );
00053 mButtonGroup->setFrameShape( TQButtonGroup::NoFrame );
00054 mButtonGroup->setColumnLayout( 0, Qt::Vertical );
00055 mButtonGroup->layout()->setSpacing( KDialog::spacingHint() );
00056 mButtonGroup->layout()->setMargin( KDialog::marginHint() );
00057
00058 TQGridLayout *groupLayout = new TQGridLayout( mButtonGroup->layout() );
00059 groupLayout->setAlignment( TQt::AlignTop );
00060
00061 mUseWholeBook = new TQRadioButton( i18n( "&All contacts" ), mButtonGroup );
00062 mUseWholeBook->setChecked( true );
00063 TQWhatsThis::add( mUseWholeBook, i18n( "Print the entire address book" ) );
00064 groupLayout->addWidget( mUseWholeBook, 0, 0 );
00065
00066 mUseSelection = new TQRadioButton( i18n( "&Selected contacts" ), mButtonGroup );
00067 TQWhatsThis::add( mUseSelection, i18n( "Only print contacts selected in KAddressBook.\n"
00068 "This option is disabled if no contacts are selected." ) );
00069 groupLayout->addWidget( mUseSelection, 1, 0 );
00070
00071 mUseFilters = new TQRadioButton( i18n( "Contacts matching &filter" ), mButtonGroup );
00072 TQWhatsThis::add( mUseFilters, i18n( "Only print contacts matching the selected filter.\n"
00073 "This option is disabled if you have not defined any filters." ) );
00074 groupLayout->addWidget( mUseFilters, 2, 0 );
00075
00076 mUseCategories = new TQRadioButton( i18n( "Category &members" ), mButtonGroup );
00077 TQWhatsThis::add( mUseCategories, i18n( "Only print contacts who are members of a category that is checked on the list to the left.\n"
00078 "This option is disabled if you have no categories." ) );
00079 groupLayout->addWidget( mUseCategories, 3, 0, TQt::AlignTop );
00080
00081 mFiltersCombo = new TQComboBox( false, mButtonGroup );
00082 TQWhatsThis::add( mFiltersCombo, i18n( "Select a filter to decide which contacts to print." ) );
00083 groupLayout->addWidget( mFiltersCombo, 2, 1 );
00084
00085 mCategoriesView = new TQListView( mButtonGroup );
00086 mCategoriesView->addColumn( "" );
00087 mCategoriesView->header()->hide();
00088 TQWhatsThis::add( mCategoriesView, i18n( "Check the categories whose members you want to print." ) );
00089 groupLayout->addWidget( mCategoriesView, 3, 1 );
00090
00091 topLayout->addWidget( mButtonGroup );
00092
00093 connect( mFiltersCombo, TQT_SIGNAL( activated(int) ), TQT_SLOT( filterChanged(int) ) );
00094 connect( mCategoriesView, TQT_SIGNAL( clicked(TQListViewItem*) ), TQT_SLOT( categoryClicked(TQListViewItem*) ) );
00095 }
00096
00097 SelectionPage::~SelectionPage()
00098 {
00099 }
00100
00101 void SelectionPage::setFilters( const TQStringList& filters )
00102 {
00103 mFiltersCombo->clear();
00104 mFiltersCombo->insertStringList( filters );
00105
00106 mUseFilters->setEnabled( filters.count() > 0 );
00107 }
00108
00109 TQString SelectionPage::filter() const
00110 {
00111 return mFiltersCombo->currentText();
00112 }
00113
00114 bool SelectionPage::useFilters() const
00115 {
00116 return mUseFilters->isChecked();
00117 }
00118
00119 void SelectionPage::setCategories( const TQStringList& list )
00120 {
00121 TQStringList::ConstIterator it;
00122 for ( it = list.begin(); it != list.end(); ++it )
00123 new TQCheckListItem( mCategoriesView, *it, TQCheckListItem::CheckBox );
00124
00125 mUseCategories->setEnabled( list.count() > 0 );
00126 }
00127
00128 TQStringList SelectionPage::categories() const
00129 {
00130 TQStringList list;
00131
00132 TQListViewItemIterator it( mCategoriesView );
00133 for ( ; it.current(); ++it ) {
00134 TQCheckListItem *qcli = static_cast<TQCheckListItem*>(it.current());
00135 if ( qcli->isOn() )
00136 list.append( it.current()->text( 0 ) );
00137 }
00138
00139 return list;
00140 }
00141
00142 bool SelectionPage::useCategories()
00143 {
00144 return mUseCategories->isChecked();
00145 }
00146
00147 void SelectionPage::setUseSelection( bool value )
00148 {
00149 mUseSelection->setEnabled( value );
00150 }
00151
00152 bool SelectionPage::useSelection() const
00153 {
00154 return mUseSelection->isChecked();
00155 }
00156
00157 void SelectionPage::filterChanged( int )
00158 {
00159 mUseFilters->setChecked( true );
00160 }
00161
00162 void SelectionPage::categoryClicked( TQListViewItem *i )
00163 {
00164 TQCheckListItem *qcli = static_cast<TQCheckListItem*>( i );
00165 if ( i && qcli->isOn() )
00166 mUseCategories->setChecked( true );
00167 }
00168
00169 #include "selectionpage.moc"