Add sizeHintForIndex() and visualRect() to QAbstractItemView
This commit is contained in:
parent
9fcc5e99d3
commit
76743cd414
@ -211,6 +211,16 @@
|
||||
this->instance->setItemDelegateForRow(row, delegate); \
|
||||
} \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value sizeHintForIndex(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
QModelIndexWrap* indexWrap = \
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(info[0].As<Napi::Object>()); \
|
||||
QModelIndex* index = indexWrap->getInternalInstance(); \
|
||||
QSize result = this->instance->sizeHintForIndex(*index); \
|
||||
auto resultInstance = QSizeWrap::constructor.New( \
|
||||
{Napi::External<QSize>::New(env, new QSize(result))}); \
|
||||
return resultInstance; \
|
||||
}
|
||||
|
||||
#define QABSTRACTITEMVIEW_WRAPPED_METHODS_DECLARATION \
|
||||
@ -235,6 +245,16 @@
|
||||
info[1].As<Napi::Number>().Int32Value()); \
|
||||
this->instance->scrollTo(*index, hint); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value visualRect(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
QModelIndexWrap* indexWrap = \
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(info[0].As<Napi::Object>()); \
|
||||
QModelIndex* index = indexWrap->getInternalInstance(); \
|
||||
QRect ret = this->instance->visualRect(*index); \
|
||||
auto instance = QRectWrap::constructor.New( \
|
||||
{Napi::External<QRect>::New(env, new QRect(ret))}); \
|
||||
return instance; \
|
||||
}
|
||||
|
||||
#endif // QABSTRACTITEMVIEW_WRAPPED_METHODS_DECLARATION
|
||||
@ -275,7 +295,9 @@
|
||||
InstanceMethod("setItemDelegateForColumn", \
|
||||
&WidgetWrapName::setItemDelegateForColumn), \
|
||||
InstanceMethod("setItemDelegateForRow", \
|
||||
&WidgetWrapName::setItemDelegateForRow),
|
||||
&WidgetWrapName::setItemDelegateForRow), \
|
||||
InstanceMethod("visualRect", &WidgetWrapName::visualRect), \
|
||||
InstanceMethod("sizeHintForIndex", &WidgetWrapName::sizeHintForIndex),
|
||||
|
||||
#endif // QABSTRACTITEMVIEW_WRAPPED_METHODS_EXPORT_DEFINE
|
||||
|
||||
|
||||
@ -21,4 +21,7 @@ class DLL_EXPORT NHeaderView : public QHeaderView, public NodeWidget {
|
||||
void _protected_scrollTo(const QModelIndex &index, ScrollHint hint) {
|
||||
scrollTo(index, hint);
|
||||
}
|
||||
QRect _protected_visualRect(const QModelIndex &index) const {
|
||||
return visualRect(index);
|
||||
}
|
||||
};
|
||||
|
||||
@ -43,6 +43,22 @@ class DLL_EXPORT QHeaderViewWrap : public Napi::ObjectWrap<QHeaderViewWrap> {
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value visualRect(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
|
||||
NHeaderView* wrapper = dynamic_cast<NHeaderView*>(this->instance.data());
|
||||
if (wrapper) {
|
||||
QModelIndexWrap* indexWrap =
|
||||
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(info[0].As<Napi::Object>());
|
||||
QModelIndex* index = indexWrap->getInternalInstance();
|
||||
QRect ret = wrapper->_protected_visualRect(*index);
|
||||
auto instance = QRectWrap::constructor.New(
|
||||
{Napi::External<QRect>::New(env, new QRect(ret))});
|
||||
return instance;
|
||||
}
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
private:
|
||||
QPointer<QHeaderView> instance;
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ import { QItemSelectionModel } from '../QtCore/QItemSelectionModel';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { wrapperCache } from '../core/WrapperCache';
|
||||
import { QAbstractItemDelegate } from './QAbstractItemDelegate';
|
||||
import { QRect } from '../QtCore/QRect';
|
||||
|
||||
/**
|
||||
|
||||
@ -197,9 +198,11 @@ export abstract class QAbstractItemView<Signals extends QAbstractItemViewSignals
|
||||
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
|
||||
// TODO: virtual int sizeHintForColumn(int column) const
|
||||
sizeHintForIndex(index: QModelIndex): QSize {
|
||||
return new QSize(this.native.sizeHintForIndex(index.native));
|
||||
}
|
||||
// TODO: virtual int sizeHintForRow(int row) const
|
||||
tabKeyNavigation(): boolean {
|
||||
return this.property('tabKeyNavigation').toBool();
|
||||
}
|
||||
@ -209,7 +212,9 @@ export abstract class QAbstractItemView<Signals extends QAbstractItemViewSignals
|
||||
verticalScrollMode(): ScrollMode {
|
||||
return this.property('verticalScrollMode').toInt();
|
||||
}
|
||||
// TODO: virtual QRect visualRect(const QModelIndex &index) const = 0
|
||||
visualRect(index: QModelIndex): QRect {
|
||||
return new QRect(this.native.visualRect(index.native));
|
||||
}
|
||||
|
||||
// *** Public Slots ***
|
||||
clearSelection(): void {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user