resourceconfigdlg.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <klocale.h>
00023 #include <kmessagebox.h>
00024
00025 #include <qgroupbox.h>
00026 #include <qlabel.h>
00027 #include <qlayout.h>
00028 #include <qpushbutton.h>
00029
00030 #include "resourcefactory.h"
00031 #include "resourceconfigdlg.h"
00032
00033 using namespace KPIM;
00034
00035 ResourceConfigDlg::ResourceConfigDlg( QWidget *parent, const QString& resourceType,
00036 const QString& type, KConfig *config, const char *name )
00037 : KDialog( parent, name, true ), mConfig( config )
00038 {
00039 ResourceFactory *factory = ResourceFactory::self( resourceType );
00040
00041 setCaption( i18n( "Resource Configuration" ) );
00042 resize( 250, 240 );
00043
00044 QVBoxLayout *mainLayout = new QVBoxLayout( this, marginHint(), spacingHint() );
00045
00046 QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, this );
00047 generalGroupBox->setTitle( i18n( "General Settings" ) );
00048
00049 new QLabel( i18n( "Name:" ), generalGroupBox );
00050
00051 mName = new KLineEdit( generalGroupBox );
00052
00053 mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox );
00054
00055 mFast = new QCheckBox( i18n( "Fast resource" ), generalGroupBox );
00056
00057 mFast->hide();
00058
00059 mainLayout->addWidget( generalGroupBox );
00060
00061 QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, this );
00062 resourceGroupBox->setTitle( i18n( "Resource Settings" ) );
00063
00064 mainLayout->addSpacing( 10 );
00065 mainLayout->addWidget( resourceGroupBox );
00066 mainLayout->addSpacing( 10 );
00067
00068 mConfigWidget = factory->configWidget( type, resourceGroupBox );
00069 if ( mConfigWidget && mConfig ) {
00070 mConfigWidget->loadSettings( mConfig );
00071 mConfigWidget->show();
00072 connect( mConfigWidget, SIGNAL( setResourceName( const QString & ) ), SLOT( setResourceName( const QString & ) ) );
00073 connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ), SLOT( setReadOnly( bool ) ) );
00074 connect( mConfigWidget, SIGNAL( setFast( bool ) ), SLOT( setFast( bool ) ) );
00075 }
00076
00077 mButtonBox = new KButtonBox( this );
00078
00079 mButtonBox->addStretch();
00080 mButtonBox->addButton( i18n( "&OK" ), this, SLOT( accept() ) )->setFocus();
00081 mButtonBox->addButton( i18n( "&Cancel" ), this, SLOT( reject() ) );
00082 mButtonBox->layout();
00083
00084 mainLayout->addWidget( mButtonBox );
00085 }
00086
00087 int ResourceConfigDlg::exec()
00088 {
00089 return QDialog::exec();
00090 }
00091
00092 bool ResourceConfigDlg::readOnly()
00093 {
00094 return mReadOnly->isChecked();
00095 }
00096
00097 bool ResourceConfigDlg::fast()
00098 {
00099 return mFast->isChecked();
00100 }
00101
00102 QString ResourceConfigDlg::resourceName()
00103 {
00104 return mName->text();
00105 }
00106
00107 void ResourceConfigDlg::setReadOnly( bool value )
00108 {
00109 mReadOnly->setChecked( value );
00110 }
00111
00112 void ResourceConfigDlg::setFast( bool value )
00113 {
00114 mFast->setChecked( value );
00115 }
00116
00117 void ResourceConfigDlg::setResourceName( const QString &name )
00118 {
00119 mName->setText( name );
00120 }
00121
00122 void ResourceConfigDlg::accept()
00123 {
00124 if ( mName->text().isEmpty() ) {
00125 KMessageBox::sorry( this, i18n( "Please enter a resource name" ) );
00126 return;
00127 }
00128
00129 if ( mConfigWidget && mConfig )
00130 mConfigWidget->saveSettings( mConfig );
00131
00132 QDialog::accept();
00133 }
00134
00135 #include "resourceconfigdlg.moc"
This file is part of the documentation for kdelibs Version 3.1.4.