resourcelocalconfig.cpp
00001 /******************************************************************* 00002 Copyright (c) 2005, The KNotes Developers 00003 00004 This file is part of KNotes. 00005 00006 KNotes is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 KNotes 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 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with KNotes; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00019 *******************************************************************/ 00020 00021 #include <tqlabel.h> 00022 #include <tqlayout.h> 00023 00024 #include <kdebug.h> 00025 #include <tdelocale.h> 00026 #include <tderesources/configwidget.h> 00027 #include <kurlrequester.h> 00028 00029 #include "resourcelocal.h" 00030 #include "resourcelocalconfig.h" 00031 00032 ResourceLocalConfig::ResourceLocalConfig( TQWidget *parent, const char *name ) 00033 : KRES::ConfigWidget( parent, name ) 00034 { 00035 TQHBoxLayout *layout = new TQHBoxLayout( this ); 00036 00037 TQLabel *label = new TQLabel( i18n( "Location:" ), this ); 00038 mURL = new KURLRequester( this ); 00039 KFile::Mode mode = static_cast<KFile::Mode>( KFile::File | 00040 KFile::LocalOnly ); 00041 mURL->setMode( mode ); 00042 layout->addWidget( label ); 00043 layout->addWidget( mURL ); 00044 } 00045 00046 ResourceLocalConfig::~ResourceLocalConfig() 00047 { 00048 } 00049 00050 void ResourceLocalConfig::loadSettings( KRES::Resource *resource ) 00051 { 00052 ResourceLocal *res = dynamic_cast<ResourceLocal *>( resource ); 00053 if ( res ) 00054 mURL->setURL( res->url().prettyURL() ); 00055 else 00056 kdDebug() << "ERROR: ResourceLocalConfig::loadSettings(): no ResourceLocal, cast failed" << endl; 00057 } 00058 00059 void ResourceLocalConfig::saveSettings( KRES::Resource *resource ) 00060 { 00061 ResourceLocal *res = dynamic_cast<ResourceLocal *>( resource ); 00062 if ( res ) 00063 res->setURL( mURL->url() ); 00064 else 00065 kdDebug() << "ERROR: ResourceLocalConfig::saveSettings(): no ResourceLocal, cast failed" << endl; 00066 } 00067 00068 #include "resourcelocalconfig.moc"