KJsEmbed

url.cpp
1 /* This file is part of the KDE libraries
2  Copyright (C) 2005, 2006 Ian Reinhart Geiser <[email protected]>
3  Copyright (C) 2005, 2006 Matt Broadstone <[email protected]>
4  Copyright (C) 2005, 2006 Richard J. Moore <[email protected]>
5  Copyright (C) 2005, 2006 Erik L. Bunce <[email protected]>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 #include "url.h"
23 
24 #include <QDebug>
25 #include <QUrl>
26 
27 using namespace KJSEmbed;
28 
29 const KJS::ClassInfo UrlBinding::info = { "QUrl", &VariantBinding::info, nullptr, nullptr };
30 UrlBinding::UrlBinding(KJS::ExecState *exec, const QUrl &value)
31  : VariantBinding(exec, value)
32 {
33  StaticBinding::publish(exec, this, VariantFactory::methods());
34  StaticBinding::publish(exec, this, Url::methods());
35 }
36 
37 namespace UrlNS
38 {
39 
40 START_VARIANT_METHOD(callisValid, QUrl)
41 bool cppValue = value.isValid();
42 result = KJS::jsBoolean(cppValue);
43 END_VARIANT_METHOD
44 
45 START_VARIANT_METHOD(toString, QUrl)
46 QUrl::FormattingOptions opts = (QUrl::FormattingOptions)KJSEmbed::extractInt(exec, args, 0, QUrl::None);
47 result = KJS::jsString(value.toString(opts));
48 END_VARIANT_METHOD
49 }
50 
51 START_METHOD_LUT(Url)
52 {"toString", 0, KJS::DontDelete | KJS::ReadOnly, &UrlNS::toString},
53 {"isValid", 0, KJS::DontDelete | KJS::ReadOnly, &UrlNS::callisValid}
54 END_METHOD_LUT
55 
56 START_ENUM_LUT(Url)
57 {"None", QUrl::None},
58 {"RemoveScheme", QUrl::RemoveScheme},
59 {"RemovePassword", QUrl::RemovePassword},
60 {"RemoveUserInfo", QUrl::RemoveUserInfo},
61 {"RemovePort", QUrl::RemovePort},
62 {"RemoveAuthority", QUrl::RemoveAuthority},
63 {"RemovePath", QUrl::RemovePath},
64 {"RemoveQuery", QUrl::RemoveQuery},
65 {"RemoveFragment", QUrl::RemoveFragment},
66 {"StripTrailingSlash", QUrl::StripTrailingSlash}
67 END_ENUM_LUT
68 
69 NO_STATICS(Url)
70 
71 START_CTOR(Url, QUrl, 0)
72 if (args.size() == 1)
73 {
74  return new KJSEmbed::UrlBinding(exec, QUrl(KJSEmbed::extractQString(exec, args, 0)));
75 }
76 
77 return new KJSEmbed::UrlBinding(exec, QUrl());
78 END_CTOR
79 
bool isValid() const const
typedef FormattingOptions
static void publish(KJS::ExecState *exec, KJS::JSObject *object, const Method *methods)
Publishes an array of Methods to an object.
QVariant based binding.
QString toString() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 10 2023 03:59:19 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.