QML ListModel.onDataChanged arguments - qml

I was wondering what kind of data I can use to handle a dataChanged-signal in a QML ListModel.
I found out that it has three arguments, two of which are QModelIndices and one is a QVariant(...).
So from the first two (which seems to be the same?) I can get the row, column (which is supposed to be 0), the model itself and uhm... stuff
But why do I get it twice?
And what is the content of the third? It is not null, but I haven't found a property I could use to retrieve some useful data from it.

A ListModel implementsQAbstractItemModel, the dataChanged signal you are seeing is the one defined in this class :
void QAbstractItemModel::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int> ())
The 2 first parameters tell us that all data between the first and second indexes are changed. The 3rd parameter is a list of roles where the data has changed, if the list is empty it means the data at all roles has potentially been changed.
In your case the first and second indexes are the same because only one row is changed at a time.

Related

Building a (process) variable in Appian using the value of another one?

As far as I understand, it is not possible in Appian to dynamically construct (process) variable names, just like you would do e.g. with bash using backticks like MY_OBJECT=pv!MY_CONS_`extract(valueOfPulldown)`. Is that correct? Is there a workaround?
I have set of Appian constants, let's call them MY_CONS_FOO, MY_CONS_BAR, MY_CONS_LALA, all of which are e.g. refering to an Appian data store entity. I would like to write an Appian expression rule which populates another variable MY_OBJECT of the same type (here: data store entity), depending e.g. of the options of a pull-down menu having the possible options stored in an array MY_CONS_OPTIONS looking as follows
FOO
BAR
LALA
I could of course build a lengthy case-structure which I have to maintain in addition to MY_CONS_OPTIONS, so I am searching for a more dynanmic approach using the extract() function depending on valueOfPulldown as the chosen value of the pulldown-menu.
Edit: Here the expression-rule (in pseudo-code) I want to avoid:
if (valueOfPulldown = 'FOO') then MY_OBJECT=pv!MY_CONS_FOO
if (valueOfPulldown = 'BAR') then MY_OBJECT=pv!MY_CONS_BAR
if (valueOfPulldown = 'LALA') then MY_OBJECT=pv!MY_CONS_LALA
The goal is to be able to change the data store entity via pulldown-menu.
This can help you find what is behind your constant.
fn!typeName(fn!typeOf(cons!YOUR_CONSTANT)).
Having in mind additional details I would do as follows:
Create separate expression that will combine details into list of Dictionary like below:
Expression results (er):
{
{dd_label: "label1", dd_value: 1, cons: "cons!YOUR_CONSTANT1" }
,{dd_label: "label2", dd_value: 2, cons: "cons!YOUR_CONSTANT2" }
}
on UI for your dropdown control use er.dd_label as choiceLabels and er.dd_value as choiceValues
when user selects value on Dropdown save dropdown value to some local variable and then use it to find your const by doing:
property( index(er, wherecontains(local!dropdownselectedvalue, tointeger(er.dd_value))), "cons")
returned value of step 3 is your constant
This might not be perfect as you still have to maintain your dictionary but you can avoid long if...else statements.
As a alternative have a look on Decisions Tables in Appian https://docs.appian.com/suite/help/21.1/Appian_Decisions.html

Objective-c check if data model changed values state

Is there any patters that I can use to understand if my data model has changed to original state.
Let's see at situation when I have an object Order which can include some price info, items number, order notes info and etc. So at start it's an empty order and if I will update any properties by adding something new I will need to detect that the model exactly changed.
So let's say I put 5 items number at start and save data mode of Order. Then I want to update this model by putting 2 new items then KVO or any other tool should tell me about updates in data model, but if I set 5 items number one more time (like NSInteger itemNumbers = 5) so it means I triggered setter of the property, but I have not modified original value.

Pentaho PDI: Final value of previous row's calculated field

I tried to use the Analytik Query step to access some calculated field of the previous row. Turns out that the rows are all calculated in parallel and that accessing the previous row's fields gives you the current value they have during their processing, which is kind of random. It does not seem to be possible to obtain the final value of a field of a previous row. Or is there any other way than the Analytik Query step? I imagine all I need is a checkbox "Wait for previous rows to complete"...
What I need this for: I am processing time dependent data and doing a state recognition. When I am currently in state A, I do other stuff with my data then when I am in state B. So I need to know the state of the previous data row (which is determined not before the end of my transformation).
It can be done is Excel really easy, so I guess there must be some way in PDI. :-)
Thanks for any help!
If i have understood your question correctly, you may try using the Block this step until steps finish. This step waits until all the step copies that are specified in the dialog have finished. Read the link for more.
Hope this helps:)
I believe that it can be resolved by using the User Defined Java Class (UDJC) step.
If you sort the rows before processing them, the Sort By step would wait for the last row set by default.
Here's the most basic example of writing an output row for each input row. One important thing to keep in mind with the User Defined Java Class step, is the fact that they rewrite your whole data set, therefore need to be well thought of, especially if you do look-backs at previous rows. I hope this helps a bit.
// A class member that stores the previous row:
public Object[] previousRow;
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi)
throws KettleException {
// Fetching row:
Object[] r = getRow();
// Check if r is null:
if (r == null) {
setOutputDone();
return false;
}
// Get some field's value:
String someFieldValue = get(Fields.In, "someFieldName").getString(r);
// Log value if you want:
logBasic("current field value is " + someFieldValue);
// Generate an output row object:
Object[] outputRow = RowDataUtil.createResizedCopy(r, data.outputRowMeta.size());
// Modify row's field values if needed:
get(Fields.Out, "someFieldName").setValue(outputRow, "a modified value here");
// Write row:
putRow(data.outputRowMeta, outputRow);
// Assign current row to previous row:
previousRow = r;
return true;
}
EDIT:
One more important thing to note about PDI - the blocking method, either by blocking steps or by the Sort by step, is done by checking row sets rather than single rows.
How can this be verified?
Right click --> Transformation Settings --> Miscellaneous --> Nr of rows in rowset.
The default value is 10000 rows. PDI developers often create a deadlock by using one of the blocking steps with a row set size that doesn't fit their data volume - do keep that in mind.
Use "Identify last row in a stream" & "Filter rows" transformations. The 1st transformation checks if its the last row and returns a Boolean value and the later can be used to filter the records based on the Boolean value returned.

Sibling model function in Qt5

We had the following code to retrieve data of type TYPE through a model, which is a custom proxy model. This is required by the next QSortFilterProxyModel to make the decision about filtering of elements. The code is actually combined from 2 functions: in the project we usually have some arbitrary index related to some ROW and use it to retrive the data from another predefined column which contains TYPE data.
QModelIndex index = sourceModel()->index(row, COLUMN1, sourceParent); /* sourceParent is always'invalid' - retrieving data from top-level items*/
ModelIndex sibling = index.sibling(row, COLUMN2);
return sibling.data(Qt::EditRole).value<TYPE>();
This worked fine with Qt4 but when moved to Qt5 sibling became 'invalid'. I wonder what has happened, taking into account that the data is actually there, which I see, by changing the code to the following
return sourceModel()->index(sourceRow, COLUMN2, sourceParent).data(Qt::EditRole).value<TYPE>();
-works fine
Looking at the implementation of sibling(), I cannot tell what makes it return an invalid index in your case. Comparing with the Qt4 implementation, maybe it's around the IndexMap use.
But why don't you simply use your solution with sourceModel()->index(sourceRow, COLUMN2, sourceParent), since it already seems to be what you actually want to do?

Filling parameter with value from Zeconfig_var table

I have the following selection parameter:
PARAMETERS: p_ver(2) AS LISTBOX VISIBLE LENGTH 5.
I would like to populate it with the results from a ZECONFIG_VAR table.
At what point would I do this. Selection Screen Output, Start of Selection, or other. I am trying to allow users the ability to decide what version of the web service they would like to call. The config table will have different url's for the different versions.
I have looked at this Answer and the tutorial provided does not make sense to me.
I would do it at the event INITIALIZATION
However, it may be even easier to just create a search-help, and assign it to p_ver using the following:
parameters: p_ver(2) visible lenghth 5 MATCHCODE OBJECT zshelpname.
Esti is right that you probably want to fill an internal table from the DB table during INITIALIZATION.
But to the populate the listbox parameter, you need to put the call to VRM_SET_VALUES in AT SELECTION-SCREEN OUTPUT.