Hello again,
I have narrowed it down to a very simple question (which I don't know the answer too)...
So first forget "roles", and TreeView, I have now followed the French example and used a ListView. And yes I am using have QxEE generated code, which has generated Q_INVOKABLEs for the child models.
The QxEE Model/Viiew generated clases of interest are:
- Code: Select all
class CRM_MODEL_VIEW_EXPORT customer_main_record_model : public customer_main_record_model_base_class
{
Q_OBJECT
public:
customer_main_record_model(QObject * parent = 0);
customer_main_record_model(qx::IxModel * other, QObject * parent);
virtual ~customer_main_record_model();
Q_INVOKABLE QObject * list_of_contact_name_link(int row, bool bLoadFromDatabase = false, const QString & sAppendRelations = QString());
Q_INVOKABLE QObject * list_of_customer_client_consultant(int row, bool bLoadFromDatabase = false, const QString & sAppendRelations = QString());
Q_INVOKABLE QObject * list_of_customer_client_consultant_1(int row, bool bLoadFromDatabase = false, const QString & sAppendRelations = QString());
Q_INVOKABLE QObject * list_of_customer_job(int row, bool bLoadFromDatabase = false, const QString & sAppendRelations = QString());
Q_INVOKABLE QObject * cmr_default_cad_id(int row, bool bLoadFromDatabase = false, const QString & sAppendRelations = QString());
Q_INVOKABLE QObject * list_of_customer_type_link(int row, bool bLoadFromDatabase = false, const QString & sAppendRelations = QString());
Q_INVOKABLE QObject * list_of_dataset_operator(int row, bool bLoadFromDatabase = false, const QString & sAppendRelations = QString());
Q_INVOKABLE QObject * list_of_sum_it_licence(int row, bool bLoadFromDatabase = false, const QString & sAppendRelations = QString());
/* List of properties exposed by the model (6) :
- cmr_id
- cmr_business_name
- cmr_sort_sequence
- cmr_user_ref
- cmr_comment
- cmr_note
*/
protected:
virtual void syncNestedModel(int row, const QStringList & relation);
virtual void syncAllNestedModel(const QStringList & relation);
};
The interesting one here is
- Code: Select all
Q_INVOKABLE QObject * cmr_default_cad_id(int row, bool bLoadFromDatabase = false, const QString & sAppendRelations = QString());
And the QeEE generated code for the secondary table is:
- Code: Select all
class CRM_MODEL_VIEW_EXPORT contact_address_model : public contact_address_model_base_class
{
Q_OBJECT
public:
contact_address_model(QObject * parent = 0);
contact_address_model(qx::IxModel * other, QObject * parent);
virtual ~contact_address_model();
Q_INVOKABLE QObject * cad_cco_id(int row, bool bLoadFromDatabase = false, const QString & sAppendRelations = QString());
Q_INVOKABLE QObject * list_of_contact_address_link(int row, bool bLoadFromDatabase = false, const QString & sAppendRelations = QString());
Q_INVOKABLE QObject * list_of_customer_main_record(int row, bool bLoadFromDatabase = false, const QString & sAppendRelations = QString());
/* List of properties exposed by the model (6) :
- cad_id
- cad_address_1
- cad_address_2
- cad_village
- cad_town
- cad_postcode
*/
protected:
virtual void syncNestedModel(int row, const QStringList & relation);
virtual void syncAllNestedModel(const QStringList & relation);
};
} // namespace crm
So first we issue "fetchALL(*)" request which populates the data model with the dependant table data (as my first post here showed in the Server output)...
- Code: Select all
"list": [
{
"key": 1,
"value": {
"cmr_business_name": "Company 1",
"cmr_comment": "",
"cmr_default_cad_id": {
"cad_address_1": "Address Line 1",
"cad_address_2": "Address Line 2",
"cad_cco_id": {
"cco_abbreviation": "",
"cco_ccu_id": null,
"cco_county": "",
"cco_id": 35,
"list_of_contact_address": [
]
},
"cad_id": 1,
...
You can see here "cmr_default_cad_id" (value ="1") from our main table refers to another table "contact_address", (and this secondard data model is populated with data "Address Line 1", "Address Line 2").
Now in our QML I tried 2 things...
First was to simply display the raw "crm_default_cmr_id" which comes from the primary table with the QML and this works fine:
- Code: Select all
QML:
Item {
id: root
CustomersModel {
id: customersModel
}
property int rowHeight: 30
Component.onCompleted: {
customersModel.qxFetchAll_("*")
}
Component {
id: customersAddressDelegate
Rectangle {
id: customersAddressCell
height: updateCol.height
color: "#c0c0c0"
Column {
id: updateCol
width: parent.width
Text {
id: updateText
text: "Address 1 = " + cmr_default_cad_id
}
}
}
}
Rectangle {
width: 360
height: 360
ListView {
id: customerAddressView
anchors.fill: parent
model: customersModel
delegate: customersAddressDelegate
}
}
}
It gives the following screen outout (see attachment).
Next I changed that QML to attempt to populate list with "cad_address_1" from the secondary table instead of the raw id:
- Code: Select all
Item {
id: root
CustomersModel {
id: customersModel
}
property int rowHeight: 30
Component.onCompleted: {
customersModel.qxFetchAll_("*")
}
Component {
id: customersAddressDelegate
Rectangle {
id: customersAddressCell
height: updateCol.height
color: "#c0c0c0"
Column {
id: updateCol
width: parent.width
Text {
id: updateText
text: "Address 1 = " + cmr_default_cad_id(0).cad_address_1
}
}
}
}
Rectangle {
width: 360
height: 360
ListView {
id: customerAddressView
anchors.fill: parent
model: customersModel
delegate: customersAddressDelegate
}
}
}
Hence, I changed:
- Code: Select all
text: "Address 1 = " + cmr_default_cad_id
To:
- Code: Select all
text: "Address 1 = " + cmr_default_cad_id(0).cad_address_1
My thinking was that "cmr_default_cad_id(0)" should give me the first object (INDEX=0) from the cmr_default_cad_id "collection", and then I would use that object to obtain the "cad_address_1" member.
However this generates the following outout errors in the debug output window:
- Code: Select all
qrc:/pages/customersPage.qml:37: TypeError: Property 'cmr_default_cad_id' of object [object Object] is not a function
(I have also tried various alternatives, such as using "Repeater"s in the QML, but always I get the same error about "cmr_default_cad_id" not being a function and all I can access is the raw integer ID)
So it is telling me that I cannot use "cmr_default_cad_id" as a function to get to the child model? If that is true, what must I do to get it?
Later we will be using the "list_of_xxxx" models, but until I have understood how to get a simple child model, the rest is on hold.