kaddressbook Library API Documentation

selectionpage.cpp

00001 /* 00002 This file is part of KAddressBook. 00003 Copyright (c) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk> 00004 Tobias Koenig <tokoe@kde.org> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 00020 As a special exception, permission is given to link this program 00021 with any edition of Qt, and distribute the resulting executable, 00022 without including the source code for Qt in the source distribution. 00023 */ 00024 00025 #include <kdialog.h> 00026 #include <klocale.h> 00027 00028 #include <qbuttongroup.h> 00029 #include <qcombobox.h> 00030 #include <qheader.h> 00031 #include <qlabel.h> 00032 #include <qlayout.h> 00033 #include <qlistview.h> 00034 #include <qpushbutton.h> 00035 #include <qradiobutton.h> 00036 #include <qstringlist.h> 00037 #include <qwhatsthis.h> 00038 00039 #include "selectionpage.h" 00040 00041 SelectionPage::SelectionPage( QWidget* parent, const char* name ) 00042 : QWidget( parent, name ) 00043 { 00044 setCaption( i18n( "Choose Which Contacts to Print" ) ); 00045 00046 QVBoxLayout *topLayout = new QVBoxLayout( this, KDialog::marginHint(), 00047 KDialog::spacingHint() ); 00048 00049 QLabel *label = new QLabel( i18n( "Which contacts do you want to print?" ), this ); 00050 topLayout->addWidget( label ); 00051 00052 mButtonGroup = new QButtonGroup( this ); 00053 mButtonGroup->setFrameShape( QButtonGroup::NoFrame ); 00054 mButtonGroup->setColumnLayout( 0, Qt::Vertical ); 00055 mButtonGroup->layout()->setSpacing( KDialog::spacingHint() ); 00056 mButtonGroup->layout()->setMargin( KDialog::marginHint() ); 00057 00058 QGridLayout *groupLayout = new QGridLayout( mButtonGroup->layout() ); 00059 groupLayout->setAlignment( Qt::AlignTop ); 00060 00061 mUseWholeBook = new QRadioButton( i18n( "&All contacts" ), mButtonGroup ); 00062 mUseWholeBook->setChecked( true ); 00063 QWhatsThis::add( mUseWholeBook, i18n( "Print the entire address book" ) ); 00064 groupLayout->addWidget( mUseWholeBook, 0, 0 ); 00065 00066 mUseSelection = new QRadioButton( i18n( "&Selected contacts" ), mButtonGroup ); 00067 QWhatsThis::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 QRadioButton( i18n( "Contacts matching &filter" ), mButtonGroup ); 00072 QWhatsThis::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 QRadioButton( i18n( "Category &members" ), mButtonGroup ); 00077 QWhatsThis::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, Qt::AlignTop ); 00080 00081 mFiltersCombo = new QComboBox( false, mButtonGroup ); 00082 QWhatsThis::add( mFiltersCombo, i18n( "Select a filter to decide which contacts to print." ) ); 00083 groupLayout->addWidget( mFiltersCombo, 2, 1 ); 00084 00085 mCategoriesView = new QListView( mButtonGroup ); 00086 mCategoriesView->addColumn( "" ); 00087 mCategoriesView->header()->hide(); 00088 QWhatsThis::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, SIGNAL( activated(int) ), SLOT( filterChanged(int) ) ); 00094 connect( mCategoriesView, SIGNAL( clicked(QListViewItem*) ), SLOT( categoryClicked(QListViewItem*) ) ); 00095 } 00096 00097 SelectionPage::~SelectionPage() 00098 { 00099 } 00100 00101 void SelectionPage::setFilters( const QStringList& filters ) 00102 { 00103 mFiltersCombo->clear(); 00104 mFiltersCombo->insertStringList( filters ); 00105 00106 mUseFilters->setEnabled( filters.count() > 0 ); 00107 } 00108 00109 QString 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 QStringList& list ) 00120 { 00121 QStringList::ConstIterator it; 00122 for ( it = list.begin(); it != list.end(); ++it ) 00123 new QCheckListItem( mCategoriesView, *it, QCheckListItem::CheckBox ); 00124 00125 mUseCategories->setEnabled( list.count() > 0 ); 00126 } 00127 00128 QStringList SelectionPage::categories() const 00129 { 00130 QStringList list; 00131 00132 QListViewItemIterator it( mCategoriesView ); 00133 for ( ; it.current(); ++it ) { 00134 QCheckListItem *qcli = static_cast<QCheckListItem*>(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( QListViewItem *i ) 00163 { 00164 QCheckListItem *qcli = static_cast<QCheckListItem*>( i ); 00165 if ( i && qcli->isOn() ) 00166 mUseCategories->setChecked( true ); 00167 } 00168 00169 #include "selectionpage.moc"
KDE Logo
This file is part of the documentation for kaddressbook Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Oct 21 19:46:37 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003