kjsembed
url.cpp
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2005, 2006 Ian Reinhart Geiser <geiseri@kde.org> 00003 Copyright (C) 2005, 2006 Matt Broadstone <mbroadst@gmail.com> 00004 Copyright (C) 2005, 2006 Richard J. Moore <rich@kde.org> 00005 Copyright (C) 2005, 2006 Erik L. Bunce <kde@bunce.us> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. 00021 */ 00022 #include "url.h" 00023 00024 #include <QtCore/QDebug> 00025 #include <QtCore/QUrl> 00026 00027 using namespace KJSEmbed; 00028 00029 const KJS::ClassInfo UrlBinding::info = { "QUrl", &VariantBinding::info, 0, 0 }; 00030 UrlBinding::UrlBinding( KJS::ExecState *exec, const QUrl &value ) 00031 : VariantBinding(exec, value ) 00032 { 00033 StaticBinding::publish( exec, this, VariantFactory::methods() ); 00034 StaticBinding::publish( exec, this, Url::methods() ); 00035 } 00036 00037 namespace UrlNS 00038 { 00039 00040 START_VARIANT_METHOD( callisValid, QUrl ) 00041 bool cppValue = value.isValid(); 00042 result = KJS::jsBoolean(cppValue); 00043 END_VARIANT_METHOD 00044 00045 START_VARIANT_METHOD( toString, QUrl ) 00046 QUrl::FormattingOptions opts = (QUrl::FormattingOptions)KJSEmbed::extractInt(exec, args, 0, QUrl::None); 00047 result = KJS::jsString( value.toString( opts ) ); 00048 END_VARIANT_METHOD 00049 } 00050 00051 START_METHOD_LUT( Url ) 00052 {"toString", 0, KJS::DontDelete|KJS::ReadOnly, &UrlNS::toString}, 00053 {"isValid", 0, KJS::DontDelete|KJS::ReadOnly, &UrlNS::callisValid} 00054 END_METHOD_LUT 00055 00056 START_ENUM_LUT( Url ) 00057 {"None", QUrl::None}, 00058 {"RemoveScheme", QUrl::RemoveScheme}, 00059 {"RemovePassword", QUrl::RemovePassword}, 00060 {"RemoveUserInfo", QUrl::RemoveUserInfo}, 00061 {"RemovePort", QUrl::RemovePort}, 00062 {"RemoveAuthority", QUrl::RemoveAuthority}, 00063 {"RemovePath", QUrl::RemovePath}, 00064 {"RemoveQuery", QUrl::RemoveQuery}, 00065 {"RemoveFragment", QUrl::RemoveFragment}, 00066 {"StripTrailingSlash", QUrl::StripTrailingSlash} 00067 END_ENUM_LUT 00068 00069 NO_STATICS( Url ) 00070 00071 START_CTOR( Url, QUrl, 0 ) 00072 if( args.size() == 1 ) 00073 { 00074 return new KJSEmbed::UrlBinding(exec, QUrl( KJSEmbed::extractQString( exec, args, 0 ) ) ); 00075 } 00076 00077 return new KJSEmbed::UrlBinding( exec, QUrl() ); 00078 END_CTOR 00079 00080 //kate: indent-spaces on; indent-width 4; replace-tabs on; indent-mode cstyle; 00081
KDE 4.6 API Reference