diff --git a/src/cpp/include/nodegui/QtWidgets/QHeaderView/qheaderview_wrap.h b/src/cpp/include/nodegui/QtWidgets/QHeaderView/qheaderview_wrap.h index ed9eb623e..522d68eb4 100644 --- a/src/cpp/include/nodegui/QtWidgets/QHeaderView/qheaderview_wrap.h +++ b/src/cpp/include/nodegui/QtWidgets/QHeaderView/qheaderview_wrap.h @@ -58,4 +58,63 @@ class DLL_EXPORT QHeaderViewWrap : public Napi::ObjectWrap { // class constructor static Napi::FunctionReference constructor; // wrapped methods + Napi::Value cascadingSectionResizes(const Napi::CallbackInfo& info); + Napi::Value count(const Napi::CallbackInfo& info); + Napi::Value defaultAlignment(const Napi::CallbackInfo& info); + Napi::Value defaultSectionSize(const Napi::CallbackInfo& info); + Napi::Value hiddenSectionCount(const Napi::CallbackInfo& info); + Napi::Value hideSection(const Napi::CallbackInfo& info); + Napi::Value highlightSections(const Napi::CallbackInfo& info); + Napi::Value isFirstSectionMovable(const Napi::CallbackInfo& info); + Napi::Value isSectionHidden(const Napi::CallbackInfo& info); + Napi::Value isSortIndicatorShown(const Napi::CallbackInfo& info); + Napi::Value length(const Napi::CallbackInfo& info); + Napi::Value logicalIndex(const Napi::CallbackInfo& info); + Napi::Value logicalIndexAt(const Napi::CallbackInfo& info); + Napi::Value logicalIndexAt_number_number(const Napi::CallbackInfo& info); + Napi::Value logicalIndexAt_qpoint(const Napi::CallbackInfo& info); + Napi::Value maximumSectionSize(const Napi::CallbackInfo& info); + Napi::Value minimumSectionSize(const Napi::CallbackInfo& info); + Napi::Value moveSection(const Napi::CallbackInfo& info); + Napi::Value offset(const Napi::CallbackInfo& info); + Napi::Value orientation(const Napi::CallbackInfo& info); + Napi::Value resetDefaultSectionSize(const Napi::CallbackInfo& info); + Napi::Value resizeContentsPrecision(const Napi::CallbackInfo& info); + Napi::Value resizeSection(const Napi::CallbackInfo& info); + Napi::Value resizeSections(const Napi::CallbackInfo& info); + Napi::Value sectionPosition(const Napi::CallbackInfo& info); + Napi::Value sectionResizeMode(const Napi::CallbackInfo& info); + Napi::Value sectionSize(const Napi::CallbackInfo& info); + Napi::Value sectionSizeHint(const Napi::CallbackInfo& info); + Napi::Value sectionViewportPosition(const Napi::CallbackInfo& info); + Napi::Value sectionsClickable(const Napi::CallbackInfo& info); + Napi::Value sectionsHidden(const Napi::CallbackInfo& info); + Napi::Value sectionsMovable(const Napi::CallbackInfo& info); + Napi::Value sectionsMoved(const Napi::CallbackInfo& info); + Napi::Value setCascadingSectionResizes(const Napi::CallbackInfo& info); + Napi::Value setDefaultAlignment(const Napi::CallbackInfo& info); + Napi::Value setDefaultSectionSize(const Napi::CallbackInfo& info); + Napi::Value setFirstSectionMovable(const Napi::CallbackInfo& info); + Napi::Value setHighlightSections(const Napi::CallbackInfo& info); + Napi::Value setMaximumSectionSize(const Napi::CallbackInfo& info); + Napi::Value setMinimumSectionSize(const Napi::CallbackInfo& info); + Napi::Value setResizeContentsPrecision(const Napi::CallbackInfo& info); + Napi::Value setSectionHidden(const Napi::CallbackInfo& info); + Napi::Value setSectionResizeMode_mode(const Napi::CallbackInfo& info); + Napi::Value setSectionResizeMode_number_mode(const Napi::CallbackInfo& info); + Napi::Value setSectionsClickable(const Napi::CallbackInfo& info); + Napi::Value setSectionsMovable(const Napi::CallbackInfo& info); + Napi::Value setSortIndicator(const Napi::CallbackInfo& info); + Napi::Value setSortIndicatorShown(const Napi::CallbackInfo& info); + Napi::Value showSection(const Napi::CallbackInfo& info); + Napi::Value sortIndicatorOrder(const Napi::CallbackInfo& info); + Napi::Value sortIndicatorSection(const Napi::CallbackInfo& info); + Napi::Value stretchSectionCount(const Napi::CallbackInfo& info); + Napi::Value swapSections(const Napi::CallbackInfo& info); + Napi::Value visualIndex(const Napi::CallbackInfo& info); + Napi::Value visualIndexAt(const Napi::CallbackInfo& info); + Napi::Value headerDataChanged(const Napi::CallbackInfo& info); + Napi::Value setOffset(const Napi::CallbackInfo& info); + Napi::Value setOffsetToLastSection(const Napi::CallbackInfo& info); + Napi::Value setOffsetToSectionPosition(const Napi::CallbackInfo& info); }; diff --git a/src/cpp/lib/QtWidgets/QHeaderView/qheaderview_wrap.cpp b/src/cpp/lib/QtWidgets/QHeaderView/qheaderview_wrap.cpp index 43f614775..e8e6abfad 100644 --- a/src/cpp/lib/QtWidgets/QHeaderView/qheaderview_wrap.cpp +++ b/src/cpp/lib/QtWidgets/QHeaderView/qheaderview_wrap.cpp @@ -9,7 +9,106 @@ Napi::Object QHeaderViewWrap::init(Napi::Env env, Napi::Object exports) { char CLASSNAME[] = "QHeaderView"; Napi::Function func = DefineClass( env, CLASSNAME, - {QABSTRACTITEMVIEW_WRAPPED_METHODS_EXPORT_DEFINE(QHeaderViewWrap)}); + { + QABSTRACTITEMVIEW_WRAPPED_METHODS_EXPORT_DEFINE(QHeaderViewWrap) + InstanceMethod("cascadingSectionResizes", + &QHeaderViewWrap::cascadingSectionResizes), + InstanceMethod("count", &QHeaderViewWrap::count), + InstanceMethod("defaultAlignment", + &QHeaderViewWrap::defaultAlignment), + InstanceMethod("defaultSectionSize", + &QHeaderViewWrap::defaultSectionSize), + InstanceMethod("hiddenSectionCount", + &QHeaderViewWrap::hiddenSectionCount), + InstanceMethod("hideSection", &QHeaderViewWrap::hideSection), + InstanceMethod("highlightSections", + &QHeaderViewWrap::highlightSections), + InstanceMethod("isFirstSectionMovable", + &QHeaderViewWrap::isFirstSectionMovable), + InstanceMethod("isSectionHidden", &QHeaderViewWrap::isSectionHidden), + InstanceMethod("isSortIndicatorShown", + &QHeaderViewWrap::isSortIndicatorShown), + InstanceMethod("length", &QHeaderViewWrap::length), + InstanceMethod("logicalIndex", &QHeaderViewWrap::logicalIndex), + InstanceMethod("logicalIndexAt", &QHeaderViewWrap::logicalIndexAt), + InstanceMethod("logicalIndexAt_number_number", + &QHeaderViewWrap::logicalIndexAt_number_number), + InstanceMethod("logicalIndexAt_qpoint", + &QHeaderViewWrap::logicalIndexAt_qpoint), + InstanceMethod("maximumSectionSize", + &QHeaderViewWrap::maximumSectionSize), + InstanceMethod("minimumSectionSize", + &QHeaderViewWrap::minimumSectionSize), + InstanceMethod("moveSection", &QHeaderViewWrap::moveSection), + InstanceMethod("offset", &QHeaderViewWrap::offset), + InstanceMethod("orientation", &QHeaderViewWrap::orientation), + InstanceMethod("resetDefaultSectionSize", + &QHeaderViewWrap::resetDefaultSectionSize), + InstanceMethod("resizeContentsPrecision", + &QHeaderViewWrap::resizeContentsPrecision), + InstanceMethod("resizeSection", &QHeaderViewWrap::resizeSection), + InstanceMethod("resizeSections", &QHeaderViewWrap::resizeSections), + InstanceMethod("sectionPosition", &QHeaderViewWrap::sectionPosition), + InstanceMethod("sectionResizeMode", + &QHeaderViewWrap::sectionResizeMode), + InstanceMethod("sectionSize", &QHeaderViewWrap::sectionSize), + InstanceMethod("sectionSizeHint", &QHeaderViewWrap::sectionSizeHint), + InstanceMethod("sectionViewportPosition", + &QHeaderViewWrap::sectionViewportPosition), + InstanceMethod("sectionsClickable", + &QHeaderViewWrap::sectionsClickable), + InstanceMethod("sectionsHidden", &QHeaderViewWrap::sectionsHidden), + InstanceMethod("sectionsMovable", &QHeaderViewWrap::sectionsMovable), + InstanceMethod("sectionsMoved", &QHeaderViewWrap::sectionsMoved), + InstanceMethod("setCascadingSectionResizes", + &QHeaderViewWrap::setCascadingSectionResizes), + InstanceMethod("setDefaultAlignment", + &QHeaderViewWrap::setDefaultAlignment), + InstanceMethod("setDefaultSectionSize", + &QHeaderViewWrap::setDefaultSectionSize), + InstanceMethod("setFirstSectionMovable", + &QHeaderViewWrap::setFirstSectionMovable), + InstanceMethod("setHighlightSections", + &QHeaderViewWrap::setHighlightSections), + InstanceMethod("setMaximumSectionSize", + &QHeaderViewWrap::setMaximumSectionSize), + InstanceMethod("setMinimumSectionSize", + &QHeaderViewWrap::setMinimumSectionSize), + InstanceMethod("setResizeContentsPrecision", + &QHeaderViewWrap::setResizeContentsPrecision), + InstanceMethod("setSectionHidden", + &QHeaderViewWrap::setSectionHidden), + InstanceMethod("setSectionResizeMode_mode", + &QHeaderViewWrap::setSectionResizeMode_mode), + InstanceMethod("setSectionResizeMode_number_mode", + &QHeaderViewWrap::setSectionResizeMode_number_mode), + InstanceMethod("setSectionsClickable", + &QHeaderViewWrap::setSectionsClickable), + InstanceMethod("setSectionsMovable", + &QHeaderViewWrap::setSectionsMovable), + InstanceMethod("setSortIndicator", + &QHeaderViewWrap::setSortIndicator), + InstanceMethod("setSortIndicatorShown", + &QHeaderViewWrap::setSortIndicatorShown), + InstanceMethod("showSection", &QHeaderViewWrap::showSection), + InstanceMethod("sortIndicatorOrder", + &QHeaderViewWrap::sortIndicatorOrder), + InstanceMethod("sortIndicatorSection", + &QHeaderViewWrap::sortIndicatorSection), + InstanceMethod("stretchSectionCount", + &QHeaderViewWrap::stretchSectionCount), + InstanceMethod("swapSections", &QHeaderViewWrap::swapSections), + InstanceMethod("visualIndex", &QHeaderViewWrap::visualIndex), + InstanceMethod("visualIndexAt", &QHeaderViewWrap::visualIndexAt), + InstanceMethod("headerDataChanged", + &QHeaderViewWrap::headerDataChanged), + InstanceMethod("setOffset", &QHeaderViewWrap::setOffset), + InstanceMethod("setOffsetToLastSection", + &QHeaderViewWrap::setOffsetToLastSection), + InstanceMethod("setOffsetToSectionPosition", + &QHeaderViewWrap::setOffsetToSectionPosition), + + }); constructor = Napi::Persistent(func); exports.Set(CLASSNAME, func); return exports; @@ -59,3 +158,498 @@ QHeaderViewWrap::QHeaderViewWrap(const Napi::CallbackInfo& info) item->getFlexNode(), false); } } + +Napi::Value QHeaderViewWrap::cascadingSectionResizes( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + bool result = this->instance->cascadingSectionResizes(); + return Napi::Boolean::New(env, result); +} + +Napi::Value QHeaderViewWrap::count(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int result = this->instance->count(); + return Napi::Number::New(env, result); +} + +Napi::Value QHeaderViewWrap::defaultAlignment(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + Qt::Alignment result = this->instance->defaultAlignment(); + return Napi::Number::New(env, static_cast(result)); +} + +Napi::Value QHeaderViewWrap::defaultSectionSize( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int result = this->instance->defaultSectionSize(); + return Napi::Number::New(env, result); +} + +Napi::Value QHeaderViewWrap::hiddenSectionCount( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int result = this->instance->hiddenSectionCount(); + return Napi::Number::New(env, result); +} + +Napi::Value QHeaderViewWrap::hideSection(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int logicalIndex = info[0].As().Int32Value(); + this->instance->hideSection(logicalIndex); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::highlightSections(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + bool result = this->instance->highlightSections(); + return Napi::Boolean::New(env, result); +} + +Napi::Value QHeaderViewWrap::isFirstSectionMovable( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + bool result = this->instance->isFirstSectionMovable(); + return Napi::Boolean::New(env, result); +} + +Napi::Value QHeaderViewWrap::isSectionHidden(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int logicalIndex = info[0].As().Int32Value(); + bool result = this->instance->isSectionHidden(logicalIndex); + return Napi::Boolean::New(env, result); +} + +Napi::Value QHeaderViewWrap::isSortIndicatorShown( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + bool result = this->instance->isSortIndicatorShown(); + return Napi::Boolean::New(env, result); +} + +Napi::Value QHeaderViewWrap::length(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int result = this->instance->length(); + return Napi::Number::New(env, result); +} + +Napi::Value QHeaderViewWrap::logicalIndex(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int visualIndex = info[0].As().Int32Value(); + int result = this->instance->logicalIndex(visualIndex); + return Napi::Number::New(env, result); +} + +Napi::Value QHeaderViewWrap::logicalIndexAt(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int position = info[0].As().Int32Value(); + int result = this->instance->logicalIndexAt(position); + return Napi::Number::New(env, result); +} + +Napi::Value QHeaderViewWrap::logicalIndexAt_number_number( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int x = info[0].As().Int32Value(); + int y = info[1].As().Int32Value(); + int result = this->instance->logicalIndexAt(x, y); + return Napi::Number::New(env, result); +} + +Napi::Value QHeaderViewWrap::logicalIndexAt_qpoint( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + QPointWrap* posWrap = + Napi::ObjectWrap::Unwrap(info[0].As()); + QPoint* pos = posWrap->getInternalInstance(); + int result = this->instance->logicalIndexAt(*pos); + return Napi::Number::New(env, result); +} + +Napi::Value QHeaderViewWrap::maximumSectionSize( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int result = this->instance->maximumSectionSize(); + return Napi::Number::New(env, result); +} + +Napi::Value QHeaderViewWrap::minimumSectionSize( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int result = this->instance->minimumSectionSize(); + return Napi::Number::New(env, result); +} + +Napi::Value QHeaderViewWrap::moveSection(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int from = info[0].As().Int32Value(); + int to = info[1].As().Int32Value(); + this->instance->moveSection(from, to); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::offset(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int result = this->instance->offset(); + return Napi::Number::New(env, result); +} + +Napi::Value QHeaderViewWrap::orientation(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + Qt::Orientation result = this->instance->orientation(); + return Napi::Number::New(env, static_cast(result)); +} + +Napi::Value QHeaderViewWrap::resetDefaultSectionSize( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + this->instance->resetDefaultSectionSize(); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::resizeContentsPrecision( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int result = this->instance->resizeContentsPrecision(); + return Napi::Number::New(env, result); +} + +Napi::Value QHeaderViewWrap::resizeSection(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int logicalIndex = info[0].As().Int32Value(); + int size = info[1].As().Int32Value(); + this->instance->resizeSection(logicalIndex, size); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::resizeSections(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + QHeaderView::ResizeMode mode = static_cast( + info[0].As().Int32Value()); + this->instance->resizeSections(mode); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::sectionPosition(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int logicalIndex = info[0].As().Int32Value(); + int result = this->instance->sectionPosition(logicalIndex); + return Napi::Number::New(env, result); +} + +Napi::Value QHeaderViewWrap::sectionResizeMode(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int logicalIndex = info[0].As().Int32Value(); + QHeaderView::ResizeMode result = + this->instance->sectionResizeMode(logicalIndex); + return Napi::Number::New(env, static_cast(result)); +} + +Napi::Value QHeaderViewWrap::sectionSize(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int logicalIndex = info[0].As().Int32Value(); + int result = this->instance->sectionSize(logicalIndex); + return Napi::Number::New(env, result); +} + +Napi::Value QHeaderViewWrap::sectionSizeHint(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int logicalIndex = info[0].As().Int32Value(); + int result = this->instance->sectionSizeHint(logicalIndex); + return Napi::Number::New(env, result); +} + +Napi::Value QHeaderViewWrap::sectionViewportPosition( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int logicalIndex = info[0].As().Int32Value(); + int result = this->instance->sectionViewportPosition(logicalIndex); + return Napi::Number::New(env, result); +} + +Napi::Value QHeaderViewWrap::sectionsClickable(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + bool result = this->instance->sectionsClickable(); + return Napi::Boolean::New(env, result); +} + +Napi::Value QHeaderViewWrap::sectionsHidden(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + bool result = this->instance->sectionsHidden(); + return Napi::Boolean::New(env, result); +} + +Napi::Value QHeaderViewWrap::sectionsMovable(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + bool result = this->instance->sectionsMovable(); + return Napi::Boolean::New(env, result); +} + +Napi::Value QHeaderViewWrap::sectionsMoved(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + bool result = this->instance->sectionsMoved(); + return Napi::Boolean::New(env, result); +} + +Napi::Value QHeaderViewWrap::setCascadingSectionResizes( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + bool enable = info[0].As().Value(); + this->instance->setCascadingSectionResizes(enable); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::setDefaultAlignment( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + Qt::Alignment alignment = + static_cast(info[0].As().Int32Value()); + this->instance->setDefaultAlignment(alignment); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::setDefaultSectionSize( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int size = info[0].As().Int32Value(); + this->instance->setDefaultSectionSize(size); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::setFirstSectionMovable( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + bool movable = info[0].As().Value(); + this->instance->setFirstSectionMovable(movable); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::setHighlightSections( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + bool highlight = info[0].As().Value(); + this->instance->setHighlightSections(highlight); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::setMaximumSectionSize( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int size = info[0].As().Int32Value(); + this->instance->setMaximumSectionSize(size); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::setMinimumSectionSize( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int size = info[0].As().Int32Value(); + this->instance->setMinimumSectionSize(size); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::setResizeContentsPrecision( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int precision = info[0].As().Int32Value(); + this->instance->setResizeContentsPrecision(precision); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::setSectionHidden(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int logicalIndex = info[0].As().Int32Value(); + bool hide = info[1].As().Value(); + this->instance->setSectionHidden(logicalIndex, hide); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::setSectionResizeMode_mode( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + QHeaderView::ResizeMode mode = static_cast( + info[0].As().Int32Value()); + this->instance->setSectionResizeMode(mode); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::setSectionResizeMode_number_mode( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int logicalIndex = info[0].As().Int32Value(); + QHeaderView::ResizeMode mode = static_cast( + info[1].As().Int32Value()); + this->instance->setSectionResizeMode(logicalIndex, mode); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::setSectionsClickable( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + bool clickable = info[0].As().Value(); + this->instance->setSectionsClickable(clickable); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::setSectionsMovable( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + bool movable = info[0].As().Value(); + this->instance->setSectionsMovable(movable); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::setSortIndicator(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int logicalIndex = info[0].As().Int32Value(); + Qt::SortOrder order = + static_cast(info[1].As().Int32Value()); + this->instance->setSortIndicator(logicalIndex, order); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::setSortIndicatorShown( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + bool show = info[0].As().Value(); + this->instance->setSortIndicatorShown(show); + return env.Null(); +} +Napi::Value QHeaderViewWrap::showSection(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int logicalIndex = info[0].As().Int32Value(); + this->instance->showSection(logicalIndex); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::sortIndicatorOrder( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + Qt::SortOrder result = this->instance->sortIndicatorOrder(); + return Napi::Number::New(env, static_cast(result)); +} + +Napi::Value QHeaderViewWrap::sortIndicatorSection( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int result = this->instance->sortIndicatorSection(); + return Napi::Number::New(env, result); +} +Napi::Value QHeaderViewWrap::stretchSectionCount( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int result = this->instance->stretchSectionCount(); + return Napi::Number::New(env, result); +} + +Napi::Value QHeaderViewWrap::swapSections(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int first = info[0].As().Int32Value(); + int second = info[1].As().Int32Value(); + this->instance->swapSections(first, second); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::visualIndex(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int logicalIndex = info[0].As().Int32Value(); + int result = this->instance->visualIndex(logicalIndex); + return Napi::Number::New(env, result); +} + +Napi::Value QHeaderViewWrap::visualIndexAt(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int position = info[0].As().Int32Value(); + int result = this->instance->visualIndexAt(position); + return Napi::Number::New(env, result); +} + +Napi::Value QHeaderViewWrap::headerDataChanged(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + Qt::Orientation orientation = + static_cast(info[0].As().Int32Value()); + int logicalFirst = info[1].As().Int32Value(); + int logicalLast = info[2].As().Int32Value(); + this->instance->headerDataChanged(orientation, logicalFirst, logicalLast); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::setOffset(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int offset = info[0].As().Int32Value(); + this->instance->setOffset(offset); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::setOffsetToLastSection( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + this->instance->setOffsetToLastSection(); + return env.Null(); +} + +Napi::Value QHeaderViewWrap::setOffsetToSectionPosition( + const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + int visualSectionNumber = info[0].As().Int32Value(); + this->instance->setOffsetToSectionPosition(visualSectionNumber); + return env.Null(); +} diff --git a/src/index.ts b/src/index.ts index 314e52535..d57cdff14 100644 --- a/src/index.ts +++ b/src/index.ts @@ -82,7 +82,7 @@ export { QToolButton, QToolButtonSignals, ToolButtonPopupMode } from './lib/QtWi export { QSpinBox, QSpinBoxSignals } from './lib/QtWidgets/QSpinBox'; export { QRadioButton, QRadioButtonSignals } from './lib/QtWidgets/QRadioButton'; export { QStackedWidget, QStackedWidgetSignals } from './lib/QtWidgets/QStackedWidget'; -export { QHeaderView, QHeaderViewSignals } from './lib/QtWidgets/QHeaderView'; +export { QHeaderView, QHeaderViewSignals, QHeaderViewResizeMode } from './lib/QtWidgets/QHeaderView'; export { QListView, QListViewSignals, diff --git a/src/lib/QtWidgets/QHeaderView.ts b/src/lib/QtWidgets/QHeaderView.ts index 0205071dc..48a6c99d3 100644 --- a/src/lib/QtWidgets/QHeaderView.ts +++ b/src/lib/QtWidgets/QHeaderView.ts @@ -2,7 +2,7 @@ import addon from '../utils/addon'; import { NodeWidget } from './QWidget'; import { NativeElement } from '../core/Component'; import { QAbstractItemView, QAbstractItemViewSignals } from './QAbstractItemView'; -import { checkIfNativeElement, Orientation } from '../..'; +import { AlignmentFlag, checkIfNativeElement, Orientation, QPoint, SortOrder } from '../..'; /** @@ -13,79 +13,195 @@ import { checkIfNativeElement, Orientation } from '../..'; */ export abstract class NodeHeaderView extends QAbstractItemView { // *** Public Function *** - // TODO: bool cascadingSectionResizes() const - // TODO: int count() const - // TODO: Qt::Alignment defaultAlignment() const - // TODO: int defaultSectionSize() const - // TODO: int hiddenSectionCount() const - // TODO: void hideSection(int logicalIndex) - // TODO: bool highlightSections() const - // TODO: bool isFirstSectionMovable() const - // TODO: bool isSectionHidden(int logicalIndex) const - // TODO: bool isSortIndicatorShown() const - // TODO: int length() const - // TODO: int logicalIndex(int visualIndex) const - // TODO: int logicalIndexAt(int position) const - // TODO: int logicalIndexAt(int x, int y) const - // TODO: int logicalIndexAt(const QPoint &pos) const - // TODO: int maximumSectionSize() const - // TODO: int minimumSectionSize() const - // TODO: void moveSection(int from, int to) - // TODO: int offset() const - // TODO: Qt::Orientation orientation() const - // TODO: void resetDefaultSectionSize() - // TODO: int resizeContentsPrecision() const - // TODO: void resizeSection(int logicalIndex, int size) - // TODO: void resizeSections(QHeaderView::ResizeMode mode) + cascadingSectionResizes(): boolean { + return this.native.cascadingSectionResizes(); + } + count(): number { + return this.native.count(); + } + defaultAlignment(): AlignmentFlag { + return this.native.defaultAlignment(); + } + defaultSectionSize(): number { + return this.native.defaultSectionSize(); + } + hiddenSectionCount(): number { + return this.native.hiddenSectionCount(); + } + hideSection(logicalIndex: number): void { + this.native.hideSection(logicalIndex); + } + highlightSections(): boolean { + return this.native.highlightSections(); + } + isFirstSectionMovable(): boolean { + return this.native.isFirstSectionMovable(); + } + isSectionHidden(logicalIndex: number): boolean { + return this.native.isSectionHidden(logicalIndex); + } + isSortIndicatorShown(): boolean { + return this.native.isSortIndicatorShown(); + } + length(): number { + return this.native.length(); + } + logicalIndex(visualIndex: number): number { + return this.native.logicalIndex(visualIndex); + } + logicalIndexAt(positionOrPosOrX: number | QPoint, y?: number): number { + if (y !== undefined) { + return this.native.logicalIndexAt_number_number(positionOrPosOrX, y); + } else if (positionOrPosOrX instanceof QPoint) { + return this.native.logicalIndexAt_qpoint(positionOrPosOrX.native); + } else { + return this.native.logicalIndexAt_number(positionOrPosOrX); + } + } + maximumSectionSize(): number { + return this.native.maximumSectionSize(); + } + minimumSectionSize(): number { + return this.native.minimumSectionSize(); + } + moveSection(from: number, to: number): void { + this.native.moveSection(from, to); + } + offset(): number { + return this.native.offset(); + } + orientation(): Orientation { + return this.native.orientation(); + } + resetDefaultSectionSize(): void { + this.native.resetDefaultSectionSize(); + } + resizeContentsPrecision(): number { + return this.native.resizeContentsPrecision(); + } + resizeSection(logicalIndex: number, size: number): void { + this.native.resizeSection(logicalIndex, size); + } + resizeSections(mode: QHeaderViewResizeMode): void { + this.native.resizeSections(mode); + } // TODO: bool restoreState(const QByteArray &state) // TODO: QByteArray saveState() const - // TODO: int sectionPosition(int logicalIndex) const - // TODO: QHeaderView::ResizeMode sectionResizeMode(int logicalIndex) const - // TODO: int sectionSize(int logicalIndex) const - // TODO: int sectionSizeHint(int logicalIndex) const - // TODO: int sectionViewportPosition(int logicalIndex) const - // TODO: bool sectionsClickable() const - // TODO: bool sectionsHidden() const - // TODO: bool sectionsMovable() const - // TODO: bool sectionsMoved() const - // TODO: void setCascadingSectionResizes(bool enable) - // TODO: void setDefaultAlignment(Qt::Alignment alignment) - // TODO: void setDefaultSectionSize(int size) - // TODO: void setFirstSectionMovable(bool movable) - // TODO: void setHighlightSections(bool highlight) - // TODO: void setMaximumSectionSize(int size) - // TODO: void setMinimumSectionSize(int size) - // TODO: void setResizeContentsPrecision(int precision) - // TODO: void setSectionHidden(int logicalIndex, bool hide) - // TODO: void setSectionResizeMode(QHeaderView::ResizeMode mode) - // TODO: void setSectionResizeMode(int logicalIndex, QHeaderView::ResizeMode mode) - // TODO: void setSectionsClickable(bool clickable) - // TODO: void setSectionsMovable(bool movable) - // TODO: void setSortIndicator(int logicalIndex, Qt::SortOrder order) - // TODO: void setSortIndicatorShown(bool show) - + sectionPosition(logicalIndex: number): number { + return this.native.sectionPosition(logicalIndex); + } + sectionResizeMode(logicalIndex: number): QHeaderViewResizeMode { + return this.native.sectionResizeMode(logicalIndex); + } + sectionSize(logicalIndex: number): number { + return this.native.sectionSize(logicalIndex); + } + sectionSizeHint(logicalIndex: number): number { + return this.native.sectionSizeHint(logicalIndex); + } + sectionViewportPosition(logicalIndex: number): number { + return this.native.sectionViewportPosition(logicalIndex); + } + sectionsClickable(): boolean { + return this.native.sectionsClickable(); + } + sectionsHidden(): boolean { + return this.native.sectionsHidden(); + } + sectionsMovable(): boolean { + return this.native.sectionsMovable(); + } + sectionsMoved(): boolean { + return this.native.sectionsMoved(); + } + setCascadingSectionResizes(enable: boolean): void { + this.native.setCascadingSectionResizes(enable); + } + setDefaultAlignment(alignment: AlignmentFlag): void { + this.native.setDefaultAlignment(alignment); + } + setDefaultSectionSize(size: number): void { + this.native.setDefaultSectionSize(size); + } + setFirstSectionMovable(movable: boolean): void { + this.native.setFirstSectionMovable(movable); + } + setHighlightSections(highlight: boolean): void { + this.native.setHighlightSections(highlight); + } + setMaximumSectionSize(size: number): void { + this.native.setMaximumSectionSize(size); + } + setMinimumSectionSize(size: number): void { + this.native.setMinimumSectionSize(size); + } + setResizeContentsPrecision(precision: number): void { + this.native.setResizeContentsPrecision(precision); + } + setSectionHidden(logicalIndex: number, hide: boolean): void { + this.native.setSectionHidden(logicalIndex, hide); + } + setSectionResizeMode(modeOrlogicalIndex: QHeaderViewResizeMode | number, mode?: QHeaderViewResizeMode): void { + if (mode !== undefined) { + this.native.setSectionResizeMode_number_mode(modeOrlogicalIndex, mode); + } else { + this.native.setSectionResizeMode_mode(modeOrlogicalIndex); + } + } + setSectionsClickable(clickable: boolean): void { + this.native.setSectionsClickable(clickable); + } + setSectionsMovable(movable: boolean): void { + this.native.setSectionsMovable(movable); + } + setSortIndicator(logicalIndex: number, order: SortOrder): void { + this.native.setSortIndicator(logicalIndex, order); + } + setSortIndicatorShown(show: boolean): void { + this.native.setSortIndicatorShown(show); + } setStretchLastSection(stretch: boolean): void { this.setProperty('stretchLastSection', stretch); } - // TODO: void showSection(int logicalIndex) - // TODO: Qt::SortOrder sortIndicatorOrder() const - // TODO: int sortIndicatorSection() const - + showSection(logicalIndex: number): void { + this.native.showSection(logicalIndex); + } + sortIndicatorOrder(): SortOrder { + return this.native.sortIndicatorOrder(); + } + sortIndicatorSection(): number { + return this.native.sortIndicatorSection(); + } stretchLastSection(): boolean { return this.property('stretchLastSection').toBool(); } - - // TODO: int stretchSectionCount() const - // TODO: void swapSections(int first, int second) - // TODO: int visualIndex(int logicalIndex) const - // TODO: int visualIndexAt(int position) const + stretchSectionCount(): number { + return this.native.stretchSectionCount(); + } + swapSections(first: number, second: number): void { + this.native.swapSections(first, second); + } + visualIndex(logicalIndex: number): number { + return this.native.visualIndex(logicalIndex); + } + visualIndexAt(position: number): number { + return this.native.visualIndexAt(position); + } // *** Public Slots *** - // TODO: void headerDataChanged(Qt::Orientation orientation, int logicalFirst, int logicalLast) - // TODO: void setOffset(int offset) - // TODO: void setOffsetToLastSection() - // TODO: void setOffsetToSectionPosition(int visualSectionNumber) + headerDataChanged(orientation: Orientation, logicalFirst: number, logicalLast: number): void { + this.native.headerDataChanged(orientation, logicalFirst, logicalLast); + } + setOffset(offset: number): void { + this.native.setOffset(offset); + } + setOffsetToLastSection(): void { + this.native.setOffsetToLastSection(); + } + setOffsetToSectionPosition(visualSectionNumber: number): void { + this.native.setOffsetToSectionPosition(visualSectionNumber); + } } export class QHeaderView extends NodeHeaderView { @@ -107,4 +223,11 @@ export class QHeaderView extends NodeHeaderView { } } +export enum QHeaderViewResizeMode { + Interactive = 0, + Fixed = 2, + Stretch = 1, + ResizeToContents = 3, +} + export type QHeaderViewSignals = QAbstractItemViewSignals; diff --git a/src/lib/QtWidgets/QTableWidget.ts b/src/lib/QtWidgets/QTableWidget.ts index ee9dcf507..b6ff25d0f 100644 --- a/src/lib/QtWidgets/QTableWidget.ts +++ b/src/lib/QtWidgets/QTableWidget.ts @@ -40,8 +40,6 @@ win.show(); export class QTableWidget extends QAbstractScrollArea { native: NativeElement; items: Set; - constructor(rows: number, columns: number); - constructor(rows: number, columns: number, parent: NodeWidget); constructor(rows: number, columns: number, parent?: NodeWidget) { let native; if (parent) {