00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
00081