Add DateTime related Class (#332)
This commit is contained in:
parent
b3ded74acf
commit
5d6806fe7d
@ -49,23 +49,29 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QKeySequence/qkeysequence_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QMovie/qmovie_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QStyle/qstyle_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtCore/QDate/qdate_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtCore/QDateTime/qdatetime_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtCore/QModelIndex/qmodelindex_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtCore/QObject/qobject_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtCore/QVariant/qvariant_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtCore/QSize/qsize_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtCore/QRect/qrect_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtCore/QPoint/qpoint_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/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"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QCalendarWidget/qcalendarwidget_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QComboBox/qcombobox_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QDateEdit/qdateedit_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QDateTimeEdit/qdatetimeedit_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QFileDialog/qfiledialog_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QListWidget/qlistwidget_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QListWidgetItem/qlistwidgetitem_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QTableWidget/qtablewidget_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QTableWidgetItem/qtablewidgetitem_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QPainter/qpainter_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QPainter/qpainter_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QGridLayout/qgridlayout_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QDial/qdial_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QLabel/qlabel_wrap.cpp"
|
||||
@ -88,6 +94,7 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QMenuBar/qmenubar_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QMenu/qmenu_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QGroupBox/qgroupbox_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QTimeEdit/qtimeedit_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QTreeWidget/qtreewidget_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QTreeWidgetItem/qtreewidgetitem_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QMessageBox/qmessagebox_wrap.cpp"
|
||||
@ -99,7 +106,10 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QWidget/nwidget.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QDialog/ndialog.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QLabel/nlabel.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QCalendarWidget/ncalendarwidget.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QCheckBox/ncheckbox.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QDateEdit/ndateedit.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QDateTimeEdit/ndatetimeedit.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QDial/ndial.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QFileDialog/nfiledialog.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QListWidget/nlistwidget.hpp"
|
||||
@ -126,6 +136,7 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QBoxLayout/nboxlayout.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QComboBox/ncombobox.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QGroupBox/ngroupbox.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QTimeEdit/ntimeedit.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QTreeWidget/ntreewidget.hpp"
|
||||
|
||||
)
|
||||
|
||||
46
src/cpp/include/nodegui/QtCore/QDate/qdate_wrap.h
Normal file
46
src/cpp/include/nodegui/QtCore/QDate/qdate_wrap.h
Normal file
@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QDate>
|
||||
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class QDateWrap : public Napi::ObjectWrap<QDateWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
std::unique_ptr<QDate> instance;
|
||||
|
||||
public:
|
||||
static Napi::FunctionReference constructor;
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QDateWrap(const Napi::CallbackInfo& info);
|
||||
~QDateWrap();
|
||||
QDate* getInternalInstance();
|
||||
// Wrapped methods
|
||||
Napi::Value addDays(const Napi::CallbackInfo& info);
|
||||
Napi::Value addMonths(const Napi::CallbackInfo& info);
|
||||
Napi::Value addYears(const Napi::CallbackInfo& info);
|
||||
Napi::Value day(const Napi::CallbackInfo& info);
|
||||
Napi::Value dayOfWeek(const Napi::CallbackInfo& info);
|
||||
Napi::Value dayOfYear(const Napi::CallbackInfo& info);
|
||||
Napi::Value daysInMonth(const Napi::CallbackInfo& info);
|
||||
Napi::Value daysInYear(const Napi::CallbackInfo& info);
|
||||
Napi::Value daysTo(const Napi::CallbackInfo& info);
|
||||
Napi::Value isNull(const Napi::CallbackInfo& info);
|
||||
Napi::Value isValid(const Napi::CallbackInfo& info);
|
||||
Napi::Value month(const Napi::CallbackInfo& info);
|
||||
Napi::Value setDate(const Napi::CallbackInfo& info);
|
||||
Napi::Value toJulianDay(const Napi::CallbackInfo& info);
|
||||
Napi::Value toString(const Napi::CallbackInfo& info);
|
||||
Napi::Value year(const Napi::CallbackInfo& info);
|
||||
};
|
||||
|
||||
namespace StaticDateWrapMethods {
|
||||
Napi::Value currentDate(const Napi::CallbackInfo& info);
|
||||
Napi::Value fromJulianDay(const Napi::CallbackInfo& info);
|
||||
Napi::Value isLeapYear(const Napi::CallbackInfo& info);
|
||||
Napi::Value isValid(const Napi::CallbackInfo& info);
|
||||
Napi::Value fromQVariant(const Napi::CallbackInfo& info);
|
||||
} // namespace StaticDateWrapMethods
|
||||
58
src/cpp/include/nodegui/QtCore/QDateTime/qdatetime_wrap.h
Normal file
58
src/cpp/include/nodegui/QtCore/QDateTime/qdatetime_wrap.h
Normal file
@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class QDateTimeWrap : public Napi::ObjectWrap<QDateTimeWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
std::unique_ptr<QDateTime> instance;
|
||||
|
||||
public:
|
||||
static Napi::FunctionReference constructor;
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QDateTimeWrap(const Napi::CallbackInfo& info);
|
||||
~QDateTimeWrap();
|
||||
QDateTime* getInternalInstance();
|
||||
// Wrapped methods
|
||||
Napi::Value addDays(const Napi::CallbackInfo& info);
|
||||
Napi::Value addMSecs(const Napi::CallbackInfo& info);
|
||||
Napi::Value addMonths(const Napi::CallbackInfo& info);
|
||||
Napi::Value addSecs(const Napi::CallbackInfo& info);
|
||||
Napi::Value addYears(const Napi::CallbackInfo& info);
|
||||
Napi::Value date(const Napi::CallbackInfo& info);
|
||||
Napi::Value daysTo(const Napi::CallbackInfo& info);
|
||||
Napi::Value isDaylightTime(const Napi::CallbackInfo& info);
|
||||
Napi::Value isNull(const Napi::CallbackInfo& info);
|
||||
Napi::Value isValid(const Napi::CallbackInfo& info);
|
||||
Napi::Value msecsTo(const Napi::CallbackInfo& info);
|
||||
Napi::Value offsetFromUtc(const Napi::CallbackInfo& info);
|
||||
Napi::Value secsTo(const Napi::CallbackInfo& info);
|
||||
Napi::Value setDate(const Napi::CallbackInfo& info);
|
||||
Napi::Value setMSecsSinceEpoch(const Napi::CallbackInfo& info);
|
||||
Napi::Value setOffsetFromUtc(const Napi::CallbackInfo& info);
|
||||
Napi::Value setSecsSinceEpoch(const Napi::CallbackInfo& info);
|
||||
Napi::Value setTime(const Napi::CallbackInfo& info);
|
||||
Napi::Value setTimeSpec(const Napi::CallbackInfo& info);
|
||||
Napi::Value time(const Napi::CallbackInfo& info);
|
||||
Napi::Value timeSpec(const Napi::CallbackInfo& info);
|
||||
Napi::Value toLocalTime(const Napi::CallbackInfo& info);
|
||||
Napi::Value toMSecsSinceEpoch(const Napi::CallbackInfo& info);
|
||||
Napi::Value toOffsetFromUtc(const Napi::CallbackInfo& info);
|
||||
Napi::Value toSecsSinceEpoch(const Napi::CallbackInfo& info);
|
||||
Napi::Value toString(const Napi::CallbackInfo& info);
|
||||
Napi::Value toTimeSpec(const Napi::CallbackInfo& info);
|
||||
Napi::Value toUTC(const Napi::CallbackInfo& info);
|
||||
};
|
||||
|
||||
namespace StaticDateTimeWrapMethods {
|
||||
Napi::Value currentDateTime(const Napi::CallbackInfo& info);
|
||||
Napi::Value currentDateTimeUtc(const Napi::CallbackInfo& info);
|
||||
Napi::Value currentMSecsSinceEpoch(const Napi::CallbackInfo& info);
|
||||
Napi::Value currentSecsSinceEpoch(const Napi::CallbackInfo& info);
|
||||
Napi::Value fromQVariant(const Napi::CallbackInfo& info);
|
||||
} // namespace StaticDateTimeWrapMethods
|
||||
45
src/cpp/include/nodegui/QtCore/QTime/qtime_wrap.h
Normal file
45
src/cpp/include/nodegui/QtCore/QTime/qtime_wrap.h
Normal file
@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QTime>
|
||||
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class QTimeWrap : public Napi::ObjectWrap<QTimeWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
std::unique_ptr<QTime> instance;
|
||||
|
||||
public:
|
||||
static Napi::FunctionReference constructor;
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QTimeWrap(const Napi::CallbackInfo& info);
|
||||
~QTimeWrap();
|
||||
QTime* getInternalInstance();
|
||||
// Wrapped methods
|
||||
Napi::Value addMSecs(const Napi::CallbackInfo& info);
|
||||
Napi::Value addSecs(const Napi::CallbackInfo& info);
|
||||
Napi::Value elapsed(const Napi::CallbackInfo& info);
|
||||
Napi::Value hour(const Napi::CallbackInfo& info);
|
||||
Napi::Value isNull(const Napi::CallbackInfo& info);
|
||||
Napi::Value isValid(const Napi::CallbackInfo& info);
|
||||
Napi::Value minute(const Napi::CallbackInfo& info);
|
||||
Napi::Value msec(const Napi::CallbackInfo& info);
|
||||
Napi::Value msecsSinceStartOfDay(const Napi::CallbackInfo& info);
|
||||
Napi::Value msecsTo(const Napi::CallbackInfo& info);
|
||||
Napi::Value restart(const Napi::CallbackInfo& info);
|
||||
Napi::Value second(const Napi::CallbackInfo& info);
|
||||
Napi::Value secsTo(const Napi::CallbackInfo& info);
|
||||
Napi::Value setHMS(const Napi::CallbackInfo& info);
|
||||
Napi::Value start(const Napi::CallbackInfo& info);
|
||||
Napi::Value toString(const Napi::CallbackInfo& info);
|
||||
};
|
||||
|
||||
namespace StaticTimeWrapMethods {
|
||||
Napi::Value currentTime(const Napi::CallbackInfo& info);
|
||||
Napi::Value fromMSecsSinceStartOfDay(const Napi::CallbackInfo& info);
|
||||
Napi::Value isValid(const Napi::CallbackInfo& info);
|
||||
Napi::Value fromQVariant(const Napi::CallbackInfo& info);
|
||||
} // namespace StaticTimeWrapMethods
|
||||
@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
#include "QtWidgets/QWidget/qwidget_macro.h"
|
||||
#include "QtWidgets/QWidget/qwidget_wrap.h"
|
||||
|
||||
/*
|
||||
|
||||
This macro adds common QAbstractSpinBox exported methods
|
||||
The exported methods are taken into this macro to avoid writing them in each
|
||||
and every widget we export.
|
||||
*/
|
||||
|
||||
#ifndef QABSTRACTSPINBOX_WRAPPED_METHODS_DECLARATION
|
||||
#define QABSTRACTSPINBOX_WRAPPED_METHODS_DECLARATION \
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION \
|
||||
Napi::Value selectAll(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
this->instance->selectAll(); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value stepDown(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
this->instance->stepDown(); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value stepUp(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
this->instance->stepUp(); \
|
||||
return env.Null(); \
|
||||
}
|
||||
|
||||
#endif // QABSTRACTSPINBOX_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
#ifndef QABSTRACTSPINBOX_WRAPPED_METHODS_EXPORT_DEFINE
|
||||
#define QABSTRACTSPINBOX_WRAPPED_METHODS_EXPORT_DEFINE(WidgetWrapName) \
|
||||
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(WidgetWrapName) \
|
||||
InstanceMethod("selectAll", &WidgetWrapName::selectAll), \
|
||||
InstanceMethod("stepDown", &WidgetWrapName::stepDown), \
|
||||
InstanceMethod("stepUp", &WidgetWrapName::stepUp),
|
||||
|
||||
#endif // QABSTRACTSPINBOX_WRAPPED_METHODS_EXPORT_DEFINE
|
||||
|
||||
#ifndef QABSTRACTSPINBOX_SIGNALS
|
||||
#define QABSTRACTSPINBOX_SIGNALS \
|
||||
QWIDGET_SIGNALS \
|
||||
QObject::connect(this, &QAbstractSpinBox::editingFinished, [=]() { \
|
||||
Napi::Env env = this->emitOnNode.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
this->emitOnNode.Call({Napi::String::New(env, "editingFinished")}); \
|
||||
});
|
||||
|
||||
#endif // QABSTRACTSPINBOX_SIGNALS
|
||||
@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
#include <QCalendarWidget>
|
||||
|
||||
#include "QtCore/QDate/qdate_wrap.h"
|
||||
#include "QtWidgets/QWidget/qwidget_macro.h"
|
||||
#include "core/NodeWidget/nodewidget.h"
|
||||
#include "napi.h"
|
||||
|
||||
class NCalendarWidget : public QCalendarWidget, public NodeWidget {
|
||||
Q_OBJECT
|
||||
NODEWIDGET_IMPLEMENTATIONS(QCalendarWidget)
|
||||
public:
|
||||
// inherit all constructors of QCalendarWidget
|
||||
using QCalendarWidget::QCalendarWidget;
|
||||
|
||||
void connectSignalsToEventEmitter() {
|
||||
// Qt Connects: Implement all signal connects here
|
||||
QWIDGET_SIGNALS
|
||||
QObject::connect(this, &QCalendarWidget::activated, [=](const QDate &date) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
auto instance = QDateWrap::constructor.New({Napi::External<QDate>::New(
|
||||
env, new QDate(date.year(), date.month(), date.day()))});
|
||||
this->emitOnNode.Call({Napi::String::New(env, "activated"), instance});
|
||||
});
|
||||
QObject::connect(this, &QCalendarWidget::clicked, [=](const QDate &date) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
auto instance = QDateWrap::constructor.New({Napi::External<QDate>::New(
|
||||
env, new QDate(date.year(), date.month(), date.day()))});
|
||||
this->emitOnNode.Call({Napi::String::New(env, "clicked"), instance});
|
||||
});
|
||||
QObject::connect(
|
||||
this, &QCalendarWidget::currentPageChanged, [=](int year, int month) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->emitOnNode.Call({Napi::String::New(env, "currentPageChanged"),
|
||||
Napi::Value::From(env, year),
|
||||
Napi::Value::From(env, month)});
|
||||
});
|
||||
QObject::connect(this, &QCalendarWidget::selectionChanged, [=]() {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->emitOnNode.Call({Napi::String::New(env, "selectionChanged")});
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtWidgets/QCalendarWidget/ncalendarwidget.hpp"
|
||||
#include "QtWidgets/QWidget/qwidget_macro.h"
|
||||
|
||||
class QCalendarWidgetWrap : public Napi::ObjectWrap<QCalendarWidgetWrap> {
|
||||
private:
|
||||
QPointer<NCalendarWidget> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QCalendarWidgetWrap(const Napi::CallbackInfo &info);
|
||||
~QCalendarWidgetWrap();
|
||||
NCalendarWidget *getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
Napi::Value monthShown(const Napi::CallbackInfo &info);
|
||||
Napi::Value yearShown(const Napi::CallbackInfo &info);
|
||||
Napi::Value setCurrentPage(const Napi::CallbackInfo &info);
|
||||
Napi::Value showNextMonth(const Napi::CallbackInfo &info);
|
||||
Napi::Value showNextYear(const Napi::CallbackInfo &info);
|
||||
Napi::Value showPreviousMonth(const Napi::CallbackInfo &info);
|
||||
Napi::Value showPreviousYear(const Napi::CallbackInfo &info);
|
||||
Napi::Value showSelectedDate(const Napi::CallbackInfo &info);
|
||||
Napi::Value showToday(const Napi::CallbackInfo &info);
|
||||
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
20
src/cpp/include/nodegui/QtWidgets/QDateEdit/ndateedit.hpp
Normal file
20
src/cpp/include/nodegui/QtWidgets/QDateEdit/ndateedit.hpp
Normal file
@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDateEdit>
|
||||
|
||||
#include "QtWidgets/QDateTimeEdit/qdatetimeedit_macro.h"
|
||||
#include "core/NodeWidget/nodewidget.h"
|
||||
#include "napi.h"
|
||||
|
||||
class NDateEdit : public QDateEdit, public NodeWidget {
|
||||
Q_OBJECT
|
||||
NODEWIDGET_IMPLEMENTATIONS(QDateEdit)
|
||||
public:
|
||||
// inherit all constructors of QDateEdit
|
||||
using QDateEdit::QDateEdit;
|
||||
|
||||
void connectSignalsToEventEmitter() {
|
||||
// Qt Connects: Implement all signal connects here
|
||||
QDATETIMEEDIT_SIGNALS
|
||||
}
|
||||
};
|
||||
24
src/cpp/include/nodegui/QtWidgets/QDateEdit/qdateedit_wrap.h
Normal file
24
src/cpp/include/nodegui/QtWidgets/QDateEdit/qdateedit_wrap.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtWidgets/QDateTimeEdit/qdatetimeedit_macro.h"
|
||||
#include "ndateedit.hpp"
|
||||
|
||||
class QDateEditWrap : public Napi::ObjectWrap<QDateEditWrap> {
|
||||
QDATETIMEEDIT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NDateEdit> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QDateEditWrap(const Napi::CallbackInfo &info);
|
||||
~QDateEditWrap();
|
||||
NDateEdit *getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
};
|
||||
@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDateTimeEdit>
|
||||
|
||||
#include "QtWidgets/QDateTimeEdit/qdatetimeedit_macro.h"
|
||||
#include "core/NodeWidget/nodewidget.h"
|
||||
#include "napi.h"
|
||||
|
||||
class NDateTimeEdit : public QDateTimeEdit, public NodeWidget {
|
||||
Q_OBJECT
|
||||
NODEWIDGET_IMPLEMENTATIONS(QDateTimeEdit)
|
||||
public:
|
||||
// inherit all constructors of QDateTimeEdit
|
||||
using QDateTimeEdit::QDateTimeEdit;
|
||||
|
||||
void connectSignalsToEventEmitter() {
|
||||
// Qt Connects: Implement all signal connects here
|
||||
QDATETIMEEDIT_SIGNALS
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,67 @@
|
||||
#pragma once
|
||||
|
||||
#include "QtCore/QDate/qdate_wrap.h"
|
||||
#include "QtCore/QDateTime/qdatetime_wrap.h"
|
||||
#include "QtCore/QTime/qtime_wrap.h"
|
||||
#include "QtWidgets/QAbstractSpinBox/qabstractspinbox_macro.h"
|
||||
#include "QtWidgets/QCalendarWidget/qcalendarwidget_wrap.h"
|
||||
|
||||
/*
|
||||
|
||||
This macro adds common QDateTimeEdit exported methods
|
||||
The exported methods are taken into this macro to avoid writing them in each
|
||||
and every widget we export.
|
||||
*/
|
||||
|
||||
#ifndef QDATETIMEEDIT_WRAPPED_METHODS_DECLARATION
|
||||
#define QDATETIMEEDIT_WRAPPED_METHODS_DECLARATION \
|
||||
QABSTRACTSPINBOX_WRAPPED_METHODS_DECLARATION \
|
||||
Napi::Value setCalendarWidget(const Napi::CallbackInfo &info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
Napi::Object calendarWidgetObject = info[0].As<Napi::Object>(); \
|
||||
QCalendarWidgetWrap *calendarWidgetWrap = \
|
||||
Napi::ObjectWrap<QCalendarWidgetWrap>::Unwrap(calendarWidgetObject); \
|
||||
this->instance->setCalendarWidget( \
|
||||
calendarWidgetWrap->getInternalInstance()); \
|
||||
return env.Null(); \
|
||||
}
|
||||
|
||||
#endif // QDATETIMEEDIT_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
#ifndef QDATETIMEEDIT_WRAPPED_METHODS_EXPORT_DEFINE
|
||||
#define QDATETIMEEDIT_WRAPPED_METHODS_EXPORT_DEFINE(WidgetWrapName) \
|
||||
QABSTRACTSPINBOX_WRAPPED_METHODS_EXPORT_DEFINE(WidgetWrapName) \
|
||||
InstanceMethod("setCalendarWidget", &WidgetWrapName::setCalendarWidget),
|
||||
|
||||
#endif // QDATETIMEEDIT_WRAPPED_METHODS_EXPORT_DEFINE
|
||||
|
||||
#ifndef QDATETIMEEDIT_SIGNALS
|
||||
#define QDATETIMEEDIT_SIGNALS \
|
||||
QABSTRACTSPINBOX_SIGNALS \
|
||||
QObject::connect(this, &QDateTimeEdit::dateChanged, [=](const QDate &date) { \
|
||||
Napi::Env env = this->emitOnNode.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
auto instance = QDateWrap::constructor.New({Napi::External<QDate>::New( \
|
||||
env, new QDate(date.year(), date.month(), date.day()))}); \
|
||||
this->emitOnNode.Call({Napi::String::New(env, "dateChanged"), instance}); \
|
||||
}); \
|
||||
QObject::connect( \
|
||||
this, &QDateTimeEdit::dateTimeChanged, [=](const QDateTime &datetime) { \
|
||||
Napi::Env env = this->emitOnNode.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
auto instance = QDateTimeWrap::constructor.New( \
|
||||
{Napi::External<QDateTime>::New(env, new QDateTime(datetime))}); \
|
||||
this->emitOnNode.Call( \
|
||||
{Napi::String::New(env, "dateTimeChanged"), instance}); \
|
||||
}); \
|
||||
QObject::connect(this, &QDateTimeEdit::timeChanged, [=](const QTime &time) { \
|
||||
Napi::Env env = this->emitOnNode.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
auto instance = QTimeWrap::constructor.New({Napi::External<QTime>::New( \
|
||||
env, \
|
||||
new QTime(time.hour(), time.minute(), time.second(), time.msec()))}); \
|
||||
this->emitOnNode.Call({Napi::String::New(env, "timeChanged"), instance}); \
|
||||
});
|
||||
|
||||
#endif // QDATETIMEEDIT_SIGNALS
|
||||
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtWidgets/QDateTimeEdit/qdatetimeedit_macro.h"
|
||||
#include "ndatetimeedit.hpp"
|
||||
|
||||
class QDateTimeEditWrap : public Napi::ObjectWrap<QDateTimeEditWrap> {
|
||||
QDATETIMEEDIT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NDateTimeEdit> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QDateTimeEditWrap(const Napi::CallbackInfo &info);
|
||||
~QDateTimeEditWrap();
|
||||
NDateTimeEdit *getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
};
|
||||
20
src/cpp/include/nodegui/QtWidgets/QTimeEdit/ntimeedit.hpp
Normal file
20
src/cpp/include/nodegui/QtWidgets/QTimeEdit/ntimeedit.hpp
Normal file
@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <QTimeEdit>
|
||||
|
||||
#include "QtWidgets/QDateTimeEdit/qdatetimeedit_macro.h"
|
||||
#include "core/NodeWidget/nodewidget.h"
|
||||
#include "napi.h"
|
||||
|
||||
class NTimeEdit : public QTimeEdit, public NodeWidget {
|
||||
Q_OBJECT
|
||||
NODEWIDGET_IMPLEMENTATIONS(QTimeEdit)
|
||||
public:
|
||||
// inherit all constructors of QTimeEdit
|
||||
using QTimeEdit::QTimeEdit;
|
||||
|
||||
void connectSignalsToEventEmitter() {
|
||||
// Qt Connects: Implement all signal connects here
|
||||
QDATETIMEEDIT_SIGNALS
|
||||
}
|
||||
};
|
||||
25
src/cpp/include/nodegui/QtWidgets/QTimeEdit/qtimeedit_wrap.h
Normal file
25
src/cpp/include/nodegui/QtWidgets/QTimeEdit/qtimeedit_wrap.h
Normal file
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtWidgets/QDateTimeEdit/qdatetimeedit_macro.h"
|
||||
#include "ntimeedit.hpp"
|
||||
|
||||
class QTimeEditWrap : public Napi::ObjectWrap<QTimeEditWrap> {
|
||||
QDATETIMEEDIT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NTimeEdit> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QTimeEditWrap(const Napi::CallbackInfo &info);
|
||||
~QTimeEditWrap();
|
||||
NTimeEdit *getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
};
|
||||
251
src/cpp/lib/QtCore/QDate/qdate_wrap.cpp
Normal file
251
src/cpp/lib/QtCore/QDate/qdate_wrap.cpp
Normal file
@ -0,0 +1,251 @@
|
||||
#include "QtCore/QDate/qdate_wrap.h"
|
||||
|
||||
#include <QDate>
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtCore/QVariant/qvariant_wrap.h"
|
||||
|
||||
Napi::FunctionReference QDateWrap::constructor;
|
||||
|
||||
Napi::Object QDateWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
Napi::HandleScope scope(env);
|
||||
char CLASSNAME[] = "QDate";
|
||||
Napi::Function func = DefineClass(
|
||||
env, CLASSNAME,
|
||||
{InstanceMethod("addDays", &QDateWrap::addDays),
|
||||
InstanceMethod("addMonths", &QDateWrap::addMonths),
|
||||
InstanceMethod("addYears", &QDateWrap::addYears),
|
||||
InstanceMethod("day", &QDateWrap::day),
|
||||
InstanceMethod("dayOfWeek", &QDateWrap::dayOfWeek),
|
||||
InstanceMethod("dayOfYear", &QDateWrap::dayOfYear),
|
||||
InstanceMethod("daysInMonth", &QDateWrap::daysInMonth),
|
||||
InstanceMethod("daysInYear", &QDateWrap::daysInYear),
|
||||
InstanceMethod("daysTo", &QDateWrap::daysTo),
|
||||
InstanceMethod("isNull", &QDateWrap::isNull),
|
||||
InstanceMethod("isValid", &QDateWrap::isValid),
|
||||
InstanceMethod("month", &QDateWrap::month),
|
||||
InstanceMethod("setDate", &QDateWrap::setDate),
|
||||
InstanceMethod("toJulianDay", &QDateWrap::toJulianDay),
|
||||
InstanceMethod("toString$", &QDateWrap::toString),
|
||||
InstanceMethod("year", &QDateWrap::year),
|
||||
StaticMethod("currentDate", &StaticDateWrapMethods::currentDate),
|
||||
StaticMethod("fromJulianDay", &StaticDateWrapMethods::fromJulianDay),
|
||||
StaticMethod("isLeapYear", &StaticDateWrapMethods::isLeapYear),
|
||||
StaticMethod("isValid", &StaticDateWrapMethods::isValid),
|
||||
StaticMethod("fromQVariant", &StaticDateWrapMethods::fromQVariant),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QDateWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
}
|
||||
|
||||
QDateWrap::QDateWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QDateWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
if (info.Length() == 3) {
|
||||
int y = info[0].As<Napi::Number>().Int32Value();
|
||||
int m = info[1].As<Napi::Number>().Int32Value();
|
||||
int d = info[2].As<Napi::Number>().Int32Value();
|
||||
this->instance = std::make_unique<QDate>(y, m, d);
|
||||
} else if (info.Length() == 1) {
|
||||
this->instance =
|
||||
std::unique_ptr<QDate>(info[0].As<Napi::External<QDate>>().Data());
|
||||
} else if (info.Length() == 0) {
|
||||
this->instance = std::make_unique<QDate>();
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureComponent(this->getInternalInstance());
|
||||
}
|
||||
|
||||
QDateWrap::~QDateWrap() { this->instance.reset(); }
|
||||
|
||||
QDate* QDateWrap::getInternalInstance() { return this->instance.get(); }
|
||||
|
||||
Napi::Value QDateWrap::addDays(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
qint64 ndays = info[0].As<Napi::Number>().Int64Value();
|
||||
QDate date = this->instance->addDays(ndays);
|
||||
auto instance = QDateWrap::constructor.New({Napi::External<QDate>::New(
|
||||
env, new QDate(date.year(), date.month(), date.day()))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value QDateWrap::addMonths(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
int nmonths = info[0].As<Napi::Number>().Int32Value();
|
||||
QDate date = this->instance->addMonths(nmonths);
|
||||
auto instance = QDateWrap::constructor.New({Napi::External<QDate>::New(
|
||||
env, new QDate(date.year(), date.month(), date.day()))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value QDateWrap::addYears(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
int nyears = info[0].As<Napi::Number>().Int32Value();
|
||||
QDate date = this->instance->addYears(nyears);
|
||||
auto instance = QDateWrap::constructor.New({Napi::External<QDate>::New(
|
||||
env, new QDate(date.year(), date.month(), date.day()))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value QDateWrap::day(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->day());
|
||||
}
|
||||
|
||||
Napi::Value QDateWrap::dayOfWeek(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->dayOfWeek());
|
||||
}
|
||||
|
||||
Napi::Value QDateWrap::dayOfYear(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->dayOfYear());
|
||||
}
|
||||
|
||||
Napi::Value QDateWrap::daysInMonth(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->daysInMonth());
|
||||
}
|
||||
|
||||
Napi::Value QDateWrap::daysInYear(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->daysInYear());
|
||||
}
|
||||
|
||||
Napi::Value QDateWrap::daysTo(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
Napi::Object dObject = info[0].As<Napi::Object>();
|
||||
QDateWrap* dWrap = Napi::ObjectWrap<QDateWrap>::Unwrap(dObject);
|
||||
qint64 result = this->instance->daysTo(*dWrap->getInternalInstance());
|
||||
return Napi::Value::From(env, result);
|
||||
}
|
||||
|
||||
Napi::Value QDateWrap::isNull(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->isNull());
|
||||
}
|
||||
|
||||
Napi::Value QDateWrap::isValid(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->isValid());
|
||||
}
|
||||
|
||||
Napi::Value QDateWrap::month(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->month());
|
||||
}
|
||||
|
||||
Napi::Value QDateWrap::setDate(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
int year = info[0].As<Napi::Number>().Int32Value();
|
||||
int month = info[1].As<Napi::Number>().Int32Value();
|
||||
int day = info[2].As<Napi::Number>().Int32Value();
|
||||
bool result = this->instance->setDate(year, month, day);
|
||||
return Napi::Value::From(env, result);
|
||||
}
|
||||
|
||||
Napi::Value QDateWrap::toJulianDay(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->toJulianDay());
|
||||
}
|
||||
|
||||
Napi::Value QDateWrap::toString(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
QString result;
|
||||
if (info[0].IsString()) {
|
||||
std::string format = info[0].As<Napi::String>().Utf8Value();
|
||||
result = this->instance->toString(QString::fromUtf8(format.c_str()));
|
||||
} else {
|
||||
int format = info[0].As<Napi::Number>().Int32Value();
|
||||
result = this->instance->toString(static_cast<Qt::DateFormat>(format));
|
||||
}
|
||||
|
||||
return Napi::String::New(env, result.toStdString());
|
||||
}
|
||||
|
||||
Napi::Value QDateWrap::year(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->year());
|
||||
}
|
||||
|
||||
Napi::Value StaticDateWrapMethods::currentDate(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
QDate date = QDate::currentDate();
|
||||
auto instance = QDateWrap::constructor.New({Napi::External<QDate>::New(
|
||||
env, new QDate(date.year(), date.month(), date.day()))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value StaticDateWrapMethods::fromJulianDay(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
qint64 jd = info[0].As<Napi::Number>().Int64Value();
|
||||
QDate date = QDate::fromJulianDay(jd);
|
||||
auto instance = QDateWrap::constructor.New({Napi::External<QDate>::New(
|
||||
env, new QDate(date.year(), date.month(), date.day()))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value StaticDateWrapMethods::isLeapYear(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
int year = info[0].As<Napi::Number>().Int32Value();
|
||||
return Napi::Value::From(env, QDate::isLeapYear(year));
|
||||
}
|
||||
|
||||
Napi::Value StaticDateWrapMethods::isValid(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
int year = info[0].As<Napi::Number>().Int32Value();
|
||||
int month = info[1].As<Napi::Number>().Int32Value();
|
||||
int day = info[2].As<Napi::Number>().Int32Value();
|
||||
|
||||
return Napi::Value::From(env, QDate::isValid(year, month, day));
|
||||
}
|
||||
|
||||
Napi::Value StaticDateWrapMethods::fromQVariant(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
Napi::Object variantObject = info[0].As<Napi::Object>();
|
||||
QVariantWrap* variantWrap =
|
||||
Napi::ObjectWrap<QVariantWrap>::Unwrap(variantObject);
|
||||
QVariant* variant = variantWrap->getInternalInstance();
|
||||
QDate date = variant->value<QDate>();
|
||||
auto instance = QDateWrap::constructor.New({Napi::External<QDate>::New(
|
||||
env, new QDate(date.year(), date.month(), date.day()))});
|
||||
return instance;
|
||||
}
|
||||
401
src/cpp/lib/QtCore/QDateTime/qdatetime_wrap.cpp
Normal file
401
src/cpp/lib/QtCore/QDateTime/qdatetime_wrap.cpp
Normal file
@ -0,0 +1,401 @@
|
||||
#include "QtCore/QDateTime/qdatetime_wrap.h"
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtCore/QDate/qdate_wrap.h"
|
||||
#include "QtCore/QTime/qtime_wrap.h"
|
||||
#include "QtCore/QVariant/qvariant_wrap.h"
|
||||
|
||||
Napi::FunctionReference QDateTimeWrap::constructor;
|
||||
|
||||
Napi::Object QDateTimeWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
Napi::HandleScope scope(env);
|
||||
char CLASSNAME[] = "QDateTime";
|
||||
Napi::Function func = DefineClass(
|
||||
env, CLASSNAME,
|
||||
{InstanceMethod("addDays", &QDateTimeWrap::addDays),
|
||||
InstanceMethod("addMSecs", &QDateTimeWrap::addMSecs),
|
||||
InstanceMethod("addMonths", &QDateTimeWrap::addMonths),
|
||||
InstanceMethod("addSecs", &QDateTimeWrap::addSecs),
|
||||
InstanceMethod("addYears", &QDateTimeWrap::addYears),
|
||||
InstanceMethod("date", &QDateTimeWrap::date),
|
||||
InstanceMethod("daysTo", &QDateTimeWrap::daysTo),
|
||||
InstanceMethod("isDaylightTime", &QDateTimeWrap::isDaylightTime),
|
||||
InstanceMethod("isNull", &QDateTimeWrap::isNull),
|
||||
InstanceMethod("isValid", &QDateTimeWrap::isValid),
|
||||
InstanceMethod("msecsTo", &QDateTimeWrap::msecsTo),
|
||||
InstanceMethod("offsetFromUtc", &QDateTimeWrap::offsetFromUtc),
|
||||
InstanceMethod("secsTo", &QDateTimeWrap::secsTo),
|
||||
InstanceMethod("setDate", &QDateTimeWrap::setDate),
|
||||
InstanceMethod("setMSecsSinceEpoch", &QDateTimeWrap::setMSecsSinceEpoch),
|
||||
InstanceMethod("setOffsetFromUtc", &QDateTimeWrap::setOffsetFromUtc),
|
||||
InstanceMethod("setSecsSinceEpoch", &QDateTimeWrap::setSecsSinceEpoch),
|
||||
InstanceMethod("setTime", &QDateTimeWrap::setTime),
|
||||
InstanceMethod("setTimeSpec", &QDateTimeWrap::setTimeSpec),
|
||||
InstanceMethod("time", &QDateTimeWrap::time),
|
||||
InstanceMethod("timeSpec", &QDateTimeWrap::timeSpec),
|
||||
InstanceMethod("toLocalTime", &QDateTimeWrap::toLocalTime),
|
||||
InstanceMethod("toMSecsSinceEpoch", &QDateTimeWrap::toMSecsSinceEpoch),
|
||||
InstanceMethod("toOffsetFromUtc", &QDateTimeWrap::toOffsetFromUtc),
|
||||
InstanceMethod("toSecsSinceEpoch", &QDateTimeWrap::toSecsSinceEpoch),
|
||||
InstanceMethod("toString$", &QDateTimeWrap::toString),
|
||||
InstanceMethod("toTimeSpec", &QDateTimeWrap::toTimeSpec),
|
||||
InstanceMethod("toUTC", &QDateTimeWrap::toUTC),
|
||||
StaticMethod("currentDateTime",
|
||||
&StaticDateTimeWrapMethods::currentDateTime),
|
||||
StaticMethod("currentDateTimeUtc",
|
||||
&StaticDateTimeWrapMethods::currentDateTimeUtc),
|
||||
StaticMethod("currentMSecsSinceEpoch",
|
||||
&StaticDateTimeWrapMethods::currentMSecsSinceEpoch),
|
||||
StaticMethod("currentSecsSinceEpoch",
|
||||
&StaticDateTimeWrapMethods::currentSecsSinceEpoch),
|
||||
StaticMethod("fromQVariant", &StaticDateTimeWrapMethods::fromQVariant),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QDateTimeWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
}
|
||||
|
||||
QDateTimeWrap::QDateTimeWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QDateTimeWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
if (info.Length() == 2) {
|
||||
Napi::Object dateObject = info[0].As<Napi::Object>();
|
||||
Napi::Object timeObject = info[1].As<Napi::Object>();
|
||||
QDateWrap* dateWrap = Napi::ObjectWrap<QDateWrap>::Unwrap(dateObject);
|
||||
QTimeWrap* timeWrap = Napi::ObjectWrap<QTimeWrap>::Unwrap(timeObject);
|
||||
this->instance = std::make_unique<QDateTime>(
|
||||
*dateWrap->getInternalInstance(), *timeWrap->getInternalInstance());
|
||||
} else if (info.Length() == 1) {
|
||||
this->instance = std::unique_ptr<QDateTime>(
|
||||
info[0].As<Napi::External<QDateTime>>().Data());
|
||||
} else if (info.Length() == 0) {
|
||||
this->instance = std::make_unique<QDateTime>();
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureComponent(this->getInternalInstance());
|
||||
}
|
||||
|
||||
QDateTimeWrap::~QDateTimeWrap() { this->instance.reset(); }
|
||||
|
||||
QDateTime* QDateTimeWrap::getInternalInstance() { return this->instance.get(); }
|
||||
|
||||
Napi::Value QDateTimeWrap::addDays(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
qint64 ndays = info[0].As<Napi::Number>().Int64Value();
|
||||
QDateTime result = this->instance->addDays(ndays);
|
||||
auto instance = QDateTimeWrap::constructor.New(
|
||||
{Napi::External<QDateTime>::New(env, new QDateTime(result))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::addMSecs(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
qint64 msecs = info[0].As<Napi::Number>().Int64Value();
|
||||
QDateTime result = this->instance->addMSecs(msecs);
|
||||
auto instance = QDateTimeWrap::constructor.New(
|
||||
{Napi::External<QDateTime>::New(env, new QDateTime(result))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::addMonths(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
int nmonths = info[0].As<Napi::Number>().Int32Value();
|
||||
QDateTime result = this->instance->addMonths(nmonths);
|
||||
auto instance = QDateTimeWrap::constructor.New(
|
||||
{Napi::External<QDateTime>::New(env, new QDateTime(result))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::addSecs(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
qint64 s = info[0].As<Napi::Number>().Int64Value();
|
||||
QDateTime result = this->instance->addSecs(s);
|
||||
auto instance = QDateTimeWrap::constructor.New(
|
||||
{Napi::External<QDateTime>::New(env, new QDateTime(result))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::addYears(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
int nyears = info[0].As<Napi::Number>().Int32Value();
|
||||
QDateTime result = this->instance->addYears(nyears);
|
||||
auto instance = QDateTimeWrap::constructor.New(
|
||||
{Napi::External<QDateTime>::New(env, new QDateTime(result))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::date(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
QDate date = this->instance->date();
|
||||
auto instance = QDateWrap::constructor.New({Napi::External<QDate>::New(
|
||||
env, new QDate(date.year(), date.month(), date.day()))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::daysTo(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
Napi::Object otherObject = info[0].As<Napi::Object>();
|
||||
QDateTimeWrap* otherWrap =
|
||||
Napi::ObjectWrap<QDateTimeWrap>::Unwrap(otherObject);
|
||||
qint64 result = this->instance->daysTo(*otherWrap->getInternalInstance());
|
||||
return Napi::Value::From(env, result);
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::isDaylightTime(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->isDaylightTime());
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::isNull(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->isNull());
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::isValid(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->isValid());
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::msecsTo(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
Napi::Object otherObject = info[0].As<Napi::Object>();
|
||||
QDateTimeWrap* otherWrap =
|
||||
Napi::ObjectWrap<QDateTimeWrap>::Unwrap(otherObject);
|
||||
qint64 result = this->instance->msecsTo(*otherWrap->getInternalInstance());
|
||||
return Napi::Value::From(env, result);
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::offsetFromUtc(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->offsetFromUtc());
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::secsTo(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
Napi::Object otherObject = info[0].As<Napi::Object>();
|
||||
QDateTimeWrap* otherWrap =
|
||||
Napi::ObjectWrap<QDateTimeWrap>::Unwrap(otherObject);
|
||||
qint64 result = this->instance->secsTo(*otherWrap->getInternalInstance());
|
||||
return Napi::Value::From(env, result);
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::setDate(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
Napi::Object dateObject = info[0].As<Napi::Object>();
|
||||
QDateWrap* dateWrap = Napi::ObjectWrap<QDateWrap>::Unwrap(dateObject);
|
||||
this->instance->setDate(*dateWrap->getInternalInstance());
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::setMSecsSinceEpoch(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
qint64 msecs = info[0].As<Napi::Number>().Int64Value();
|
||||
this->instance->setMSecsSinceEpoch(msecs);
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::setOffsetFromUtc(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
int offsetSeconds = info[0].As<Napi::Number>().Int32Value();
|
||||
this->instance->setOffsetFromUtc(offsetSeconds);
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::setSecsSinceEpoch(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
qint64 secs = info[0].As<Napi::Number>().Int64Value();
|
||||
this->instance->setSecsSinceEpoch(secs);
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::setTime(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
Napi::Object timeObject = info[0].As<Napi::Object>();
|
||||
QTimeWrap* timeWrap = Napi::ObjectWrap<QTimeWrap>::Unwrap(timeObject);
|
||||
this->instance->setTime(*timeWrap->getInternalInstance());
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::setTimeSpec(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
int spec = info[0].As<Napi::Number>().Int32Value();
|
||||
this->instance->setTimeSpec(static_cast<Qt::TimeSpec>(spec));
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::time(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
QTime time = this->instance->time();
|
||||
auto instance = QTimeWrap::constructor.New({Napi::External<QTime>::New(
|
||||
env, new QTime(time.hour(), time.minute(), time.second(), time.msec()))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::timeSpec(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
Qt::TimeSpec spec = this->instance->timeSpec();
|
||||
return Napi::Value::From(env, static_cast<int>(spec));
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::toLocalTime(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
QDateTime local = this->instance->toLocalTime();
|
||||
auto instance = QDateTimeWrap::constructor.New(
|
||||
{Napi::External<QDateTime>::New(env, new QDateTime(local))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::toMSecsSinceEpoch(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->toMSecsSinceEpoch());
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::toOffsetFromUtc(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
int offsetSeconds = info[0].As<Napi::Number>().Int32Value();
|
||||
QDateTime result = this->instance->toOffsetFromUtc(offsetSeconds);
|
||||
auto instance = QDateTimeWrap::constructor.New(
|
||||
{Napi::External<QDateTime>::New(env, new QDateTime(result))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::toSecsSinceEpoch(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->toSecsSinceEpoch());
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::toString(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
QString result;
|
||||
if (info[0].IsString()) {
|
||||
std::string format = info[0].As<Napi::String>().Utf8Value();
|
||||
result = this->instance->toString(QString::fromUtf8(format.c_str()));
|
||||
} else {
|
||||
int format = info[0].As<Napi::Number>().Int32Value();
|
||||
result = this->instance->toString(static_cast<Qt::DateFormat>(format));
|
||||
}
|
||||
|
||||
return Napi::String::New(env, result.toStdString());
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::toTimeSpec(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
int spec = info[0].As<Napi::Number>().Int32Value();
|
||||
QDateTime result =
|
||||
this->instance->toTimeSpec(static_cast<Qt::TimeSpec>(spec));
|
||||
auto instance = QDateTimeWrap::constructor.New(
|
||||
{Napi::External<QDateTime>::New(env, new QDateTime(result))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value QDateTimeWrap::toUTC(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
QDateTime result = this->instance->toUTC();
|
||||
auto instance = QDateTimeWrap::constructor.New(
|
||||
{Napi::External<QDateTime>::New(env, new QDateTime(result))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value StaticDateTimeWrapMethods::currentDateTime(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
QDateTime result = QDateTime::currentDateTime();
|
||||
auto instance = QDateTimeWrap::constructor.New(
|
||||
{Napi::External<QDateTime>::New(env, new QDateTime(result))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value StaticDateTimeWrapMethods::currentDateTimeUtc(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
QDateTime result = QDateTime::currentDateTimeUtc();
|
||||
auto instance = QDateTimeWrap::constructor.New(
|
||||
{Napi::External<QDateTime>::New(env, new QDateTime(result))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value StaticDateTimeWrapMethods::currentMSecsSinceEpoch(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, QDateTime::currentMSecsSinceEpoch());
|
||||
}
|
||||
|
||||
Napi::Value StaticDateTimeWrapMethods::currentSecsSinceEpoch(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, QDateTime::currentSecsSinceEpoch());
|
||||
}
|
||||
|
||||
Napi::Value StaticDateTimeWrapMethods::fromQVariant(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
Napi::Object variantObject = info[0].As<Napi::Object>();
|
||||
QVariantWrap* variantWrap =
|
||||
Napi::ObjectWrap<QVariantWrap>::Unwrap(variantObject);
|
||||
QVariant* variant = variantWrap->getInternalInstance();
|
||||
QDateTime datetime = variant->value<QDateTime>();
|
||||
auto instance = QDateTimeWrap::constructor.New(
|
||||
{Napi::External<QDateTime>::New(env, new QDateTime(datetime))});
|
||||
return instance;
|
||||
}
|
||||
245
src/cpp/lib/QtCore/QTime/qtime_wrap.cpp
Normal file
245
src/cpp/lib/QtCore/QTime/qtime_wrap.cpp
Normal file
@ -0,0 +1,245 @@
|
||||
#include "QtCore/QTime/qtime_wrap.h"
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtCore/QVariant/qvariant_wrap.h"
|
||||
|
||||
Napi::FunctionReference QTimeWrap::constructor;
|
||||
|
||||
Napi::Object QTimeWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
Napi::HandleScope scope(env);
|
||||
char CLASSNAME[] = "QTime";
|
||||
Napi::Function func = DefineClass(
|
||||
env, CLASSNAME,
|
||||
{InstanceMethod("addMSecs", &QTimeWrap::addMSecs),
|
||||
InstanceMethod("addSecs", &QTimeWrap::addSecs),
|
||||
InstanceMethod("elapsed", &QTimeWrap::elapsed),
|
||||
InstanceMethod("hour", &QTimeWrap::hour),
|
||||
InstanceMethod("isNull", &QTimeWrap::isNull),
|
||||
InstanceMethod("isValid", &QTimeWrap::isValid),
|
||||
InstanceMethod("minute", &QTimeWrap::minute),
|
||||
InstanceMethod("msec", &QTimeWrap::msec),
|
||||
InstanceMethod("msecsSinceStartOfDay", &QTimeWrap::msecsSinceStartOfDay),
|
||||
InstanceMethod("msecsTo", &QTimeWrap::msecsTo),
|
||||
InstanceMethod("restart", &QTimeWrap::restart),
|
||||
InstanceMethod("second", &QTimeWrap::second),
|
||||
InstanceMethod("secsTo", &QTimeWrap::secsTo),
|
||||
InstanceMethod("setHMS", &QTimeWrap::setHMS),
|
||||
InstanceMethod("start", &QTimeWrap::start),
|
||||
InstanceMethod("toString$", &QTimeWrap::toString),
|
||||
StaticMethod("currentTime", &StaticTimeWrapMethods::currentTime),
|
||||
StaticMethod("fromMSecsSinceStartOfDay",
|
||||
&StaticTimeWrapMethods::fromMSecsSinceStartOfDay),
|
||||
StaticMethod("isValid", &StaticTimeWrapMethods::isValid),
|
||||
StaticMethod("fromQVariant", &StaticTimeWrapMethods::fromQVariant),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QTimeWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
}
|
||||
|
||||
QTimeWrap::QTimeWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QTimeWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
if (info.Length() == 4) {
|
||||
int h = info[0].As<Napi::Number>().Int32Value();
|
||||
int m = info[1].As<Napi::Number>().Int32Value();
|
||||
int s = info[2].As<Napi::Number>().Int32Value();
|
||||
int ms = info[3].As<Napi::Number>().Int32Value();
|
||||
this->instance = std::make_unique<QTime>(h, m, s, ms);
|
||||
} else if (info.Length() == 1) {
|
||||
this->instance =
|
||||
std::unique_ptr<QTime>(info[0].As<Napi::External<QTime>>().Data());
|
||||
} else if (info.Length() == 0) {
|
||||
this->instance = std::make_unique<QTime>();
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureComponent(this->getInternalInstance());
|
||||
}
|
||||
|
||||
QTimeWrap::~QTimeWrap() { this->instance.reset(); }
|
||||
|
||||
QTime* QTimeWrap::getInternalInstance() { return this->instance.get(); }
|
||||
|
||||
Napi::Value QTimeWrap::addMSecs(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
int ms = info[0].As<Napi::Number>().Int32Value();
|
||||
QTime time = this->instance->addMSecs(ms);
|
||||
auto instance = QTimeWrap::constructor.New({Napi::External<QTime>::New(
|
||||
env, new QTime(time.hour(), time.minute(), time.second(), time.msec()))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value QTimeWrap::addSecs(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
int s = info[0].As<Napi::Number>().Int32Value();
|
||||
QTime time = this->instance->addSecs(s);
|
||||
auto instance = QTimeWrap::constructor.New({Napi::External<QTime>::New(
|
||||
env, new QTime(time.hour(), time.minute(), time.second(), time.msec()))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value QTimeWrap::elapsed(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->elapsed());
|
||||
}
|
||||
|
||||
Napi::Value QTimeWrap::hour(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->hour());
|
||||
}
|
||||
|
||||
Napi::Value QTimeWrap::isNull(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->isNull());
|
||||
}
|
||||
|
||||
Napi::Value QTimeWrap::isValid(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->isValid());
|
||||
}
|
||||
|
||||
Napi::Value QTimeWrap::minute(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->minute());
|
||||
}
|
||||
|
||||
Napi::Value QTimeWrap::msec(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->msec());
|
||||
}
|
||||
|
||||
Napi::Value QTimeWrap::msecsSinceStartOfDay(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->msecsSinceStartOfDay());
|
||||
}
|
||||
|
||||
Napi::Value QTimeWrap::msecsTo(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
Napi::Object tObject = info[0].As<Napi::Object>();
|
||||
QTimeWrap* tWrap = Napi::ObjectWrap<QTimeWrap>::Unwrap(tObject);
|
||||
int result = this->instance->msecsTo(*tWrap->getInternalInstance());
|
||||
return Napi::Value::From(env, result);
|
||||
}
|
||||
|
||||
Napi::Value QTimeWrap::restart(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
int result = this->instance->restart();
|
||||
return Napi::Value::From(env, result);
|
||||
}
|
||||
|
||||
Napi::Value QTimeWrap::second(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->second());
|
||||
}
|
||||
|
||||
Napi::Value QTimeWrap::secsTo(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
Napi::Object tObject = info[0].As<Napi::Object>();
|
||||
QTimeWrap* tWrap = Napi::ObjectWrap<QTimeWrap>::Unwrap(tObject);
|
||||
int result = this->instance->secsTo(*tWrap->getInternalInstance());
|
||||
return Napi::Value::From(env, result);
|
||||
}
|
||||
|
||||
Napi::Value QTimeWrap::setHMS(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
int h = info[0].As<Napi::Number>().Int32Value();
|
||||
int m = info[1].As<Napi::Number>().Int32Value();
|
||||
int s = info[2].As<Napi::Number>().Int32Value();
|
||||
int ms = info[3].As<Napi::Number>().Int32Value();
|
||||
bool result = this->instance->setHMS(h, m, s, ms);
|
||||
return Napi::Value::From(env, result);
|
||||
}
|
||||
|
||||
Napi::Value QTimeWrap::start(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->instance->start();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QTimeWrap::toString(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
QString result;
|
||||
if (info[0].IsString()) {
|
||||
std::string format = info[0].As<Napi::String>().Utf8Value();
|
||||
result = this->instance->toString(QString::fromUtf8(format.c_str()));
|
||||
} else {
|
||||
int format = info[0].As<Napi::Number>().Int32Value();
|
||||
result = this->instance->toString(static_cast<Qt::DateFormat>(format));
|
||||
}
|
||||
|
||||
return Napi::String::New(env, result.toStdString());
|
||||
}
|
||||
|
||||
Napi::Value StaticTimeWrapMethods::currentTime(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
QTime time = QTime::currentTime();
|
||||
auto instance = QTimeWrap::constructor.New({Napi::External<QTime>::New(
|
||||
env, new QTime(time.hour(), time.minute(), time.second(), time.msec()))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value StaticTimeWrapMethods::fromMSecsSinceStartOfDay(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
int msecs = info[0].As<Napi::Number>().Int32Value();
|
||||
QTime time = QTime::fromMSecsSinceStartOfDay(msecs);
|
||||
auto instance = QTimeWrap::constructor.New({Napi::External<QTime>::New(
|
||||
env, new QTime(time.hour(), time.minute(), time.second(), time.msec()))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value StaticTimeWrapMethods::isValid(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
int h = info[0].As<Napi::Number>().Int32Value();
|
||||
int m = info[1].As<Napi::Number>().Int32Value();
|
||||
int s = info[2].As<Napi::Number>().Int32Value();
|
||||
int ms = info[3].As<Napi::Number>().Int32Value();
|
||||
|
||||
return Napi::Value::From(env, QTime::isValid(h, m, s, ms));
|
||||
}
|
||||
|
||||
Napi::Value StaticTimeWrapMethods::fromQVariant(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
Napi::Object variantObject = info[0].As<Napi::Object>();
|
||||
QVariantWrap* variantWrap =
|
||||
Napi::ObjectWrap<QVariantWrap>::Unwrap(variantObject);
|
||||
QVariant* variant = variantWrap->getInternalInstance();
|
||||
QTime time = variant->value<QTime>();
|
||||
auto instance = QTimeWrap::constructor.New({Napi::External<QTime>::New(
|
||||
env, new QTime(time.hour(), time.minute(), time.second(), time.msec()))});
|
||||
return instance;
|
||||
}
|
||||
131
src/cpp/lib/QtWidgets/QCalendarWidget/qcalendarwidget_wrap.cpp
Normal file
131
src/cpp/lib/QtWidgets/QCalendarWidget/qcalendarwidget_wrap.cpp
Normal file
@ -0,0 +1,131 @@
|
||||
#include "QtWidgets/QCalendarWidget/qcalendarwidget_wrap.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtGui/QIcon/qicon_wrap.h"
|
||||
#include "QtWidgets/QWidget/qwidget_wrap.h"
|
||||
|
||||
Napi::FunctionReference QCalendarWidgetWrap::constructor;
|
||||
|
||||
Napi::Object QCalendarWidgetWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
Napi::HandleScope scope(env);
|
||||
char CLASSNAME[] = "QCalendarWidget";
|
||||
Napi::Function func = DefineClass(
|
||||
env, CLASSNAME,
|
||||
{InstanceMethod("monthShown", &QCalendarWidgetWrap::monthShown),
|
||||
InstanceMethod("yearShown", &QCalendarWidgetWrap::yearShown),
|
||||
InstanceMethod("setCurrentPage", &QCalendarWidgetWrap::setCurrentPage),
|
||||
InstanceMethod("showNextMonth", &QCalendarWidgetWrap::showNextMonth),
|
||||
InstanceMethod("showNextYear", &QCalendarWidgetWrap::showNextYear),
|
||||
InstanceMethod("showPreviousMonth",
|
||||
&QCalendarWidgetWrap::showPreviousMonth),
|
||||
InstanceMethod("showPreviousYear",
|
||||
&QCalendarWidgetWrap::showPreviousYear),
|
||||
InstanceMethod("showSelectedDate",
|
||||
&QCalendarWidgetWrap::showSelectedDate),
|
||||
InstanceMethod("showToday", &QCalendarWidgetWrap::showToday),
|
||||
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QCalendarWidgetWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NCalendarWidget *QCalendarWidgetWrap::getInternalInstance() {
|
||||
return this->instance;
|
||||
}
|
||||
|
||||
QCalendarWidgetWrap::~QCalendarWidgetWrap() {
|
||||
extrautils::safeDelete(this->instance);
|
||||
}
|
||||
|
||||
QCalendarWidgetWrap::QCalendarWidgetWrap(const Napi::CallbackInfo &info)
|
||||
: Napi::ObjectWrap<QCalendarWidgetWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
QWidgetWrap *parentWidgetWrap =
|
||||
Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NCalendarWidget(
|
||||
parentWidgetWrap
|
||||
->getInternalInstance()); // this sets the parent to current widget
|
||||
} else if (info.Length() == 0) {
|
||||
this->instance = new NCalendarWidget();
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureQWidget(
|
||||
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
|
||||
true);
|
||||
}
|
||||
|
||||
Napi::Value QCalendarWidgetWrap::monthShown(const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->monthShown());
|
||||
}
|
||||
|
||||
Napi::Value QCalendarWidgetWrap::yearShown(const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
return Napi::Value::From(env, this->instance->yearShown());
|
||||
}
|
||||
|
||||
Napi::Value QCalendarWidgetWrap::setCurrentPage(
|
||||
const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
int year = info[0].As<Napi::Number>().Int32Value();
|
||||
int month = info[1].As<Napi::Number>().Int32Value();
|
||||
this->instance->setCurrentPage(year, month);
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QCalendarWidgetWrap::showNextMonth(const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->instance->showNextMonth();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QCalendarWidgetWrap::showNextYear(const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->instance->showNextYear();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QCalendarWidgetWrap::showPreviousMonth(
|
||||
const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->instance->showPreviousMonth();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QCalendarWidgetWrap::showPreviousYear(
|
||||
const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->instance->showPreviousYear();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QCalendarWidgetWrap::showSelectedDate(
|
||||
const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->instance->showSelectedDate();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QCalendarWidgetWrap::showToday(const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->instance->showToday();
|
||||
return env.Null();
|
||||
}
|
||||
41
src/cpp/lib/QtWidgets/QDateEdit/qdateedit_wrap.cpp
Normal file
41
src/cpp/lib/QtWidgets/QDateEdit/qdateedit_wrap.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include "QtWidgets/QDateEdit/qdateedit_wrap.h"
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
|
||||
Napi::FunctionReference QDateEditWrap::constructor;
|
||||
|
||||
Napi::Object QDateEditWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
Napi::HandleScope scope(env);
|
||||
char CLASSNAME[] = "QDateEdit";
|
||||
Napi::Function func =
|
||||
DefineClass(env, CLASSNAME,
|
||||
{QDATETIMEEDIT_WRAPPED_METHODS_EXPORT_DEFINE(QDateEditWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NDateEdit* QDateEditWrap::getInternalInstance() { return this->instance; }
|
||||
|
||||
QDateEditWrap::QDateEditWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QDateEditWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
QWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NDateEdit(parentWidgetWrap->getInternalInstance());
|
||||
} else if (info.Length() == 0) {
|
||||
this->instance = new NDateEdit();
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureQWidget(
|
||||
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
|
||||
true);
|
||||
}
|
||||
|
||||
QDateEditWrap::~QDateEditWrap() { extrautils::safeDelete(this->instance); }
|
||||
45
src/cpp/lib/QtWidgets/QDateTimeEdit/qdatetimeedit_wrap.cpp
Normal file
45
src/cpp/lib/QtWidgets/QDateTimeEdit/qdatetimeedit_wrap.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
#include "QtWidgets/QDateTimeEdit/qdatetimeedit_wrap.h"
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
|
||||
Napi::FunctionReference QDateTimeEditWrap::constructor;
|
||||
|
||||
Napi::Object QDateTimeEditWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
Napi::HandleScope scope(env);
|
||||
char CLASSNAME[] = "QDateTimeEdit";
|
||||
Napi::Function func = DefineClass(
|
||||
env, CLASSNAME,
|
||||
{QDATETIMEEDIT_WRAPPED_METHODS_EXPORT_DEFINE(QDateTimeEditWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NDateTimeEdit* QDateTimeEditWrap::getInternalInstance() {
|
||||
return this->instance;
|
||||
}
|
||||
|
||||
QDateTimeEditWrap::QDateTimeEditWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QDateTimeEditWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
QWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NDateTimeEdit(parentWidgetWrap->getInternalInstance());
|
||||
} else if (info.Length() == 0) {
|
||||
this->instance = new NDateTimeEdit();
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureQWidget(
|
||||
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
|
||||
true);
|
||||
}
|
||||
|
||||
QDateTimeEditWrap::~QDateTimeEditWrap() {
|
||||
extrautils::safeDelete(this->instance);
|
||||
}
|
||||
41
src/cpp/lib/QtWidgets/QTimeEdit/qtimeedit_wrap.cpp
Normal file
41
src/cpp/lib/QtWidgets/QTimeEdit/qtimeedit_wrap.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include "QtWidgets/QTimeEdit/qtimeedit_wrap.h"
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
|
||||
Napi::FunctionReference QTimeEditWrap::constructor;
|
||||
|
||||
Napi::Object QTimeEditWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
Napi::HandleScope scope(env);
|
||||
char CLASSNAME[] = "QTimeEdit";
|
||||
Napi::Function func =
|
||||
DefineClass(env, CLASSNAME,
|
||||
{QDATETIMEEDIT_WRAPPED_METHODS_EXPORT_DEFINE(QTimeEditWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NTimeEdit* QTimeEditWrap::getInternalInstance() { return this->instance; }
|
||||
|
||||
QTimeEditWrap::QTimeEditWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QTimeEditWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
QWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NTimeEdit(parentWidgetWrap->getInternalInstance());
|
||||
} else if (info.Length() == 0) {
|
||||
this->instance = new NTimeEdit();
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureQWidget(
|
||||
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
|
||||
true);
|
||||
}
|
||||
|
||||
QTimeEditWrap::~QTimeEditWrap() { extrautils::safeDelete(this->instance); }
|
||||
@ -1,11 +1,14 @@
|
||||
#include <napi.h>
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtCore/QDate/qdate_wrap.h"
|
||||
#include "QtCore/QDateTime/qdatetime_wrap.h"
|
||||
#include "QtCore/QModelIndex/qmodelindex_wrap.h"
|
||||
#include "QtCore/QObject/qobject_wrap.h"
|
||||
#include "QtCore/QPoint/qpoint_wrap.h"
|
||||
#include "QtCore/QRect/qrect_wrap.h"
|
||||
#include "QtCore/QSize/qsize_wrap.h"
|
||||
#include "QtCore/QTime/qtime_wrap.h"
|
||||
#include "QtCore/QUrl/qurl_wrap.h"
|
||||
#include "QtCore/QVariant/qvariant_wrap.h"
|
||||
#include "QtGui/QApplication/qapplication_wrap.h"
|
||||
@ -23,8 +26,11 @@
|
||||
#include "QtGui/QStyle/qstyle_wrap.h"
|
||||
#include "QtWidgets/QAction/qaction_wrap.h"
|
||||
#include "QtWidgets/QBoxLayout/qboxlayout_wrap.h"
|
||||
#include "QtWidgets/QCalendarWidget/qcalendarwidget_wrap.h"
|
||||
#include "QtWidgets/QCheckBox/qcheckbox_wrap.h"
|
||||
#include "QtWidgets/QComboBox/qcombobox_wrap.h"
|
||||
#include "QtWidgets/QDateEdit/qdateedit_wrap.h"
|
||||
#include "QtWidgets/QDateTimeEdit/qdatetimeedit_wrap.h"
|
||||
#include "QtWidgets/QDial/qdial_wrap.h"
|
||||
#include "QtWidgets/QDialog/qdialog_wrap.h"
|
||||
#include "QtWidgets/QFileDialog/qfiledialog_wrap.h"
|
||||
@ -52,6 +58,7 @@
|
||||
#include "QtWidgets/QTabWidget/qtabwidget_wrap.h"
|
||||
#include "QtWidgets/QTableWidget/qtablewidget_wrap.h"
|
||||
#include "QtWidgets/QTableWidgetItem/qtablewidgetitem_wrap.h"
|
||||
#include "QtWidgets/QTimeEdit/qtimeedit_wrap.h"
|
||||
#include "QtWidgets/QToolButton/qtoolbutton_wrap.h"
|
||||
#include "QtWidgets/QTreeWidget/qtreewidget_wrap.h"
|
||||
#include "QtWidgets/QTreeWidgetItem/qtreewidgetitem_wrap.h"
|
||||
@ -67,14 +74,17 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
|
||||
InitPrivateHelpers(env);
|
||||
NUtilsWrap::init(env, exports);
|
||||
QApplicationWrap::init(env, exports);
|
||||
QDateWrap::init(env, exports);
|
||||
QDateTimeWrap::init(env, exports);
|
||||
QModelIndexWrap::init(env, exports);
|
||||
QObjectWrap::init(env, exports);
|
||||
QVariantWrap::init(env, exports);
|
||||
QSizeWrap::init(env, exports);
|
||||
QRectWrap::init(env, exports);
|
||||
QPointWrap::init(env, exports);
|
||||
QColorWrap::init(env, exports);
|
||||
QRectWrap::init(env, exports);
|
||||
QSizeWrap::init(env, exports);
|
||||
QTimeWrap::init(env, exports);
|
||||
QUrlWrap::init(env, exports);
|
||||
QVariantWrap::init(env, exports);
|
||||
QColorWrap::init(env, exports);
|
||||
QClipboardWrap::init(env, exports);
|
||||
QDialogWrap::init(env, exports);
|
||||
QWidgetWrap::init(env, exports);
|
||||
@ -86,8 +96,11 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
|
||||
QMovieWrap::init(env, exports);
|
||||
QStyleWrap::init(env, exports);
|
||||
QCursorWrap::init(env, exports);
|
||||
QCalendarWidgetWrap::init(env, exports);
|
||||
QComboBoxWrap::init(env, exports);
|
||||
QBoxLayoutWrap::init(env, exports);
|
||||
QDateEditWrap::init(env, exports);
|
||||
QDateTimeEditWrap::init(env, exports);
|
||||
QFileDialogWrap::init(env, exports);
|
||||
QListWidgetWrap::init(env, exports);
|
||||
QListWidgetItemWrap::init(env, exports);
|
||||
@ -121,6 +134,7 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
|
||||
QMenuWrap::init(env, exports);
|
||||
QMenuBarWrap::init(env, exports);
|
||||
QMessageBoxWrap::init(env, exports);
|
||||
QTimeEditWrap::init(env, exports);
|
||||
return exports;
|
||||
}
|
||||
|
||||
|
||||
22
src/demo.ts
22
src/demo.ts
@ -2,6 +2,11 @@ import { FlexLayout, QMainWindow, QWidget } from './index';
|
||||
import { QLabel } from './lib/QtWidgets/QLabel';
|
||||
import { QFont, QFontCapitalization } from './lib/QtGui/QFont';
|
||||
import { QPushButton } from './lib/QtWidgets/QPushButton';
|
||||
import { QDateTimeEdit } from './lib/QtWidgets/QDateTimeEdit';
|
||||
import { QCalendarWidget } from './lib/QtWidgets/QCalendarWidget';
|
||||
import { QDate } from './lib/QtCore/QDate';
|
||||
import { QDateTime } from './lib/QtCore/QDateTime';
|
||||
import { QTime } from './lib/QtCore/QTime';
|
||||
|
||||
const win = new QMainWindow();
|
||||
const center = new QWidget();
|
||||
@ -22,8 +27,25 @@ btn.addEventListener('clicked', () => {
|
||||
console.log('point', font2.pointSize());
|
||||
label.setFont(font2);
|
||||
});
|
||||
const dtEdit = new QDateTimeEdit();
|
||||
const calendar = new QCalendarWidget();
|
||||
const date = QDate.currentDate();
|
||||
const time = QTime.currentTime();
|
||||
const datetime = QDateTime.currentDateTime();
|
||||
const strDate = date.toString('dd.MM.yyyy');
|
||||
const strTime = time.toString('hh:mm:ss.zzz');
|
||||
const strDt = datetime.toString('dd.MM.yyyy hh:mm:ss.zzz');
|
||||
console.log(strDate);
|
||||
console.log(strTime);
|
||||
console.log(strDt);
|
||||
dtEdit.setDate(date);
|
||||
dtEdit.setTime(time);
|
||||
dtEdit.setCalendarPopup(true);
|
||||
dtEdit.setCalendarWidget(calendar);
|
||||
|
||||
layout.addWidget(label);
|
||||
layout.addWidget(btn);
|
||||
layout.addWidget(dtEdit);
|
||||
|
||||
win.setCentralWidget(center);
|
||||
win.resize(400, 400);
|
||||
|
||||
@ -25,8 +25,12 @@ export { QAbstractScrollArea } from './lib/QtWidgets/QAbstractScrollArea';
|
||||
export { QAbstractSlider, QAbstractSliderSignals } from './lib/QtWidgets/QAbstractSlider';
|
||||
export { QAbstractButton, QAbstractButtonSignals } from './lib/QtWidgets/QAbstractButton';
|
||||
export { QAbstractItemView, QAbstractItemViewSignals } from './lib/QtWidgets/QAbstractItemView';
|
||||
export { QAbstractSpinBox } from './lib/QtWidgets/QAbstractSpinBox';
|
||||
// Widgets:
|
||||
export { QCalendarWidget, QCalendarWidgetSignals } from './lib/QtWidgets/QCalendarWidget';
|
||||
export { QCheckBox, QCheckBoxSignals } from './lib/QtWidgets/QCheckBox';
|
||||
export { QDateEdit } from './lib/QtWidgets/QDateEdit';
|
||||
export { QDateTimeEdit, QDateTimeEditSignals } from './lib/QtWidgets/QDateTimeEdit';
|
||||
export { QLabel, QLabelSignals } from './lib/QtWidgets/QLabel';
|
||||
export { QDial, QDialSignals } from './lib/QtWidgets/QDial';
|
||||
export { QFileDialog, QFileDialogSignals } from './lib/QtWidgets/QFileDialog';
|
||||
@ -48,6 +52,7 @@ export { QMenu, QMenuSignals } from './lib/QtWidgets/QMenu';
|
||||
export { QMenuBar, QMenuBarSignals } from './lib/QtWidgets/QMenuBar';
|
||||
export { QPlainTextEdit, QPlainTextEditSignals, LineWrapMode } from './lib/QtWidgets/QPlainTextEdit';
|
||||
export { QScrollArea, QScrollAreaSignals } from './lib/QtWidgets/QScrollArea';
|
||||
export { QTimeEdit } from './lib/QtWidgets/QTimeEdit';
|
||||
export { QTreeWidget, QTreeWidgetSignals } from './lib/QtWidgets/QTreeWidget';
|
||||
export { QTreeWidgetItem } from './lib/QtWidgets/QTreeWidgetItem';
|
||||
export { QPainter, RenderHint } from './lib/QtWidgets/QPainter';
|
||||
@ -63,6 +68,8 @@ export { QAction, QActionSignals } from './lib/QtWidgets/QAction';
|
||||
export { QShortcut, QShortcutSignals } from './lib/QtWidgets/QShortcut';
|
||||
export { QGroupBox, QGroupBoxSignals } from './lib/QtWidgets/QGroupBox';
|
||||
// Core
|
||||
export { QDate } from './lib/QtCore/QDate';
|
||||
export { QDateTime } from './lib/QtCore/QDateTime';
|
||||
export { QModelIndex } from './lib/QtCore/QModelIndex';
|
||||
export { QObject, QObjectSignals, NodeObject } from './lib/QtCore/QObject';
|
||||
export { QVariant } from './lib/QtCore/QVariant';
|
||||
@ -70,6 +77,7 @@ export { QSize } from './lib/QtCore/QSize';
|
||||
export { QRect } from './lib/QtCore/QRect';
|
||||
export { QPoint } from './lib/QtCore/QPoint';
|
||||
export { QColor } from './lib/QtGui/QColor';
|
||||
export { QTime } from './lib/QtCore/QTime';
|
||||
export { QUrl, ParsingMode } from './lib/QtCore/QUrl';
|
||||
// Layouts:
|
||||
export { QBoxLayout, QBoxLayoutSignals } from './lib/QtWidgets/QBoxLayout';
|
||||
|
||||
83
src/lib/QtCore/QDate.ts
Normal file
83
src/lib/QtCore/QDate.ts
Normal file
@ -0,0 +1,83 @@
|
||||
import addon from '../utils/addon';
|
||||
import { checkIfNativeElement } from '../utils/helpers';
|
||||
import { NativeElement, Component } from '../core/Component';
|
||||
import { QVariant } from './QVariant';
|
||||
import { DateFormat } from '../QtEnums';
|
||||
|
||||
export class QDate extends Component {
|
||||
native: NativeElement;
|
||||
constructor(arg?: NativeElement | number, month?: number, day?: number) {
|
||||
super();
|
||||
const count = arguments.length;
|
||||
if (count == 3) {
|
||||
this.native = new addon.QDate(arg, month, day);
|
||||
} else if (count == 1 && checkIfNativeElement(arg)) {
|
||||
this.native = arg as NativeElement;
|
||||
} else {
|
||||
this.native = new addon.QDate();
|
||||
}
|
||||
}
|
||||
addDays(ndays: number): QDate {
|
||||
return new QDate(this.native.addDays(ndays));
|
||||
}
|
||||
addMonths(nmonths: number): QDate {
|
||||
return new QDate(this.native.addMonths(nmonths));
|
||||
}
|
||||
addYears(nyears: number): QDate {
|
||||
return new QDate(this.native.addYears(nyears));
|
||||
}
|
||||
day(): number {
|
||||
return this.native.day();
|
||||
}
|
||||
dayOfWeek(): number {
|
||||
return this.native.dayOfWeek();
|
||||
}
|
||||
dayOfYear(): number {
|
||||
return this.native.dayOfYear();
|
||||
}
|
||||
daysInMonth(): number {
|
||||
return this.native.daysInMonth();
|
||||
}
|
||||
daysInYear(): number {
|
||||
return this.native.daysInYear();
|
||||
}
|
||||
daysTo(d: QDate): number {
|
||||
return this.native.daysTo(d.native);
|
||||
}
|
||||
isNull(): boolean {
|
||||
return this.native.isNull();
|
||||
}
|
||||
isValid(): boolean {
|
||||
return this.native.isValid();
|
||||
}
|
||||
month(): number {
|
||||
return this.native.month();
|
||||
}
|
||||
setDate(year: number, month: number, day: number): boolean {
|
||||
return this.native.setDate(year, month, day);
|
||||
}
|
||||
toJulianDay(): number {
|
||||
return this.native.toJulianDay();
|
||||
}
|
||||
toString(format: string | DateFormat): string {
|
||||
return this.native.toString$(format);
|
||||
}
|
||||
year(): number {
|
||||
return this.native.year();
|
||||
}
|
||||
static currentDate(): QDate {
|
||||
return new QDate(addon.QDate.currentDate());
|
||||
}
|
||||
static fromJulianDay(jd: number): QDate {
|
||||
return new QDate(addon.QDate.fromJulianDay(jd));
|
||||
}
|
||||
static isLeapYear(year: number): boolean {
|
||||
return addon.QDate.isLeapYear(year);
|
||||
}
|
||||
static isValid(year: number, month: number, day: number): boolean {
|
||||
return addon.QDate.isValid(year, month, day);
|
||||
}
|
||||
static fromQVariant(variant: QVariant): QDate {
|
||||
return new QDate(addon.QDate.fromQVariant(variant.native));
|
||||
}
|
||||
}
|
||||
121
src/lib/QtCore/QDateTime.ts
Normal file
121
src/lib/QtCore/QDateTime.ts
Normal file
@ -0,0 +1,121 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NativeElement, Component } from '../core/Component';
|
||||
import { checkIfNativeElement } from '../utils/helpers';
|
||||
import { QVariant } from './QVariant';
|
||||
import { QDate } from './QDate';
|
||||
import { QTime } from './QTime';
|
||||
import { TimeSpec, DateFormat } from '../QtEnums';
|
||||
|
||||
export class QDateTime extends Component {
|
||||
native: NativeElement;
|
||||
constructor(arg?: NativeElement, time?: NativeElement) {
|
||||
super();
|
||||
const count = arguments.length;
|
||||
if (arg && time) {
|
||||
this.native = new addon.QDateTime(arg.native, time.native);
|
||||
} else if (count == 1 && checkIfNativeElement(arg)) {
|
||||
this.native = arg as NativeElement;
|
||||
} else {
|
||||
this.native = new addon.QDateTime();
|
||||
}
|
||||
}
|
||||
addDays(ndays: number): QDateTime {
|
||||
return new QDateTime(this.native.addDays(ndays));
|
||||
}
|
||||
addMSecs(msecs: number): QDateTime {
|
||||
return new QDateTime(this.native.addMSecs(msecs));
|
||||
}
|
||||
addMonths(nmonths: number): QDateTime {
|
||||
return new QDateTime(this.native.addMonths(nmonths));
|
||||
}
|
||||
addSecs(s: number): QDateTime {
|
||||
return new QDateTime(this.native.addSecs(s));
|
||||
}
|
||||
addYears(nyears: number): QDateTime {
|
||||
return new QDateTime(this.native.addYears(nyears));
|
||||
}
|
||||
date(): QDate {
|
||||
return new QDate(this.native.date());
|
||||
}
|
||||
daysTo(other: QDateTime): number {
|
||||
return this.native.daysTo(other.native);
|
||||
}
|
||||
isDaylightTime(): boolean {
|
||||
return this.native.isDaylightTime();
|
||||
}
|
||||
isNull(): boolean {
|
||||
return this.native.isNull();
|
||||
}
|
||||
isValid(): boolean {
|
||||
return this.native.isValid();
|
||||
}
|
||||
msecsTo(other: QDateTime): number {
|
||||
return this.native.msecsTo(other.native);
|
||||
}
|
||||
offsetFromUtc(): number {
|
||||
return this.native.offsetFromUtc();
|
||||
}
|
||||
secsTo(other: QDateTime): number {
|
||||
return this.native.secsTo(other.native);
|
||||
}
|
||||
setDate(date: QDate): void {
|
||||
this.native.setDate(date.native);
|
||||
}
|
||||
setMSecsSinceEpoch(msecs: number): void {
|
||||
this.native.setMSecsSinceEpoch(msecs);
|
||||
}
|
||||
setOffsetFromUtc(offsetSeconds: number): void {
|
||||
this.native.setOffsetFromUtc(offsetSeconds);
|
||||
}
|
||||
setSecsSinceEpoch(secs: number): void {
|
||||
this.native.setSecsSinceEpoch(secs);
|
||||
}
|
||||
setTime(time: QTime): void {
|
||||
this.native.setTime(time.native);
|
||||
}
|
||||
setTimeSpec(spec: TimeSpec): void {
|
||||
this.native.setTimeSpec(spec);
|
||||
}
|
||||
time(): QTime {
|
||||
return new QTime(this.native.time());
|
||||
}
|
||||
timeSpec(): TimeSpec {
|
||||
return this.native.timeSpec();
|
||||
}
|
||||
toLocalTime(): QDateTime {
|
||||
return new QDateTime(this.native.toLocalTime());
|
||||
}
|
||||
toMSecsSinceEpoch(): number {
|
||||
return this.native.toMSecsSinceEpoch();
|
||||
}
|
||||
toOffsetFromUtc(offsetSeconds: number): QDateTime {
|
||||
return new QDateTime(this.native.toOffsetFromUtc(offsetSeconds));
|
||||
}
|
||||
toSecsSinceEpoch(): number {
|
||||
return this.native.toSecsSinceEpoch();
|
||||
}
|
||||
toString(format: string | DateFormat): string {
|
||||
return this.native.toString$(format);
|
||||
}
|
||||
toTimeSpec(spec: TimeSpec): QDateTime {
|
||||
return new QDateTime(this.native.toTimeSpec(spec));
|
||||
}
|
||||
toUTC(): QDateTime {
|
||||
return new QDateTime(this.native.toUTC());
|
||||
}
|
||||
static currentDateTime(): QDateTime {
|
||||
return new QDateTime(addon.QDateTime.currentDateTime());
|
||||
}
|
||||
static currentDateTimeUtc(): QDateTime {
|
||||
return new QDateTime(addon.QDateTime.currentDateTimeUtc());
|
||||
}
|
||||
static currentMSecsSinceEpoch(): number {
|
||||
return addon.QDateTime.currentMSecsSinceEpoch();
|
||||
}
|
||||
static currentSecsSinceEpoch(): number {
|
||||
return addon.QDateTime.currentSecsSinceEpoch();
|
||||
}
|
||||
static fromQVariant(variant: QVariant): QDateTime {
|
||||
return new QDateTime(addon.QDateTime.fromQVariant(variant.native));
|
||||
}
|
||||
}
|
||||
80
src/lib/QtCore/QTime.ts
Normal file
80
src/lib/QtCore/QTime.ts
Normal file
@ -0,0 +1,80 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NativeElement, Component } from '../core/Component';
|
||||
import { checkIfNativeElement } from '../utils/helpers';
|
||||
import { QVariant } from './QVariant';
|
||||
import { DateFormat } from '../QtEnums';
|
||||
|
||||
export class QTime extends Component {
|
||||
native: NativeElement;
|
||||
constructor(arg?: NativeElement | number, m?: number, s = 0, ms = 0) {
|
||||
super();
|
||||
const count = arguments.length;
|
||||
if (count > 1) {
|
||||
this.native = new addon.QTime(arg, m, s, ms);
|
||||
} else if (count == 1 && checkIfNativeElement(arg)) {
|
||||
this.native = arg as NativeElement;
|
||||
} else {
|
||||
this.native = new addon.QTime();
|
||||
}
|
||||
}
|
||||
addMSecs(ms: number): QTime {
|
||||
return new QTime(this.native.addMSecs(ms));
|
||||
}
|
||||
addSecs(s: number): QTime {
|
||||
return new QTime(this.native.addSecs(s));
|
||||
}
|
||||
elapsed(): number {
|
||||
return this.native.elapsed();
|
||||
}
|
||||
hour(): number {
|
||||
return this.native.hour();
|
||||
}
|
||||
isNull(): boolean {
|
||||
return this.native.isNull();
|
||||
}
|
||||
isValid(): boolean {
|
||||
return this.native.isValid();
|
||||
}
|
||||
minute(): number {
|
||||
return this.native.minute();
|
||||
}
|
||||
msec(): number {
|
||||
return this.native.msec();
|
||||
}
|
||||
msecsSinceStartOfDay(): number {
|
||||
return this.native.msecsSinceStartOfDay();
|
||||
}
|
||||
msecsTo(t: QTime): number {
|
||||
return this.native.msecsTo(t.native);
|
||||
}
|
||||
restart(): number {
|
||||
return this.native.restart();
|
||||
}
|
||||
second(): number {
|
||||
return this.native.second();
|
||||
}
|
||||
secsTo(t: QTime): number {
|
||||
return this.native.secsTo(t.native);
|
||||
}
|
||||
setHMS(h: number, m: number, s: number, ms = 0): boolean {
|
||||
return this.native.setHMS(h, m, s, ms);
|
||||
}
|
||||
start(): void {
|
||||
this.native.start();
|
||||
}
|
||||
toString(format: string | DateFormat): string {
|
||||
return this.native.toString$(format);
|
||||
}
|
||||
static currentTime(): QTime {
|
||||
return new QTime(addon.QTime.currentTime());
|
||||
}
|
||||
static fromMSecsSinceStartOfDay(msecs: number): QTime {
|
||||
return new QTime(addon.QTime.fromMSecsSinceStartOfDay(msecs));
|
||||
}
|
||||
static isValid(h: number, m: number, s: number, ms = 0): boolean {
|
||||
return addon.QTime.isValid(h, m, s, ms);
|
||||
}
|
||||
static fromQVariant(variant: QVariant): QTime {
|
||||
return new QTime(addon.QTime.fromQVariant(variant.native));
|
||||
}
|
||||
}
|
||||
95
src/lib/QtWidgets/QAbstractSpinBox.ts
Normal file
95
src/lib/QtWidgets/QAbstractSpinBox.ts
Normal file
@ -0,0 +1,95 @@
|
||||
import { NodeWidget, QWidgetSignals } from './QWidget';
|
||||
import { AlignmentFlag } from '../QtEnums';
|
||||
|
||||
export enum ButtonSymbols {
|
||||
UpDownArrows,
|
||||
PlusMinus,
|
||||
NoButtons,
|
||||
}
|
||||
|
||||
export enum CorrectionMode {
|
||||
CorrectToPreviousValue,
|
||||
CorrectToNearestValue,
|
||||
}
|
||||
|
||||
export interface QAbstractSpinBoxSignals extends QWidgetSignals {
|
||||
editingFinished: () => void;
|
||||
}
|
||||
|
||||
export abstract class QAbstractSpinBox<Signals extends QAbstractSpinBoxSignals> extends NodeWidget<Signals> {
|
||||
selectAll(): void {
|
||||
this.native.selectAll();
|
||||
}
|
||||
stepDown(): void {
|
||||
this.native.stepDown();
|
||||
}
|
||||
stepUp(): void {
|
||||
this.native.stepUp();
|
||||
}
|
||||
setAccelerated(on: boolean): void {
|
||||
this.setProperty('accelerated', on);
|
||||
}
|
||||
isAccelerated(): boolean {
|
||||
return this.property('accelerated').toBool();
|
||||
}
|
||||
hasAcceptableInput(): boolean {
|
||||
return this.property('acceptableInput').toBool();
|
||||
}
|
||||
setAlignment(alignment: AlignmentFlag): void {
|
||||
this.setProperty('alignment', alignment);
|
||||
}
|
||||
alignment(): AlignmentFlag {
|
||||
return this.property('alignment').toInt();
|
||||
}
|
||||
setButtonSymbols(bs: ButtonSymbols): void {
|
||||
this.setProperty('buttonSymbols', bs);
|
||||
}
|
||||
buttonSymbols(): ButtonSymbols {
|
||||
return this.property('buttonSymbols').toInt();
|
||||
}
|
||||
setCorrectionMode(cm: CorrectionMode): void {
|
||||
this.setProperty('correctionMode', cm);
|
||||
}
|
||||
correctionMode(): CorrectionMode {
|
||||
return this.property('correctionMode').toInt();
|
||||
}
|
||||
setFrame(enable: boolean): void {
|
||||
this.setProperty('frame', enable);
|
||||
}
|
||||
hasFrame(): boolean {
|
||||
return this.property('frame').toBool();
|
||||
}
|
||||
setKeyboardTracking(kt: boolean): void {
|
||||
this.setProperty('keyboardTracking', kt);
|
||||
}
|
||||
keyboardTracking(): boolean {
|
||||
return this.property('keyboardTracking').toBool();
|
||||
}
|
||||
setReadOnly(r: boolean): void {
|
||||
this.setProperty('readOnly', r);
|
||||
}
|
||||
isReadOnly(): boolean {
|
||||
return this.property('readOnly').toBool();
|
||||
}
|
||||
setGroupSeparatorShown(shown: boolean): void {
|
||||
this.setProperty('showGroupSeparator', shown);
|
||||
}
|
||||
isGroupSeparatorShown(): boolean {
|
||||
return this.property('showGroupSeparator').toBool();
|
||||
}
|
||||
setSpecialValueText(txt: string): void {
|
||||
this.setProperty('specialValueText', txt);
|
||||
}
|
||||
specialValueText(): string {
|
||||
return this.property('specialValueText').toString();
|
||||
}
|
||||
text(): string {
|
||||
return this.property('text').toString();
|
||||
}
|
||||
setWrapping(w: boolean): void {
|
||||
this.setProperty('wrapping', w);
|
||||
}
|
||||
wrapping(): boolean {
|
||||
return this.property('wrapping').toBool();
|
||||
}
|
||||
}
|
||||
94
src/lib/QtWidgets/QCalendarWidget.ts
Normal file
94
src/lib/QtWidgets/QCalendarWidget.ts
Normal file
@ -0,0 +1,94 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget, QWidgetSignals } from './QWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { QDate } from '../QtCore/QDate';
|
||||
import { DayOfWeek } from '../QtEnums';
|
||||
|
||||
export enum HorizontalHeaderFormat {
|
||||
NoHorizontalHeader,
|
||||
SingleLetterDayNames,
|
||||
ShortDayNames,
|
||||
LongDayNames,
|
||||
}
|
||||
|
||||
export enum VerticalHeaderFormat {
|
||||
NoVerticalHeader,
|
||||
ISOWeekNumbers,
|
||||
}
|
||||
|
||||
export enum SelectionMode {
|
||||
NoSelection,
|
||||
SingleSelection,
|
||||
}
|
||||
|
||||
export interface QCalendarWidgetSignals extends QWidgetSignals {
|
||||
activated: (date: QDate) => void;
|
||||
clicked: (date: QDate) => void;
|
||||
currentPageChanged: (year: number, month: number) => void;
|
||||
selectionChanged: () => void;
|
||||
}
|
||||
|
||||
export class QCalendarWidget extends NodeWidget<QCalendarWidgetSignals> {
|
||||
native: NativeElement;
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QCalendarWidget(parent.native);
|
||||
} else {
|
||||
native = new addon.QCalendarWidget();
|
||||
}
|
||||
super(native);
|
||||
this.native = native;
|
||||
this.setNodeParent(parent);
|
||||
}
|
||||
setDateEditAcceptDelay(delay: number): void {
|
||||
this.setProperty('dateEditAcceptDelay', delay);
|
||||
}
|
||||
dateEditAcceptDelay(): number {
|
||||
return this.property('dateEditAcceptDelay').toInt();
|
||||
}
|
||||
setDateEditEnabled(enable: boolean): void {
|
||||
this.setProperty('dateEditEnabled', enable);
|
||||
}
|
||||
isDateEditEnabled(): boolean {
|
||||
return this.property('dateEditEnabled').toBool();
|
||||
}
|
||||
setFirstDayOfWeek(dayOfWeek: DayOfWeek): void {
|
||||
this.setProperty('firstDayOfWeek', dayOfWeek);
|
||||
}
|
||||
firstDayOfWeek(): DayOfWeek {
|
||||
return this.property('firstDayOfWeek').toInt();
|
||||
}
|
||||
setGridVisible(show: boolean): void {
|
||||
this.setProperty('gridVisible', show);
|
||||
}
|
||||
isGridVisible(): boolean {
|
||||
return this.property('gridVisible').toBool();
|
||||
}
|
||||
setHorizontalHeaderFormat(format: HorizontalHeaderFormat): void {
|
||||
this.setProperty('horizontalHeaderFormat', format);
|
||||
}
|
||||
horizontalHeaderFormat(): HorizontalHeaderFormat {
|
||||
return this.property('horizontalHeaderFormat').toInt();
|
||||
}
|
||||
setNavigationBarVisible(visible: boolean): void {
|
||||
this.setProperty('navigationBarVisible', visible);
|
||||
}
|
||||
isNavigationBarVisible(): boolean {
|
||||
return this.property('navigationBarVisible').toBool();
|
||||
}
|
||||
setSelectionMode(mode: SelectionMode): void {
|
||||
this.setProperty('selectionMode', mode);
|
||||
}
|
||||
selectionMode(): SelectionMode {
|
||||
return this.property('selectionMode').toInt();
|
||||
}
|
||||
setVerticalHeaderFormat(format: VerticalHeaderFormat): void {
|
||||
this.setProperty('verticalHeaderFormat', format);
|
||||
}
|
||||
verticalHeaderFormat(): VerticalHeaderFormat {
|
||||
return this.property('verticalHeaderFormat').toInt();
|
||||
}
|
||||
}
|
||||
21
src/lib/QtWidgets/QDateEdit.ts
Normal file
21
src/lib/QtWidgets/QDateEdit.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { QDateTimeEdit } from './QDateTimeEdit';
|
||||
|
||||
export class QDateEdit extends QDateTimeEdit {
|
||||
native: NativeElement;
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QDateEdit(parent.native);
|
||||
} else {
|
||||
native = new addon.QDateEdit();
|
||||
}
|
||||
super(native);
|
||||
this.native = native;
|
||||
this.setNodeParent(parent);
|
||||
}
|
||||
}
|
||||
83
src/lib/QtWidgets/QDateTimeEdit.ts
Normal file
83
src/lib/QtWidgets/QDateTimeEdit.ts
Normal file
@ -0,0 +1,83 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { QAbstractSpinBox, QAbstractSpinBoxSignals } from './QAbstractSpinBox';
|
||||
import { QCalendarWidget } from './QCalendarWidget';
|
||||
import { QDate } from '../QtCore/QDate';
|
||||
import { QDateTime } from '../QtCore/QDateTime';
|
||||
import { QTime } from '../QtCore/QTime';
|
||||
import { TimeSpec } from '../QtEnums';
|
||||
|
||||
export interface QDateTimeEditSignals extends QAbstractSpinBoxSignals {
|
||||
dateChanged: (date: QDate) => void;
|
||||
dateTimeChanged: (datetime: QDateTime) => void;
|
||||
timeChanged: (time: QTime) => void;
|
||||
}
|
||||
|
||||
export class QDateTimeEdit extends QAbstractSpinBox<QDateTimeEditSignals> {
|
||||
native: NativeElement;
|
||||
calendar?: QCalendarWidget;
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QDateTimeEdit(parent.native);
|
||||
} else {
|
||||
native = new addon.QDateTimeEdit();
|
||||
}
|
||||
super(native);
|
||||
this.native = native;
|
||||
this.setNodeParent(parent);
|
||||
}
|
||||
setCalendarWidget(calendarWidget: QCalendarWidget): void {
|
||||
this.calendar = calendarWidget;
|
||||
this.native.setCalendarWidget(calendarWidget.native);
|
||||
}
|
||||
calendarWidget(): QCalendarWidget | null {
|
||||
const calendar = this.calendar;
|
||||
if (calendar) {
|
||||
return calendar;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
setCalendarPopup(enable: boolean): void {
|
||||
this.setProperty('calendarPopup', enable);
|
||||
}
|
||||
calendarPopup(): boolean {
|
||||
return this.property('calendarPopup').toBool();
|
||||
}
|
||||
setDate(date: QDate): void {
|
||||
this.setProperty('date', date.native);
|
||||
}
|
||||
date(): QDate {
|
||||
const date = this.property('date');
|
||||
return QDate.fromQVariant(date);
|
||||
}
|
||||
setDateTime(datetime: QDateTime): void {
|
||||
this.setProperty('dateTime', datetime.native);
|
||||
}
|
||||
dateTime(): QDateTime {
|
||||
const datetime = this.property('dateTime');
|
||||
return QDateTime.fromQVariant(datetime);
|
||||
}
|
||||
setDisplayFormat(format: string): void {
|
||||
this.setProperty('displayFormat', format);
|
||||
}
|
||||
displayFormat(): string {
|
||||
return this.property('displayFormat').toString();
|
||||
}
|
||||
setTime(time: QTime): void {
|
||||
this.setProperty('time', time.native);
|
||||
}
|
||||
time(): QTime {
|
||||
const time = this.property('time');
|
||||
return QTime.fromQVariant(time);
|
||||
}
|
||||
setTimeSpec(spec: TimeSpec): void {
|
||||
this.setProperty('timeSpec', spec);
|
||||
}
|
||||
timeSpec(): TimeSpec {
|
||||
return this.property('timeSpec').toInt();
|
||||
}
|
||||
}
|
||||
21
src/lib/QtWidgets/QTimeEdit.ts
Normal file
21
src/lib/QtWidgets/QTimeEdit.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NodeWidget } from './QWidget';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { QDateTimeEdit } from './QDateTimeEdit';
|
||||
|
||||
export class QTimeEdit extends QDateTimeEdit {
|
||||
native: NativeElement;
|
||||
constructor();
|
||||
constructor(parent: NodeWidget<any>);
|
||||
constructor(parent?: NodeWidget<any>) {
|
||||
let native;
|
||||
if (parent) {
|
||||
native = new addon.QTimeEdit(parent.native);
|
||||
} else {
|
||||
native = new addon.QTimeEdit();
|
||||
}
|
||||
super(native);
|
||||
this.native = native;
|
||||
this.setNodeParent(parent);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user