Added QMimeData, additional methods to QUrl, and Dropping should now be supported (#614)

* Added QWheelEvent

* removed x y

* Added QNativeGestureEvent

* Changed wrong type of QNativeGestureEventWrap value

* Added QTabletEvent

* Fixing build error for QTabletEvent

* adding dropaction

* fix typos

* Added more functions to QPainterPath

* Added more functions to QPainterPath

* Fixed multiple typos

* Fixed multiple typos

* Got QPainterPath additions working.

* Modified QPainterPath to use qreal instead

* Added QPointF, added a few missing methods to QPoint

* Added QRectF

* implemented QRectF

* Added acceptDrops and setAcceptDrops to QWidget, will be useful for addon implementation of Drag and Drop

* Added more methods to QUrl

* Added QMimeData, additional methods to QUrl, and Dropping should now be supported

* refactored

* Fixed more merge conflicts

* Is this my final merge conflict??

* All merge conflicts resolved

* All merge conflicts resolved

* Adds guide for drag and drop

* lint fix

Co-authored-by: Switt Kongdachalert <switt1995@yahoo.com>
Co-authored-by: Atul R <atulanand94@gmail.com>
This commit is contained in:
swittk 2020-06-27 22:35:31 +07:00 committed by GitHub
parent f4d656d8ef
commit 3cb3424250
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 2808 additions and 58 deletions

View File

@ -50,6 +50,7 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QTabletEvent/qtabletevent_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QDropEvent/qdropevent_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QDragMoveEvent/qdragmoveevent_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QDragLeaveEvent/qdragleaveevent_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QFontDatabase/qfontdatabase_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QPicture/qpicture_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QPixmap/qpixmap_wrap.cpp"
@ -72,6 +73,7 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtCore/QPointF/qpointf_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtCore/QTime/qtime_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtCore/QUrl/qurl_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtCore/QMimeData/qmimedata_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QWidget/qwidget_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QDialog/qdialog_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QBoxLayout/qboxlayout_wrap.cpp"

View File

@ -0,0 +1,43 @@
#pragma once
#include <napi.h>
#include <QMimeData>
#include "Extras/Export/export.h"
#include "core/Component/component_macro.h"
class DLL_EXPORT QMimeDataWrap : public Napi::ObjectWrap<QMimeDataWrap> {
COMPONENT_WRAPPED_METHODS_DECLARATION
private:
std::unique_ptr<QMimeData> instance;
public:
static Napi::Object init(Napi::Env env, Napi::Object exports);
QMimeDataWrap(const Napi::CallbackInfo& info);
~QMimeDataWrap();
QMimeData* getInternalInstance();
// class constructor
static Napi::FunctionReference constructor;
static void cloneFromMimeDataToData(QMimeData* fromData, QMimeData* toData);
void cloneFromMimeData(QMimeData* data);
// wrapped methods
Napi::Value clear(const Napi::CallbackInfo& info);
Napi::Value hasColor(const Napi::CallbackInfo& info);
Napi::Value hasHtml(const Napi::CallbackInfo& info);
Napi::Value hasImage(const Napi::CallbackInfo& info);
Napi::Value hasText(const Napi::CallbackInfo& info);
Napi::Value hasUrls(const Napi::CallbackInfo& info);
Napi::Value html(const Napi::CallbackInfo& info);
Napi::Value removeFormat(const Napi::CallbackInfo& info);
// Will need implementation with Buffer or UInt8Array
// Napi::Value setData(const Napi::CallbackInfo& info);
Napi::Value setHtml(const Napi::CallbackInfo& info);
Napi::Value setText(const Napi::CallbackInfo& info);
Napi::Value setUrls(const Napi::CallbackInfo& info);
Napi::Value text(const Napi::CallbackInfo& info);
Napi::Value urls(const Napi::CallbackInfo& info);
};

View File

@ -21,8 +21,49 @@ class DLL_EXPORT QUrlWrap : public Napi::ObjectWrap<QUrlWrap> {
// Wrapped methods
Napi::Value setUrl(const Napi::CallbackInfo& info);
Napi::Value toString(const Napi::CallbackInfo& info);
Napi::Value adjusted(const Napi::CallbackInfo& info);
Napi::Value authority(const Napi::CallbackInfo& info);
Napi::Value clear(const Napi::CallbackInfo& info);
Napi::Value errorString(const Napi::CallbackInfo& info);
Napi::Value fileName(const Napi::CallbackInfo& info);
Napi::Value fragment(const Napi::CallbackInfo& info);
Napi::Value hasFragment(const Napi::CallbackInfo& info);
Napi::Value hasQuery(const Napi::CallbackInfo& info);
Napi::Value host(const Napi::CallbackInfo& info);
Napi::Value isEmpty(const Napi::CallbackInfo& info);
Napi::Value isLocalFile(const Napi::CallbackInfo& info);
Napi::Value isParentOf(const Napi::CallbackInfo& info);
Napi::Value isRelative(const Napi::CallbackInfo& info);
Napi::Value isValid(const Napi::CallbackInfo& info);
Napi::Value matches(const Napi::CallbackInfo& info);
Napi::Value password(const Napi::CallbackInfo& info);
Napi::Value path(const Napi::CallbackInfo& info);
Napi::Value port(const Napi::CallbackInfo& info);
Napi::Value query(const Napi::CallbackInfo& info);
Napi::Value resolved(const Napi::CallbackInfo& info);
Napi::Value scheme(const Napi::CallbackInfo& info);
Napi::Value setAuthority(const Napi::CallbackInfo& info);
Napi::Value setFragment(const Napi::CallbackInfo& info);
Napi::Value setHost(const Napi::CallbackInfo& info);
Napi::Value setPassword(const Napi::CallbackInfo& info);
Napi::Value setPath(const Napi::CallbackInfo& info);
Napi::Value setPort(const Napi::CallbackInfo& info);
Napi::Value setQuery(const Napi::CallbackInfo& info);
Napi::Value setScheme(const Napi::CallbackInfo& info);
Napi::Value setUserInfo(const Napi::CallbackInfo& info);
Napi::Value setUserName(const Napi::CallbackInfo& info);
Napi::Value swap(const Napi::CallbackInfo& info);
Napi::Value toDisplayString(const Napi::CallbackInfo& info);
Napi::Value toLocalFile(const Napi::CallbackInfo& info);
Napi::Value toString_withOpts(const Napi::CallbackInfo& info);
Napi::Value url(const Napi::CallbackInfo& info);
Napi::Value userInfo(const Napi::CallbackInfo& info);
Napi::Value userName(const Napi::CallbackInfo& info);
};
namespace StaticQUrlWrapMethods {
DLL_EXPORT Napi::Value fromQVariant(const Napi::CallbackInfo& info);
DLL_EXPORT Napi::Value fromLocalFile(const Napi::CallbackInfo& info);
DLL_EXPORT Napi::Value fromUserInput(const Napi::CallbackInfo& info);
} // namespace StaticQUrlWrapMethods

View File

@ -0,0 +1,28 @@
#pragma once
#include <napi.h>
#include <QDragLeaveEvent>
#include "Extras/Export/export.h"
#include "QtGui/QEvent/QEvent/qevent_macro.h"
#include "core/Component/component_macro.h"
class DLL_EXPORT QDragLeaveEventWrap
: public Napi::ObjectWrap<QDragLeaveEventWrap> {
COMPONENT_WRAPPED_METHODS_DECLARATION
private:
QDragLeaveEvent* instance;
public:
static Napi::Object init(Napi::Env env, Napi::Object exports);
QDragLeaveEventWrap(const Napi::CallbackInfo& info);
~QDragLeaveEventWrap();
QDragLeaveEvent* getInternalInstance();
// class constructor
static Napi::FunctionReference constructor;
// wrapped methods (none)
// Methods from QEvent
QEVENT_WRAPPED_METHODS_DECLARATION
};

View File

@ -37,8 +37,7 @@ class DLL_EXPORT QDragMoveEventWrap
Napi::Value dropAction(const Napi::CallbackInfo& info);
Napi::Value keyboardModifiers(const Napi::CallbackInfo& info);
Napi::Value mouseButtons(const Napi::CallbackInfo& info);
// Need to implement mimeData first?
// Napi::Value QDragMoveEventWrap::mimeData
Napi::Value mimeData(const Napi::CallbackInfo& info);
Napi::Value pos(const Napi::CallbackInfo& info);
Napi::Value possibleActions(const Napi::CallbackInfo& info);
Napi::Value proposedAction(const Napi::CallbackInfo& info);

View File

@ -26,8 +26,7 @@ class DLL_EXPORT QDropEventWrap : public Napi::ObjectWrap<QDropEventWrap> {
Napi::Value dropAction(const Napi::CallbackInfo& info);
Napi::Value keyboardModifiers(const Napi::CallbackInfo& info);
Napi::Value mouseButtons(const Napi::CallbackInfo& info);
// Need to implement mimeData first?
// Napi::Value QDropEventWrap::mimeData
Napi::Value mimeData(const Napi::CallbackInfo& info);
Napi::Value pos(const Napi::CallbackInfo& info);
Napi::Value possibleActions(const Napi::CallbackInfo& info);
Napi::Value proposedAction(const Napi::CallbackInfo& info);

View File

@ -0,0 +1,235 @@
#include "QtCore/QMimeData/qmimedata_wrap.h"
#include "Extras/Utils/nutils.h"
#include "QtCore/QUrl/qurl_wrap.h"
Napi::FunctionReference QMimeDataWrap::constructor;
Napi::Object QMimeDataWrap::init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QMimeData";
Napi::Function func =
DefineClass(env, CLASSNAME,
{InstanceMethod("clear", &QMimeDataWrap::clear),
InstanceMethod("hasColor", &QMimeDataWrap::hasColor),
InstanceMethod("hasHtml", &QMimeDataWrap::hasHtml),
InstanceMethod("hasImage", &QMimeDataWrap::hasImage),
InstanceMethod("hasText", &QMimeDataWrap::hasText),
InstanceMethod("hasUrls", &QMimeDataWrap::hasUrls),
InstanceMethod("html", &QMimeDataWrap::html),
InstanceMethod("removeFormat", &QMimeDataWrap::removeFormat),
// InstanceMethod("setData",&QMimeDataWrap::setData),
InstanceMethod("setHtml", &QMimeDataWrap::setHtml),
InstanceMethod("setText", &QMimeDataWrap::setText),
InstanceMethod("setUrls", &QMimeDataWrap::setUrls),
InstanceMethod("text", &QMimeDataWrap::text),
InstanceMethod("urls", &QMimeDataWrap::urls),
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QMimeDataWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
}
QMimeData* QMimeDataWrap::getInternalInstance() { return this->instance.get(); }
QMimeDataWrap::~QMimeDataWrap() { this->instance.reset(); }
QMimeDataWrap::QMimeDataWrap(const Napi::CallbackInfo& info)
: Napi::ObjectWrap<QMimeDataWrap>(info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if (info.Length() == 1) {
Napi::External<QMimeData> eventObject =
info[0].As<Napi::External<QMimeData>>();
this->instance = std::make_unique<QMimeData>();
// Copy data to our instance
QMimeData* mimeReference = eventObject.Data();
this->cloneFromMimeData(mimeReference);
// foreach(QString format, mimeReference->formats())
// {
// // Retrieving data
// QByteArray data = mimeReference->data(format);
// // Checking for custom MIME types
// if(format.startsWith("application/x-qt"))
// {
// // Retrieving true format name
// int indexBegin = format.indexOf('"') + 1;
// int indexEnd = format.indexOf('"', indexBegin);
// format = format.mid(indexBegin, indexEnd - indexBegin);
// }
// this->instance->setData(format, data);
// }
} else {
this->instance = std::make_unique<QMimeData>();
}
this->rawData = extrautils::configureComponent(this->getInternalInstance());
}
void QMimeDataWrap::cloneFromMimeDataToData(QMimeData* fromData,
QMimeData* toData) {
foreach (QString format, fromData->formats()) {
// Retrieving data
QByteArray data = fromData->data(format);
// Checking for custom MIME types
if (format.startsWith("application/x-qt")) {
// Retrieving true format name
int indexBegin = format.indexOf('"') + 1;
int indexEnd = format.indexOf('"', indexBegin);
format = format.mid(indexBegin, indexEnd - indexBegin);
}
toData->setData(format, data);
}
}
void QMimeDataWrap::cloneFromMimeData(QMimeData* mimeReference) {
foreach (QString format, mimeReference->formats()) {
// Retrieving data
QByteArray data = mimeReference->data(format);
// Checking for custom MIME types
if (format.startsWith("application/x-qt")) {
// Retrieving true format name
int indexBegin = format.indexOf('"') + 1;
int indexEnd = format.indexOf('"', indexBegin);
format = format.mid(indexBegin, indexEnd - indexBegin);
}
this->instance->setData(format, data);
}
}
// Instance Methods Here
Napi::Value QMimeDataWrap::clear(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
this->instance->clear();
return env.Null();
}
Napi::Value QMimeDataWrap::hasColor(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Boolean::New(env, this->instance->hasColor());
}
Napi::Value QMimeDataWrap::hasHtml(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Boolean::New(env, this->instance->hasHtml());
}
Napi::Value QMimeDataWrap::hasImage(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Boolean::New(env, this->instance->hasImage());
}
Napi::Value QMimeDataWrap::hasText(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Boolean::New(env, this->instance->hasText());
}
Napi::Value QMimeDataWrap::hasUrls(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Boolean::New(env, this->instance->hasUrls());
}
Napi::Value QMimeDataWrap::html(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::String::New(env, this->instance->html().toStdString());
}
Napi::Value QMimeDataWrap::removeFormat(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QString input0 =
QString::fromStdString(info[0].As<Napi::String>().Utf8Value());
this->instance->removeFormat(input0);
return env.Null();
}
// TODO: Maybe implement a Buffer or UInt8Array
// Napi::Value QMimeDataWrap::setData(const Napi::CallbackInfo& info) {
// Napi::Env env = info.Env();
// Napi::HandleScope scope(env);
// QString input0 =
// QString::fromStdString(info[0].As<Napi::String>().Utf8Value());
// Napi::Object wrap1_0 = info[1].As<Napi::Object>();
// constWrap* wrap1_1 = Napi::ObjectWrap<constWrap>::Unwrap(wrap1_0);
// const* input1 = wrap1_1->getInternalInstance();
// this->instance->setData(input0, *input1);
// return env.Null();
// }
Napi::Value QMimeDataWrap::setHtml(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QString input0 =
QString::fromStdString(info[0].As<Napi::String>().Utf8Value());
this->instance->setHtml(input0);
return env.Null();
}
Napi::Value QMimeDataWrap::setText(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QString input0 =
QString::fromStdString(info[0].As<Napi::String>().Utf8Value());
this->instance->setText(input0);
return env.Null();
}
Napi::Value QMimeDataWrap::setUrls(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Array urls = info[0].As<Napi::Array>();
QList<QUrl> list;
for (int i = 0; i < urls.Length(); i++) {
Napi::Object urlObj = static_cast<Napi::Value>(urls[i]).As<Napi::Object>();
QUrlWrap* urlWrap = Napi::ObjectWrap<QUrlWrap>::Unwrap(urlObj);
QUrl* url = urlWrap->getInternalInstance();
list.append(*url);
}
this->instance->setUrls(list);
return env.Null();
}
Napi::Value QMimeDataWrap::text(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::String::New(env, this->instance->text().toStdString());
}
Napi::Value QMimeDataWrap::urls(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QList<QUrl> urls = this->instance->urls();
int length = urls.length();
Napi::Array retval = Napi::Array::New(env, length);
for (int i = 0; i < length; i++) {
QUrl url = urls[i];
auto instance = QUrlWrap::constructor.New(
{Napi::External<QUrl>::New(env, new QUrl(url))});
retval[i] = instance;
}
return retval;
}
// Static Methods here

View File

@ -13,6 +13,49 @@ Napi::Object QUrlWrap::init(Napi::Env env, Napi::Object exports) {
{InstanceMethod("setUrl", &QUrlWrap::setUrl),
InstanceMethod("toString", &QUrlWrap::toString),
StaticMethod("fromQVariant", &StaticQUrlWrapMethods::fromQVariant),
InstanceMethod("adjusted", &QUrlWrap::adjusted),
InstanceMethod("authority", &QUrlWrap::authority),
InstanceMethod("clear", &QUrlWrap::clear),
InstanceMethod("errorString", &QUrlWrap::errorString),
InstanceMethod("fileName", &QUrlWrap::fileName),
InstanceMethod("fragment", &QUrlWrap::fragment),
InstanceMethod("hasFragment", &QUrlWrap::hasFragment),
InstanceMethod("hasQuery", &QUrlWrap::hasQuery),
InstanceMethod("host", &QUrlWrap::host),
InstanceMethod("isEmpty", &QUrlWrap::isEmpty),
InstanceMethod("isLocalFile", &QUrlWrap::isLocalFile),
InstanceMethod("isParentOf", &QUrlWrap::isParentOf),
InstanceMethod("isRelative", &QUrlWrap::isRelative),
InstanceMethod("isValid", &QUrlWrap::isValid),
InstanceMethod("matches", &QUrlWrap::matches),
InstanceMethod("password", &QUrlWrap::password),
InstanceMethod("path", &QUrlWrap::path),
InstanceMethod("port", &QUrlWrap::port),
InstanceMethod("query", &QUrlWrap::query),
InstanceMethod("resolved", &QUrlWrap::resolved),
InstanceMethod("scheme", &QUrlWrap::scheme),
InstanceMethod("setAuthority", &QUrlWrap::setAuthority),
InstanceMethod("setFragment", &QUrlWrap::setFragment),
InstanceMethod("setHost", &QUrlWrap::setHost),
InstanceMethod("setPassword", &QUrlWrap::setPassword),
InstanceMethod("setPath", &QUrlWrap::setPath),
InstanceMethod("setPort", &QUrlWrap::setPort),
InstanceMethod("setQuery", &QUrlWrap::setQuery),
InstanceMethod("setScheme", &QUrlWrap::setScheme),
// InstanceMethod("setUrl",&QUrlWrap::setUrl),
InstanceMethod("setUserInfo", &QUrlWrap::setUserInfo),
InstanceMethod("setUserName", &QUrlWrap::setUserName),
InstanceMethod("swap", &QUrlWrap::swap),
InstanceMethod("toDisplayString", &QUrlWrap::toDisplayString),
InstanceMethod("toLocalFile", &QUrlWrap::toLocalFile),
InstanceMethod("toString_withOpts", &QUrlWrap::toString),
InstanceMethod("url", &QUrlWrap::url),
InstanceMethod("userInfo", &QUrlWrap::userInfo),
InstanceMethod("userName", &QUrlWrap::userName),
StaticMethod("fromLocalFile", &StaticQUrlWrapMethods::fromLocalFile),
StaticMethod("fromUserInput", &StaticQUrlWrapMethods::fromUserInput),
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QUrlWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
@ -50,13 +93,6 @@ QUrlWrap::~QUrlWrap() { this->instance.reset(); }
QUrl* QUrlWrap::getInternalInstance() { return this->instance.get(); }
Napi::Value QUrlWrap::setUrl(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
std::string url = info[0].As<Napi::String>().Utf8Value();
this->instance->setUrl(QString::fromStdString(url));
return env.Null();
}
Napi::Value QUrlWrap::toString(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
@ -77,3 +113,420 @@ Napi::Value StaticQUrlWrapMethods::fromQVariant(
{Napi::External<QUrl>::New(env, new QUrl(url))});
return instance;
}
// Additional methods
Napi::Value QUrlWrap::adjusted(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QUrl::FormattingOptions input0 =
(QUrl::FormattingOptions)info[0].As<Napi::Number>().Int32Value();
QUrl ret = this->instance->adjusted(input0);
auto instance = QUrlWrap::constructor.New(
{Napi::External<QUrl>::New(env, new QUrl(ret))});
return instance;
}
Napi::Value QUrlWrap::authority(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QUrl::ComponentFormattingOptions input0 =
(QUrl::ComponentFormattingOptions)info[0].As<Napi::Number>().Int32Value();
return Napi::String::New(env,
this->instance->authority(input0).toStdString());
}
Napi::Value QUrlWrap::clear(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
this->instance->clear();
return env.Null();
}
Napi::Value QUrlWrap::errorString(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::String::New(env, this->instance->errorString().toStdString());
}
Napi::Value QUrlWrap::fileName(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QUrl::ComponentFormattingOptions input0 =
(QUrl::ComponentFormattingOptions)info[0].As<Napi::Number>().Int32Value();
return Napi::String::New(env, this->instance->fileName(input0).toStdString());
}
Napi::Value QUrlWrap::fragment(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QUrl::ComponentFormattingOptions input0 =
(QUrl::ComponentFormattingOptions)info[0].As<Napi::Number>().Int32Value();
return Napi::String::New(env, this->instance->fragment(input0).toStdString());
}
Napi::Value QUrlWrap::hasFragment(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Boolean::New(env, this->instance->hasFragment());
}
Napi::Value QUrlWrap::hasQuery(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Boolean::New(env, this->instance->hasQuery());
}
Napi::Value QUrlWrap::host(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QUrl::ComponentFormattingOptions input0 =
(QUrl::ComponentFormattingOptions)info[0].As<Napi::Number>().Int32Value();
return Napi::String::New(env, this->instance->host(input0).toStdString());
}
Napi::Value QUrlWrap::isEmpty(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Boolean::New(env, this->instance->isEmpty());
}
Napi::Value QUrlWrap::isLocalFile(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Boolean::New(env, this->instance->isLocalFile());
}
Napi::Value QUrlWrap::isParentOf(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QUrlWrap* wrap0_1 = Napi::ObjectWrap<QUrlWrap>::Unwrap(wrap0_0);
QUrl* input0 = wrap0_1->getInternalInstance();
return Napi::Boolean::New(env, this->instance->isParentOf(*input0));
}
Napi::Value QUrlWrap::isRelative(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Boolean::New(env, this->instance->isRelative());
}
Napi::Value QUrlWrap::isValid(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Boolean::New(env, this->instance->isValid());
}
Napi::Value QUrlWrap::matches(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QUrlWrap* wrap0_1 = Napi::ObjectWrap<QUrlWrap>::Unwrap(wrap0_0);
QUrl* input0 = wrap0_1->getInternalInstance();
QUrl::FormattingOptions input1 =
(QUrl::FormattingOptions)info[1].As<Napi::Number>().Int32Value();
return Napi::Boolean::New(env, this->instance->matches(*input0, input1));
}
Napi::Value QUrlWrap::password(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QUrl::ComponentFormattingOptions input0 =
(QUrl::ComponentFormattingOptions)info[0].As<Napi::Number>().Int32Value();
return Napi::String::New(env, this->instance->password(input0).toStdString());
}
Napi::Value QUrlWrap::path(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QUrl::ComponentFormattingOptions input0 =
(QUrl::ComponentFormattingOptions)info[0].As<Napi::Number>().Int32Value();
return Napi::String::New(env, this->instance->path(input0).toStdString());
}
Napi::Value QUrlWrap::port(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int input0 = info[0].As<Napi::Number>().Int32Value();
return Napi::Number::New(env, this->instance->port(input0));
}
Napi::Value QUrlWrap::query(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QUrl::ComponentFormattingOptions input0 =
(QUrl::ComponentFormattingOptions)info[0].As<Napi::Number>().Int32Value();
return Napi::String::New(env, this->instance->query(input0).toStdString());
}
Napi::Value QUrlWrap::resolved(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QUrlWrap* wrap0_1 = Napi::ObjectWrap<QUrlWrap>::Unwrap(wrap0_0);
QUrl* input0 = wrap0_1->getInternalInstance();
QUrl ret = this->instance->resolved(*input0);
auto instance = QUrlWrap::constructor.New(
{Napi::External<QUrl>::New(env, new QUrl(ret))});
return instance;
}
Napi::Value QUrlWrap::scheme(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::String::New(env, this->instance->scheme().toStdString());
}
Napi::Value QUrlWrap::setAuthority(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QString input0 =
QString::fromStdString(info[0].As<Napi::String>().Utf8Value());
QUrl::ParsingMode input1 =
static_cast<QUrl::ParsingMode>(info[1].As<Napi::Number>().Int32Value());
this->instance->setAuthority(input0, input1);
return env.Null();
}
Napi::Value QUrlWrap::setFragment(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QString input0 =
QString::fromStdString(info[0].As<Napi::String>().Utf8Value());
QUrl::ParsingMode input1 =
static_cast<QUrl::ParsingMode>(info[1].As<Napi::Number>().Int32Value());
this->instance->setFragment(input0, input1);
return env.Null();
}
Napi::Value QUrlWrap::setHost(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QString input0 =
QString::fromStdString(info[0].As<Napi::String>().Utf8Value());
QUrl::ParsingMode input1 =
static_cast<QUrl::ParsingMode>(info[1].As<Napi::Number>().Int32Value());
this->instance->setHost(input0, input1);
return env.Null();
}
Napi::Value QUrlWrap::setPassword(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QString input0 =
QString::fromStdString(info[0].As<Napi::String>().Utf8Value());
QUrl::ParsingMode input1 =
static_cast<QUrl::ParsingMode>(info[1].As<Napi::Number>().Int32Value());
this->instance->setPassword(input0, input1);
return env.Null();
}
Napi::Value QUrlWrap::setPath(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QString input0 =
QString::fromStdString(info[0].As<Napi::String>().Utf8Value());
QUrl::ParsingMode input1 =
static_cast<QUrl::ParsingMode>(info[1].As<Napi::Number>().Int32Value());
this->instance->setPath(input0, input1);
return env.Null();
}
Napi::Value QUrlWrap::setPort(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int input0 = info[0].As<Napi::Number>().Int32Value();
this->instance->setPort(input0);
return env.Null();
}
Napi::Value QUrlWrap::setQuery(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QString input0 =
QString::fromStdString(info[0].As<Napi::String>().Utf8Value());
QUrl::ParsingMode input1 =
static_cast<QUrl::ParsingMode>(info[1].As<Napi::Number>().Int32Value());
this->instance->setQuery(input0, input1);
return env.Null();
}
Napi::Value QUrlWrap::setScheme(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QString input0 =
QString::fromStdString(info[0].As<Napi::String>().Utf8Value());
this->instance->setScheme(input0);
return env.Null();
}
Napi::Value QUrlWrap::setUrl(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QString input0 =
QString::fromStdString(info[0].As<Napi::String>().Utf8Value());
QUrl::ParsingMode input1 =
static_cast<QUrl::ParsingMode>(info[1].As<Napi::Number>().Int32Value());
this->instance->setUrl(input0, input1);
return env.Null();
}
Napi::Value QUrlWrap::setUserInfo(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QString input0 =
QString::fromStdString(info[0].As<Napi::String>().Utf8Value());
QUrl::ParsingMode input1 =
static_cast<QUrl::ParsingMode>(info[1].As<Napi::Number>().Int32Value());
this->instance->setUserInfo(input0, input1);
return env.Null();
}
Napi::Value QUrlWrap::setUserName(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QString input0 =
QString::fromStdString(info[0].As<Napi::String>().Utf8Value());
QUrl::ParsingMode input1 =
static_cast<QUrl::ParsingMode>(info[1].As<Napi::Number>().Int32Value());
this->instance->setUserName(input0, input1);
return env.Null();
}
Napi::Value QUrlWrap::swap(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QUrlWrap* wrap0_1 = Napi::ObjectWrap<QUrlWrap>::Unwrap(wrap0_0);
QUrl* input0 = wrap0_1->getInternalInstance();
this->instance->swap(*input0);
return env.Null();
}
Napi::Value QUrlWrap::toDisplayString(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QUrl::FormattingOptions input0 =
(QUrl::FormattingOptions)info[0].As<Napi::Number>().Int32Value();
return Napi::String::New(
env, this->instance->toDisplayString(input0).toStdString());
}
Napi::Value QUrlWrap::toLocalFile(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::String::New(env, this->instance->toLocalFile().toStdString());
}
Napi::Value QUrlWrap::toString_withOpts(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QUrl::FormattingOptions input0 =
(QUrl::FormattingOptions)info[0].As<Napi::Number>().Int32Value();
return Napi::String::New(env, this->instance->toString(input0).toStdString());
}
Napi::Value QUrlWrap::url(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QUrl::FormattingOptions input0 =
(QUrl::FormattingOptions)info[0].As<Napi::Number>().Int32Value();
return Napi::String::New(env, this->instance->url(input0).toStdString());
}
Napi::Value QUrlWrap::userInfo(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QUrl::ComponentFormattingOptions input0 =
(QUrl::ComponentFormattingOptions)info[0].As<Napi::Number>().Int32Value();
return Napi::String::New(env, this->instance->userInfo(input0).toStdString());
}
Napi::Value QUrlWrap::userName(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QUrl::ComponentFormattingOptions input0 =
(QUrl::ComponentFormattingOptions)info[0].As<Napi::Number>().Int32Value();
return Napi::String::New(env, this->instance->userName(input0).toStdString());
}
// Static Methods here
Napi::Value StaticQUrlWrapMethods::fromLocalFile(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QString input0 =
QString::fromStdString(info[0].As<Napi::String>().Utf8Value());
QUrl ret = QUrl::fromLocalFile(input0);
auto instance = QUrlWrap::constructor.New(
{Napi::External<QUrl>::New(env, new QUrl(ret))});
return instance;
}
Napi::Value StaticQUrlWrapMethods::fromUserInput(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if (info.Length() == 1) {
QString input0 =
QString::fromStdString(info[0].As<Napi::String>().Utf8Value());
QUrl ret = QUrl::fromUserInput(input0);
auto instance = QUrlWrap::constructor.New(
{Napi::External<QUrl>::New(env, new QUrl(ret))});
return instance;
}
QString input0 =
QString::fromStdString(info[0].As<Napi::String>().Utf8Value());
QString input1 =
QString::fromStdString(info[1].As<Napi::String>().Utf8Value());
QUrl::UserInputResolutionOptions input2 =
(QUrl::UserInputResolutionOptions)info[2].As<Napi::Number>().Int32Value();
QUrl ret = QUrl::fromUserInput(input0, input1, input2);
auto instance = QUrlWrap::constructor.New(
{Napi::External<QUrl>::New(env, new QUrl(ret))});
return instance;
}

View File

@ -0,0 +1,45 @@
#include "QtGui/QEvent/QDragLeaveEvent/qdragleaveevent_wrap.h"
#include <QPoint>
#include "Extras/Utils/nutils.h"
Napi::FunctionReference QDragLeaveEventWrap::constructor;
Napi::Object QDragLeaveEventWrap::init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QDragLeaveEvent";
Napi::Function func = DefineClass(
env, CLASSNAME,
{// Methods inherited from QEvent
QEVENT_WRAPPED_METHODS_EXPORT_DEFINE(QDragLeaveEventWrap)
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QDragLeaveEventWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
}
QDragLeaveEvent* QDragLeaveEventWrap::getInternalInstance() {
return this->instance;
}
QDragLeaveEventWrap::QDragLeaveEventWrap(const Napi::CallbackInfo& info)
: Napi::ObjectWrap<QDragLeaveEventWrap>(info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if (info.Length() == 1) {
Napi::External<QDragLeaveEvent> eventObject =
info[0].As<Napi::External<QDragLeaveEvent>>();
this->instance = static_cast<QDragLeaveEvent*>(eventObject.Data());
} else {
Napi::TypeError::New(env, "Wrong number of arguments")
.ThrowAsJavaScriptException();
}
this->rawData = extrautils::configureComponent(this->getInternalInstance());
}
QDragLeaveEventWrap::~QDragLeaveEventWrap() {
// Do not destroy instance here. It will be done by Qt Event loop.
}
// Methods from QEvent defined in Macro already

View File

@ -3,6 +3,7 @@
#include <QPoint>
#include "Extras/Utils/nutils.h"
#include "QtCore/QMimeData/qmimedata_wrap.h"
#include "QtCore/QRect/qrect_wrap.h"
Napi::FunctionReference QDragMoveEventWrap::constructor;
@ -19,7 +20,7 @@ Napi::Object QDragMoveEventWrap::init(Napi::Env env, Napi::Object exports) {
InstanceMethod("dropAction", &QDragMoveEventWrap::dropAction),
InstanceMethod("keyboardModifiers",
&QDragMoveEventWrap::keyboardModifiers),
// InstanceMethod("mimeData", &QDragMoveEventWrap::mimeData),
InstanceMethod("mimeData", &QDragMoveEventWrap::mimeData),
InstanceMethod("mouseButtons", &QDragMoveEventWrap::mouseButtons),
InstanceMethod("pos", &QDragMoveEventWrap::pos),
InstanceMethod("possibleActions", &QDragMoveEventWrap::possibleActions),
@ -94,12 +95,17 @@ Napi::Value QDragMoveEventWrap::mouseButtons(const Napi::CallbackInfo& info) {
return Napi::Number::From(env, m);
}
// TODO: Implement MimeData to do this...
// Napi::Value QDragMoveEventWrap::mimeData(const Napi::CallbackInfo& info) {
// Napi::Env env = info.Env();
// int modifierFlags = static_cast<int>(this->instance->keyboardModifiers());
// return Napi::Number::From(env, modifierFlags);
// }
Napi::Value QDragMoveEventWrap::mimeData(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
const QMimeData* ret = this->instance->mimeData();
QMimeData* clone = new QMimeData();
// QMimeData has no copy constructor so I do this
QMimeDataWrap::cloneFromMimeDataToData((QMimeData*)ret, clone);
auto instance = QMimeDataWrap::constructor.New(
{Napi::External<QMimeData>::New(env, clone)});
return instance;
}
Napi::Value QDragMoveEventWrap::pos(const Napi::CallbackInfo& info) {
// Uses QPoint

View File

@ -3,6 +3,7 @@
#include <QPoint>
#include "Extras/Utils/nutils.h"
#include "QtCore/QMimeData/qmimedata_wrap.h"
Napi::FunctionReference QDropEventWrap::constructor;
@ -15,7 +16,7 @@ Napi::Object QDropEventWrap::init(Napi::Env env, Napi::Object exports) {
&QDropEventWrap::acceptProposedAction),
InstanceMethod("dropAction", &QDropEventWrap::dropAction),
InstanceMethod("keyboardModifiers", &QDropEventWrap::keyboardModifiers),
// InstanceMethod("mimeData", &QDropEventWrap::mimeData),
InstanceMethod("mimeData", &QDropEventWrap::mimeData),
InstanceMethod("mouseButtons", &QDropEventWrap::mouseButtons),
InstanceMethod("pos", &QDropEventWrap::pos),
InstanceMethod("possibleActions", &QDropEventWrap::possibleActions),
@ -77,12 +78,17 @@ Napi::Value QDropEventWrap::mouseButtons(const Napi::CallbackInfo& info) {
return Napi::Number::From(env, m);
}
// TODO: Implement MimeData to do this...
// Napi::Value QDropEventWrap::mimeData(const Napi::CallbackInfo& info) {
// Napi::Env env = info.Env();
// int modifierFlags = static_cast<int>(this->instance->keyboardModifiers());
// return Napi::Number::From(env, modifierFlags);
// }
Napi::Value QDropEventWrap::mimeData(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
const QMimeData* ret = this->instance->mimeData();
QMimeData* clone = new QMimeData();
// QMimeData has no copy constructor so I do this
QMimeDataWrap::cloneFromMimeDataToData((QMimeData*)ret, clone);
auto instance = QMimeDataWrap::constructor.New(
{Napi::External<QMimeData>::New(env, clone)});
return instance;
}
Napi::Value QDropEventWrap::pos(const Napi::CallbackInfo& info) {
// Uses QPoint

View File

@ -3,6 +3,7 @@
#include "Extras/Utils/nutils.h"
#include "QtCore/QDate/qdate_wrap.h"
#include "QtCore/QDateTime/qdatetime_wrap.h"
#include "QtCore/QMimeData/qmimedata_wrap.h"
#include "QtCore/QModelIndex/qmodelindex_wrap.h"
#include "QtCore/QObject/qobject_wrap.h"
#include "QtCore/QPoint/qpoint_wrap.h"
@ -19,6 +20,7 @@
#include "QtGui/QClipboard/qclipboard_wrap.h"
#include "QtGui/QColor/qcolor_wrap.h"
#include "QtGui/QCursor/qcursor_wrap.h"
#include "QtGui/QEvent/QDragLeaveEvent/qdragleaveevent_wrap.h"
#include "QtGui/QEvent/QDragMoveEvent/qdragmoveevent_wrap.h"
#include "QtGui/QEvent/QDropEvent/qdropevent_wrap.h"
#include "QtGui/QEvent/QKeyEvent/qkeyevent_wrap.h"
@ -110,6 +112,7 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
QApplicationWrap::init(env, exports);
QDateWrap::init(env, exports);
QDateTimeWrap::init(env, exports);
QMimeDataWrap::init(env, exports);
QModelIndexWrap::init(env, exports);
QObjectWrap::init(env, exports);
QPointWrap::init(env, exports);
@ -179,6 +182,7 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
QTabletEventWrap::init(env, exports);
QDropEventWrap::init(env, exports);
QDragMoveEventWrap::init(env, exports);
QDragLeaveEventWrap::init(env, exports);
QNativeGestureEventWrap::init(env, exports);
QPlainTextEditWrap::init(env, exports);
QDialWrap::init(env, exports);

View File

@ -25,6 +25,7 @@ export { QNativeGestureEvent } from './lib/QtGui/QEvent/QNativeGestureEvent';
export { QTabletEvent } from './lib/QtGui/QEvent/QTabletEvent';
export { QDropEvent } from './lib/QtGui/QEvent/QDropEvent';
export { QDragMoveEvent } from './lib/QtGui/QEvent/QDragMoveEvent';
export { QDragLeaveEvent } from './lib/QtGui/QEvent/QDragLeaveEvent';
export { WidgetEventTypes } from './lib/core/EventWidget';
// Abstract:
export { NodeWidget, QWidget, QWidgetSignals } from './lib/QtWidgets/QWidget';
@ -123,6 +124,7 @@ export {
export { QDate } from './lib/QtCore/QDate';
export { QDateTime } from './lib/QtCore/QDateTime';
export { QModelIndex } from './lib/QtCore/QModelIndex';
export { QMimeData } from './lib/QtCore/QMimeData';
export { QObject, QObjectSignals, NodeObject } from './lib/QtCore/QObject';
export { QVariant } from './lib/QtCore/QVariant';
export { QSize } from './lib/QtCore/QSize';

124
src/lib/QtCore/QMimeData.ts Normal file
View File

@ -0,0 +1,124 @@
import { NativeElement, Component } from '../core/Component';
import addon from '../utils/addon';
import { checkIfNativeElement } from '../utils/helpers';
import { QUrl } from './QUrl';
/**
* description
*/
export class QMimeData extends Component {
native: NativeElement;
constructor(arg?: NativeElement) {
super();
if (checkIfNativeElement(arg)) {
this.native = arg as NativeElement;
} else {
this.native = new addon.QMimeData();
}
}
/**
Removes all the MIME type and data entries in the object.
*/
clear(): void {
return this.native.clear();
}
/**
Returns true if the object can return a color (MIME type application/x-color); otherwise returns false.
*/
hasColor(): boolean {
return this.native.hasColor();
}
/**
Returns true if the object can return HTML (MIME type text/html); otherwise returns false.
*/
hasHtml(): boolean {
return this.native.hasHtml();
}
/**
Returns true if the object can return an image; otherwise returns false.
*/
hasImage(): boolean {
return this.native.hasImage();
}
/**
Returns true if the object can return plain text (MIME type text/plain); otherwise returns false.
*/
hasText(): boolean {
return this.native.hasText();
}
/**
Returns true if the object can return a list of urls; otherwise returns false.
*/
hasUrls(): boolean {
return this.native.hasUrls();
}
/**
Returns a string if the data stored in the object is HTML (MIME type text/html); otherwise returns an empty string.
*/
html(): string {
return this.native.html();
}
/**
Removes the data entry for mimeType in the object.
*/
removeFormat(mimeType: string): void {
return this.native.removeFormat(mimeType);
}
/*
Sets the data associated with the MIME type given by mimeType to the specified data.
This is not implemented yet; need to do stuff with either Buffer or UInt8Array
*/
// setData(mimeType: string, QByteArray: const): void {
// return this.native.setData(mimeType, QByteArray)
// }
/**
Sets html as the HTML (MIME type text/html) used to represent the data.
*/
setHtml(html: string): void {
return this.native.setHtml(html);
}
/**
Sets text as the plain text (MIME type text/plain) used to represent the data.
*/
setText(text: string): void {
return this.native.setText(text);
}
/**
Sets the URLs stored in the MIME data object to those specified by urls.
*/
setUrls(urls: [QUrl]): void {
const natives = urls.map((v) => {
return v.native;
});
return this.native.setUrls(natives);
}
/**
Returns a plain text (MIME type text/plain) representation of the data.
*/
text(): string {
return this.native.text();
}
/**
* Returns a list of URLs contained within the MIME data object.
*
* URLs correspond to the MIME type text/uri-list.
*/
urls(): [QUrl] {
const natives = this.native.urls();
return natives.map((v: NativeElement) => {
return new QUrl(v);
});
}
}

View File

@ -3,13 +3,63 @@ import addon from '../utils/addon';
import { checkIfNativeElement } from '../utils/helpers';
import { QVariant } from './QVariant';
enum ComponentFormattingOption {
/** The component is returned in a "pretty form", with most percent-encoded characters decoded. The exact behavior of PrettyDecoded varies from component to component and may also change from Qt release to Qt release. This is the default. */
PrettyDecoded = 0x000000,
/** Leave space characters in their encoded form ("%20"). */
EncodeSpaces = 0x100000,
/** Leave non-US-ASCII characters encoded in their UTF-8 percent-encoded form (e.g., "%C3%A9" for the U+00E9 codepoint, LATIN SMALL LETTER E WITH ACUTE). */
EncodeUnicode = 0x200000,
/** Leave certain delimiters in their encoded form, as would appear in the URL when the full URL is represented as text. The delimiters are affected by this option change from component to component. This flag has no effect in toString() or toEncoded().*/
EncodeDelimiters = 0x400000 | 0x800000,
/** Leave US-ASCII characters not permitted in the URL by the specification in their encoded form. This is the default on toString() and toEncoded(). */
EncodeReserved = 0x1000000,
/** Decode the US-ASCII characters that the URL specification does not allow to appear in the URL. This is the default on the getters of individual components. */
DecodeReserved = 0x2000000,
/** Leave all characters in their properly-encoded form, as this component would appear as part of a URL. When used with toString(), this produces a fully-compliant URL in QString form, exactly equal to the result of toEncoded() */
FullyEncoded = EncodeSpaces | EncodeUnicode | EncodeDelimiters | EncodeReserved,
/** Attempt to decode as much as possible. For individual components of the URL, this decodes every percent encoding sequence, including control characters (U+0000 to U+001F) and UTF-8 sequences found in percent-encoded form. Use of this mode may cause data loss, see below for more information. */
FullyDecoded = FullyEncoded | DecodeReserved | 0x4000000,
}
export enum ParsingMode {
TolerantMode,
StrictMode,
DecodedMode,
/** QUrl will try to correct some common errors in URLs. This mode is useful for parsing URLs coming from sources not known to be strictly standards-conforming. */
TolerantMode = 0,
/** Only valid URLs are accepted. This mode is useful for general URL validation.*/
StrictMode = 1,
/** QUrl will interpret the URL component in the fully-decoded form, where percent characters stand for themselves, not as the beginning of a percent-encoded sequence. This mode is only valid for the setters setting components of a URL; it is not permitted in the QUrl constructor, in fromEncoded() or in setUrl(). For more information on this mode, see the documentation for QUrl::FullyDecoded.*/
DecodedMode = 2,
}
enum UrlFormattingOption {
None = 0x0,
RemoveScheme = 0x1,
RemovePassword = 0x2,
RemoveUserInfo,
RemovePort = 0x8,
RemoveAuthority,
RemovePath = 0x20,
RemoveQuery = 0x40,
RemoveFragment = 0x80,
RemoveFilename = 0x800,
PreferLocalFile = 0x200,
StripTrailingSlash = 0x400,
NormalizePathSegments = 0x1000,
}
enum UserInputResolutionOption {
/** The default resolution mechanism is to check whether a local file exists, in the working directory given to fromUserInput, and only return a local path in that case. Otherwise a URL is assumed. */
DefaultResolution = 0,
/** This option makes fromUserInput() always return a local path unless the input contains a scheme, such as http://file.pl. This is useful for applications such as text editors, which are able to create the file if it doesn't exist. */
AssumeLocalFile = 1,
}
export class QUrl extends Component {
static readonly ComponentFormattingOption = ComponentFormattingOption;
static readonly ParsingMode = ParsingMode;
static readonly UrlFormattingOption = UrlFormattingOption;
static readonly UserInputResolutionOption = UserInputResolutionOption;
readonly ComponentFormattingOption = ComponentFormattingOption;
readonly ParsingMode = ParsingMode;
readonly UrlFormattingOption = UrlFormattingOption;
readonly UserInputResolutionOption = UserInputResolutionOption;
native: NativeElement;
constructor();
constructor(nativeElement: NativeElement);
@ -24,13 +74,307 @@ export class QUrl extends Component {
this.native = new addon.QUrl(arg, parsingMode);
}
}
setUrl(url: string): void {
return this.native.setUrl(url);
}
toString(): string {
return this.native.toString();
}
static fromQVariant(variant: QVariant): QUrl {
return new QUrl(addon.QUrl.fromQVariant(variant.native));
}
/**
Returns an adjusted version of the URL. The output can be customized by passing flags with options.
*/
adjusted(options: number): QUrl {
return new QUrl(this.native.adjusted(options));
}
/**
Returns the authority of the URL if it is defined; otherwise an empty string is returned.
*/
authority(options: number = ComponentFormattingOption.PrettyDecoded): string {
return this.native.authority(options);
}
/**
Resets the content of the QUrl. After calling this function, the QUrl is equal to one that has been constructed with the default empty constructor.
*/
clear(): void {
return this.native.clear();
}
/**
Returns an error message if the last operation that modified this QUrl object ran into a parsing error. If no error was detected, this function returns an empty string and isValid() returns true.
*/
errorString(): string {
return this.native.errorString();
}
/**
Returns the name of the file, excluding the directory path.
*/
fileName(options: number = ComponentFormattingOption.FullyDecoded): string {
return this.native.fileName(options);
}
/**
Returns the fragment of the URL. To determine if the parsed URL contained a fragment, use hasFragment().
*/
fragment(options: number = ComponentFormattingOption.PrettyDecoded): string {
return this.native.fragment(options);
}
/**
Returns true if this URL contains a fragment (i.e., if # was seen on it).
*/
hasFragment(): boolean {
return this.native.hasFragment();
}
/**
Returns true if this URL contains a Query (i.e., if ? was seen on it).
*/
hasQuery(): boolean {
return this.native.hasQuery();
}
/**
Returns the host of the URL if it is defined; otherwise an empty string is returned.
*/
host(options: number = ComponentFormattingOption.FullyDecoded): string {
return this.native.host(options);
}
/**
Returns true if the URL has no data; otherwise returns false.
*/
isEmpty(): boolean {
return this.native.isEmpty();
}
/**
Returns true if this URL is pointing to a local file path. A URL is a local file path if the scheme is "file".
*/
isLocalFile(): boolean {
return this.native.isLocalFile();
}
/**
Returns true if this URL is a parent of childUrl. childUrl is a child of this URL if the two URLs share the same scheme and authority, and this URL's path is a parent of the path of childUrl.
*/
isParentOf(childUrl: QUrl): boolean {
return this.native.isParentOf(childUrl.native);
}
/**
Returns true if the URL is relative; otherwise returns false. A URL is relative reference if its scheme is undefined; this function is therefore equivalent to calling scheme().isEmpty().
*/
isRelative(): boolean {
return this.native.isRelative();
}
/**
Returns true if the URL is non-empty and valid; otherwise returns false.
*/
isValid(): boolean {
return this.native.isValid();
}
/**
Returns true if this URL and the given url are equal after applying options to both; otherwise returns false.
*/
matches(url: QUrl, options: number): boolean {
return this.native.matches(url.native, options);
}
/**
Returns the password of the URL if it is defined; otherwise an empty string is returned.
*/
password(options: number = ComponentFormattingOption.FullyDecoded): string {
return this.native.password(options);
}
/**
Returns the path of the URL.
*/
path(options: number = ComponentFormattingOption.FullyDecoded): string {
return this.native.path(options);
}
/**
Returns the port of the URL, or defaultPort if the port is unspecified.
*/
port(defaultPort = -1): number {
return this.native.port(defaultPort);
}
/**
Returns the query string of the URL if there's a query string, or an empty result if not. To determine if the parsed URL contained a query string, use hasQuery().
*/
query(options: number = ComponentFormattingOption.PrettyDecoded): string {
return this.native.query(options);
}
/**
Returns the result of the merge of this URL with relative. This URL is used as a base to convert relative to an absolute URL.
*/
resolved(relative: QUrl): QUrl {
return new QUrl(this.native.resolved(relative.native));
}
/**
Returns the scheme of the URL. If an empty string is returned, this means the scheme is undefined and the URL is then relative.
*/
scheme(): string {
return this.native.scheme();
}
/**
Sets the authority of the URL to authority.
*/
setAuthority(authority: string, mode: ParsingMode = ParsingMode.TolerantMode): void {
return this.native.setAuthority(authority, mode);
}
/**
Sets the fragment of the URL to fragment. The fragment is the last part of the URL, represented by a '#' followed by a string of characters. It is typically used in HTTP for referring to a certain link or point on a page:
*/
setFragment(fragment: string, mode: ParsingMode = ParsingMode.TolerantMode): void {
return this.native.setFragment(fragment, mode);
}
/**
Sets the host of the URL to host. The host is part of the authority.
*/
setHost(host: string, mode: ParsingMode = ParsingMode.DecodedMode): void {
return this.native.setHost(host, mode);
}
/**
Sets the URL's password to password. The password is part of the user info element in the authority of the URL, as described in setUserInfo().
*/
setPassword(password: string, mode: ParsingMode = ParsingMode.DecodedMode): void {
return this.native.setPassword(password, mode);
}
/**
Sets the path of the URL to path. The path is the part of the URL that comes after the authority but before the query string.
*/
setPath(path: string, mode: ParsingMode = ParsingMode.DecodedMode): void {
return this.native.setPath(path, mode);
}
/**
Sets the port of the URL to port. The port is part of the authority of the URL, as described in setAuthority().
*/
setPort(port: number): void {
return this.native.setPort(port);
}
/**
Sets the query string of the URL to query.
*/
setQuery(query: string, mode: ParsingMode = ParsingMode.TolerantMode): void {
return this.native.setQuery(query, mode);
}
/**
Sets the scheme of the URL to scheme. As a scheme can only contain ASCII characters, no conversion or decoding is done on the input. It must also start with an ASCII letter.
*/
setScheme(scheme: string): void {
return this.native.setScheme(scheme);
}
/**
Parses url and sets this object to that value. QUrl will automatically percent encode all characters that are not allowed in a URL and decode the percent-encoded sequences that represent an unreserved character (letters, digits, hyphens, undercores, dots and tildes). All other characters are left in their original forms.
*/
setUrl(url: string, parsingMode: ParsingMode = ParsingMode.TolerantMode): void {
return this.native.setUrl(url, parsingMode);
}
/**
Sets the user info of the URL to userInfo. The user info is an optional part of the authority of the URL, as described in setAuthority().
*/
setUserInfo(userInfo: string, mode: ParsingMode = ParsingMode.TolerantMode): void {
return this.native.setUserInfo(userInfo, mode);
}
/**
Sets the URL's user name to userName. The userName is part of the user info element in the authority of the URL, as described in setUserInfo().
*/
setUserName(userName: string, mode: ParsingMode = ParsingMode.DecodedMode): void {
return this.native.setUserName(userName, mode);
}
/**
Swaps URL other with this URL. This operation is very fast and never fails.
*/
swap(other: QUrl): void {
return this.native.swap(other.native);
}
/**
Returns a human-displayable string representation of the URL. The output can be customized by passing flags with options. The option RemovePassword is always enabled, since passwords should never be shown back to users.
*/
toDisplayString(options: number = ComponentFormattingOption.PrettyDecoded): string {
return this.native.toDisplayString(options);
}
/**
Returns the path of this URL formatted as a local file path. The path returned will use forward slashes, even if it was originally created from one with backslashes.
*/
toLocalFile(): string {
return this.native.toLocalFile();
}
/**
Returns a string representation of the URL. The output can be customized by passing flags with options. The option QUrl::FullyDecoded is not permitted in this function since it would generate ambiguous data.
See QUrl::ComponentFormattingOption for flags
*/
toString(options?: number): string {
if (arguments.length == 1) {
return this.native.toString_withOpts(options);
}
return this.native.toString();
}
/**
Returns a string representation of the URL. The output can be customized by passing flags with options. The option QUrl::FullyDecoded is not permitted in this function since it would generate ambiguous data.
*/
url(options: number): string {
return this.native.url(options);
}
/**
Returns the user info of the URL, or an empty string if the user info is undefined.
*/
userInfo(options: number = ComponentFormattingOption.PrettyDecoded): string {
return this.native.userInfo(options);
}
/**
Returns the user name of the URL if it is defined; otherwise an empty string is returned.
*/
userName(options: number = ComponentFormattingOption.FullyDecoded): string {
return this.native.userName(options);
}
/**
Returns a QUrl representation of localFile, interpreted as a local file. This function accepts paths separated by slashes as well as the native separator for this platform.
*/
static fromLocalFile(localFile: string): QUrl {
return new QUrl(addon.QUrl.fromLocalFile(localFile));
}
/**
Returns a valid URL from a user supplied userInput string if one can be deduced. In the case that is not possible, an invalid QUrl() is returned.
*/
static fromUserInput(
userInput: string,
workingDirectory?: string,
options: number = UserInputResolutionOption.DefaultResolution,
): QUrl {
if (!workingDirectory) {
return new QUrl(addon.QUrl.fromUserInput(userInput));
}
return new QUrl(addon.QUrl.fromUserInput(userInput, workingDirectory, options));
}
}

View File

@ -0,0 +1,49 @@
import addon from '../../utils/addon';
import { NativeElement } from '../../core/Component';
export class QDragLeaveEvent {
native: NativeElement;
constructor(event: NativeElement) {
this.native = new addon.QDragLeaveEvent(event);
}
//Methods from QEvent ---------------------------
/**
* Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
* Setting the accept parameter indicates that the event receiver wants the event. Unwanted events might be propagated to the parent widget
*/
accept(): void {
return this.native.accept();
}
/**
* Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
* Clearing the accept parameter indicates that the event receiver does not want the event.
* Unwanted events might be propagated to the parent widget.
*/
ignore(): void {
return this.native.ignore();
}
isAccepted(): boolean {
return this.native.isAccepted();
}
/**
* Sets the accept flag of the event object
*/
setAccepted(accepted: boolean): void {
return this.native.setAccepted(accepted);
}
/**
* Returns true if the event originated outside the application (a system event); otherwise returns false.
*
* The return value of this function is not defined for paint events.
*/
spontaneous(): boolean {
return this.native.spontaneous();
}
/**
* Returns the event type
* @returns {Number} This is QEvent::Type
*/
type(): number {
return this.native._type();
}
}

View File

@ -1,6 +1,7 @@
import addon from '../../utils/addon';
import { NativeElement } from '../../core/Component';
import { DropAction } from '../../QtEnums';
import { QMimeData } from '../../QtCore/QMimeData';
export class QDragMoveEvent {
native: NativeElement;
@ -60,13 +61,12 @@ export class QDragMoveEvent {
keyboardModifiers(): number {
return this.native.keyboardModifiers();
}
/*
* Cannot implement yet; need to implement QMimeData first
/**
* Returns the data that was dropped on the widget and its associated MIME type information
*/
// mimeData(): QMimeData {
// return this.native.pos();
// }
mimeData(): QMimeData {
return new QMimeData(this.native.mimeData());
}
/**
* Returns the mouse buttons that are pressed
*

View File

@ -1,6 +1,7 @@
import addon from '../../utils/addon';
import { NativeElement } from '../../core/Component';
import { DropAction } from '../../QtEnums';
import { QMimeData } from '../../QtCore/QMimeData';
export class QDropEvent {
native: NativeElement;
@ -28,13 +29,12 @@ export class QDropEvent {
keyboardModifiers(): number {
return this.native.keyboardModifiers();
}
/*
* Cannot implement yet; need to implement QMimeData first
/**
* Returns the data that was dropped on the widget and its associated MIME type information
*/
// mimeData(): QMimeData {
// return this.native.pos();
// }
mimeData(): QMimeData {
return new QMimeData(this.native.mimeData());
}
/**
* Returns the mouse buttons that are pressed
*

View File

@ -51,6 +51,10 @@ Its the root base class in NodeGui world.
↳ [QFontDatabase](qfontdatabase.md)
↳ [QUrl](qurl.md)
↳ [QMimeData](qmimedata.md)
↳ [QPoint](qpoint.md)
↳ [QModelIndex](qmodelindex.md)
@ -73,8 +77,6 @@ Its the root base class in NodeGui world.
↳ [QPainter](qpainter.md)
↳ [QUrl](qurl.md)
↳ [QPointF](qpointf.md)
↳ [QRectF](qrectf.md)

View File

@ -0,0 +1,119 @@
---
id: "qdragleaveevent"
title: "QDragLeaveEvent"
sidebar_label: "QDragLeaveEvent"
---
## Hierarchy
* **QDragLeaveEvent**
## Index
### Constructors
* [constructor](qdragleaveevent.md#constructor)
### Properties
* [native](qdragleaveevent.md#native)
### Methods
* [accept](qdragleaveevent.md#accept)
* [ignore](qdragleaveevent.md#ignore)
* [isAccepted](qdragleaveevent.md#isaccepted)
* [setAccepted](qdragleaveevent.md#setaccepted)
* [spontaneous](qdragleaveevent.md#spontaneous)
* [type](qdragleaveevent.md#type)
## Constructors
### constructor
\+ **new QDragLeaveEvent**(`event`: [NativeElement](../globals.md#nativeelement)): *[QDragLeaveEvent](qdragleaveevent.md)*
**Parameters:**
Name | Type |
------ | ------ |
`event` | [NativeElement](../globals.md#nativeelement) |
**Returns:** *[QDragLeaveEvent](qdragleaveevent.md)*
## Properties
### native
**native**: *[NativeElement](../globals.md#nativeelement)*
## Methods
### accept
**accept**(): *void*
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
Setting the accept parameter indicates that the event receiver wants the event. Unwanted events might be propagated to the parent widget
**Returns:** *void*
___
### ignore
**ignore**(): *void*
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Clearing the accept parameter indicates that the event receiver does not want the event.
Unwanted events might be propagated to the parent widget.
**Returns:** *void*
___
### isAccepted
**isAccepted**(): *boolean*
**Returns:** *boolean*
___
### setAccepted
**setAccepted**(`accepted`: boolean): *void*
Sets the accept flag of the event object
**Parameters:**
Name | Type |
------ | ------ |
`accepted` | boolean |
**Returns:** *void*
___
### spontaneous
**spontaneous**(): *boolean*
Returns true if the event originated outside the application (a system event); otherwise returns false.
The return value of this function is not defined for paint events.
**Returns:** *boolean*
___
### type
**type**(): *number*
Returns the event type
**Returns:** *number*
This is QEvent::Type

View File

@ -27,6 +27,7 @@ sidebar_label: "QDragMoveEvent"
* [ignore](qdragmoveevent.md#ignore)
* [isAccepted](qdragmoveevent.md#isaccepted)
* [keyboardModifiers](qdragmoveevent.md#keyboardmodifiers)
* [mimeData](qdragmoveevent.md#mimedata)
* [mouseButtons](qdragmoveevent.md#mousebuttons)
* [pos](qdragmoveevent.md#pos)
* [posF](qdragmoveevent.md#posf)
@ -162,6 +163,16 @@ see Qt::KeyboardModifier for flags
___
### mimeData
**mimeData**(): *[QMimeData](qmimedata.md)*
Returns the data that was dropped on the widget and its associated MIME type information
**Returns:** *[QMimeData](qmimedata.md)*
___
### mouseButtons
**mouseButtons**(): *number*

View File

@ -26,6 +26,7 @@ sidebar_label: "QDropEvent"
* [ignore](qdropevent.md#ignore)
* [isAccepted](qdropevent.md#isaccepted)
* [keyboardModifiers](qdropevent.md#keyboardmodifiers)
* [mimeData](qdropevent.md#mimedata)
* [mouseButtons](qdropevent.md#mousebuttons)
* [pos](qdropevent.md#pos)
* [posF](qdropevent.md#posf)
@ -123,6 +124,16 @@ see Qt::KeyboardModifier for flags
___
### mimeData
**mimeData**(): *[QMimeData](qmimedata.md)*
Returns the data that was dropped on the widget and its associated MIME type information
**Returns:** *[QMimeData](qmimedata.md)*
___
### mouseButtons
**mouseButtons**(): *number*

View File

@ -0,0 +1,254 @@
---
id: "qmimedata"
title: "QMimeData"
sidebar_label: "QMimeData"
---
description
## Hierarchy
* [Component](component.md)
↳ **QMimeData**
## Index
### Constructors
* [constructor](qmimedata.md#constructor)
### Properties
* [native](qmimedata.md#native)
* [nodeChildren](qmimedata.md#nodechildren)
* [nodeParent](qmimedata.md#optional-nodeparent)
### Methods
* [clear](qmimedata.md#clear)
* [hasColor](qmimedata.md#hascolor)
* [hasHtml](qmimedata.md#hashtml)
* [hasImage](qmimedata.md#hasimage)
* [hasText](qmimedata.md#hastext)
* [hasUrls](qmimedata.md#hasurls)
* [html](qmimedata.md#html)
* [removeFormat](qmimedata.md#removeformat)
* [setHtml](qmimedata.md#sethtml)
* [setNodeParent](qmimedata.md#setnodeparent)
* [setText](qmimedata.md#settext)
* [setUrls](qmimedata.md#seturls)
* [text](qmimedata.md#text)
* [urls](qmimedata.md#urls)
## Constructors
### constructor
\+ **new QMimeData**(`arg?`: [NativeElement](../globals.md#nativeelement)): *[QMimeData](qmimedata.md)*
*Overrides [Component](component.md).[constructor](component.md#constructor)*
**Parameters:**
Name | Type |
------ | ------ |
`arg?` | [NativeElement](../globals.md#nativeelement) |
**Returns:** *[QMimeData](qmimedata.md)*
## Properties
### native
**native**: *[NativeElement](../globals.md#nativeelement)*
*Overrides [Component](component.md).[native](component.md#abstract-native)*
___
### nodeChildren
**nodeChildren**: *Set[Component](component.md)*
*Inherited from [Component](component.md).[nodeChildren](component.md#nodechildren)*
___
### `Optional` nodeParent
**nodeParent**? : *[Component](component.md)*
*Inherited from [Component](component.md).[nodeParent](component.md#optional-nodeparent)*
## Methods
### clear
**clear**(): *void*
Removes all the MIME type and data entries in the object.
**Returns:** *void*
___
### hasColor
**hasColor**(): *boolean*
Returns true if the object can return a color (MIME type application/x-color); otherwise returns false.
**Returns:** *boolean*
___
### hasHtml
**hasHtml**(): *boolean*
Returns true if the object can return HTML (MIME type text/html); otherwise returns false.
**Returns:** *boolean*
___
### hasImage
**hasImage**(): *boolean*
Returns true if the object can return an image; otherwise returns false.
**Returns:** *boolean*
___
### hasText
**hasText**(): *boolean*
Returns true if the object can return plain text (MIME type text/plain); otherwise returns false.
**Returns:** *boolean*
___
### hasUrls
**hasUrls**(): *boolean*
Returns true if the object can return a list of urls; otherwise returns false.
**Returns:** *boolean*
___
### html
**html**(): *string*
Returns a string if the data stored in the object is HTML (MIME type text/html); otherwise returns an empty string.
**Returns:** *string*
___
### removeFormat
**removeFormat**(`mimeType`: string): *void*
Removes the data entry for mimeType in the object.
**Parameters:**
Name | Type |
------ | ------ |
`mimeType` | string |
**Returns:** *void*
___
### setHtml
**setHtml**(`html`: string): *void*
Sets html as the HTML (MIME type text/html) used to represent the data.
**Parameters:**
Name | Type |
------ | ------ |
`html` | string |
**Returns:** *void*
___
### setNodeParent
**setNodeParent**(`parent?`: [Component](component.md)): *void*
*Inherited from [Component](component.md).[setNodeParent](component.md#setnodeparent)*
**Parameters:**
Name | Type |
------ | ------ |
`parent?` | [Component](component.md) |
**Returns:** *void*
___
### setText
**setText**(`text`: string): *void*
Sets text as the plain text (MIME type text/plain) used to represent the data.
**Parameters:**
Name | Type |
------ | ------ |
`text` | string |
**Returns:** *void*
___
### setUrls
**setUrls**(`urls`: [[QUrl](qurl.md)]): *void*
Sets the URLs stored in the MIME data object to those specified by urls.
**Parameters:**
Name | Type |
------ | ------ |
`urls` | [[QUrl](qurl.md)] |
**Returns:** *void*
___
### text
**text**(): *string*
Returns a plain text (MIME type text/plain) representation of the data.
**Returns:** *string*
___
### urls
**urls**(): *[[QUrl](qurl.md)]*
Returns a list of URLs contained within the MIME data object.
URLs correspond to the MIME type text/uri-list.
**Returns:** *[[QUrl](qurl.md)]*

View File

@ -18,16 +18,63 @@ sidebar_label: "QUrl"
### Properties
* [ComponentFormattingOption](qurl.md#readonly-componentformattingoption)
* [ParsingMode](qurl.md#readonly-parsingmode)
* [UrlFormattingOption](qurl.md#readonly-urlformattingoption)
* [UserInputResolutionOption](qurl.md#readonly-userinputresolutionoption)
* [native](qurl.md#native)
* [nodeChildren](qurl.md#nodechildren)
* [nodeParent](qurl.md#optional-nodeparent)
* [ComponentFormattingOption](qurl.md#static-readonly-componentformattingoption)
* [ParsingMode](qurl.md#static-readonly-parsingmode)
* [UrlFormattingOption](qurl.md#static-readonly-urlformattingoption)
* [UserInputResolutionOption](qurl.md#static-readonly-userinputresolutionoption)
### Methods
* [adjusted](qurl.md#adjusted)
* [authority](qurl.md#authority)
* [clear](qurl.md#clear)
* [errorString](qurl.md#errorstring)
* [fileName](qurl.md#filename)
* [fragment](qurl.md#fragment)
* [hasFragment](qurl.md#hasfragment)
* [hasQuery](qurl.md#hasquery)
* [host](qurl.md#host)
* [isEmpty](qurl.md#isempty)
* [isLocalFile](qurl.md#islocalfile)
* [isParentOf](qurl.md#isparentof)
* [isRelative](qurl.md#isrelative)
* [isValid](qurl.md#isvalid)
* [matches](qurl.md#matches)
* [password](qurl.md#password)
* [path](qurl.md#path)
* [port](qurl.md#port)
* [query](qurl.md#query)
* [resolved](qurl.md#resolved)
* [scheme](qurl.md#scheme)
* [setAuthority](qurl.md#setauthority)
* [setFragment](qurl.md#setfragment)
* [setHost](qurl.md#sethost)
* [setNodeParent](qurl.md#setnodeparent)
* [setPassword](qurl.md#setpassword)
* [setPath](qurl.md#setpath)
* [setPort](qurl.md#setport)
* [setQuery](qurl.md#setquery)
* [setScheme](qurl.md#setscheme)
* [setUrl](qurl.md#seturl)
* [setUserInfo](qurl.md#setuserinfo)
* [setUserName](qurl.md#setusername)
* [swap](qurl.md#swap)
* [toDisplayString](qurl.md#todisplaystring)
* [toLocalFile](qurl.md#tolocalfile)
* [toString](qurl.md#tostring)
* [url](qurl.md#url)
* [userInfo](qurl.md#userinfo)
* [userName](qurl.md#username)
* [fromLocalFile](qurl.md#static-fromlocalfile)
* [fromQVariant](qurl.md#static-fromqvariant)
* [fromUserInput](qurl.md#static-fromuserinput)
## Constructors
@ -51,7 +98,7 @@ Name | Type |
**Returns:** *[QUrl](qurl.md)*
\+ **new QUrl**(`url`: string, `parsingMode?`: [ParsingMode](../enums/parsingmode.md)): *[QUrl](qurl.md)*
\+ **new QUrl**(`url`: string, `parsingMode?`: [ParsingMode](qurl.md#readonly-parsingmode)): *[QUrl](qurl.md)*
*Overrides [Component](component.md).[constructor](component.md#constructor)*
@ -60,12 +107,36 @@ Name | Type |
Name | Type |
------ | ------ |
`url` | string |
`parsingMode?` | [ParsingMode](../enums/parsingmode.md) |
`parsingMode?` | [ParsingMode](qurl.md#readonly-parsingmode) |
**Returns:** *[QUrl](qurl.md)*
## Properties
### `Readonly` ComponentFormattingOption
**ComponentFormattingOption**: *[ComponentFormattingOption](../enums/componentformattingoption.md)* = ComponentFormattingOption
___
### `Readonly` ParsingMode
**ParsingMode**: *[ParsingMode](../enums/parsingmode.md)* = ParsingMode
___
### `Readonly` UrlFormattingOption
**UrlFormattingOption**: *[UrlFormattingOption](../enums/urlformattingoption.md)* = UrlFormattingOption
___
### `Readonly` UserInputResolutionOption
**UserInputResolutionOption**: *[UserInputResolutionOption](../enums/userinputresolutionoption.md)* = UserInputResolutionOption
___
### native
**native**: *[NativeElement](../globals.md#nativeelement)*
@ -88,8 +159,366 @@ ___
*Inherited from [Component](component.md).[nodeParent](component.md#optional-nodeparent)*
___
### `Static` `Readonly` ComponentFormattingOption
**ComponentFormattingOption**: *[ComponentFormattingOption](../enums/componentformattingoption.md)* = ComponentFormattingOption
___
### `Static` `Readonly` ParsingMode
**ParsingMode**: *[ParsingMode](../enums/parsingmode.md)* = ParsingMode
___
### `Static` `Readonly` UrlFormattingOption
**UrlFormattingOption**: *[UrlFormattingOption](../enums/urlformattingoption.md)* = UrlFormattingOption
___
### `Static` `Readonly` UserInputResolutionOption
**UserInputResolutionOption**: *[UserInputResolutionOption](../enums/userinputresolutionoption.md)* = UserInputResolutionOption
## Methods
### adjusted
**adjusted**(`options`: number): *[QUrl](qurl.md)*
Returns an adjusted version of the URL. The output can be customized by passing flags with options.
**Parameters:**
Name | Type |
------ | ------ |
`options` | number |
**Returns:** *[QUrl](qurl.md)*
___
### authority
**authority**(`options`: number): *string*
Returns the authority of the URL if it is defined; otherwise an empty string is returned.
**Parameters:**
Name | Type | Default |
------ | ------ | ------ |
`options` | number | ComponentFormattingOption.PrettyDecoded |
**Returns:** *string*
___
### clear
**clear**(): *void*
Resets the content of the QUrl. After calling this function, the QUrl is equal to one that has been constructed with the default empty constructor.
**Returns:** *void*
___
### errorString
**errorString**(): *string*
Returns an error message if the last operation that modified this QUrl object ran into a parsing error. If no error was detected, this function returns an empty string and isValid() returns true.
**Returns:** *string*
___
### fileName
**fileName**(`options`: number): *string*
Returns the name of the file, excluding the directory path.
**Parameters:**
Name | Type | Default |
------ | ------ | ------ |
`options` | number | ComponentFormattingOption.FullyDecoded |
**Returns:** *string*
___
### fragment
**fragment**(`options`: number): *string*
Returns the fragment of the URL. To determine if the parsed URL contained a fragment, use hasFragment().
**Parameters:**
Name | Type | Default |
------ | ------ | ------ |
`options` | number | ComponentFormattingOption.PrettyDecoded |
**Returns:** *string*
___
### hasFragment
**hasFragment**(): *boolean*
Returns true if this URL contains a fragment (i.e., if # was seen on it).
**Returns:** *boolean*
___
### hasQuery
**hasQuery**(): *boolean*
Returns true if this URL contains a Query (i.e., if ? was seen on it).
**Returns:** *boolean*
___
### host
**host**(`options`: number): *string*
Returns the host of the URL if it is defined; otherwise an empty string is returned.
**Parameters:**
Name | Type | Default |
------ | ------ | ------ |
`options` | number | ComponentFormattingOption.FullyDecoded |
**Returns:** *string*
___
### isEmpty
**isEmpty**(): *boolean*
Returns true if the URL has no data; otherwise returns false.
**Returns:** *boolean*
___
### isLocalFile
**isLocalFile**(): *boolean*
Returns true if this URL is pointing to a local file path. A URL is a local file path if the scheme is "file".
**Returns:** *boolean*
___
### isParentOf
**isParentOf**(`childUrl`: [QUrl](qurl.md)): *boolean*
Returns true if this URL is a parent of childUrl. childUrl is a child of this URL if the two URLs share the same scheme and authority, and this URL's path is a parent of the path of childUrl.
**Parameters:**
Name | Type |
------ | ------ |
`childUrl` | [QUrl](qurl.md) |
**Returns:** *boolean*
___
### isRelative
**isRelative**(): *boolean*
Returns true if the URL is relative; otherwise returns false. A URL is relative reference if its scheme is undefined; this function is therefore equivalent to calling scheme().isEmpty().
**Returns:** *boolean*
___
### isValid
**isValid**(): *boolean*
Returns true if the URL is non-empty and valid; otherwise returns false.
**Returns:** *boolean*
___
### matches
**matches**(`url`: [QUrl](qurl.md), `options`: number): *boolean*
Returns true if this URL and the given url are equal after applying options to both; otherwise returns false.
**Parameters:**
Name | Type |
------ | ------ |
`url` | [QUrl](qurl.md) |
`options` | number |
**Returns:** *boolean*
___
### password
**password**(`options`: number): *string*
Returns the password of the URL if it is defined; otherwise an empty string is returned.
**Parameters:**
Name | Type | Default |
------ | ------ | ------ |
`options` | number | ComponentFormattingOption.FullyDecoded |
**Returns:** *string*
___
### path
**path**(`options`: number): *string*
Returns the path of the URL.
**Parameters:**
Name | Type | Default |
------ | ------ | ------ |
`options` | number | ComponentFormattingOption.FullyDecoded |
**Returns:** *string*
___
### port
**port**(`defaultPort`: number): *number*
Returns the port of the URL, or defaultPort if the port is unspecified.
**Parameters:**
Name | Type | Default |
------ | ------ | ------ |
`defaultPort` | number | -1 |
**Returns:** *number*
___
### query
**query**(`options`: number): *string*
Returns the query string of the URL if there's a query string, or an empty result if not. To determine if the parsed URL contained a query string, use hasQuery().
**Parameters:**
Name | Type | Default |
------ | ------ | ------ |
`options` | number | ComponentFormattingOption.PrettyDecoded |
**Returns:** *string*
___
### resolved
**resolved**(`relative`: [QUrl](qurl.md)): *[QUrl](qurl.md)*
Returns the result of the merge of this URL with relative. This URL is used as a base to convert relative to an absolute URL.
**Parameters:**
Name | Type |
------ | ------ |
`relative` | [QUrl](qurl.md) |
**Returns:** *[QUrl](qurl.md)*
___
### scheme
**scheme**(): *string*
Returns the scheme of the URL. If an empty string is returned, this means the scheme is undefined and the URL is then relative.
**Returns:** *string*
___
### setAuthority
**setAuthority**(`authority`: string, `mode`: [ParsingMode](../enums/parsingmode.md)): *void*
Sets the authority of the URL to authority.
**Parameters:**
Name | Type | Default |
------ | ------ | ------ |
`authority` | string | - |
`mode` | [ParsingMode](../enums/parsingmode.md) | ParsingMode.TolerantMode |
**Returns:** *void*
___
### setFragment
**setFragment**(`fragment`: string, `mode`: [ParsingMode](../enums/parsingmode.md)): *void*
Sets the fragment of the URL to fragment. The fragment is the last part of the URL, represented by a '#' followed by a string of characters. It is typically used in HTTP for referring to a certain link or point on a page:
**Parameters:**
Name | Type | Default |
------ | ------ | ------ |
`fragment` | string | - |
`mode` | [ParsingMode](../enums/parsingmode.md) | ParsingMode.TolerantMode |
**Returns:** *void*
___
### setHost
**setHost**(`host`: string, `mode`: [ParsingMode](../enums/parsingmode.md)): *void*
Sets the host of the URL to host. The host is part of the authority.
**Parameters:**
Name | Type | Default |
------ | ------ | ------ |
`host` | string | - |
`mode` | [ParsingMode](../enums/parsingmode.md) | ParsingMode.DecodedMode |
**Returns:** *void*
___
### setNodeParent
**setNodeParent**(`parent?`: [Component](component.md)): *void*
@ -106,28 +535,264 @@ Name | Type |
___
### setUrl
### setPassword
**setUrl**(`url`: string): *void*
**setPassword**(`password`: string, `mode`: [ParsingMode](../enums/parsingmode.md)): *void*
Sets the URL's password to password. The password is part of the user info element in the authority of the URL, as described in setUserInfo().
**Parameters:**
Name | Type |
------ | ------ |
`url` | string |
Name | Type | Default |
------ | ------ | ------ |
`password` | string | - |
`mode` | [ParsingMode](../enums/parsingmode.md) | ParsingMode.DecodedMode |
**Returns:** *void*
___
### toString
### setPath
**toString**(): *string*
**setPath**(`path`: string, `mode`: [ParsingMode](../enums/parsingmode.md)): *void*
Sets the path of the URL to path. The path is the part of the URL that comes after the authority but before the query string.
**Parameters:**
Name | Type | Default |
------ | ------ | ------ |
`path` | string | - |
`mode` | [ParsingMode](../enums/parsingmode.md) | ParsingMode.DecodedMode |
**Returns:** *void*
___
### setPort
**setPort**(`port`: number): *void*
Sets the port of the URL to port. The port is part of the authority of the URL, as described in setAuthority().
**Parameters:**
Name | Type |
------ | ------ |
`port` | number |
**Returns:** *void*
___
### setQuery
**setQuery**(`query`: string, `mode`: [ParsingMode](../enums/parsingmode.md)): *void*
Sets the query string of the URL to query.
**Parameters:**
Name | Type | Default |
------ | ------ | ------ |
`query` | string | - |
`mode` | [ParsingMode](../enums/parsingmode.md) | ParsingMode.TolerantMode |
**Returns:** *void*
___
### setScheme
**setScheme**(`scheme`: string): *void*
Sets the scheme of the URL to scheme. As a scheme can only contain ASCII characters, no conversion or decoding is done on the input. It must also start with an ASCII letter.
**Parameters:**
Name | Type |
------ | ------ |
`scheme` | string |
**Returns:** *void*
___
### setUrl
**setUrl**(`url`: string, `parsingMode`: [ParsingMode](../enums/parsingmode.md)): *void*
Parses url and sets this object to that value. QUrl will automatically percent encode all characters that are not allowed in a URL and decode the percent-encoded sequences that represent an unreserved character (letters, digits, hyphens, undercores, dots and tildes). All other characters are left in their original forms.
**Parameters:**
Name | Type | Default |
------ | ------ | ------ |
`url` | string | - |
`parsingMode` | [ParsingMode](../enums/parsingmode.md) | ParsingMode.TolerantMode |
**Returns:** *void*
___
### setUserInfo
**setUserInfo**(`userInfo`: string, `mode`: [ParsingMode](../enums/parsingmode.md)): *void*
Sets the user info of the URL to userInfo. The user info is an optional part of the authority of the URL, as described in setAuthority().
**Parameters:**
Name | Type | Default |
------ | ------ | ------ |
`userInfo` | string | - |
`mode` | [ParsingMode](../enums/parsingmode.md) | ParsingMode.TolerantMode |
**Returns:** *void*
___
### setUserName
**setUserName**(`userName`: string, `mode`: [ParsingMode](../enums/parsingmode.md)): *void*
Sets the URL's user name to userName. The userName is part of the user info element in the authority of the URL, as described in setUserInfo().
**Parameters:**
Name | Type | Default |
------ | ------ | ------ |
`userName` | string | - |
`mode` | [ParsingMode](../enums/parsingmode.md) | ParsingMode.DecodedMode |
**Returns:** *void*
___
### swap
**swap**(`other`: [QUrl](qurl.md)): *void*
Swaps URL other with this URL. This operation is very fast and never fails.
**Parameters:**
Name | Type |
------ | ------ |
`other` | [QUrl](qurl.md) |
**Returns:** *void*
___
### toDisplayString
**toDisplayString**(`options`: number): *string*
Returns a human-displayable string representation of the URL. The output can be customized by passing flags with options. The option RemovePassword is always enabled, since passwords should never be shown back to users.
**Parameters:**
Name | Type | Default |
------ | ------ | ------ |
`options` | number | ComponentFormattingOption.PrettyDecoded |
**Returns:** *string*
___
### toLocalFile
**toLocalFile**(): *string*
Returns the path of this URL formatted as a local file path. The path returned will use forward slashes, even if it was originally created from one with backslashes.
**Returns:** *string*
___
### toString
**toString**(`options?`: undefined | number): *string*
Returns a string representation of the URL. The output can be customized by passing flags with options. The option QUrl::FullyDecoded is not permitted in this function since it would generate ambiguous data.
See QUrl::ComponentFormattingOption for flags
**Parameters:**
Name | Type |
------ | ------ |
`options?` | undefined &#124; number |
**Returns:** *string*
___
### url
**url**(`options`: number): *string*
Returns a string representation of the URL. The output can be customized by passing flags with options. The option QUrl::FullyDecoded is not permitted in this function since it would generate ambiguous data.
**Parameters:**
Name | Type |
------ | ------ |
`options` | number |
**Returns:** *string*
___
### userInfo
**userInfo**(`options`: number): *string*
Returns the user info of the URL, or an empty string if the user info is undefined.
**Parameters:**
Name | Type | Default |
------ | ------ | ------ |
`options` | number | ComponentFormattingOption.PrettyDecoded |
**Returns:** *string*
___
### userName
**userName**(`options`: number): *string*
Returns the user name of the URL if it is defined; otherwise an empty string is returned.
**Parameters:**
Name | Type | Default |
------ | ------ | ------ |
`options` | number | ComponentFormattingOption.FullyDecoded |
**Returns:** *string*
___
### `Static` fromLocalFile
**fromLocalFile**(`localFile`: string): *[QUrl](qurl.md)*
Returns a QUrl representation of localFile, interpreted as a local file. This function accepts paths separated by slashes as well as the native separator for this platform.
**Parameters:**
Name | Type |
------ | ------ |
`localFile` | string |
**Returns:** *[QUrl](qurl.md)*
___
### `Static` fromQVariant
**fromQVariant**(`variant`: [QVariant](qvariant.md)): *[QUrl](qurl.md)*
@ -139,3 +804,21 @@ Name | Type |
`variant` | [QVariant](qvariant.md) |
**Returns:** *[QUrl](qurl.md)*
___
### `Static` fromUserInput
**fromUserInput**(`userInput`: string, `workingDirectory?`: undefined | string, `options`: number): *[QUrl](qurl.md)*
Returns a valid URL from a user supplied userInput string if one can be deduced. In the case that is not possible, an invalid QUrl() is returned.
**Parameters:**
Name | Type | Default |
------ | ------ | ------ |
`userInput` | string | - |
`workingDirectory?` | undefined &#124; string | - |
`options` | number | UserInputResolutionOption.DefaultResolution |
**Returns:** *[QUrl](qurl.md)*

View File

@ -0,0 +1,82 @@
---
id: "componentformattingoption"
title: "ComponentFormattingOption"
sidebar_label: "ComponentFormattingOption"
---
## Index
### Enumeration members
* [DecodeReserved](componentformattingoption.md#decodereserved)
* [EncodeDelimiters](componentformattingoption.md#encodedelimiters)
* [EncodeReserved](componentformattingoption.md#encodereserved)
* [EncodeSpaces](componentformattingoption.md#encodespaces)
* [EncodeUnicode](componentformattingoption.md#encodeunicode)
* [FullyDecoded](componentformattingoption.md#fullydecoded)
* [FullyEncoded](componentformattingoption.md#fullyencoded)
* [PrettyDecoded](componentformattingoption.md#prettydecoded)
## Enumeration members
### DecodeReserved
**DecodeReserved**: = 33554432
Decode the US-ASCII characters that the URL specification does not allow to appear in the URL. This is the default on the getters of individual components.
___
### EncodeDelimiters
**EncodeDelimiters**: = 0x400000 | 0x800000
Leave certain delimiters in their encoded form, as would appear in the URL when the full URL is represented as text. The delimiters are affected by this option change from component to component. This flag has no effect in toString() or toEncoded().
___
### EncodeReserved
**EncodeReserved**: = 16777216
Leave US-ASCII characters not permitted in the URL by the specification in their encoded form. This is the default on toString() and toEncoded().
___
### EncodeSpaces
**EncodeSpaces**: = 1048576
Leave space characters in their encoded form ("%20").
___
### EncodeUnicode
**EncodeUnicode**: = 2097152
Leave non-US-ASCII characters encoded in their UTF-8 percent-encoded form (e.g., "%C3%A9" for the U+00E9 codepoint, LATIN SMALL LETTER E WITH ACUTE).
___
### FullyDecoded
**FullyDecoded**: = FullyEncoded | DecodeReserved | 0x4000000
Attempt to decode as much as possible. For individual components of the URL, this decodes every percent encoding sequence, including control characters (U+0000 to U+001F) and UTF-8 sequences found in percent-encoded form. Use of this mode may cause data loss, see below for more information.
___
### FullyEncoded
**FullyEncoded**: = EncodeSpaces | EncodeUnicode | EncodeDelimiters | EncodeReserved
Leave all characters in their properly-encoded form, as this component would appear as part of a URL. When used with toString(), this produces a fully-compliant URL in QString form, exactly equal to the result of toEncoded()
___
### PrettyDecoded
**PrettyDecoded**: = 0
The component is returned in a "pretty form", with most percent-encoded characters decoded. The exact behavior of PrettyDecoded varies from component to component and may also change from Qt release to Qt release. This is the default.

View File

@ -16,16 +16,22 @@ sidebar_label: "ParsingMode"
### DecodedMode
**DecodedMode**:
**DecodedMode**: = 2
QUrl will interpret the URL component in the fully-decoded form, where percent characters stand for themselves, not as the beginning of a percent-encoded sequence. This mode is only valid for the setters setting components of a URL; it is not permitted in the QUrl constructor, in fromEncoded() or in setUrl(). For more information on this mode, see the documentation for QUrl::FullyDecoded.
___
### StrictMode
**StrictMode**:
**StrictMode**: = 1
Only valid URLs are accepted. This mode is useful for general URL validation.
___
### TolerantMode
**TolerantMode**:
**TolerantMode**: = 0
QUrl will try to correct some common errors in URLs. This mode is useful for parsing URLs coming from sources not known to be strictly standards-conforming.

View File

@ -0,0 +1,101 @@
---
id: "urlformattingoption"
title: "UrlFormattingOption"
sidebar_label: "UrlFormattingOption"
---
## Index
### Enumeration members
* [None](urlformattingoption.md#none)
* [NormalizePathSegments](urlformattingoption.md#normalizepathsegments)
* [PreferLocalFile](urlformattingoption.md#preferlocalfile)
* [RemoveAuthority](urlformattingoption.md#removeauthority)
* [RemoveFilename](urlformattingoption.md#removefilename)
* [RemoveFragment](urlformattingoption.md#removefragment)
* [RemovePassword](urlformattingoption.md#removepassword)
* [RemovePath](urlformattingoption.md#removepath)
* [RemovePort](urlformattingoption.md#removeport)
* [RemoveQuery](urlformattingoption.md#removequery)
* [RemoveScheme](urlformattingoption.md#removescheme)
* [RemoveUserInfo](urlformattingoption.md#removeuserinfo)
* [StripTrailingSlash](urlformattingoption.md#striptrailingslash)
## Enumeration members
### None
**None**: = 0
___
### NormalizePathSegments
**NormalizePathSegments**: = 4096
___
### PreferLocalFile
**PreferLocalFile**: = 512
___
### RemoveAuthority
**RemoveAuthority**:
___
### RemoveFilename
**RemoveFilename**: = 2048
___
### RemoveFragment
**RemoveFragment**: = 128
___
### RemovePassword
**RemovePassword**: = 2
___
### RemovePath
**RemovePath**: = 32
___
### RemovePort
**RemovePort**: = 8
___
### RemoveQuery
**RemoveQuery**: = 64
___
### RemoveScheme
**RemoveScheme**: = 1
___
### RemoveUserInfo
**RemoveUserInfo**:
___
### StripTrailingSlash
**StripTrailingSlash**: = 1024

View File

@ -0,0 +1,28 @@
---
id: "userinputresolutionoption"
title: "UserInputResolutionOption"
sidebar_label: "UserInputResolutionOption"
---
## Index
### Enumeration members
* [AssumeLocalFile](userinputresolutionoption.md#assumelocalfile)
* [DefaultResolution](userinputresolutionoption.md#defaultresolution)
## Enumeration members
### AssumeLocalFile
**AssumeLocalFile**: = 1
This option makes fromUserInput() always return a local path unless the input contains a scheme, such as http://file.pl. This is useful for applications such as text editors, which are able to create the file if it doesn't exist.
___
### DefaultResolution
**DefaultResolution**: = 0
The default resolution mechanism is to check whether a local file exists, in the working directory given to fromUserInput, and only return a local path in that case. Otherwise a URL is assumed.

View File

@ -29,6 +29,7 @@ sidebar_label: "Globals"
* [ChecksumType](enums/checksumtype.md)
* [ClipOperation](enums/clipoperation.md)
* [ColorDialogOption](enums/colordialogoption.md)
* [ComponentFormattingOption](enums/componentformattingoption.md)
* [ConnectionType](enums/connectiontype.md)
* [ContextMenuPolicy](enums/contextmenupolicy.md)
* [CoordinateSystem](enums/coordinatesystem.md)
@ -151,6 +152,8 @@ sidebar_label: "Globals"
* [TouchPointState](enums/touchpointstate.md)
* [TransformationMode](enums/transformationmode.md)
* [UIEffect](enums/uieffect.md)
* [UrlFormattingOption](enums/urlformattingoption.md)
* [UserInputResolutionOption](enums/userinputresolutionoption.md)
* [VerticalHeaderFormat](enums/verticalheaderformat.md)
* [ViewMode](enums/viewmode.md)
* [WhiteSpaceMode](enums/whitespacemode.md)
@ -201,6 +204,7 @@ sidebar_label: "Globals"
* [QDial](classes/qdial.md)
* [QDialog](classes/qdialog.md)
* [QDoubleSpinBox](classes/qdoublespinbox.md)
* [QDragLeaveEvent](classes/qdragleaveevent.md)
* [QDragMoveEvent](classes/qdragmoveevent.md)
* [QDropEvent](classes/qdropevent.md)
* [QErrorMessage](classes/qerrormessage.md)
@ -228,6 +232,7 @@ sidebar_label: "Globals"
* [QMenu](classes/qmenu.md)
* [QMenuBar](classes/qmenubar.md)
* [QMessageBox](classes/qmessagebox.md)
* [QMimeData](classes/qmimedata.md)
* [QModelIndex](classes/qmodelindex.md)
* [QMouseEvent](classes/qmouseevent.md)
* [QMovie](classes/qmovie.md)

View File

@ -0,0 +1,62 @@
---
sidebar_label: Drag and drop
title: Drag and drop
---
NodeGui supports drag and drop functionality.
In order to enable a widget to accept drops you need call
```js
widget.setAcceptDrops(true);
```
Following this you can then listen to few QEvents like `DragEnter`, `DragMove`, `DragLeave` and `Drop`
The complete code would look something like this:
```js
widget.setAcceptDrops(true);
widget.addEventListener(WidgetEventTypes.DragEnter, (e) => {
let ev = new QDragMoveEvent(e);
console.log('dragEnter', ev.proposedAction());
let mimeData = ev.mimeData();
mimeData.text(); //Inspection of text works
console.log('mimeData', {
hasColor: mimeData.hasColor(),
hasHtml: mimeData.hasHtml(),
hasImage: mimeData.hasImage(),
hasText: mimeData.hasText(),
hasUrls: mimeData.hasUrls(),
html: mimeData.html(),
text: mimeData.text(),
}); //Inspection of MIME data works
let urls = mimeData.urls(); //Get QUrls
for (let url of urls) {
let str = url.toString();
console.log('url', str); //Log out Urls in the event
}
ev.accept(); //Accept the drop event, which is crucial for accepting further events
});
widget.addEventListener(WidgetEventTypes.DragMove, (e) => {
let ev = new QDragMoveEvent(e);
console.log('dragMove');
});
widget.addEventListener(WidgetEventTypes.DragLeave, (e) => {
console.log('dragLeave', e);
let ev = new QDragLeaveEvent(e);
ev.ignore(); //Ignore the event when it leaves
console.log('ignored', ev);
});
widget.addEventListener(WidgetEventTypes.Drop, (e) => {
let dropEvent = new QDropEvent(e);
let mimeData = dropEvent.mimeData();
console.log('dropped', dropEvent.type());
let urls = mimeData.urls();
for (let url of urls) {
let str = url.toString();
console.log('url', str); //Example of inspection of dropped data.
}
});
```

View File

@ -40,6 +40,7 @@ module.exports = {
"api/generated/classes/qdial",
"api/generated/classes/qdialog",
"api/generated/classes/qdoublespinbox",
"api/generated/classes/qdragleaveevent",
"api/generated/classes/qdragmoveevent",
"api/generated/classes/qdropevent",
"api/generated/classes/qerrormessage",
@ -67,6 +68,7 @@ module.exports = {
"api/generated/classes/qmenu",
"api/generated/classes/qmenubar",
"api/generated/classes/qmessagebox",
"api/generated/classes/qmimedata",
"api/generated/classes/qmodelindex",
"api/generated/classes/qmouseevent",
"api/generated/classes/qmovie",
@ -141,6 +143,7 @@ module.exports = {
"api/generated/enums/checksumtype",
"api/generated/enums/clipoperation",
"api/generated/enums/colordialogoption",
"api/generated/enums/componentformattingoption",
"api/generated/enums/connectiontype",
"api/generated/enums/contextmenupolicy",
"api/generated/enums/coordinatesystem",
@ -263,6 +266,8 @@ module.exports = {
"api/generated/enums/touchpointstate",
"api/generated/enums/transformationmode",
"api/generated/enums/uieffect",
"api/generated/enums/urlformattingoption",
"api/generated/enums/userinputresolutionoption",
"api/generated/enums/verticalheaderformat",
"api/generated/enums/viewmode",
"api/generated/enums/whitespacemode",
@ -335,6 +340,7 @@ module.exports = {
"guides/handle-events",
"guides/scroll-view",
"guides/images",
"guides/drag-drop",
"guides/networking",
"guides/helpful-links"
],