| # kabc Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# resourceconfigdlg.cpp

    00001 /*
    00002     This file is part of libkabc.
    00003     Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
    00004
    00005     This library is free software; you can redistribute it and/or
    00006     modify it under the terms of the GNU Library General Public
    00007     License as published by the Free Software Foundation; either
    00008     version 2 of the License, or (at your option) any later version.
    00009
    00010     This library 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 GNU
    00013     Library General Public License for more details.
    00014
    00015     You should have received a copy of the GNU Library General Public License
    00016     along with this library; see the file COPYING.LIB.  If not, write to
    00017     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00018     Boston, MA 02111-1307, USA.
    00019 */
    00020
    00021 #include <klocale.h>
    00022 #include <kmessagebox.h>
    00023
    00024 #include <qgroupbox.h>
    00025 #include <qlabel.h>
    00026 #include <qlayout.h>
    00027 #include <qpushbutton.h>
    00028
    00029 #include "resourcefactory.h"
    00030 #include "resourceconfigdlg.h"
    00031
    00032 ResourceConfigDlg::ResourceConfigDlg( QWidget *parent, const QString& type,
    00033     KConfig *config, const char *name )
    00034   : KDialog( parent, name, true ), mConfig( config )
    00035 {
    00036   KABC::ResourceFactory *factory = KABC::ResourceFactory::self();
    00037
    00038   setCaption( i18n( "Resource Configuration" ) );
    00039   resize( 250, 240 );
    00040
    00041   QVBoxLayout *mainLayout = new QVBoxLayout( this, marginHint(), spacingHint() );
    00042
    00043   QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal,  this );
    00044   generalGroupBox->setTitle( i18n( "General Settings" ) );
    00045
    00046   new QLabel( i18n( "Name:" ), generalGroupBox );
    00047
    00048   mName = new KLineEdit( generalGroupBox );
    00049
    00050   mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox );
    00051
    00052   mFast = new QCheckBox( i18n( "Fast resource" ), generalGroupBox );
    00053   // we hide this checkbox until we find a meanigfull name :)
    00054   mFast->hide();
    00055
    00056   mainLayout->addWidget( generalGroupBox );
    00057
    00058   QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal,  this );
    00059   resourceGroupBox->setTitle( i18n( "Resource Settings" ) );
    00060
    00061   mainLayout->addSpacing( 10 );
    00062   mainLayout->addWidget( resourceGroupBox );
    00063   mainLayout->addSpacing( 10 );
    00064
    00065   mConfigWidget = factory->configWidget( type, resourceGroupBox );
    00066   if ( mConfigWidget && mConfig ) {
    00067     mConfigWidget->setEditMode( false );
    00068     mConfigWidget->loadSettings( mConfig );
    00069     mConfigWidget->show();
    00070     connect( mConfigWidget, SIGNAL( setResourceName( const QString & ) ), SLOT( setResourceName( const QString & ) ) );
    00071     connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ), SLOT( setReadOnly( bool ) ) );
    00072     connect( mConfigWidget, SIGNAL( setFast( bool ) ), SLOT( setFast( bool ) ) );
    00073   }
    00074
    00075   mButtonBox = new KButtonBox( this );
    00076
    00077   mButtonBox->addStretch();
    00078   mButtonBox->addButton( i18n( "&OK" ), this, SLOT( accept() ) )->setFocus();
    00079   mButtonBox->addButton( i18n( "&Cancel" ), this, SLOT( reject() ) );
    00080   mButtonBox->layout();
    00081
    00082   mainLayout->addWidget( mButtonBox );
    00083 }
    00084
    00085 int ResourceConfigDlg::exec()
    00086 {
    00087   return QDialog::exec();
    00088 }
    00089
    00090 bool ResourceConfigDlg::readOnly()
    00091 {
    00092   return mReadOnly->isChecked();
    00093 }
    00094
    00095 bool ResourceConfigDlg::fast()
    00096 {
    00097   return mFast->isChecked();
    00098 }
    00099
    00100 QString ResourceConfigDlg::resourceName()
    00101 {
    00102   return mName->text();
    00103 }
    00104
    00105 void ResourceConfigDlg::setReadOnly( bool value )
    00106 {
    00107   mReadOnly->setChecked( value );
    00108 }
    00109
    00110 void ResourceConfigDlg::setFast( bool value )
    00111 {
    00112   mFast->setChecked( value );
    00113 }
    00114
    00115 void ResourceConfigDlg::setResourceName( const QString &name )
    00116 {
    00117   mName->setText( name );
    00118 }
    00119
    00120 void ResourceConfigDlg::setEditMode( bool value )
    00121 {
    00122   if ( mConfigWidget )
    00123     mConfigWidget->setEditMode( value );
    00124 }
    00125
    00126 void ResourceConfigDlg::accept()
    00127 {
    00128   if ( mName->text().isEmpty() ) {
    00129     KMessageBox::sorry( this, i18n( "Please enter a resource name" ) );
    00130     return;
    00131   }
    00132
    00133   if ( mConfigWidget && mConfig )
    00134     mConfigWidget->saveSettings( mConfig );
    00135
    00136   QDialog::accept();
    00137 }
    00138
    00139 #include "resourceconfigdlg.moc"

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:29:21 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001