Empty line at end, DragNDrop extensions

You find a bug using QxOrm library and you know how to fix it : submit a patch on this forum

Empty line at end, DragNDrop extensions

Postby jimmytaker » Sun Jan 01, 2017 6:42 am

I extended the functionality by quite a bit.
I added 2 interesting new features:
1. The model can now display an empty line (if the property is set - setShowEmptyLine(true)) as the last line. This gives the feeling of QxEntityEditor for when inputting a new row (item) in your table. I have only tested this with e_auto_update_on_field_change. The dirty line is marked with "*" in the vertical header (like in QSqlTableModel). If this is used with generated classes from QxEntityEditor - patches are needed in the generated code. See the bottom of:
http://www.qxorm.com/forum/phpbb/viewtopic.php?f=9&t=750
2. DragNDrop - available if dependency with QT_WIDGETS_LIB is enabled in the .pri. Supports internal moving around of items following the relationships of nested models. I built it implementing QUndoCommand, however I have not (yet) implemented any undo functionality. I might or might not add this in the future.
To use this mode of DragNDrop:
Code: Select all
   model->setAutoUpdateDatabase(IxModel::e_auto_update_on_field_change);
   model->setOnlyDelRelations(true);
   model->setDragDropMode(IxModel::e_drag_drop_relations, m_undo); //you need to provide an undo stack

I also added a drag and drop support mode (e_drag_drop_all) for the app to implement (e.g. in a proxy model). I use this mode for InternalMove of tables that need to be arranged by the user.

There are also a few patches to the code:
1. QxOrm.pro - fix output dir:

DESTDIR = $$PWD/lib/

2. QxOrm.pro - Performance String concat. Add QT_USE_QSTRINGBUILDER

3. IxModel.cpp - Fix IxModel::setHeaderData - using it with default role (Qt::EditRole) should change the header in a headerview (role Qt::DisplayRole).

4. IxModel.cpp - You have a field Description in QxEntityEditor for the properties. What this does is setDescription. This description never gets read afterwards. What I did is put this description (if present) as the default headerview column name. IxModel::headerData

5. removeRows for e_auto_update_on_field_change.

My App is ready for an alpha test phase by my colleagues, that will commence in a few weeks. This is when my extensions to QxOrm will get some real world testing as well. For now it is off my agenda. I will try to keep you posted, if we find bugs during the test phase. I only wish I could have added the RESELECT feature I mentioned here:
http://www.qxorm.com/forum/phpbb/viewtopic.php?f=2&t=752
I have an idea how to implement it, but it will need quite a few changes and it is not that important. Maybe you will suggest an easier solution.

QxOrm.part01.rar
(256 KiB) Downloaded 4427 times
QxOrm.part02.rar
(26.66 KiB) Downloaded 4346 times
jimmytaker
 
Posts: 19
Joined: Fri Dec 23, 2016 11:04 pm

Re: Empty line at end, DragNDrop extensions

Postby qxorm » Fri Mar 10, 2017 12:22 pm

Hello,

Here is a BETA version which include all your patchs : https://www.qxorm.com/version/QxOrm_1.4.4_BETA_21.zip
FYI, here is the current changes log of this BETA version :
Thx to Jimmy Taker for several improvments and new features in QxModelView module !

- QxModelView module : all models based on qx::IxModel class can now be sorted (on all columns), please note that you can also use QSortFilterProxyModel Qt class to sort your model
- QxModelView module - qx::QxModel<T> : fix setData() with e_auto_update_on_field_change option when an error occurred saving data in database, now previous value is restored if an error occurred
- QxModelView module - qx::IxModel : fix setHeaderData() using it with default role (Qt::EditRole) changes the header in a header view (role Qt::DisplayRole)
- QxModelView module - qx::IxModel : if a description is registered in QxOrm context, then it is displayed in header for each property
- QxModelView module : new feature available to add automatically an empty row at the end of the table to insert quickly new items (setShowEmptyLine() method)
- QxModelView module : possibility to define an intermediate base class between qx::IxModel and qx::QxModel<T> to provide your own model features, for example imagine you develop a drag&drop feature in a class named IxModelDragDrop, you can now create a QxOrm model like this (see the second template parameter) : qx::IxModel * pModel = new qx::QxModel<MyPersistantClass, IxModelDragDrop>();
- QxOrm.pro : fix DESTDIR parameter on Windows
- QxOrm.pri and QxOrm.cmake : add a section to enable QT_USE_QSTRINGBUILDER to optimize QString operations
- QxOrm library is now tested with MSVC 2015 compiler (support all MSVC versions from 2008)
- Fix a bug in QxSqlError.h file with a qPrintable() call on a temporary object
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am


Return to QxOrm - Submit a patch

Who is online

Users browsing this forum: No registered users and 4 guests

cron