I'm working on a QT mock-up which we can use for screenshots for the proposal for DH2011, and making use of the opportunity to hack around with various options for handling the graphics in the interface of the actual application. What I learned today, after many hours' work, is not to trust QT Designer at all. I could find no way to make a layout with QT Designer that would actually expand when the window containing it expanded. I spent a long time testing all the options, and nothing at all worked. As soon as I built the layout manually in the source file, it worked perfectly. In future, I think I'll use QT Designer for the basic setup of a window (menu, toolbar, status bar), but then everything inside the centralWidget I'll do manually. Much simpler.
MT and I are going to submit a proposal for DH 2011 about plans for IMT 2, so we need to create some mockups for screenshots. In the process of doing this, I can also create some new icons I'll need, and try out various configurations for the application GUI layout, so it's quite useful. I've created three new icons which look OK (although I might thicken up some of the lines a little to make them clearer at small size), and I've made some progress with basic toolbar and menu setup.
Today double-buffering in widget creation (something we might well use in IMT, for large images that need to be zoomed often), and also some gotchas about using the STL -- the sample code from the book I'm using didn't include the includes I needed. Note to self: remember
#include <cstdlib> and
#include <cmath> etc. if you want to use e.g.
Managed to get some time to do some more QT learning. I've been creating custom widgets, and learning about QRegExpValidator and QMap.
Downloaded the latest QT Creator and installed it (without sudo) alongside my older ones, in my home dir. Then I found I couldn't build some of my apps, because of an error: ‘Quit’ is not a member of ‘QKeySequence’. A little Googling suggested that Creator was trying to build with an older qmake, or against an older version of QT4. The new version of QT Creator is 2.0, but it Abouts itself as "QT 4.7", although the QT4 version shows as 4.6.3, which is really confusing. In the end, I deleted the new install, and re-installed with sudo to the place it wanted to install to, in /opt. Then I specified 4.6.3 as the QT version, and I was able to build my dom application. I still don't have a QT version in my path; I'm not sure whether that's a good thing (because I often upgrade QT and have different versions on the system) or a bad thing (because QT libraries are occasionally not found, which could be the cause of various problems in building the Phonon example). We'll see...
The issue of synchronizing the two views of the document structure (list of xml:ids and tree view) is holding me up to a degree which is not commensurate with its importance. It's extremely complicated, because in fact the two views do not ultimately inherit from the same data source (the id list is constructed by parsing the document into a QStringList), so formally correct approaches to synchronizing selection using identification of equivalent QModelIndexes by tracing back to the source data won't fly, so some ad-hoc solution is going to be required. And in any case, it's by no means crucial that the two views stay in sync, at least initially. So I'm going to move on to the next stage, which will enable me to get some more code-writing experience in QT, and return to this issue at a much later stage.
The next stage is to plan the class structure that underlies the data model, by reviewing our previous plans, and starting from MJ's zone-defining code.
I'm currently re-reading all the material about model/view architecture in QT to figure out how best to approach the synchronization of two views which have two underlying models (one tree, one string list), and where the synchronization code should live (in the code for the dialog box holding the view controls, or in the HcmcImtDoc class). An added complication is that the QSortFilterProxyModel which is currently filtering the list view by regexp currently lives in the dialog box code, but I think it should almost certainly move to the HcmcImtDoc class.
Fixed the duplicate item bug in the string list filter, and fixed an unused parameter issue in the constructor of HcmcImtDoc. Also spent a bit of time narrowing down an error message when running the application: CRITICAL **: atk_object_set_name: assertion `name != NULL' failed. This turns out to be a bug in GTK/Gnome, which is Ubuntu's problem, not QT's. If you run the app with "-style windows" you don't see it. It doesn't affect anything.
The next task is to figure out how to hook together selections between the two views of the document (the tree view and the xml:id list), so that if you select something in one view, it gets selected in the other. I suspect this will be something like:
- Get the model index for the selected item, and derive the source item from it.
- Get the model index for the same item in the parallel view (if there is one).
- Set the selection in the parallel view, without triggering the reverse process.
Went back to square one and created a new QSortFilterProxyModel to filter the list of xml:ids coming from the HcmcImtDoc object. This has solved the problem; I now have a working regular expression filter in the GUI, which can be used to select items in the list.
A new problem has emerged, though: each xml:id in the list is duplicated. This is not caused by the new filter; if I change back to the original unfiltered behaviour, I still get two of each item in the list. So this is due to what looks like duplicated code in HcmcImtDoc, which I think ended up in there when I was making changes to allow switching on and off of namespace-awareness. Shouldn't be hard to fix.
Did a QT update, but the issue still remains: "source_parent was not valid", in either filterAcceptsRow or filterAcceptsColumn of HcmcIdFilter. I'll probably need to re-read all the documentation on QSortFilterProxyModel...