Seeking Qt5 WYSIGWG editor design advice - c++

I am planning a new desktop application. It will provide a WYSIWYG editor for HL7
files (OSS Project). HL7 is a structured file format often used by hospitals for
exchanging data between systems.
The basic structure of the format comprises of records which are \r
delimited. A record can have N fields which are | delimited. A field itself
can be sub-devided into components ^ and sub-components & and
fields can be repeated ~ (similar to an array). Every message type has a
different number of fields/components and sub-components. Empty fields at the
end of a record can be omitted.
Example of a simple record:
OBX|14|NM|0050–5^Calcium||8.9|mg/dl|8.4–10.4||||F
I have already implemented an efficient parser which turns a whole file into a
hirarchial data structure in C. I want to implement an application that
allows editing these files like in a text editor. I want to keep the underlaying
hirarchial datastructure at any point, so it is easy to validate structure and
content of every field, upon user changes, quickly.
Also note worthy is, that I already implemented a viewer where the document
strcuture is displayed in a QTreeView. The structure is using a QAbstractItemModel.
Now to my actual question: how would I approach the problem of having a text editor
with a structured data model in Qt. I have done some research:
there is a QDomDocument, it seems to be made to work with xml data. I could convert my structure into XML but can the dom object be used with a text editor ?
Is there a way to bind a tree like document model to QTextEdit or QPlainTextEdit?
is it possible to bind a QAbstractItemModel to a document in QTextEdit or QPlainTextEdit?
What would be the best approach to tackle the problem of having a textual representation of a tree that gets updated once text and/or stricture is changed by editing in the text field?
Performance and cross platform capability is important, so this project will be implemented in C++.
Thanks for any advice and examples appreciated if you have any.
-S

Related

sitecore fields data type for xml data

I will need to save a serialized data in a field. Can anybody please help me figure out how can i do it in sitecore.
In a sql server I can define xml field-type which is sufficient for this. But similarly I can't find anything in sitecore. Though there are two types called html & memo which are deprecated. Also want to know can I use any of these.
We are using sitecore 7.2 BTW.
You can simply store it in a multi-line text field. If you wanted to get real fancy then you could create a custom field type. I've previously even used an IFrame field type for this kind of data, since the text is blanked out to the end user (but still viewable using Raw Values) and since the underlying data is just text it worked fine.
In any case, if your field is populated automatically from an external source then you probably don't want that data editable from the content editor. Lock the field down using the security editor and using correct roles & permissions so that normal editors do not have Field Write permissions (set on the template itself, not the created items)
In Sitecore, all fields are internally kept as strings by design (except media blobs). I think the best field type to store serialized XML would be multi-line text.
Of course, you should care about all serialization and deserialization the data into that field

Qt Editing Custom Data Structures

I am trying to utilize the Model/View architecture to accomplish my goal but I am unsure as to whether this is the proper tool to use for this task.
I have a Material System I have been using, which I more recently have created an editor for using Qt, it uses a QGraphicsView to display items which are interconnected to form a final fragment shader code, this works extremely well however, I am having difficulties finding a way to display these custom data structures without hand coding widgets for each type of item.
These custom data structures are simply classes with members which I wish to modify using an interface depending on each members type. For instance if the item is a Value which in my material system represents a single variable, like a texture, I would like to be able to have 2 editable areas, one for the texture's path on disk, and one for the name of the variable.
What is the best approach for interpreting custom structures like this and creating widgets based on their type, and then mapping those widgets to edit/display them. All the google searching I found led me to the Model/View architecture however it seems this is more made for things like SQL databases and XML files.
class Value
{
std::string m_strType, m_strName, m_strValue, m_strLocation;
};
It sounds like you're looking for something like the Property Browser Framework. In short, you'll make all of the members you want to edit properties, and then use the property browser framework to create a model that you can then attach a view to.

Keping history in Winforms C++

I have an application made in winform using C++ (developed in VS 2010). The GUIs have certain text fields, radio button, check boxes etc. To operate the software one has to fill in these fields/buttons/boxes etc.
There are roughly such 50 different GUIs, having roughly 20 fields in each one.
I want that after the application is closed, and restarted, most recent parameters in this fields automatically fill in, so the user do not need to re-enter all those values again.
What is the easiest and simplest way to achieve this?
This is best solved using MVC pattern where the Model contains the data that was filled. The view contains the way it will be presented(such as in Winforms) And lastly the controller which besides doing business logic will need to do some work (for saving the state).
I prefer using serialization for this. You can serialize the model fields and read them back(fields that are necessary only).
If you don't like serialization you can try writing to INI files that will be easy to modify.
Thirdly you can use a database mdf file to store the state.
But to do all this well you will need to modify the App to use MVC architecture.
You can use the Windows Registry with
WindowsFormName (subkey)
---------> ControlName (subkey)
-----------------> ControlValue (subkey)
When the Form is Closing you save the values for each control in the Registry
When the Form is Loading you read the values
If you are satisfied with a quick and dirty solution you can try this:
Implement a save mechanism:
Iterate to all the form controls (recursively if there are panels or
other containers)
If the control is edit (or other type that holds
data) save the control text together with his name
Store the name,
value pairs (INI file for example)
Implement a load mechanism. This assumes that there are no dependencies between values (If there are automated computed fields do not save them)
Load the values from the storage (if you choose files the file name can be the form name)
iterate to all the form controls and if you find its name in loaded data set the value
Once implemented this approach can be used for all the forms and it will cope with adding/removing controls. However if there are business rules maybe is better to use a MVC approach and serialize the model.

Saving user's data for my application

I was wondering what would be the correct method for saving all user data for an application I am working on. The application is in QT. The user inputs a lot of data into the application and the data will be different for every user. I want the ability for the user to save all the current data to a file that can be user by the loaded by the application again once the user wants to use it again or use it on another computer running the application.
What would be the correct and best way to do this? Do I need to use xml format? And then use the xmlreader for QT? Or do I just need to create my own file format and just use the stream to just read everything in. The data in the file will need to be labeled, because it will need to put the data in certain spots on the gui. And the user has the option to dynamically create boxes and tabs that hold certain information.
If you need any more information, please let me know.
A short example:
I am not only reading gui locations.
But the contents of those. For
instance. The user is able to create
tabs that contain edit text boxes. And
those tabs are associated with items
that are in a list. When the user
clicks on an item in the list the user
will be presented with a whole set of
new tabs. And each tab has some
editing forms. The file will need to
contain what is in the list, what tabs
the user has created under each item
in that list and the contents of each
tab associated with the tab of each
item in the list.
In essense, yes you'll be creating your own file format, but the actual content can just be XML in whatever scheme you need. Then you can use Qt's built-in XML processing capabilities to pull the heavy lifting of parsing the text (I personally prefer the DOM model, so I use QDomDocument as my base point), and you'll just need to worry about parsing things to and from the individual nodes.
The Qt framework has some great XML samples if I remember correctly that helped me get off the ground almost immediately. Hope they help!
Another great solution is to use internal database implementation (QSQL on top of sqlite). Compared to the xml solution, it might be more versatile (update when needed, can use external keys). Qt has some rgeat examples about using it aas well.
In terms of dependencies, XML solution will require you to use xml and xmlpatterns (if you want to validate stuff), whereas sqlite solution will require QSQL + sqlite plugin. I think that sqlite guarantees atomicity of writing , thus preventing corruption of data (think : the user is killing the app while it's saving).

XSL TreeView Define whether the xsl div is open/closed

I'v done a tree view in xsl using a javascript function
I want to change the icons depending on the status (+ for to open , - for to close)
This questions is as clear as thick molasses in a pool of mud. (Will try to answer, though.)
I assume you mean XML stylesheets with xsl. If you meant Excel, it should have been xls. But let's assume you mean stylesheets and you're using it to generate a webpage which contains a treeview. In this treeview there are icons indicating if the node is expanded or not. If expanded, display +, else display -. Am I right, here?
Now, it depends on how you've implemented this treeview in your stylesheet. The most practical way would be to just send the tree data fully expanded to the page and let the Javascript handle this client-side. In that case, all you need to know is how to expand and collapse nodes in Javascript with the additional icon change.
Another possible implementation would be when expanding and collapsing is done serverside, thus you'd only send the visible data. In that case you can also just tell the page which icon to use and there would be no need for any javascript. The icon would just be a link back to the server, updating the data through a new requests which builds a new webpage.
A third option would be the WEB 2.0 solution, where you just send the list as a collapsed treeview and every time the user clicks an icon, a AJAX event gets triggered, collecing the additional node data and changing the icon of the treenode.
These are three very different techniques and they're not always the best solution. The first solution is a problem when dealing with lots of data in your tree. It needs to load it all. The second option will generate a lot more traffic with the server but handles better with large amounts of data because you only display the open node. The third option is a bit of a mixture between the first two options. You don't need all data from the beginning and you're not recreating the webpage over and over again. But it's also more complex to code.
Now, I wonder which of these options you use. Once we know this, we can help you. (Edit your question to provide this information and perhaps even add the JavaScript tag to it.)
To be honest, xsl is only used to change the shape of an XML document and it knows nothing about treeviews or whatever. So I don't see any link between xsl and treeviews. It's just that you use xsl to transform your data into something that some Javascript library can process as a treeview. Which Javascript library is this?