View AIS- Data with QT? - c++

anyone know how i can get the Data from a AIS site and view they in a QT Gui?
Can i save them in a SQL database ?
I would have the data from this site : http://www.aishub.net/
AIS : The Automatic Identification System (AIS) is an automatic tracking system used on ships and by vessel traffic services (VTS) for identifying and locating vessels by electronically exchanging data with other nearby ships, AIS base stations, and satellites. When satellites are used to detect AIS signatures then the term Satellite-AIS (S-AIS) is used. AIS information supplements marine radar, which continues to be the primary method of collision avoidance for water transport.

You should register account at http://www.aishub.net/ and subscribe to get access for their API described here. At desktop side you should build Qt application, that will not frequently then every minute call their API URL with your credentials using QNetworkRequest, retrieve QNetworkReply result output (this will be XML or JSON). And then parse the XML or JSON with Qt build-in classes for processing XML or JSON documents. After parsing you should display processed data in your preferred way, for example, sortable table view, or save in database, whatever.

This is not entirely a coding question.. you should found out how to get the data from the site on your own..
But anyway - there's a XML API on that site
Qt supports XML nicely.. you can store the xml if you want in file or in sqllite database, or just parse it an show it.
You can use some view widget to show the parsed data - something like QListView, QTableView ..

Related

Kentico 10 - Use a repeater to display multiple page types

We are currently use the oob page types for Blog, News and Event. We have one page for each of these types that includes a repeater to show a list of the pages of that type. We would also like to have a page that includes a repeater that shows all blog, news and event pages in one spot, sorted by their created date.
I have seen some old comments (here, here) on devnet saying that although a repeater can render multiple page types, the fields rendered must be identical across each of those page types. The workarounds suggested are either to create the same fields in each page type, or to create a custom SQL query and use a query repeater to render the data. I've done this and it works just fine, but it was pretty cumbersome to create and will be difficult to maintain. (If we want to add other page types, for example.) Can anyone suggest a more out-of-the-box method available in Kentico 10?
Update:
I'm trying to accomplish this as Brenden described, but am running into trouble.
My page structure is as follows:
Root
.RollupPage (CMS.MenuItem)
..BlogPosts (CMS.Blog)
...January 2017 (CMS.BlogMonth)
....blog post 1 (CMS.BlogPost)
...February 2017 (CMS.BlogMonth)
....blog post 2 (CMS.BlogPost)
..Events (CMS.MenuItem)
...Event1 (CMS.BookingEvent)
...Event2 (CMS.BookingEvent)
I've attempted to use a universal viewer, but failed to get it to return any data.
I configured it with:
Path: /RollupPage/%
Page types: CMS.BlogPost;CMS.BookingEvent
Hierarchical Transformation: CMS.MenuItem.HierTrans1
HierTrans1 has the following transformations:
CMS.BlogPost.Default (Item transformation for type CMS.BlogPost)
CMS.BookingEvent.EventCalendarItem (Item transformation for type CMS.BookingEvent)
These aren't customized at all; they are standard OOB transformations just so I can see it work.
When I view the RollupPage, the universal viewer displays nothing.
I attempted to use a Hierarchical Viewer with the same settings as I did with the Universal Viewer. It kind-of worked. It displayed my booking events but did not display any blog posts. Yet using the same blog post transformation (CMS.BlogPost.default) with hierarchical viewer whose Path was set to /RollupPage/BlogPosts/% displayed my blog posts correctly but, obviously, did not display my booking events.
The results I've gotten so far makes me think a) something about the way I've created my pages is stopping the universal viewer from traversing the whole tree and/or b) the hierarchical viewer either only goes a couple of levels deep, or maybe it is being blocked from traversing the tree too... No events are recorded when I edit or view these web parts.
Any idea what I may be doing wrong?
For this scenario use a universal viewer. Reason being is you can create a hierarchical transformation which will have different transformations for each of your unique page types. You most likely won't use the hierarchy at all but you can simply add 3 different item transformations for the different page types.
You can use the Hierarchical viewer or the Universal viewer, as Brenden Kehren mentioned, to achieve the goal you are describing.
When configuring the web part you must select all the Page types that are included in the hierarchy, in your case: CMS.MenuItem, CMS.Blog, CMS.BlogMonth, CMS.BlogPost and CMSBookingEvent.
Create a Hierarchical transformation to be used with your viewer and add an Item transformation for each of the items you wish to display. Also make sure the Level setting for each transformation is configured properly (-1 applies the transformation to all levels).
For Universal viewer it is necessary to check the property Load hierarchical data in the section Extended settings of the configuration.
As an additional note, you can leave the path property empty in case you are viewing the child documents of the current page.
For reference there is also an example on the Corporate Site example site in the content tree path Examples > Web Parts > Listings and viewers > Pages > Hierarchical viewer (or Universal viewer).
Hope this helps!
The other ways are this
Evaluate right fieldname by check object classname inside the transformation and assign appropriate value.
Dynamically assign transformation by checking the object classname

Handling fields of Attachment type in MS Access using ADO

I have some fields in my database that will need to store images ( bitmap, JPG or PNG ) and PDF ( or Excel/RTF/TXT ) files. Browsing through Internet, I have learned that MS Access 2007 ( and newer versions ) have a field of type Attachment that can suit my needs.
However, I am filling database via GUI ( made in C++ and WinAPI ), using ADO. I was not able to find an example of inserting/loading such data into/from database using ADO. Searching here through some similar questions ( VB, Delphi, Python...) I have found out that my approach might not be the best, but seems possible to do.
Being inexperienced, and since this is my first time tackling this type of task, I ask community to help me solve this task. Therefore my question:
How should I handle inserting/loading this type of data ( images, documents...) into/from MS Access 2007 (or higher) database using ADO?
Can you provide small code snippet that illustrates inserting/loading such data into/from database using ADO?
Thank you.
If you are planning to only use the C++ application as the front-end and do not expect users to be opening the database in Access itself then I suggest that you avoid using the Attachment field type. Instead, use a separate child table named [Attachments] with a one-to-many Relationship (foreign key constraint) between the [Attachments] table and the parent table (where you were considering using the Attachment field). Then, save the documents as raw binary data in an OLE Object (long binary) field in the child table.
The Attachment field type offers several advantages for applications that use the Access UI. Support for multiple attachments to a single database record can be as simple as dropping an Attachment control onto an Access form. Attachments can also be accessed from Datasheet view, although all you see there is a "paper clip" icon.
Attachment fields can be manipulated from code, but only by using an ACE DAO Recordset2 object (example here). In order to be able to save multiple attachments per record, the Access Database Engine uses a hidden child table. It is possible to pull some information into a SELECT query using "magic" field name qualifiers (e.g., Field1.FileName) but neither ADO nor ODBC can INSERT or UPDATE Attachment field entries.
Since you will not be using the Access UI for your application
you will not be able to use many of the advantages that an Attachment field has to offer, and
you could still manipulate the Attachment field via ACE DAO from your C++ app, but it would be a nuisance.
The one (possibly) significant advantage that you might miss by not using an Attachment field is that the Access Database Engine automatically compresses files in an Attachment field but raw binary data in an OLE Object field is stored uncompressed. If the files you intend to save were all in compressed formats anyway (e.g., JPEG, .docx, .xlsx) then this would not be an issue. However, if you plan to store a lot of large documents in uncompressed formats (e.g., .txt, .rtf) then file bloat could be a problem. In that case you could have your C++ app automatically compress those documents (perhaps using GZipStream) before saving them and uncompress them on retrieval.

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).

GWT set variable values with Django templates

I am using a tree control in my GWT application. The tree has different items based on the user logged in. One way to populate the tree would be to query the server from my GWT code to get a list of tree items. But since the items will always be shown would it not be better to include information regarding them in the page itself? I am looking for views to achieve this. Would it be possible to get a template engine like django to insert these values into GWT string variables at serving time? Then I can use these string variables to populate the tree. Or is there a better way to achieve this?
I answered a very similar question in the GWT group last year, so you might want to take a look there.
The idea, as you said, is to embed this data inside the host page, instead of firing an additional GWT RPC request during the app's initialization. You can:
Embed the data inside a JavaScript variable in your host page, and access it using the Dictionary class
This is a simple solution, especially if your data is serializable as a dictionary of strings. You could use the templating engine of your choice to insert this data in your host page (Django's, Mustache, FreeMarker, JSP...).
Embed a GWT-RPC payload inside your host page, as explained here and there
This is better if you need to serialize a whole object graph (which might be what you want for your Tree widget, depending on its complexity). It's like a standard GWT-RPC request, but instead of sending an HTTP request at startup, the GWT-RPC "response" would have been be embedded inside your host page when you serve it.

How do you save data in MFC?

I still remember in Delphi, developer can just make the UI(textbox, listbox...) directly connect to database, and then when user click a button, just call the post action, then the data will be saved automatically.
What I want to know is that is there any similar mechanism in MFC? Or I can use GetDlgItem(...).Text and then use this value to save to database ?
Or any other suggestions will be appreciated.
In VC++ , you have to use Microsoft ActiveX Data Object Library (ADO typelib) .
To store data you can follow these steps:
1.Retrive data from all controls
2.Validate the data retrived
3.Use sql query to store the data to database.
You can use ODBC API which is independent of any database management system.
http://msdn.microsoft.com/en-us/library/ms714562(VS.85).aspx
http://www.odbc.net/api/index.shtml
To be fair on Delphi these are specialized widgets, not the ordinary GDI textbox etc, but controls with an additional database aware layer that are connected to dataset and tables.
.NET has something similar concepts too, don't know about MFC
MFC's abstraction of data in Doc/View/Frame is in CDocument. When you save the document, MFC prompts the user for the file name if the file does not have a saved path, then construct a CArchive on the file and triggers CDocument::Serialize. You can store the connection string in your document class and use it to save data in CDocument::Serialize.
If you have a file based database, it is easier to integrate. Override CDocument::OnNewDocument to create a new file based database for the document, and
override CDocument::OnOpenDocument to read from existing database. If you don't have a file based database, you can suppress the file dialog with a CDocument::SaveModified override that saves the data and clears the modified flag.