• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kalarm

resourceconfigdialog.cpp

Go to the documentation of this file.
00001 /*
00002  *  resourceconfigdialog.cpp  -  KAlarm resource configuration dialog
00003  *  Program:  kalarm
00004  *  Copyright © 2006-2008 by David Jarvie <djarvie@kde.org>
00005  *  Based on configdialog.cpp in kdelibs/kresources,
00006  *  Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
00007  *  Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
00008  *  Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
00009  *
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00018  *  GNU General Public License for more details.
00019  *
00020  *  You should have received a copy of the GNU General Public License along
00021  *  with this program; if not, write to the Free Software Foundation, Inc.,
00022  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00023  */
00024 
00025 #include <klocale.h>
00026 #include <klineedit.h>
00027 #include <kmessagebox.h>
00028 
00029 #include <QGroupBox>
00030 #include <QLabel>
00031 #include <QLayout>
00032 #include <QCheckBox>
00033 
00034 #include <kresources/factory.h>
00035 #include "alarmresource.h"
00036 #include "resourceconfigdialog.moc"
00037 
00038 using namespace KRES;
00039 
00040 ResourceConfigDialog::ResourceConfigDialog( QWidget *parent, AlarmResource* resource )
00041   : KDialog( parent ), mResource( resource )
00042 {
00043   Factory *factory = Factory::self(QLatin1String("alarms"));
00044 
00045   QFrame *main = new QFrame( this );
00046   setMainWidget( main );
00047   setCaption(i18nc("@title:window", "Resource Configuration"));
00048   setButtons( Ok|Cancel );
00049   setDefaultButton( Ok );
00050   setModal( true );
00051 
00052   QVBoxLayout *mainLayout = new QVBoxLayout( main );
00053   mainLayout->setSpacing( spacingHint() );
00054 
00055   QGroupBox *generalGroupBox = new QGroupBox( main );
00056   QGridLayout *gbLayout = new QGridLayout;
00057   gbLayout->setSpacing( spacingHint() );
00058   generalGroupBox->setLayout( gbLayout );
00059 
00060   generalGroupBox->setTitle(i18nc("@title:group", "General Settings"));
00061 
00062   gbLayout->addWidget(new QLabel(i18nc("@label:textbox Resource name", "Name:"), generalGroupBox ), 0, 0 );
00063 
00064   mName = new KLineEdit();
00065   gbLayout->addWidget( mName, 0, 1 );
00066 
00067   mReadOnly = new QCheckBox(i18nc("@option:check", "Read-only"), generalGroupBox );
00068   gbLayout->addWidget( mReadOnly, 1, 0, 1, 2 );
00069 
00070   mName->setText( mResource->resourceName() );
00071   mReadOnly->setChecked( mResource->readOnly() );
00072 
00073   mainLayout->addWidget( generalGroupBox );
00074 
00075   QGroupBox *resourceGroupBox = new QGroupBox( main );
00076   QGridLayout *resourceLayout = new QGridLayout;
00077   resourceLayout->setSpacing( spacingHint() );
00078   resourceGroupBox->setLayout( resourceLayout );
00079 
00080   resourceGroupBox->setTitle(i18nc("@title:group", "<resource>%1</resource> Resource Settings",
00081                                 factory->typeName( resource->type() ) ) );
00082   mainLayout->addWidget( resourceGroupBox );
00083 
00084   mainLayout->addStretch();
00085 
00086   mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox );
00087   if ( mConfigWidget ) {
00088     resourceLayout->addWidget( mConfigWidget );
00089     mConfigWidget->setInEditMode( false );
00090     mConfigWidget->loadSettings( mResource );
00091     mConfigWidget->show();
00092     connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ),
00093         SLOT( setReadOnly( bool ) ) );
00094   }
00095 
00096   connect( mName, SIGNAL( textChanged(const QString &)),
00097       SLOT( slotNameChanged(const QString &)));
00098 
00099   slotNameChanged( mName->text() );
00100   setMinimumSize( sizeHint() );
00101 }
00102 
00103 void ResourceConfigDialog::setInEditMode( bool value )
00104 {
00105   if ( mConfigWidget )
00106     mConfigWidget->setInEditMode( value );
00107 }
00108 
00109 void ResourceConfigDialog::slotNameChanged( const QString &text)
00110 {
00111   enableButtonOk( !text.isEmpty() );
00112 }
00113 
00114 void ResourceConfigDialog::setReadOnly( bool value )
00115 {
00116   mReadOnly->setChecked( value );
00117 }
00118 
00119 void ResourceConfigDialog::accept()
00120 {
00121   if ( mName->text().isEmpty() ) {
00122     KMessageBox::sorry(this, i18nc("@info", "Please enter a resource name."));
00123     return;
00124   }
00125 
00126   mResource->startReconfig();
00127   mResource->setResourceName( mName->text() );
00128   mResource->setReadOnly( mReadOnly->isChecked() );
00129 
00130   if ( mConfigWidget ) {
00131     // First save generic information
00132     // Also save setting of specific resource type
00133     mConfigWidget->saveSettings( mResource );
00134   }
00135   mResource->applyReconfig();
00136 
00137   KDialog::accept();
00138 }

kalarm

Skip menu "kalarm"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal