Hello Francoise,

I find your code a bit hard to read. It would be nice if you use full names like list instead of l. I know it is annoying, but makes live easier in the long run.

Why do you have more then one Remorse? This is not clear to me. Maybe you can explain?
Where do you close your db connection? - May I have overlooked this :(
Could not find the method Match in the documentation or in the code :(.
QModelIndexList l = this->match( this->index(0, 0), MModel::IdRole, itemId, 1, Qt::MatchExactly);


I check against http://doc.qt.io/qt-5/qsqltablemodel.html What is your reference?

SQLLite may only support multiple readers or one writer. Maybe this is your Problem?

I would honestly have One Data Object that knows how to read from the DB and open and closes the Connection for each operation with the DB seperatly. Not sure if this solves you Problem but it makes it easier to debug and Maintain. (Maybe Code is slower... But I rather have a rugged Code then a fast one.)

I would think in Layers:
USER
VIEW
APPDATAMODEL
DATABASE CONNECTOR
DATABSE

Hope this helps you a bit.

All the best
Peter


On 28.12.2015 21:59, François K. wrote:
Hello,

I sent the following email a few weeks ago but got no answer. The github statistics also 
show that only one person downloaded the "dummy" project I wrote to demonstrate 
my issue... :(
With the recent announcements and the Jolla boat sailing on, I'd like to get 
this solved.

I'm even willing to pay if necessary.

Thanks a lot,
All the best,


----- Mail original -----
I have a model that inherits from QSqlTableModel. A SilicaListView
shows the data. This is very easy to do, thanks to Qt/QML :)

Each list item has a ContextMenu with a "Delete" entry that allows
the user to delete the item. It runs a remorse, and, at the end of
the remorse, the item is deleted from the model (and the database).
Again, this works quite well... until you try to delete several items
at the same time

A QSqlTableModel can have 3 different edit strategies :
OnManualSubmit, OnRowChange or OnFieldChange.

If I set it to "OnManualSubmit", the item is deleted from the model,
but it remains in the view and in the database until I call
QSqlTableModel::submitAll(). This method actually commits the
changes to the database, and resets the model by calling
QSqlTableModel::select(). Since the model is resetted, it loses all
other running remorses and causes a segfault.

If I set it to "OnFieldChanged", the item is deleted from the model
and from the database, but it will still remain visible in the view.
According to the Qt doc, I should call select() to update the view.
But, as we've seen before, this destroys the other running remorses
and also causes a segfault.

I've made a very small app to demonstrate the problem, you can get it
here and try it in your emulator : git clone
https://github.com/Frzk/dummy.git
You can use the PullDownMenu to switch between OnManualSubmit and
OnFieldChanged strategies.

How should I deal with this ? This is a very simple case, yet I can't
seem to find a solution :(


_______________________________________________
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org

Reply via email to