libkcal

resourcelocaldirconfig.cpp

00001 /*
00002     This file is part of libkcal.
00003 
00004     Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include <typeinfo>
00023 
00024 #include <tqlabel.h>
00025 #include <tqlayout.h>
00026 
00027 #include <klocale.h>
00028 #include <kdebug.h>
00029 #include <kmessagebox.h>
00030 #include <kstandarddirs.h>
00031 
00032 #include "vcaldrag.h"
00033 #include "vcalformat.h"
00034 #include "icalformat.h"
00035 
00036 #include "resourcelocaldir.h"
00037 
00038 #include "resourcelocaldirconfig.h"
00039 
00040 using namespace KCal;
00041 
00042 ResourceLocalDirConfig::ResourceLocalDirConfig( TQWidget* parent,  const char* name )
00043     : KRES::ConfigWidget( parent, name )
00044 {
00045   resize( 245, 115 );
00046   TQGridLayout *mainLayout = new TQGridLayout( this, 2, 2 );
00047 
00048   TQLabel *label = new TQLabel( i18n( "Location:" ), this );
00049   mURL = new KURLRequester( this );
00050   mURL->setMode( KFile::Directory | KFile::LocalOnly );
00051   mainLayout->addWidget( label, 1, 0 );
00052   mainLayout->addWidget( mURL, 1, 1 );
00053 }
00054 
00055 void ResourceLocalDirConfig::loadSettings( KRES::Resource *resource )
00056 {
00057   ResourceLocalDir* res = static_cast<ResourceLocalDir*>( resource );
00058   if ( res ) {
00059     mURL->setURL( res->mURL.prettyURL() );
00060   } else
00061     kdDebug(5700) << "ERROR: ResourceLocalDirConfig::loadSettings(): no ResourceLocalDir, cast failed" << endl;
00062 }
00063 
00064 void ResourceLocalDirConfig::saveSettings( KRES::Resource *resource )
00065 {
00066   ResourceLocalDir* res = static_cast<ResourceLocalDir*>( resource );
00067   if (res) {
00068     res->mURL = mURL->url();
00069     if ( mURL->url().isEmpty() && !resource->readOnly() ) {
00070       KMessageBox::information(
00071         this,
00072         i18n( "No location specified.  The calendar will be read-only." ),
00073         TQString(),
00074         "ResourceLocalDirUrl" );
00075       resource->setReadOnly( true );
00076     }
00077   } else
00078     kdDebug(5700) << "ERROR: ResourceLocalDirConfig::saveSettings(): no ResourceLocalDir, cast failed" << endl;
00079 }
00080 
00081 #include "resourcelocaldirconfig.moc"