kaddressbook Library API Documentation

addhostdialog.cpp

00001 /*
00002     This file is part of KAddressBook.
00003     Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
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 #include <qlayout.h>
00026 #include <qlineedit.h>
00027 #include <qpushbutton.h>
00028 #include <qspinbox.h>
00029 #include <qtooltip.h>
00030 
00031 #include <kbuttonbox.h>
00032 #include <klocale.h>
00033 
00034 #include "addhostdialog.h"
00035 
00036 AddHostDialog::AddHostDialog( QWidget* parent,  const char* name )
00037   : KDialogBase( Plain, i18n( "Add Host" ), Ok | Cancel, Ok, parent, name, true, true )
00038 {
00039   QWidget *page = plainPage();
00040 
00041   QGridLayout *layout = new QGridLayout( page, 3, 3, marginHint(), spacingHint() );
00042 
00043   mHostEdit = new QLineEdit( page );
00044   layout->addMultiCellWidget( mHostEdit, 0, 0, 1, 2 );
00045   connect(mHostEdit, SIGNAL( textChanged ( const QString & )), this, SLOT(slotHostEditChanged( const QString & )));
00046   QLabel *label = new QLabel( i18n( "&Host:" ), page );
00047   label->setBuddy( mHostEdit );
00048   layout->addWidget( label, 0, 0 );
00049 
00050   mPortSpinBox = new QSpinBox( page );
00051   mPortSpinBox->setMaxValue( 65535 );
00052   mPortSpinBox->setValue( 389 );
00053   layout->addWidget( mPortSpinBox, 1, 1 );
00054 
00055   label = new QLabel( i18n( "&Port:" ), page );
00056   QToolTip::add( label, i18n( "The port number of the directory server if it is using a non-standard port (389 is the standard)" ) );
00057   label->setBuddy( mPortSpinBox );
00058   layout->addWidget( label, 1, 0 );
00059 
00060   mBaseEdit = new QLineEdit( page );
00061   layout->addMultiCellWidget( mBaseEdit, 2, 2, 1, 2 );
00062 
00063   label = new QLabel( i18n( "&Base DN:" ), page );
00064   QToolTip::add( label, i18n( "The base DN used for searching" ) );
00065   label->setBuddy( mBaseEdit );
00066   layout->addWidget( label, 2, 0 );
00067 
00068   resize( QSize( 380, 150 ).expandedTo( sizeHint() ) );
00069   enableButtonOK( !mHostEdit->text().isEmpty());
00070   mHostEdit->setFocus();
00071 }
00072 
00073 AddHostDialog::~AddHostDialog()
00074 {
00075 }
00076 
00077 void AddHostDialog::slotHostEditChanged( const QString &text )
00078 {
00079     enableButtonOK( !text.isEmpty());
00080 }
00081 
00082 void AddHostDialog::setHost( const QString &host )
00083 {
00084   mHostEdit->setText( host );
00085 }
00086 
00087 void AddHostDialog::setPort( int port )
00088 {
00089   mPortSpinBox->setValue( port );
00090 }
00091 
00092 void AddHostDialog::setBaseDN( const QString &baseDN )
00093 {
00094   mBaseEdit->setText( baseDN );
00095 }
00096 
00097 QString AddHostDialog::host() const
00098 {
00099   return mHostEdit->text().stripWhiteSpace();
00100 }
00101 
00102 int AddHostDialog::port() const
00103 {
00104   return mPortSpinBox->value();
00105 }
00106 
00107 QString AddHostDialog::baseDN() const
00108 {
00109   return mBaseEdit->text().stripWhiteSpace();
00110 }
00111 
00112 #include "addhostdialog.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