kaddressbook Library API Documentation

viewconfigurefilterpage.cpp

00001 /* 00002 This file is part of KAddressBook. 00003 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 00019 As a special exception, permission is given to link this program 00020 with any edition of Qt, and distribute the resulting executable, 00021 without including the source code for Qt in the source distribution. 00022 */ 00023 00024 #include <qbuttongroup.h> 00025 #include <qlabel.h> 00026 #include <qlayout.h> 00027 #include <qradiobutton.h> 00028 00029 #include <kconfig.h> 00030 #include <kcombobox.h> 00031 #include <kdialog.h> 00032 #include <klocale.h> 00033 00034 #include "viewconfigurefilterpage.h" 00035 #include "filter.h" 00036 00037 ViewConfigureFilterPage::ViewConfigureFilterPage( QWidget *parent, 00038 const char *name ) 00039 : QWidget( parent, name ) 00040 { 00041 QBoxLayout *topLayout = new QVBoxLayout( this, 0, KDialog::spacingHint() ); 00042 00043 mFilterGroup = new QButtonGroup(); 00044 connect( mFilterGroup, SIGNAL( clicked( int ) ), SLOT( buttonClicked( int ) ) ); 00045 00046 QLabel *label = new QLabel( i18n( "The default filter will be activated whenever" 00047 " this view is displayed. This feature allows you to configure views that only" 00048 " interact with certain types of information based on the filter. Once the view" 00049 " is activated, the filter can be changed at anytime." ), this ); 00050 label->setAlignment( Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak ); 00051 topLayout->addWidget( label ); 00052 00053 QWidget *spacer = new QWidget( this ); 00054 spacer->setMinimumHeight( 5 ); 00055 topLayout->addWidget( spacer ); 00056 00057 QRadioButton *button = new QRadioButton( i18n( "No default filter" ), this ); 00058 mFilterGroup->insert( button ); 00059 topLayout->addWidget( button ); 00060 00061 button = new QRadioButton( i18n( "Use last active filter" ), this ); 00062 mFilterGroup->insert( button ); 00063 topLayout->addWidget( button ); 00064 00065 QBoxLayout *comboLayout = new QHBoxLayout(); 00066 topLayout->addLayout( comboLayout ); 00067 button = new QRadioButton( i18n( "Use filter:" ), this ); 00068 mFilterGroup->insert( button ); 00069 comboLayout->addWidget( button ); 00070 00071 mFilterCombo = new KComboBox( this ); 00072 comboLayout->addWidget( mFilterCombo ); 00073 } 00074 00075 ViewConfigureFilterPage::~ViewConfigureFilterPage() 00076 { 00077 delete mFilterGroup; 00078 } 00079 00080 void ViewConfigureFilterPage::restoreSettings( KConfig *config ) 00081 { 00082 mFilterCombo->clear(); 00083 00084 // Load the filter combo 00085 Filter::List list = Filter::restore( config, "Filter" ); 00086 Filter::List::Iterator it; 00087 for ( it = list.begin(); it != list.end(); ++it ) 00088 mFilterCombo->insertItem( (*it).name() ); 00089 00090 int id = config->readNumEntry( "DefaultFilterType", 1 ); 00091 mFilterGroup->setButton( id ); 00092 buttonClicked( id ); 00093 00094 if ( id == 2 ) // has default filter 00095 mFilterCombo->setCurrentText( config->readEntry( "DefaultFilterName" ) ); 00096 } 00097 00098 void ViewConfigureFilterPage::saveSettings( KConfig *config ) 00099 { 00100 config->writeEntry( "DefaultFilterName", mFilterCombo->currentText() ); 00101 config->writeEntry( "DefaultFilterType", mFilterGroup->id( mFilterGroup->selected() ) ); 00102 } 00103 00104 void ViewConfigureFilterPage::buttonClicked( int id ) 00105 { 00106 mFilterCombo->setEnabled( id == 2 ); 00107 } 00108 00109 #include "viewconfigurefilterpage.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