Open dogboydog opened 3 days ago
The error message is from QSortFilterProxyModel
, and it says the QModelIndex
you're using is from the wrong model. That's because mWangColorModel->colorIndex
returns an index in the source model, which still needs to be mapped to the model used by the view (the mWangColorFilterModel
).
I don't recall now what this sort-filter-model is used for (I couldn't immediately find a reason for it to exist in the current code). The easiest thing to do for now is to call mWangColorFilterModel->mapFromSource(index)
, as done in a slightly mode convoluted way in WangDock::editWangColorName
.
Hmm, in fact, you could likely adjust WangDock::onColorCaptured
, which is basically doing what you're after with WangDock::setCurrentWangColor
.
Just note that there's an assert in WangColorModel::colorIndex
, which should not be possible to trigger from script. Potentially we could just turn the assert into a regular condition and return QModelIndex()
in that case.
Thanks, I think I implemented what you suggested. It's working without errors now. I updated the scripting docs and NEWS.md
https://github.com/user-attachments/assets/4225ce99-23ad-4255-ae55-e7b7478b32e3
Fix #4101
currentWangSet setter: seems to be working:
Currently crashing, I'm doing something wrong setting the currentWangColorIndex :
I didn't see an existing public method to change the selection so I tried to make one based on reading the rest of the code in wangdock.cpp . Maybe I missed something existing or just have a logic error in my setter. Visually at least, it seems to change the color selection though.
Causes crash:
TODO (@dogboydog )