Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,9 @@ class DLL_EXPORT QTableWidgetWrap : public Napi::ObjectWrap<QTableWidgetWrap> {
Napi::Value visualColumn(const Napi::CallbackInfo& info);
Napi::Value visualItemRect(const Napi::CallbackInfo& info);
Napi::Value visualRow(const Napi::CallbackInfo& info);
Napi::Value columnCount(const Napi::CallbackInfo& info);
Napi::Value rowCount(const Napi::CallbackInfo& info);
Napi::Value setColumnCount(const Napi::CallbackInfo& info);
Napi::Value setRowCount(const Napi::CallbackInfo& info);

};
48 changes: 48 additions & 0 deletions src/cpp/lib/QtWidgets/QTableWidget/qtablewidget_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,27 @@ Napi::Object QTableWidgetWrap::init(Napi::Env env, Napi::Object exports) {
InstanceMethod("insertRow", &QTableWidgetWrap::insertRow),
InstanceMethod("removeRow", &QTableWidgetWrap::removeRow),
InstanceMethod("scrollToItem", &QTableWidgetWrap::scrollToItem),
InstanceMethod("cellWidget", &QTableWidgetWrap::cellWidget),
InstanceMethod("column", &QTableWidgetWrap::column),
InstanceMethod("row", &QTableWidgetWrap::row),
InstanceMethod("currentColumn", &QTableWidgetWrap::currentColumn),
InstanceMethod("currentItem", &QTableWidgetWrap::currentItem),
InstanceMethod("currentRow", &QTableWidgetWrap::currentRow),
InstanceMethod("findItems", &QTableWidgetWrap::findItems),
InstanceMethod("item", &QTableWidgetWrap::item),
InstanceMethod("itemAt", &QTableWidgetWrap::itemAt),
InstanceMethod("removeCellWidget", &QTableWidgetWrap::removeCellWidget),
InstanceMethod("setCurrentCell", &QTableWidgetWrap::setCurrentCell),
InstanceMethod("setCurrentItem", &QTableWidgetWrap::setCurrentItem),
InstanceMethod("sortItems", &QTableWidgetWrap::sortItems),
InstanceMethod("takeItem", &QTableWidgetWrap::takeItem),
InstanceMethod("visualColumn", &QTableWidgetWrap::visualColumn),
InstanceMethod("visualItemRect", &QTableWidgetWrap::visualItemRect),
InstanceMethod("visualRow", &QTableWidgetWrap::visualRow),
InstanceMethod("columnCount", &QTableWidgetWrap::columnCount),
InstanceMethod("rowCount", &QTableWidgetWrap::rowCount),
InstanceMethod("setColumnCount", &QTableWidgetWrap::setColumnCount),
InstanceMethod("setRowCount", &QTableWidgetWrap::setRowCount),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we have a whole bunch of code in there which just was never hooked up to the nodejs wrapper?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I added the 4 actual missing functions that everything got somehow removed, and then re-wired the 15 or so missing InstanceMethod that should have been tied to code that still existed in both the C/H & TS files -- but somehow lost the InstanceMethods. So that code was failing from the TS/JS side since they weren't actually wired up...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should probably also mention the existing code still works and was originally from one of my prior PR's. It was hooked up before the refactoring, as I've been using several of those functions with QT 5. I finally upgraded the library to the current version and found all the broken issues.

My program seems to now be working again with the changes I've made into this PR.

InstanceMethod(
"isPersistentEditorOpen_qtablewidgetitem",
&QTableWidgetWrap::isPersistentEditorOpen_qtablewidgetitem),
Expand Down Expand Up @@ -451,3 +472,30 @@ Napi::Value QTableWidgetWrap::visualRow(const Napi::CallbackInfo& info) {
int row = this->instance->visualRow(logicalRow);
return Napi::Number::New(env, row);
}

Napi::Value QTableWidgetWrap::columnCount(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int count = static_cast<int>(this->instance->columnCount());
return Napi::Number::New(env, count);
}

Napi::Value QTableWidgetWrap::rowCount(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int count = static_cast<int>(this->instance->rowCount());
return Napi::Number::New(env, count);
}

Napi::Value QTableWidgetWrap::setColumnCount(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int count = info[0].As<Napi::Number>().Int32Value();
this->instance->setColumnCount(count);
return env.Null();
}

Napi::Value QTableWidgetWrap::setRowCount(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int count = info[0].As<Napi::Number>().Int32Value();
this->instance->setRowCount(count);
return env.Null();
}

12 changes: 12 additions & 0 deletions src/lib/QtWidgets/QTableWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,18 @@ export class QTableWidget extends QTableView<QTableWidgetSignals> {
visualRow(logicalRow = 0): number {
return this.native.visualColumn(logicalRow);
}
columnCount(): number {
return this.native.columnCount();
}
rowCount(): number {
return this.native.rowCount();
}
setColumnCount(count: number): void {
this.native.setColumnCount(count);
}
setRowCount(count: number): void {
this.native.setRowCount(count);
}
}
wrapperCache.registerWrapper('QTableWidgetWrap', QTableWidget);

Expand Down