Accept edited wigets with QDataWidgetMapper - qt

I'm making a small application that represents a to-do list.
The list is stored in a cusom model (derived from QAbstractItemModel) and is displayed in a QTableView.
I have also a custom widget (TaskDialog) that is used to browse and edit tasks from the list. The children of the TaskDialog are mapped to the model with a QDataWidgetMMapper.
On the task dialog I have also buttons that allow browsing through all the tasks in my to-do list (QDataWidgetMapper::toPrevious() ...).
The problem is that if I'm editing a task in the TaskDialog (e.g. the tasks name) and then browse to another task, the new edited enty isn't set in the model.
But if I edit something in the TaskDialog, then first change the focus to an other child widget of the TaskDialog and then press one of the browsing button, than the changes are written to the model.
How can I achive that widgets that are in a editing mode are accepted and written to the model.
I also tried the example of QDataWidgetMapper from Nokia. There it works perfectly. But they use a QStandardItemModel.
Best regards
Luke

I found a solution:
The submit policy of the QDataWidgetMapper has to be set to QDataWidgetMapper::ManualSubmit.
Then allways when I browse to a new item (i.e. one of the browse buttons is pressed) i submit the changes with QDataWidgetMapper::submit().

Related

How to design process with view and edit mode?

I have process as shown below.
Simple Process
Here I have two task i.e., Draft and Review.(fig1)
In draft i have outcomes as "save & submit".
When i click on save the draft task should display in read only mode so for this i have created the new task as Draft view using display value pallet element(fig 2), in the draft view i have again outcome like edit, submit.
when i click on edit again it moves to draft task. The thing is here i have created the new task for draft view. As this is simple process i can create but for complex project it requires me to create one extra task.
And for the review also i have review view task.
In activiti there is save button is provided, but here if i click on save button it will be in edit mode not in the view mode. And for view mode i have different outcomes for example: edit and submit, when i click on edit outcome again the task should open in edit mode(should show outcomes save and submit). The submit always move to next task.
Please Can anyone provide me the solution to avoid creating the task as draft view and review view.
Thanks & Regards
Amruta Wandakar
Instead of relying on the OOTB buttons create your custom buttons "save" turns your form to read-only, and "edit" makes it writable. you find examples on creating custom form fields in activiti. if you are using activiti embedded in Alfresco you can customize your task definition (model) to include buttons and then register onClick listeners using js

Set enable/disable on menuitem depending on data modification

I am new on java and javafx. I made a simple application on javafx using mvc pattern. This application handles a person table and is structured in this way.
Model containing the persons data
View containing a menu
View containing the tableview of the persons, the detail of the selected person and three buttons (New --> add new person, Edit --> change a person, Delete --> cancel a person
View that allows to change contents of the selected person
All works fine, but I have a problem with the menu. I would like to handle the menuitem 'Save' changing the 'Disable' flag in the way that it set to 'false' or 'true' programmatically, depending on if the user changed the data or not, but I do not know how can pass it from a scene to another.
I have been searching a lot on this web site and on other sites without any result.
I have found a question on stackoverflow called 'Toggle enable/disable on Menuitem javafx from another scene?' that probably could solve my question, but unfortunately I did not understand the solution.
Is there somebody who can help me?
Thank you in advance.
Alberto

QListView and QAbstractListModel: how to manually set an item under editing, with cursor flashing?

I have a QAbstractListModel and QListView (for example, a list of input ports of an electronic device).
I've just added a row into the model, gave it a temp name (something like "RENAME_ME_PLZ_ASAP"). I want user to rename it, and I want to set the editing focus to this cell to make it possible to start typing the new port name without aiming the mouse to the cell added and double-clicking on it.
The editing of the item should begin, and its temp text contents should be selected (to be deleted by user when the typing will start).
How can it be done?
As you said you should should be able to edit, without aiming the mouse to the cell added and double-clicking on it.
Probably you can use QAbstractItemView::CurrentChanged edit trigger.
QListView *pListView = new QListView(<<Your parent widget>>); //rough
pListView->setEditTriggers(QAbstractItemView::CurrentChanged);
You have many edit triggers in below link, but I guess the above one suits you best.
http://doc.qt.io/qt-5/qabstractitemview.html#EditTrigger-enum
And if you are on embedded LINUX you can also use.
pListView->setEditFocus(true);
Well, I've just called QAbstractItemModel::edit(...) method.
^__^

Nested getcmsfields_forpopup showing in same popup in silverstripe

I have form in getcmsfields_forpopup for backend(admin panel) in silverstrip. In that form, I have added nested dataobjectmanager field to enter multiple dates(has_many relation). When main form open in popup window and I click on add date link, then second popup form open in the same window not in separate one. That means after entering date data and saving it, when I click on close button, whole form is closed rather going back to main form. Please help in this regard.
This can't be done using SilverStripe's default popup form unless, maybe, you extended the DataObject Manager field and had it render itself in an iFrame.
The best option would be to manage your parent DataObjects with DataObjectManger as well. DataObjectManager supports nested DataObjectManager fields. See this tutorial "Nested DataObjectManager" (on YouTube).
If you're able, can I suggest that you try out SilverStripe 3.0? The support for this kind of thing is much better in SilverStripe 3.0 than it is in 2.4.

Flex Spark tabbar : initialize hidden tabs

problem is I have a spark Tabbar, with many forms in each tab.
But I have a single global save button. Problem is, if I don't open a Tab,
it doesn't get initialized and therefore the forms it contains do not exist..
How Can I make it as if the user had clicked on every tab?
The best way to handle this is to have a data model that each tab is displaying and editing, rather than trying to go in and read the values out of the controls in each tab, and save those. This is at the heart of MVC.
However, if you're too invested in your current architecture to be able to change it and you are using a ViewStack with your TabBar, you may find that setting creationPolicy to "all" does what you want. If you're using States, I don't think you can force all of them to be instantiated without putting your application into each State at least once.

Resources