[SailfishDevel] QSqlTableModel and running several remorses

François K. daitheflu at free.fr
Tue Dec 29 22:02:53 UTC 2015


Hi Peter, hi guys,

First, thanks for your answer and ideas :)

> 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.

Yeah, sorry about that. I'm not used to working in team and I also avoid variable names that can look like keywords (i.e. "list").
I also always use "r" for the variable that is returned.

I have uploaded a new version of the code with "l" replaced with "list" and some more comments.
If you have other remarks, please tell me, I'll try to improve that :)


> Why do you have more then one Remorse? This is not clear to me. Maybe
> you can explain?

Well it's seems pretty obvious : I want to remove several items from the list, one after the other.
When you do this quickly, several remorses can run at the same time.


> Where do you close your db connection? - May I have overlooked this
> :(

You didn't overlooked it. I don't close it in the small example I wrote.
In my real app, I have a "Storage" class that opens the database when the app starts and closes it when the object is destroyed.


> 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?

It's inherited from QAbstractItemModel : http://doc.qt.io/qt-5/qabstractitemmodel.html#match


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

I don't think so, I'm writing (deleting) one item after another.


> 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

I'm not sure that would make a difference here but I will definitely consider this, thanks :)


> Hope this helps you a bit.

Of course it does :)


Thanks a lot,

Cheers,

-- 
François


More information about the Devel mailing list