kaddressbook Library API Documentation

filterselectionwidget.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., 675 Mass Ave, Cambridge, MA 02139, 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 <qlabel.h>
00025 
00026 #include <klocale.h>
00027 #include <kcombobox.h>
00028 
00029 #include "filterselectionwidget.h"
00030 
00031 FilterSelectionWidget::FilterSelectionWidget(QWidget *parent, const char *name)
00032   : QHBox(parent, name)
00033 {
00034   (void) new QLabel(i18n("Filter:"), this);
00035   
00036   mFilterCombo = new KComboBox(this, "mFilterCombo");
00037   connect(mFilterCombo, SIGNAL(activated(int)), SLOT(activated(int)));
00038 }
00039 
00040 FilterSelectionWidget::~FilterSelectionWidget()
00041 {
00042 }
00043 
00044 int FilterSelectionWidget::currentItem() const
00045 {
00046   return mFilterCombo->currentItem() - 1;
00047 }
00048 
00049 void FilterSelectionWidget::setCurrentItem(int index)
00050 {
00051   mFilterCombo->setCurrentItem(index);
00052 }
00053 
00054 unsigned int FilterSelectionWidget::count() const
00055 {
00056   return mFilterCombo->count();
00057 }
00058 
00059 QString FilterSelectionWidget::text(int index) const
00060 {
00061   return mFilterCombo->text(index);
00062 }
00063 
00064 void FilterSelectionWidget::setFilterNames(const QStringList &names)
00065 {
00066   mFilterCombo->clear();
00067   mFilterCombo->insertItem(i18n("None"));
00068   mFilterCombo->insertStringList(names);
00069   
00070   emit filterActivated(-1);
00071 }
00072 
00073 QString FilterSelectionWidget::currentFilterName() const
00074 {
00075   return mFilterCombo->currentText();
00076 }
00077    
00078 void FilterSelectionWidget::setCurrentFilterName(const QString &name)
00079 {
00080   mFilterCombo->setCurrentText(name);
00081 }
00082 
00083 void FilterSelectionWidget::activated(int index)
00084 {
00085   emit filterActivated(index-1);
00086 }
00087 
00088 #include "filterselectionwidget.moc"
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Oct 18 02:47:09 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001