kaddressbook Library API Documentation

addviewdialog.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 <qlineedit.h> 00028 #include <qradiobutton.h> 00029 00030 #include <klocale.h> 00031 00032 #include "kaddressbookview.h" 00033 00034 #include "addviewdialog.h" 00035 00036 AddViewDialog::AddViewDialog( QDict<ViewFactory> *viewFactoryDict, 00037 QWidget *parent, const char *name ) 00038 : KDialogBase( KDialogBase::Plain, i18n( "Add View" ), 00039 KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, 00040 parent, name ), 00041 mViewFactoryDict( viewFactoryDict ) 00042 { 00043 mTypeId = 0; 00044 00045 QWidget *page = plainPage(); 00046 00047 QGridLayout *layout = new QGridLayout( page, 2, 2 ); 00048 layout->setSpacing( spacingHint() ); 00049 layout->setRowStretch( 1, 1 ); 00050 layout->setColStretch( 1, 1 ); 00051 00052 QLabel *label = new QLabel( i18n( "View name:" ), page ); 00053 layout->addWidget( label, 0, 0 ); 00054 00055 mViewNameEdit = new QLineEdit( page ); 00056 connect( mViewNameEdit, SIGNAL( textChanged( const QString& ) ), 00057 SLOT( textChanged( const QString& ) ) ); 00058 layout->addWidget( mViewNameEdit, 0, 1 ); 00059 00060 mTypeGroup = new QButtonGroup( 2, Qt::Horizontal, i18n( "View Type" ), page ); 00061 connect( mTypeGroup, SIGNAL( clicked( int ) ), this, SLOT( clicked( int ) ) ); 00062 layout->addMultiCellWidget( mTypeGroup, 1, 1, 0, 1 ); 00063 00064 // Now create the radio buttons. This needs some layout work. 00065 QDictIterator<ViewFactory> iter( *mViewFactoryDict ); 00066 for ( iter.toFirst(); iter.current(); ++iter ) { 00067 new QRadioButton( i18n((*iter)->type().utf8()), mTypeGroup, 00068 (*iter)->type().latin1() ); 00069 label = new QLabel( (*iter)->description(), mTypeGroup ); 00070 label->setAlignment( Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak ); 00071 } 00072 00073 mTypeGroup->setButton( 0 ); 00074 mViewNameEdit->setFocus(); 00075 enableButton( KDialogBase::Ok, false ); 00076 } 00077 00078 AddViewDialog::~AddViewDialog() 00079 { 00080 } 00081 00082 QString AddViewDialog::viewName()const 00083 { 00084 return mViewNameEdit->text(); 00085 } 00086 00087 QString AddViewDialog::viewType()const 00088 { 00089 // we missuse the name property for storing the type 00090 return mTypeGroup->find( mTypeId )->name(); 00091 } 00092 00093 void AddViewDialog::clicked( int id ) 00094 { 00095 mTypeId = id; 00096 } 00097 00098 void AddViewDialog::textChanged( const QString &text ) 00099 { 00100 enableButton( KDialogBase::Ok, !text.isEmpty() ); 00101 } 00102 00103 #include "addviewdialog.moc"
KDE Logo
This file is part of the documentation for kaddressbook Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:58:07 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003