24#include <tqbuttongroup.h> 
   27#include <tqlineedit.h> 
   28#include <tqradiobutton.h> 
   32#include "kaddressbookview.h" 
   34#include "addviewdialog.h" 
   36AddViewDialog::AddViewDialog( TQDict<ViewFactory> *viewFactoryDict,
 
   37                              TQWidget *parent, 
const char *name )
 
   38  : KDialogBase( KDialogBase::Plain, i18n( 
"Add View" ),
 
   39                 KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok,
 
   41   mViewFactoryDict( viewFactoryDict )
 
   45  TQWidget *page = plainPage();
 
   47  TQGridLayout *layout = 
new TQGridLayout( page, 2, 2 );
 
   48  layout->setSpacing( spacingHint() );
 
   49  layout->setRowStretch( 1, 1 );
 
   50  layout->setColStretch( 1, 1 );
 
   52  TQLabel *label = 
new TQLabel( i18n( 
"View name:" ), page );
 
   53  layout->addWidget( label, 0, 0 );
 
   55  mViewNameEdit = 
new TQLineEdit( page );
 
   56  connect( mViewNameEdit, TQ_SIGNAL( textChanged( 
const TQString& ) ),
 
   57           TQ_SLOT( textChanged( 
const TQString& ) ) );
 
   58  layout->addWidget( mViewNameEdit, 0, 1 );
 
   60  mTypeGroup = 
new TQButtonGroup( 0, TQt::Horizontal, i18n( 
"View Type" ), page );
 
   61  connect( mTypeGroup, TQ_SIGNAL( clicked( 
int ) ), 
this, TQ_SLOT( clicked( 
int ) ) );
 
   62  layout->addMultiCellWidget( mTypeGroup, 1, 1, 0, 1 );
 
   63  TQGridLayout *groupLayout = 
new TQGridLayout( mTypeGroup->layout(), 3, 2 );
 
   64  groupLayout->setSpacing( spacingHint() );
 
   67  TQDictIterator<ViewFactory> iter( *mViewFactoryDict );
 
   68  for ( iter.toFirst(); iter.current(); ++iter ) {
 
   69    TQRadioButton *button = 
new TQRadioButton( i18n((*iter)->type().utf8()),
 
   70                                             mTypeGroup, (*iter)->type().latin1() );
 
   71    label = 
new TQLabel( (*iter)->description(), mTypeGroup );
 
   72    label->setAlignment( TQt::WordBreak );
 
   74    groupLayout->addWidget( button, row, 0, TQt::AlignTop );
 
   75    groupLayout->addWidget( label, row, 1, TQt::AlignTop );
 
   80  mTypeGroup->setButton( 0 );
 
   81  mViewNameEdit->setFocus();
 
   82  enableButton( KDialogBase::Ok, 
false );
 
   85AddViewDialog::~AddViewDialog()
 
   89TQString AddViewDialog::viewName()
const 
   91  return mViewNameEdit->text();
 
   94TQString AddViewDialog::viewType()
const 
   97  return mTypeGroup->find( mTypeId )->name();
 
  107  enableButton( KDialogBase::Ok, !text.isEmpty() );
 
  110#include "addviewdialog.moc" 
void textChanged(const TQString &text)
Called when the user changes the text in the name of the view.
void clicked(int id)
Called when the user selects a type radio button.