Fill in QAbstractItemView methods & enums; add QItemSelectionModel
This commit is contained in:
parent
8c79f3d093
commit
edf437f056
@ -68,6 +68,7 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtCore/QAbstractItemModel/qabstractitemmodel_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/QItemSelectionModel/qitemselectionmodel_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"
|
||||
@ -147,6 +148,7 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QDesktopWidget/qdesktopwidget_wrap.cpp"
|
||||
# Custom widgets (include them for automoc since they contain Q_OBJECT)
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtCore/QAbstractItemModel/nabstractitemmodel.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtCore/QItemSelectionModel/nitemselectionmodel.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtCore/QObject/nobject.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/core/FlexLayout/flexlayout.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtGui/QMovie/nmovie.hpp"
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include <QItemSelectionModel>
|
||||
|
||||
#include "Extras/Export/export.h"
|
||||
#include "QtCore/QObject/qobject_macro.h"
|
||||
#include "core/NodeWidget/nodewidget.h"
|
||||
#include "napi.h"
|
||||
|
||||
class DLL_EXPORT NItemSelectionModel : public QItemSelectionModel,
|
||||
public EventWidget {
|
||||
Q_OBJECT
|
||||
EVENTWIDGET_IMPLEMENTATIONS(QItemSelectionModel)
|
||||
public:
|
||||
Napi::FunctionReference dispatchOnNode;
|
||||
|
||||
virtual void connectSignalsToEventEmitter() {
|
||||
// Qt Connects: Implement all signal connects here
|
||||
QOBJECT_SIGNALS
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
#include "Extras/Export/export.h"
|
||||
#include "QtCore/QObject/qobject_macro.h"
|
||||
#include "nitemselectionmodel.hpp"
|
||||
|
||||
class DLL_EXPORT QItemSelectionModelWrap
|
||||
: public Napi::ObjectWrap<QItemSelectionModelWrap> {
|
||||
QOBJECT_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
private:
|
||||
QPointer<QItemSelectionModel> instance;
|
||||
bool disableDeletion;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QItemSelectionModelWrap(const Napi::CallbackInfo& info);
|
||||
~QItemSelectionModelWrap();
|
||||
QItemSelectionModel* getInternalInstance();
|
||||
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
Napi::Value columnIntersectsSelection(const Napi::CallbackInfo& info);
|
||||
Napi::Value currentIndex(const Napi::CallbackInfo& info);
|
||||
Napi::Value hasSelection(const Napi::CallbackInfo& info);
|
||||
Napi::Value isColumnSelected(const Napi::CallbackInfo& info);
|
||||
Napi::Value isRowSelected(const Napi::CallbackInfo& info);
|
||||
Napi::Value isSelected(const Napi::CallbackInfo& info);
|
||||
Napi::Value rowIntersectsSelection(const Napi::CallbackInfo& info);
|
||||
Napi::Value clear(const Napi::CallbackInfo& info);
|
||||
Napi::Value clearCurrentIndex(const Napi::CallbackInfo& info);
|
||||
Napi::Value clearSelection(const Napi::CallbackInfo& info);
|
||||
Napi::Value reset(const Napi::CallbackInfo& info);
|
||||
Napi::Value select(const Napi::CallbackInfo& info);
|
||||
Napi::Value setCurrentIndex(const Napi::CallbackInfo& info);
|
||||
Napi::Value selectedColumns(const Napi::CallbackInfo& info);
|
||||
Napi::Value selectedIndexes(const Napi::CallbackInfo& info);
|
||||
Napi::Value selectedRows(const Napi::CallbackInfo& info);
|
||||
};
|
||||
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "QtCore/QAbstractItemModel/qabstractitemmodel_wrap.h"
|
||||
#include "QtCore/QItemSelectionModel/qitemselectionmodel_wrap.h"
|
||||
#include "QtCore/QModelIndex/qmodelindex_wrap.h"
|
||||
#include "QtWidgets/QAbstractScrollArea/qabstractscrollarea_macro.h"
|
||||
#include "QtWidgets/QWidget/qwidget_wrap.h"
|
||||
@ -13,92 +14,210 @@
|
||||
*/
|
||||
|
||||
#ifndef QABSTRACTITEMVIEW_WRAPPED_METHODS_DECLARATION
|
||||
#define QABSTRACTITEMVIEW_WRAPPED_METHODS_DECLARATION \
|
||||
QABSTRACTSCROLLAREA_WRAPPED_METHODS_DECLARATION \
|
||||
Napi::Value setCurrentIndex(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
Napi::Object indexObject = info[0].As<Napi::Object>(); \
|
||||
QModelIndexWrap* indexWrap = \
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(indexObject); \
|
||||
this->instance->setCurrentIndex(*indexWrap->getInternalInstance()); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value currentIndex(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
QModelIndex current = this->instance->currentIndex(); \
|
||||
auto instance = QModelIndexWrap::constructor.New( \
|
||||
{Napi::External<QModelIndex>::New(env, new QModelIndex(current))}); \
|
||||
return instance; \
|
||||
} \
|
||||
Napi::Value setIndexWidget(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
Napi::Object indexObject = info[0].As<Napi::Object>(); \
|
||||
Napi::Object widgetObject = info[1].As<Napi::Object>(); \
|
||||
QModelIndexWrap* indexWrap = \
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(indexObject); \
|
||||
NodeWidgetWrap* widgetWrap = \
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(widgetObject); \
|
||||
this->instance->setIndexWidget(*indexWrap->getInternalInstance(), \
|
||||
widgetWrap->getInternalInstance()); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value indexWidget(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
Napi::Object indexObject = info[0].As<Napi::Object>(); \
|
||||
QModelIndexWrap* indexWrap = \
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(indexObject); \
|
||||
QWidget* widget = \
|
||||
this->instance->indexWidget(*indexWrap->getInternalInstance()); \
|
||||
auto instance = QWidgetWrap::constructor.New( \
|
||||
{Napi::External<QWidget>::New(env, widget), \
|
||||
Napi::Boolean::New(env, true)}); \
|
||||
return instance; \
|
||||
} \
|
||||
Napi::Value resetHorizontalScrollMode(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
this->instance->resetHorizontalScrollMode(); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value resetVerticalScrollMode(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
this->instance->resetVerticalScrollMode(); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value rootIndex(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
QModelIndex root = this->instance->rootIndex(); \
|
||||
auto instance = QModelIndexWrap::constructor.New( \
|
||||
{Napi::External<QModelIndex>::New(env, new QModelIndex(root))}); \
|
||||
return instance; \
|
||||
} \
|
||||
Napi::Value scrollToBottom(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
this->instance->scrollToBottom(); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value scrollToTop(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
this->instance->scrollToTop(); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value setModel(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
Napi::Object modelObject = info[0].As<Napi::Object>(); \
|
||||
QAbstractItemModelWrap* modelWrap = \
|
||||
Napi::ObjectWrap<QAbstractItemModelWrap>::Unwrap(modelObject); \
|
||||
QAbstractItemView* instance = this->instance; \
|
||||
instance->setModel(modelWrap->getInternalInstance()); \
|
||||
return env.Null(); \
|
||||
|
||||
// This silly *WITHOUT_INDEXAT nonsense is for the benefit of QHeaderView and
|
||||
// its redefinition of `indexAt()` as protected(!) instead of plain public.
|
||||
// *sigh*
|
||||
#define QABSTRACTITEMVIEW_WRAPPED_METHODS_DECLARATION_NO_QHEADERVIEW_PROTECTED \
|
||||
QABSTRACTSCROLLAREA_WRAPPED_METHODS_DECLARATION \
|
||||
Napi::Value setCurrentIndex(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
Napi::Object indexObject = info[0].As<Napi::Object>(); \
|
||||
QModelIndexWrap* indexWrap = \
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(indexObject); \
|
||||
this->instance->setCurrentIndex(*indexWrap->getInternalInstance()); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value currentIndex(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
QModelIndex current = this->instance->currentIndex(); \
|
||||
auto instance = QModelIndexWrap::constructor.New( \
|
||||
{Napi::External<QModelIndex>::New(env, new QModelIndex(current))}); \
|
||||
return instance; \
|
||||
} \
|
||||
Napi::Value setIndexWidget(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
Napi::Object indexObject = info[0].As<Napi::Object>(); \
|
||||
Napi::Object widgetObject = info[1].As<Napi::Object>(); \
|
||||
QModelIndexWrap* indexWrap = \
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(indexObject); \
|
||||
NodeWidgetWrap* widgetWrap = \
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(widgetObject); \
|
||||
this->instance->setIndexWidget(*indexWrap->getInternalInstance(), \
|
||||
widgetWrap->getInternalInstance()); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value indexWidget(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
Napi::Object indexObject = info[0].As<Napi::Object>(); \
|
||||
QModelIndexWrap* indexWrap = \
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(indexObject); \
|
||||
QWidget* widget = \
|
||||
this->instance->indexWidget(*indexWrap->getInternalInstance()); \
|
||||
auto instance = QWidgetWrap::constructor.New( \
|
||||
{Napi::External<QWidget>::New(env, widget), \
|
||||
Napi::Boolean::New(env, true)}); \
|
||||
return instance; \
|
||||
} \
|
||||
Napi::Value resetHorizontalScrollMode(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
this->instance->resetHorizontalScrollMode(); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value resetVerticalScrollMode(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
this->instance->resetVerticalScrollMode(); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value rootIndex(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
QModelIndex root = this->instance->rootIndex(); \
|
||||
auto instance = QModelIndexWrap::constructor.New( \
|
||||
{Napi::External<QModelIndex>::New(env, new QModelIndex(root))}); \
|
||||
return instance; \
|
||||
} \
|
||||
Napi::Value scrollToBottom(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
this->instance->scrollToBottom(); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value scrollToTop(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
this->instance->scrollToTop(); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value setModel(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
Napi::Object modelObject = info[0].As<Napi::Object>(); \
|
||||
QAbstractItemModelWrap* modelWrap = \
|
||||
Napi::ObjectWrap<QAbstractItemModelWrap>::Unwrap(modelObject); \
|
||||
QAbstractItemView* instance = this->instance; \
|
||||
instance->setModel(modelWrap->getInternalInstance()); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value closePersistentEditor(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
QModelIndexWrap* indexWrap = \
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(info[0].As<Napi::Object>()); \
|
||||
QModelIndex* index = indexWrap->getInternalInstance(); \
|
||||
this->instance->QAbstractItemView::closePersistentEditor(*index); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value clearSelection(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
this->instance->clearSelection(); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value edit(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
QModelIndexWrap* indexWrap = \
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(info[0].As<Napi::Object>()); \
|
||||
QModelIndex* index = indexWrap->getInternalInstance(); \
|
||||
this->instance->edit(*index); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value reset(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
this->instance->reset(); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value selectAll(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
this->instance->selectAll(); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value setRootIndex(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
QModelIndexWrap* indexWrap = \
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(info[0].As<Napi::Object>()); \
|
||||
QModelIndex* index = indexWrap->getInternalInstance(); \
|
||||
this->instance->setRootIndex(*index); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value update_QModelIndex(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
QModelIndexWrap* indexWrap = \
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(info[0].As<Napi::Object>()); \
|
||||
QModelIndex* index = indexWrap->getInternalInstance(); \
|
||||
this->instance->update(*index); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value selectionModel(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
QItemSelectionModel* model = this->instance->selectionModel(); \
|
||||
auto modelExt = Napi::External<QItemSelectionModel>::New(env, model); \
|
||||
auto instance = QItemSelectionModelWrap::constructor.New({modelExt}); \
|
||||
return instance; \
|
||||
} \
|
||||
Napi::Value isPersistentEditorOpen(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
QModelIndexWrap* indexWrap = \
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(info[0].As<Napi::Object>()); \
|
||||
QModelIndex* index = indexWrap->getInternalInstance(); \
|
||||
bool result = this->instance->isPersistentEditorOpen(*index); \
|
||||
return Napi::Boolean::New(env, result); \
|
||||
} \
|
||||
Napi::Value openPersistentEditor(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
QModelIndexWrap* indexWrap = \
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(info[0].As<Napi::Object>()); \
|
||||
QModelIndex* index = indexWrap->getInternalInstance(); \
|
||||
this->instance->QAbstractItemView::openPersistentEditor(*index); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value keyboardSearch(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
std::string searchNapiText = info[0].As<Napi::String>().Utf8Value(); \
|
||||
QString search = QString::fromUtf8(searchNapiText.c_str()); \
|
||||
this->instance->keyboardSearch(search); \
|
||||
return env.Null(); \
|
||||
}
|
||||
|
||||
#define QABSTRACTITEMVIEW_WRAPPED_METHODS_DECLARATION \
|
||||
QABSTRACTITEMVIEW_WRAPPED_METHODS_DECLARATION_NO_QHEADERVIEW_PROTECTED \
|
||||
Napi::Value indexAt(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
QPointWrap* pointWrap = \
|
||||
Napi::ObjectWrap<QPointWrap>::Unwrap(info[0].As<Napi::Object>()); \
|
||||
QPoint* point = pointWrap->getInternalInstance(); \
|
||||
QModelIndex result = this->instance->indexAt(*point); \
|
||||
auto resultInstance = QModelIndexWrap::constructor.New( \
|
||||
{Napi::External<QModelIndex>::New(env, new QModelIndex(result))}); \
|
||||
return resultInstance; \
|
||||
} \
|
||||
Napi::Value scrollTo(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
QModelIndexWrap* indexWrap = \
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(info[0].As<Napi::Object>()); \
|
||||
QModelIndex* index = indexWrap->getInternalInstance(); \
|
||||
QAbstractItemView::ScrollHint hint = \
|
||||
static_cast<QAbstractItemView::ScrollHint>( \
|
||||
info[1].As<Napi::Number>().Int32Value()); \
|
||||
this->instance->scrollTo(*index, hint); \
|
||||
return env.Null(); \
|
||||
}
|
||||
|
||||
#endif // QABSTRACTITEMVIEW_WRAPPED_METHODS_DECLARATION
|
||||
@ -117,17 +236,88 @@
|
||||
InstanceMethod("rootIndex", &WidgetWrapName::rootIndex), \
|
||||
InstanceMethod("scrollToBottom", &WidgetWrapName::scrollToBottom), \
|
||||
InstanceMethod("scrollToTop", &WidgetWrapName::scrollToTop), \
|
||||
InstanceMethod("setModel", &WidgetWrapName::setModel),
|
||||
InstanceMethod("setModel", &WidgetWrapName::setModel), \
|
||||
InstanceMethod("closePersistentEditor", \
|
||||
&WidgetWrapName::closePersistentEditor), \
|
||||
InstanceMethod("clearSelection", &WidgetWrapName::clearSelection), \
|
||||
InstanceMethod("edit", &WidgetWrapName::edit), \
|
||||
InstanceMethod("reset", &WidgetWrapName::reset), \
|
||||
InstanceMethod("selectAll", &WidgetWrapName::selectAll), \
|
||||
InstanceMethod("setRootIndex", &WidgetWrapName::setRootIndex), \
|
||||
InstanceMethod("update_QModelIndex", \
|
||||
&WidgetWrapName::update_QModelIndex), \
|
||||
InstanceMethod("indexAt", &WidgetWrapName::indexAt), \
|
||||
InstanceMethod("selectionModel", &WidgetWrapName::selectionModel), \
|
||||
InstanceMethod("scrollTo", &WidgetWrapName::scrollTo), \
|
||||
InstanceMethod("isPersistentEditorOpen", \
|
||||
&WidgetWrapName::isPersistentEditorOpen), \
|
||||
InstanceMethod("openPersistentEditor", \
|
||||
&WidgetWrapName::openPersistentEditor), \
|
||||
InstanceMethod("keyboardSearch", &WidgetWrapName::keyboardSearch),
|
||||
|
||||
#endif // QABSTRACTITEMVIEW_WRAPPED_METHODS_EXPORT_DEFINE
|
||||
|
||||
#ifndef QABSTRACTITEMVIEW_SIGNALS
|
||||
#define QABSTRACTITEMVIEW_SIGNALS \
|
||||
QABSTRACTSCROLLAREA_SIGNALS \
|
||||
QObject::connect(this, &QAbstractItemView::viewportEntered, [=]() { \
|
||||
Napi::Env env = this->emitOnNode.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
this->emitOnNode.Call({Napi::String::New(env, "viewportEntered")}); \
|
||||
#define QABSTRACTITEMVIEW_SIGNALS \
|
||||
QABSTRACTSCROLLAREA_SIGNALS \
|
||||
QObject::connect( \
|
||||
this, &QAbstractItemView::activated, [=](const QModelIndex& index) { \
|
||||
Napi::Env env = this->emitOnNode.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
auto indexInstance = QModelIndexWrap::constructor.New( \
|
||||
{Napi::External<QModelIndex>::New(env, new QModelIndex(index))}); \
|
||||
this->emitOnNode.Call( \
|
||||
{Napi::String::New(env, "activated"), indexInstance}); \
|
||||
}); \
|
||||
QObject::connect( \
|
||||
this, &QAbstractItemView::clicked, [=](const QModelIndex& index) { \
|
||||
Napi::Env env = this->emitOnNode.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
auto indexInstance = QModelIndexWrap::constructor.New( \
|
||||
{Napi::External<QModelIndex>::New(env, new QModelIndex(index))}); \
|
||||
this->emitOnNode.Call( \
|
||||
{Napi::String::New(env, "clicked"), indexInstance}); \
|
||||
}); \
|
||||
QObject::connect( \
|
||||
this, &QAbstractItemView::doubleClicked, [=](const QModelIndex& index) { \
|
||||
Napi::Env env = this->emitOnNode.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
auto indexInstance = QModelIndexWrap::constructor.New( \
|
||||
{Napi::External<QModelIndex>::New(env, new QModelIndex(index))}); \
|
||||
this->emitOnNode.Call( \
|
||||
{Napi::String::New(env, "doubleClicked"), indexInstance}); \
|
||||
}); \
|
||||
QObject::connect( \
|
||||
this, &QAbstractItemView::entered, [=](const QModelIndex& index) { \
|
||||
Napi::Env env = this->emitOnNode.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
auto indexInstance = QModelIndexWrap::constructor.New( \
|
||||
{Napi::External<QModelIndex>::New(env, new QModelIndex(index))}); \
|
||||
this->emitOnNode.Call( \
|
||||
{Napi::String::New(env, "entered"), indexInstance}); \
|
||||
}); \
|
||||
QObject::connect( \
|
||||
this, &QAbstractItemView::iconSizeChanged, [=](const QSize& size) { \
|
||||
Napi::Env env = this->emitOnNode.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
auto sizeInstance = QSizeWrap::constructor.New( \
|
||||
{Napi::External<QSize>::New(env, new QSize(size))}); \
|
||||
this->emitOnNode.Call( \
|
||||
{Napi::String::New(env, "iconSizeChanged"), sizeInstance}); \
|
||||
}); \
|
||||
QObject::connect( \
|
||||
this, &QAbstractItemView::pressed, [=](const QModelIndex& index) { \
|
||||
Napi::Env env = this->emitOnNode.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
auto indexInstance = QModelIndexWrap::constructor.New( \
|
||||
{Napi::External<QModelIndex>::New(env, new QModelIndex(index))}); \
|
||||
this->emitOnNode.Call( \
|
||||
{Napi::String::New(env, "pressed"), indexInstance}); \
|
||||
}); \
|
||||
QObject::connect(this, &QAbstractItemView::viewportEntered, [=]() { \
|
||||
Napi::Env env = this->emitOnNode.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
this->emitOnNode.Call({Napi::String::New(env, "viewportEntered")}); \
|
||||
});
|
||||
|
||||
#endif // QABSTRACTITEMVIEW_SIGNALS
|
||||
|
||||
@ -9,7 +9,33 @@
|
||||
#include "QtWidgets/QHeaderView/nheaderview.hpp"
|
||||
|
||||
class DLL_EXPORT QHeaderViewWrap : public Napi::ObjectWrap<QHeaderViewWrap> {
|
||||
QABSTRACTITEMVIEW_WRAPPED_METHODS_DECLARATION
|
||||
QABSTRACTITEMVIEW_WRAPPED_METHODS_DECLARATION_NO_QHEADERVIEW_PROTECTED
|
||||
|
||||
Napi::Value indexAt(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
QPointWrap* pointWrap =
|
||||
Napi::ObjectWrap<QPointWrap>::Unwrap(info[0].As<Napi::Object>());
|
||||
QPoint* point = pointWrap->getInternalInstance();
|
||||
QModelIndex result = this->instance->QAbstractItemView::indexAt(*point);
|
||||
auto resultInstance = QModelIndexWrap::constructor.New(
|
||||
{Napi::External<QModelIndex>::New(env, new QModelIndex(result))});
|
||||
return resultInstance;
|
||||
}
|
||||
|
||||
Napi::Value scrollTo(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
QModelIndexWrap* indexWrap =
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(info[0].As<Napi::Object>());
|
||||
QModelIndex* index = indexWrap->getInternalInstance();
|
||||
QAbstractItemView::ScrollHint hint =
|
||||
static_cast<QAbstractItemView::ScrollHint>(
|
||||
info[1].As<Napi::Number>().Int32Value());
|
||||
this->instance->QAbstractItemView::scrollTo(*index, hint);
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
private:
|
||||
QPointer<QHeaderView> instance;
|
||||
bool disableDeletion;
|
||||
|
||||
@ -24,17 +24,20 @@ class DLL_EXPORT QListWidgetWrap : public Napi::ObjectWrap<QListWidgetWrap> {
|
||||
// wrapped methods
|
||||
Napi::Value addItem(const Napi::CallbackInfo& info);
|
||||
Napi::Value addItems(const Napi::CallbackInfo& info);
|
||||
Napi::Value closePersistentEditor(const Napi::CallbackInfo& info);
|
||||
Napi::Value closePersistentEditor_QListWidgetItem(
|
||||
const Napi::CallbackInfo& info);
|
||||
Napi::Value currentItem(const Napi::CallbackInfo& info);
|
||||
Napi::Value editItem(const Napi::CallbackInfo& info);
|
||||
Napi::Value findItems(const Napi::CallbackInfo& info);
|
||||
Napi::Value insertItem(const Napi::CallbackInfo& info);
|
||||
Napi::Value insertItems(const Napi::CallbackInfo& info);
|
||||
Napi::Value isPersistentEditorOpen(const Napi::CallbackInfo& info);
|
||||
Napi::Value isPersistentEditorOpen_QListWidgetItem(
|
||||
const Napi::CallbackInfo& info);
|
||||
Napi::Value item(const Napi::CallbackInfo& info);
|
||||
Napi::Value itemAt(const Napi::CallbackInfo& info);
|
||||
Napi::Value itemWidget(const Napi::CallbackInfo& info);
|
||||
Napi::Value openPersistentEditor(const Napi::CallbackInfo& info);
|
||||
Napi::Value openPersistentEditor_QListWidgetItem(
|
||||
const Napi::CallbackInfo& info);
|
||||
Napi::Value removeItemWidget(const Napi::CallbackInfo& info);
|
||||
Napi::Value row(const Napi::CallbackInfo& info);
|
||||
Napi::Value selectedItems(const Napi::CallbackInfo& info);
|
||||
|
||||
@ -0,0 +1,238 @@
|
||||
#include "QtCore/QItemSelectionModel/qitemselectionmodel_wrap.h"
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtCore/QModelIndex/qmodelindex_wrap.h"
|
||||
|
||||
Napi::FunctionReference QItemSelectionModelWrap::constructor;
|
||||
|
||||
Napi::Object QItemSelectionModelWrap::init(Napi::Env env,
|
||||
Napi::Object exports) {
|
||||
Napi::HandleScope scope(env);
|
||||
char CLASSNAME[] = "QItemSelectionModel";
|
||||
Napi::Function func = DefineClass(
|
||||
env, CLASSNAME,
|
||||
{InstanceMethod("columnIntersectsSelection",
|
||||
&QItemSelectionModelWrap::columnIntersectsSelection),
|
||||
InstanceMethod("currentIndex", &QItemSelectionModelWrap::currentIndex),
|
||||
InstanceMethod("hasSelection", &QItemSelectionModelWrap::hasSelection),
|
||||
InstanceMethod("isColumnSelected",
|
||||
&QItemSelectionModelWrap::isColumnSelected),
|
||||
InstanceMethod("isRowSelected", &QItemSelectionModelWrap::isRowSelected),
|
||||
InstanceMethod("isSelected", &QItemSelectionModelWrap::isSelected),
|
||||
InstanceMethod("rowIntersectsSelection",
|
||||
&QItemSelectionModelWrap::rowIntersectsSelection),
|
||||
InstanceMethod("clear", &QItemSelectionModelWrap::clear),
|
||||
InstanceMethod("clearCurrentIndex",
|
||||
&QItemSelectionModelWrap::clearCurrentIndex),
|
||||
InstanceMethod("clearSelection",
|
||||
&QItemSelectionModelWrap::clearSelection),
|
||||
InstanceMethod("reset", &QItemSelectionModelWrap::reset),
|
||||
InstanceMethod("select", &QItemSelectionModelWrap::select),
|
||||
InstanceMethod("setCurrentIndex",
|
||||
&QItemSelectionModelWrap::setCurrentIndex),
|
||||
InstanceMethod("selectedColumns",
|
||||
&QItemSelectionModelWrap::selectedColumns),
|
||||
InstanceMethod("selectedIndexes",
|
||||
&QItemSelectionModelWrap::selectedIndexes),
|
||||
InstanceMethod("selectedRows", &QItemSelectionModelWrap::selectedRows),
|
||||
QOBJECT_WRAPPED_METHODS_EXPORT_DEFINE(QItemSelectionModelWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
}
|
||||
|
||||
QItemSelectionModel* QItemSelectionModelWrap::getInternalInstance() {
|
||||
return this->instance;
|
||||
}
|
||||
QItemSelectionModelWrap::~QItemSelectionModelWrap() {
|
||||
if (!this->disableDeletion) {
|
||||
extrautils::safeDelete(this->instance);
|
||||
}
|
||||
}
|
||||
|
||||
QItemSelectionModelWrap::QItemSelectionModelWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QItemSelectionModelWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
if (info.Length() == 0) {
|
||||
this->instance = new NItemSelectionModel();
|
||||
this->disableDeletion = false;
|
||||
} else {
|
||||
this->instance = info[0].As<Napi::External<QItemSelectionModel>>().Data();
|
||||
this->disableDeletion = true;
|
||||
}
|
||||
}
|
||||
Napi::Value QItemSelectionModelWrap::columnIntersectsSelection(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
int column = info[0].As<Napi::Number>().Int32Value();
|
||||
QModelIndexWrap* parentWrap =
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(info[1].As<Napi::Object>());
|
||||
QModelIndex* parent = parentWrap->getInternalInstance();
|
||||
bool result = this->instance->columnIntersectsSelection(column, *parent);
|
||||
return Napi::Boolean::New(env, result);
|
||||
}
|
||||
|
||||
Napi::Value QItemSelectionModelWrap::currentIndex(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
QModelIndex result = this->instance->currentIndex();
|
||||
auto resultInstance = QModelIndexWrap::constructor.New(
|
||||
{Napi::External<QModelIndex>::New(env, new QModelIndex(result))});
|
||||
return resultInstance;
|
||||
}
|
||||
|
||||
Napi::Value QItemSelectionModelWrap::hasSelection(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
bool result = this->instance->hasSelection();
|
||||
return Napi::Boolean::New(env, result);
|
||||
}
|
||||
|
||||
Napi::Value QItemSelectionModelWrap::isColumnSelected(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
int column = info[0].As<Napi::Number>().Int32Value();
|
||||
QModelIndexWrap* parentWrap =
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(info[1].As<Napi::Object>());
|
||||
QModelIndex* parent = parentWrap->getInternalInstance();
|
||||
bool result = this->instance->isColumnSelected(column, *parent);
|
||||
return Napi::Boolean::New(env, result);
|
||||
}
|
||||
|
||||
Napi::Value QItemSelectionModelWrap::isRowSelected(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
int row = info[0].As<Napi::Number>().Int32Value();
|
||||
QModelIndexWrap* parentWrap =
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(info[1].As<Napi::Object>());
|
||||
QModelIndex* parent = parentWrap->getInternalInstance();
|
||||
bool result = this->instance->isRowSelected(row, *parent);
|
||||
return Napi::Boolean::New(env, result);
|
||||
}
|
||||
|
||||
Napi::Value QItemSelectionModelWrap::isSelected(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
QModelIndexWrap* indexWrap =
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(info[0].As<Napi::Object>());
|
||||
QModelIndex* index = indexWrap->getInternalInstance();
|
||||
bool result = this->instance->isSelected(*index);
|
||||
return Napi::Boolean::New(env, result);
|
||||
}
|
||||
|
||||
Napi::Value QItemSelectionModelWrap::rowIntersectsSelection(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
int row = info[0].As<Napi::Number>().Int32Value();
|
||||
QModelIndexWrap* parentWrap =
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(info[1].As<Napi::Object>());
|
||||
QModelIndex* parent = parentWrap->getInternalInstance();
|
||||
bool result = this->instance->rowIntersectsSelection(row, *parent);
|
||||
return Napi::Boolean::New(env, result);
|
||||
}
|
||||
|
||||
Napi::Value QItemSelectionModelWrap::clear(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->instance->clear();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QItemSelectionModelWrap::clearCurrentIndex(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->instance->clearCurrentIndex();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QItemSelectionModelWrap::clearSelection(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->instance->clearSelection();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QItemSelectionModelWrap::reset(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->instance->reset();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QItemSelectionModelWrap::select(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
QModelIndexWrap* indexWrap =
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(info[0].As<Napi::Object>());
|
||||
QModelIndex* index = indexWrap->getInternalInstance();
|
||||
QItemSelectionModel::SelectionFlags command =
|
||||
static_cast<QItemSelectionModel::SelectionFlags>(
|
||||
info[1].As<Napi::Number>().Int32Value());
|
||||
this->instance->select(*index, command);
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QItemSelectionModelWrap::setCurrentIndex(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
QModelIndexWrap* indexWrap =
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(info[0].As<Napi::Object>());
|
||||
QModelIndex* index = indexWrap->getInternalInstance();
|
||||
QItemSelectionModel::SelectionFlags command =
|
||||
static_cast<QItemSelectionModel::SelectionFlags>(
|
||||
info[1].As<Napi::Number>().Int32Value());
|
||||
this->instance->setCurrentIndex(*index, command);
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Value QItemSelectionModelWrap::selectedColumns(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
int row = info[0].As<Napi::Number>().Int32Value();
|
||||
QModelIndexList result = this->instance->selectedColumns(row);
|
||||
Napi::Array resultArrayNapi = Napi::Array::New(env, result.size());
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
resultArrayNapi[i] = QModelIndexWrap::constructor.New(
|
||||
{Napi::External<QModelIndex>::New(env, new QModelIndex(result[i]))});
|
||||
}
|
||||
return resultArrayNapi;
|
||||
}
|
||||
|
||||
Napi::Value QItemSelectionModelWrap::selectedIndexes(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
QModelIndexList result = this->instance->selectedIndexes();
|
||||
Napi::Array resultArrayNapi = Napi::Array::New(env, result.size());
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
resultArrayNapi[i] = QModelIndexWrap::constructor.New(
|
||||
{Napi::External<QModelIndex>::New(env, new QModelIndex(result[i]))});
|
||||
}
|
||||
return resultArrayNapi;
|
||||
}
|
||||
|
||||
Napi::Value QItemSelectionModelWrap::selectedRows(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
int column = info[0].As<Napi::Number>().Int32Value();
|
||||
QModelIndexList result = this->instance->selectedRows(column);
|
||||
Napi::Array resultArrayNapi = Napi::Array::New(env, result.size());
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
resultArrayNapi[i] = QModelIndexWrap::constructor.New(
|
||||
{Napi::External<QModelIndex>::New(env, new QModelIndex(result[i]))});
|
||||
}
|
||||
return resultArrayNapi;
|
||||
}
|
||||
@ -14,20 +14,20 @@ Napi::Object QListWidgetWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
env, CLASSNAME,
|
||||
{InstanceMethod("addItem", &QListWidgetWrap::addItem),
|
||||
InstanceMethod("addItems", &QListWidgetWrap::addItems),
|
||||
InstanceMethod("closePersistentEditor",
|
||||
&QListWidgetWrap::closePersistentEditor),
|
||||
InstanceMethod("closePersistentEditor_QListWidgetItem",
|
||||
&QListWidgetWrap::closePersistentEditor_QListWidgetItem),
|
||||
InstanceMethod("currentItem", &QListWidgetWrap::currentItem),
|
||||
InstanceMethod("editItem", &QListWidgetWrap::editItem),
|
||||
InstanceMethod("findItems", &QListWidgetWrap::findItems),
|
||||
InstanceMethod("insertItem", &QListWidgetWrap::insertItem),
|
||||
InstanceMethod("insertItems", &QListWidgetWrap::insertItems),
|
||||
InstanceMethod("isPersistentEditorOpen",
|
||||
&QListWidgetWrap::isPersistentEditorOpen),
|
||||
InstanceMethod("isPersistentEditorOpen_QModelIndex",
|
||||
&QListWidgetWrap::isPersistentEditorOpen_QListWidgetItem),
|
||||
InstanceMethod("item", &QListWidgetWrap::item),
|
||||
InstanceMethod("itemAt", &QListWidgetWrap::itemAt),
|
||||
InstanceMethod("itemWidget", &QListWidgetWrap::itemWidget),
|
||||
InstanceMethod("openPersistentEditor",
|
||||
&QListWidgetWrap::openPersistentEditor),
|
||||
InstanceMethod("openPersistentEditor_QListWidgetItem",
|
||||
&QListWidgetWrap::openPersistentEditor_QListWidgetItem),
|
||||
InstanceMethod("removeItemWidget", &QListWidgetWrap::removeItemWidget),
|
||||
InstanceMethod("row", &QListWidgetWrap::row),
|
||||
InstanceMethod("selectedItems", &QListWidgetWrap::selectedItems),
|
||||
@ -95,7 +95,7 @@ Napi::Value QListWidgetWrap::addItems(const Napi::CallbackInfo& info) {
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QListWidgetWrap::closePersistentEditor(
|
||||
Napi::Value QListWidgetWrap::closePersistentEditor_QListWidgetItem(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
@ -178,7 +178,7 @@ Napi::Value QListWidgetWrap::insertItems(const Napi::CallbackInfo& info) {
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QListWidgetWrap::isPersistentEditorOpen(
|
||||
Napi::Value QListWidgetWrap::isPersistentEditorOpen_QListWidgetItem(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
@ -230,7 +230,7 @@ Napi::Value QListWidgetWrap::itemWidget(const Napi::CallbackInfo& info) {
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value QListWidgetWrap::openPersistentEditor(
|
||||
Napi::Value QListWidgetWrap::openPersistentEditor_QListWidgetItem(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include "QtCore/QAbstractItemModel/qabstractitemmodel_wrap.h"
|
||||
#include "QtCore/QDate/qdate_wrap.h"
|
||||
#include "QtCore/QDateTime/qdatetime_wrap.h"
|
||||
#include "QtCore/QItemSelectionModel/qitemselectionmodel_wrap.h"
|
||||
#include "QtCore/QMimeData/qmimedata_wrap.h"
|
||||
#include "QtCore/QModelIndex/qmodelindex_wrap.h"
|
||||
#include "QtCore/QObject/qobject_wrap.h"
|
||||
@ -224,6 +225,7 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
|
||||
QPaletteWrap::init(env, exports);
|
||||
QAbstractItemModelWrap::init(env, exports);
|
||||
QHeaderViewWrap::init(env, exports);
|
||||
QItemSelectionModelWrap::init(env, exports);
|
||||
return exports;
|
||||
}
|
||||
|
||||
|
||||
11
src/index.ts
11
src/index.ts
@ -38,7 +38,15 @@ export { NodeLayout, QLayoutSignals, SizeConstraint } from './lib/QtWidgets/QLay
|
||||
export { QAbstractScrollArea } from './lib/QtWidgets/QAbstractScrollArea';
|
||||
export { QAbstractSlider, QAbstractSliderSignals, SliderAction } from './lib/QtWidgets/QAbstractSlider';
|
||||
export { QAbstractButton, QAbstractButtonSignals } from './lib/QtWidgets/QAbstractButton';
|
||||
export { QAbstractItemView, QAbstractItemViewSignals } from './lib/QtWidgets/QAbstractItemView';
|
||||
export {
|
||||
DragDropMode,
|
||||
EditTrigger,
|
||||
QAbstractItemView,
|
||||
QAbstractItemViewSignals,
|
||||
QAbstractItemViewSelectionBehavior,
|
||||
ScrollMode,
|
||||
SelectionMode,
|
||||
} from './lib/QtWidgets/QAbstractItemView';
|
||||
export {
|
||||
QAbstractSpinBox,
|
||||
QAbstractSpinBoxSignals,
|
||||
@ -133,6 +141,7 @@ export { QAbstractItemModel } from './lib/QtCore/QAbstractItemModel';
|
||||
export { QAbstractTableModel } from './lib/QtCore/QAbstractTableModel';
|
||||
export { QDate } from './lib/QtCore/QDate';
|
||||
export { QDateTime } from './lib/QtCore/QDateTime';
|
||||
export { QItemSelectionModel, SelectionFlag } from './lib/QtCore/QItemSelectionModel';
|
||||
export { QModelIndex } from './lib/QtCore/QModelIndex';
|
||||
export { QMimeData } from './lib/QtCore/QMimeData';
|
||||
export { QObject, QObjectSignals, NodeObject } from './lib/QtCore/QObject';
|
||||
|
||||
@ -217,7 +217,13 @@ export class QAbstractItemModel extends NodeObject<any> {
|
||||
destinationParent: QModelIndex,
|
||||
destinationChild: number,
|
||||
): boolean {
|
||||
return this.native.beginMoveColumns(sourceParent.native, sourceFirst, sourceLast, destinationParent.native, destinationChild);
|
||||
return this.native.beginMoveColumns(
|
||||
sourceParent.native,
|
||||
sourceFirst,
|
||||
sourceLast,
|
||||
destinationParent.native,
|
||||
destinationChild,
|
||||
);
|
||||
}
|
||||
|
||||
beginMoveRows(
|
||||
@ -227,7 +233,13 @@ export class QAbstractItemModel extends NodeObject<any> {
|
||||
destinationParent: QModelIndex,
|
||||
destinationChild: number,
|
||||
): boolean {
|
||||
return this.native.beginMoveRows(sourceParent.native, sourceFirst, sourceLast, destinationParent.native, destinationChild);
|
||||
return this.native.beginMoveRows(
|
||||
sourceParent.native,
|
||||
sourceFirst,
|
||||
sourceLast,
|
||||
destinationParent.native,
|
||||
destinationChild,
|
||||
);
|
||||
}
|
||||
|
||||
beginRemoveColumns(parent: QModelIndex, first: number, last: number): void {
|
||||
|
||||
120
src/lib/QtCore/QItemSelectionModel.ts
Normal file
120
src/lib/QtCore/QItemSelectionModel.ts
Normal file
@ -0,0 +1,120 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { NodeObject, QObjectSignals } from '../QtCore/QObject';
|
||||
import { QModelIndex } from './QModelIndex';
|
||||
import { checkIfNativeElement } from '../utils/helpers';
|
||||
|
||||
export type QItemSelectionModelSignals = QObjectSignals;
|
||||
|
||||
export class QItemSelectionModel extends NodeObject<QItemSelectionModelSignals> {
|
||||
native: NativeElement;
|
||||
constructor(arg?: NativeElement) {
|
||||
let native = null;
|
||||
if (arg == null) {
|
||||
native = new addon.QItemSelectionModel();
|
||||
} else if (checkIfNativeElement(arg)) {
|
||||
native = arg as NativeElement;
|
||||
} else {
|
||||
throw new Error('QItemSelectionModel cannot be initialised this way.');
|
||||
}
|
||||
super(native);
|
||||
this.native = native;
|
||||
}
|
||||
|
||||
// *** Public Functions ***
|
||||
columnIntersectsSelection(column: number, parent: QModelIndex = new QModelIndex()): boolean {
|
||||
return this.native.columnIntersectsSelection(column, parent.native);
|
||||
}
|
||||
|
||||
currentIndex(): QModelIndex {
|
||||
return this.native.currentIndex();
|
||||
}
|
||||
|
||||
hasSelection(): boolean {
|
||||
return this.native.hasSelection();
|
||||
}
|
||||
|
||||
isColumnSelected(column: number, parent: QModelIndex = new QModelIndex()): boolean {
|
||||
return this.native.isColumnSelected(column, parent.native);
|
||||
}
|
||||
|
||||
isRowSelected(row: number, parent: QModelIndex = new QModelIndex()): boolean {
|
||||
return this.native.isRowSelected(row, parent.native);
|
||||
}
|
||||
|
||||
isSelected(index: QModelIndex): boolean {
|
||||
return this.native.isSelected(index.native);
|
||||
}
|
||||
|
||||
// TODO: const QAbstractItemModel * model() const
|
||||
// TODO: QAbstractItemModel * model()
|
||||
rowIntersectsSelection(row: number, parent: QModelIndex = new QModelIndex()): boolean {
|
||||
return this.native.rowIntersectsSelection(row, parent.native);
|
||||
}
|
||||
|
||||
selectedColumns(row = 0): QModelIndex[] {
|
||||
const methodResult = this.native.selectedColumns(row);
|
||||
return methodResult.map((item: any) => new QModelIndex(item));
|
||||
}
|
||||
|
||||
selectedIndexes(): QModelIndex[] {
|
||||
const methodResult = this.native.selectedIndexes();
|
||||
return methodResult.map((item: any) => new QModelIndex(item));
|
||||
}
|
||||
|
||||
selectedRows(column = 0): QModelIndex[] {
|
||||
const methodResult = this.native.selectedRows(column);
|
||||
return methodResult.map((item: any) => new QModelIndex(item));
|
||||
}
|
||||
|
||||
// TODO: const QItemSelection selection() const
|
||||
// TODO: void setModel(QAbstractItemModel *model)
|
||||
|
||||
// *** Public Slots ***
|
||||
clear(): void {
|
||||
this.native.clear();
|
||||
}
|
||||
|
||||
clearCurrentIndex(): void {
|
||||
this.native.clearCurrentIndex();
|
||||
}
|
||||
|
||||
clearSelection(): void {
|
||||
this.native.clearSelection();
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this.native.reset();
|
||||
}
|
||||
|
||||
// TODO: virtual void select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command)
|
||||
|
||||
select(index: QModelIndex, command: SelectionFlag): void {
|
||||
this.native.select(index.native, command);
|
||||
}
|
||||
|
||||
setCurrentIndex(index: QModelIndex, command: SelectionFlag): void {
|
||||
this.native.setCurrentIndex(index.native, command);
|
||||
}
|
||||
|
||||
// *** Signals ***
|
||||
// TODO: void currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||
// TODO: void currentColumnChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||
// TODO: void currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||
// TODO: void modelChanged(QAbstractItemModel *model)
|
||||
// TODO: void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
|
||||
}
|
||||
|
||||
export enum SelectionFlag {
|
||||
NoUpdate = 0x0000,
|
||||
Clear = 0x0001,
|
||||
Select = 0x0002,
|
||||
Deselect = 0x0004,
|
||||
Toggle = 0x0008,
|
||||
Current = 0x0010,
|
||||
Rows = 0x0020,
|
||||
Columns = 0x0040,
|
||||
SelectCurrent = SelectionFlag.Select | SelectionFlag.Current,
|
||||
ToggleCurrent = SelectionFlag.Toggle | SelectionFlag.Current,
|
||||
ClearAndSelect = SelectionFlag.Clear | SelectionFlag.Select,
|
||||
}
|
||||
@ -5,6 +5,9 @@ import { QSize } from '../QtCore/QSize';
|
||||
import { DropAction } from '../QtEnums/DropAction';
|
||||
import { TextElideMode } from '../QtEnums/TextElideMode';
|
||||
import { QAbstractItemModel } from '../QtCore/QAbstractItemModel';
|
||||
import { QPoint } from '../QtCore/QPoint';
|
||||
import { QItemSelectionModel } from '../QtCore/QItemSelectionModel';
|
||||
import { NativeElement } from '../core/Component';
|
||||
|
||||
/**
|
||||
|
||||
@ -18,138 +21,201 @@ It is inherited by QListWidget. (n/a QColumnView, QHeaderView, QListView, QTable
|
||||
*/
|
||||
|
||||
export abstract class QAbstractItemView<Signals extends QAbstractItemViewSignals> extends QAbstractScrollArea<Signals> {
|
||||
setCurrentIndex(index: QModelIndex): void {
|
||||
this.native.setCurrentIndex(index.native);
|
||||
// *** Public Functions ***
|
||||
alternatingRowColors(): boolean {
|
||||
return this.property('alternatingRowColors').toBool();
|
||||
}
|
||||
autoScrollMargin(): number {
|
||||
return this.property('autoScrollMargin').toInt();
|
||||
}
|
||||
closePersistentEditor(index: QModelIndex): void {
|
||||
this.native.closePersistentEditor(index);
|
||||
}
|
||||
currentIndex(): QModelIndex {
|
||||
return new QModelIndex(this.native.currentIndex());
|
||||
}
|
||||
setIndexWidget(index: QModelIndex, widget: QWidget): void {
|
||||
this.native.setIndexWidget(index.native, widget.native);
|
||||
defaultDropAction(): DropAction {
|
||||
return this.property('defaultDropAction').toInt();
|
||||
}
|
||||
dragDropMode(): DragDropMode {
|
||||
return this.property('dragDropMode').toInt();
|
||||
}
|
||||
dragDropOverwriteMode(): boolean {
|
||||
return this.property('dragDropOverwriteMode').toBool();
|
||||
}
|
||||
dragEnabled(): boolean {
|
||||
return this.property('dragEnabled').toBool();
|
||||
}
|
||||
editTriggers(): number {
|
||||
return this.property('editTriggers').toInt();
|
||||
}
|
||||
hasAutoScroll(): boolean {
|
||||
return this.property('autoScroll').toBool();
|
||||
}
|
||||
horizontalScrollMode(): ScrollMode {
|
||||
return this.property('horizontalScrollMode').toInt();
|
||||
}
|
||||
iconSize(): QSize {
|
||||
const iconSize = this.property('iconSize');
|
||||
return QSize.fromQVariant(iconSize);
|
||||
}
|
||||
indexAt(point: QPoint): QModelIndex {
|
||||
return this.native.indexAt(point);
|
||||
}
|
||||
indexWidget(index: QModelIndex): QWidget {
|
||||
return new QWidget(this.native.indexWidget(index));
|
||||
}
|
||||
|
||||
isPersistentEditorOpen(index: QModelIndex): boolean {
|
||||
return this.native.isPersistentEditorOpen(index.native);
|
||||
}
|
||||
// TODO: QAbstractItemDelegate * itemDelegate() const
|
||||
// TODO: QAbstractItemDelegate * itemDelegate(const QModelIndex &index) const
|
||||
// TODO: QAbstractItemDelegate * itemDelegateForColumn(int column) const
|
||||
// TODO: QAbstractItemDelegate * itemDelegateForRow(int row) const
|
||||
keyboardSearch(search: string): void {
|
||||
this.native.keyboardSearch(search);
|
||||
}
|
||||
// TODO: QAbstractItemModel * model() const
|
||||
openPersistentEditor(index: QModelIndex): void {
|
||||
this.native.openPersistentEditor(index.native);
|
||||
}
|
||||
resetHorizontalScrollMode(): void {
|
||||
this.native.resetHorizontalScrollMode();
|
||||
}
|
||||
resetVerticalScrollMode(): void {
|
||||
this.native.resetVerticalScrollMode();
|
||||
}
|
||||
rootIndex(): QModelIndex {
|
||||
return new QModelIndex(this.native.rootIndex());
|
||||
}
|
||||
scrollTo(index: QModelIndex, hint = ScrollHint.EnsureVisible): void {
|
||||
this.native.scrollTo(index.native, hint);
|
||||
}
|
||||
selectionBehavior(): QAbstractItemViewSelectionBehavior {
|
||||
return this.property('selectionBehavior').toInt();
|
||||
}
|
||||
selectionMode(): SelectionMode {
|
||||
return this.property('selectionMode').toInt();
|
||||
}
|
||||
selectionModel(): QItemSelectionModel {
|
||||
return new QItemSelectionModel(this.native.selectionModel());
|
||||
}
|
||||
setAlternatingRowColors(enable: boolean): void {
|
||||
this.setProperty('alternatingRowColors', enable);
|
||||
}
|
||||
setAutoScroll(enable: boolean): void {
|
||||
this.setProperty('autoScroll', enable);
|
||||
}
|
||||
setAutoScrollMargin(margin: number): void {
|
||||
this.setProperty('autoScrollMargin', margin);
|
||||
}
|
||||
setDefaultDropAction(dropAction: DropAction): void {
|
||||
this.setProperty('defaultDropAction', dropAction);
|
||||
}
|
||||
setDragDropMode(behavior: DragDropMode): void {
|
||||
this.setProperty('dragDropMode', behavior);
|
||||
}
|
||||
setDragDropOverwriteMode(overwrite: boolean): void {
|
||||
this.setProperty('dragDropOverwriteMode', overwrite);
|
||||
}
|
||||
setDragEnabled(enable: boolean): void {
|
||||
this.setProperty('dragEnabled', enable);
|
||||
}
|
||||
setDropIndicatorShown(enable: boolean): void {
|
||||
this.setProperty('showDropIndicator', enable);
|
||||
}
|
||||
setEditTriggers(triggers: number): void {
|
||||
this.setProperty('editTriggers', triggers);
|
||||
}
|
||||
setHorizontalScrollMode(mode: boolean): void {
|
||||
this.setProperty('horizontalScrollMode', mode);
|
||||
}
|
||||
setIconSize(iconSize: QSize): void {
|
||||
this.setProperty('iconSize', iconSize.native);
|
||||
}
|
||||
setIndexWidget(index: QModelIndex, widget: QWidget): void {
|
||||
this.native.setIndexWidget(index.native, widget.native);
|
||||
}
|
||||
// TODO: void setItemDelegate(QAbstractItemDelegate *delegate)
|
||||
// TODO: void setItemDelegateForColumn(int column, QAbstractItemDelegate *delegate)
|
||||
// TODO: void setItemDelegateForRow(int row, QAbstractItemDelegate *delegate)
|
||||
setModel(model: QAbstractItemModel): void {
|
||||
this.native.setModel(model.native);
|
||||
}
|
||||
setSelectionBehavior(behavior: QAbstractItemViewSelectionBehavior): void {
|
||||
this.setProperty('selectionBehavior', behavior);
|
||||
}
|
||||
setSelectionMode(mode: SelectionMode): void {
|
||||
this.setProperty('selectionMode', mode);
|
||||
}
|
||||
// TODO: virtual void setSelectionModel(QItemSelectionModel *selectionModel)
|
||||
setTabKeyNavigation(enable: boolean): void {
|
||||
this.setProperty('tabKeyNavigation', enable);
|
||||
}
|
||||
setTextElideMode(mode: TextElideMode): void {
|
||||
this.setProperty('textElideMode', mode);
|
||||
}
|
||||
setVerticalScrollMode(mode: ScrollMode): void {
|
||||
this.setProperty('verticalScrollMode', mode);
|
||||
}
|
||||
showDropIndicator(): boolean {
|
||||
return this.property('showDropIndicator').toBool();
|
||||
}
|
||||
// TODO: virtual int sizeHintForColumn(int column) const
|
||||
// TODO: QSize sizeHintForIndex(const QModelIndex &index) const
|
||||
// TODO: virtual int sizeHintForRow(int row) const
|
||||
tabKeyNavigation(): boolean {
|
||||
return this.property('tabKeyNavigation').toBool();
|
||||
}
|
||||
textElideMode(): TextElideMode {
|
||||
return this.property('textElideMode').toInt();
|
||||
}
|
||||
verticalScrollMode(): ScrollMode {
|
||||
return this.property('verticalScrollMode').toInt();
|
||||
}
|
||||
// TODO: virtual QRect visualRect(const QModelIndex &index) const = 0
|
||||
|
||||
// *** Public Slots ***
|
||||
clearSelection(): void {
|
||||
this.native.clearSelection();
|
||||
}
|
||||
edit(index: QModelIndex): void {
|
||||
this.native.edit(index.native);
|
||||
}
|
||||
reset(): void {
|
||||
this.native.reset();
|
||||
}
|
||||
scrollToBottom(): void {
|
||||
this.native.scrollToBottom();
|
||||
}
|
||||
scrollToTop(): void {
|
||||
this.native.scrollToTop();
|
||||
}
|
||||
setAlternatingRowColors(enable: boolean): void {
|
||||
this.setProperty('alternatingRowColors', enable);
|
||||
selectAll(): void {
|
||||
this.native.selectAll();
|
||||
}
|
||||
alternatingRowColors(): boolean {
|
||||
return this.property('alternatingRowColors').toBool();
|
||||
setCurrentIndex(index: QModelIndex): void {
|
||||
this.native.setCurrentIndex(index.native);
|
||||
}
|
||||
setAutoScroll(enable: boolean): void {
|
||||
this.setProperty('autoScroll', enable);
|
||||
setRootIndex(index: QModelIndex): void {
|
||||
this.native.setRootIndex(index.native);
|
||||
}
|
||||
hasAutoScroll(): boolean {
|
||||
return this.property('autoScroll').toBool();
|
||||
}
|
||||
setAutoScrollMargin(margin: number): void {
|
||||
this.setProperty('autoScrollMargin', margin);
|
||||
}
|
||||
autoScrollMargin(): number {
|
||||
return this.property('autoScrollMargin').toInt();
|
||||
}
|
||||
setDefaultDropAction(dropAction: DropAction): void {
|
||||
this.setProperty('defaultDropAction', dropAction);
|
||||
}
|
||||
defaultDropAction(): DropAction {
|
||||
return this.property('defaultDropAction').toInt();
|
||||
}
|
||||
setDragDropMode(behavior: DragDropMode): void {
|
||||
this.setProperty('dragDropMode', behavior);
|
||||
}
|
||||
dragDropMode(): DragDropMode {
|
||||
return this.property('dragDropMode').toInt();
|
||||
}
|
||||
setDragDropOverwriteMode(overwrite: boolean): void {
|
||||
this.setProperty('dragDropOverwriteMode', overwrite);
|
||||
}
|
||||
dragDropOverwriteMode(): boolean {
|
||||
return this.property('dragDropOverwriteMode').toBool();
|
||||
}
|
||||
setDragEnabled(enable: boolean): void {
|
||||
this.setProperty('dragEnabled', enable);
|
||||
}
|
||||
dragEnabled(): boolean {
|
||||
return this.property('dragEnabled').toBool();
|
||||
}
|
||||
setEditTriggers(triggers: number): void {
|
||||
this.setProperty('editTriggers', triggers);
|
||||
}
|
||||
editTriggers(): number {
|
||||
return this.property('editTriggers').toInt();
|
||||
}
|
||||
setHorizontalScrollMode(mode: boolean): void {
|
||||
this.setProperty('horizontalScrollMode', mode);
|
||||
}
|
||||
horizontalScrollMode(): ScrollMode {
|
||||
return this.property('horizontalScrollMode').toInt();
|
||||
}
|
||||
resetHorizontalScrollMode(): void {
|
||||
this.native.resetHorizontalScrollMode();
|
||||
}
|
||||
setIconSize(iconSize: QSize): void {
|
||||
this.setProperty('iconSize', iconSize.native);
|
||||
}
|
||||
iconSize(): QSize {
|
||||
const iconSize = this.property('iconSize');
|
||||
return QSize.fromQVariant(iconSize);
|
||||
}
|
||||
setSelectionBehavior(behavior: SelectionBehavior): void {
|
||||
this.setProperty('selectionBehavior', behavior);
|
||||
}
|
||||
selectionBehavior(): SelectionBehavior {
|
||||
return this.property('selectionBehavior').toInt();
|
||||
}
|
||||
setSelectionMode(mode: SelectionMode): void {
|
||||
this.setProperty('selectionMode', mode);
|
||||
}
|
||||
selectionMode(): SelectionMode {
|
||||
return this.property('selectionMode').toInt();
|
||||
}
|
||||
setDropIndicatorShown(enable: boolean): void {
|
||||
this.setProperty('showDropIndicator', enable);
|
||||
}
|
||||
showDropIndicator(): boolean {
|
||||
return this.property('showDropIndicator').toBool();
|
||||
}
|
||||
setTabKeyNavigation(enable: boolean): void {
|
||||
this.setProperty('tabKeyNavigation', enable);
|
||||
}
|
||||
tabKeyNavigation(): boolean {
|
||||
return this.property('tabKeyNavigation').toBool();
|
||||
}
|
||||
setTextElideMode(mode: TextElideMode): void {
|
||||
this.setProperty('textElideMode', mode);
|
||||
}
|
||||
textElideMode(): TextElideMode {
|
||||
return this.property('textElideMode').toInt();
|
||||
}
|
||||
setVerticalScrollMode(mode: ScrollMode): void {
|
||||
this.setProperty('verticalScrollMode', mode);
|
||||
}
|
||||
verticalScrollMode(): ScrollMode {
|
||||
return this.property('verticalScrollMode').toInt();
|
||||
}
|
||||
resetVerticalScrollMode(): void {
|
||||
this.native.resetVerticalScrollMode();
|
||||
}
|
||||
setModel(model: QAbstractItemModel): void {
|
||||
this.native.setModel(model.native);
|
||||
update(index?: QModelIndex): void {
|
||||
if (index == null) {
|
||||
super.update();
|
||||
} else {
|
||||
this.native.update_QModelIndex(index.native);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export enum DragDropMode {
|
||||
NoDragDrop,
|
||||
DragOnly,
|
||||
DropOnly,
|
||||
DragDrop,
|
||||
InternalMove,
|
||||
NoDragDrop = 0,
|
||||
DragOnly = 1,
|
||||
DropOnly = 2,
|
||||
DragDrop = 3,
|
||||
InternalMove = 4,
|
||||
}
|
||||
|
||||
export enum EditTrigger {
|
||||
@ -162,25 +228,39 @@ export enum EditTrigger {
|
||||
AllEditTriggers = 31,
|
||||
}
|
||||
|
||||
export enum ScrollMode {
|
||||
ScrollPerItem,
|
||||
ScrollPerPixel,
|
||||
export enum ScrollHint {
|
||||
EnsureVisible = 0,
|
||||
PositionAtTop = 1,
|
||||
PositionAtBottom = 2,
|
||||
PositionAtCenter = 3,
|
||||
}
|
||||
|
||||
export enum SelectionBehavior {
|
||||
SelectItems,
|
||||
SelectRows,
|
||||
SelectColumns,
|
||||
export enum ScrollMode {
|
||||
ScrollPerItem = 0,
|
||||
ScrollPerPixel = 1,
|
||||
}
|
||||
|
||||
// QTabBar also has a SelectionBehavior, so we prefix this one.
|
||||
export enum QAbstractItemViewSelectionBehavior {
|
||||
SelectItems = 0,
|
||||
SelectRows = 1,
|
||||
SelectColumns = 2,
|
||||
}
|
||||
|
||||
export enum SelectionMode {
|
||||
NoSelection,
|
||||
SingleSelection,
|
||||
MultiSelection,
|
||||
ExtendedSelection,
|
||||
ContiguousSelection,
|
||||
NoSelection = 0,
|
||||
SingleSelection = 1,
|
||||
MultiSelection = 2,
|
||||
ExtendedSelection = 3,
|
||||
ContiguousSelection = 4,
|
||||
}
|
||||
|
||||
export interface QAbstractItemViewSignals extends QAbstractScrollAreaSignals {
|
||||
activated: (index: NativeElement /* QModelIndex */) => void;
|
||||
clicked: (index: NativeElement /* QModelIndex */) => void;
|
||||
doubleClicked: (index: NativeElement /* QModelIndex */) => void;
|
||||
entered: (index: NativeElement /* QModelIndex */) => void;
|
||||
iconSizeChanged: (size: NativeElement /* QSize */) => void;
|
||||
pressed: (index: NativeElement /* QModelIndex */) => void;
|
||||
viewportEntered: () => void;
|
||||
}
|
||||
|
||||
@ -5,9 +5,10 @@ import { QListWidgetItem } from './QListWidgetItem';
|
||||
import { NodeListView, QListViewSignals } from './QListView';
|
||||
import { QRect } from '../QtCore/QRect';
|
||||
import { SortOrder, ScrollHint, MatchFlag } from '../QtEnums';
|
||||
import { QModelIndex } from '../QtCore/QModelIndex';
|
||||
|
||||
/**
|
||||
|
||||
|
||||
> Create and control a item-based list.
|
||||
|
||||
* **This class is a JS wrapper around Qt's [QListWidget class](https://doc.qt.io/qt-5/qlistwidget.html)**
|
||||
@ -70,8 +71,12 @@ export class QListWidget extends NodeListView<QListWidgetSignals> {
|
||||
addItems(labels: string[]): void {
|
||||
this.native.addItems(labels);
|
||||
}
|
||||
closePersistentEditor(item: QListWidgetItem): void {
|
||||
this.native.closePersistentEditor(item.native);
|
||||
closePersistentEditor(itemOrIndex: QListWidgetItem | QModelIndex): void {
|
||||
if (itemOrIndex instanceof QListWidgetItem) {
|
||||
this.native.closePersistentEditor_QListWidgetItem(itemOrIndex.native);
|
||||
} else {
|
||||
this.native.closePersistentEditor(itemOrIndex.native);
|
||||
}
|
||||
}
|
||||
currentItem(): QListWidgetItem {
|
||||
return new QListWidgetItem(this.native.currentItem());
|
||||
@ -92,8 +97,12 @@ export class QListWidget extends NodeListView<QListWidgetSignals> {
|
||||
insertItems(row: number, labels: string[]): void {
|
||||
this.native.insertItems(row, labels);
|
||||
}
|
||||
isPersistentEditorOpen(item: QListWidgetItem): boolean {
|
||||
return this.native.isPersistentEditorOpen(item.native);
|
||||
isPersistentEditorOpen(itemOrIndex: QListWidgetItem | QModelIndex): boolean {
|
||||
if (itemOrIndex instanceof QListWidgetItem) {
|
||||
return this.native.isPersistentEditorOpen_QListWidgetItem(itemOrIndex.native);
|
||||
} else {
|
||||
return this.native.isPersistentEditorOpen(itemOrIndex.native);
|
||||
}
|
||||
}
|
||||
item(row: number): QListWidgetItem {
|
||||
return new QListWidgetItem(this.native.item(row));
|
||||
@ -104,8 +113,12 @@ export class QListWidget extends NodeListView<QListWidgetSignals> {
|
||||
itemWidget(item: QListWidgetItem): QWidget {
|
||||
return new QWidget(this.native.itemWidget(item.native));
|
||||
}
|
||||
openPersistentEditor(item: QListWidgetItem): void {
|
||||
this.native.openPersistentEditor(item.native);
|
||||
openPersistentEditor(itemOrIndex: QListWidgetItem | QModelIndex): void {
|
||||
if (itemOrIndex instanceof QListWidgetItem) {
|
||||
this.native.openPersistentEditor_QListWidgetItem(itemOrIndex.native);
|
||||
} else {
|
||||
this.native.openPersistentEditor(itemOrIndex.native);
|
||||
}
|
||||
}
|
||||
removeItemWidget(item: QListWidgetItem): void {
|
||||
this.native.removeItemWidget(item.native);
|
||||
|
||||
@ -7,7 +7,7 @@ import { QAbstractScrollArea, QAbstractScrollAreaSignals } from './QAbstractScro
|
||||
import { QRect } from '../QtCore/QRect';
|
||||
|
||||
/**
|
||||
|
||||
|
||||
> Creates and item-based table view.
|
||||
|
||||
* **This class is a JS wrapper around Qt's [QTableWidget class](https://doc.qt.io/qt-5/qtablewidget.html)**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user