[Qgis-developer] Patch to Remove Qt3 Dependencies
Tom Elwertowski
telwertowski at comcast.net
Thu Apr 24 22:43:54 EDT 2008
Hello all,
Here is a patch which removes use of Qt3 routines for all of QGIS except the GRASS plugin:
http://telwertowski.home.comcast.net/qgisqt4_r8378.diff
Please test it and send comments. After resolving any issues, I would like to submit it to svn trunk.
The GRASS plugin, which probably contains about half of the Qt3 dependencies, will be done later. The patch was done to build with the Qt/Mac/64bit alpha1 release; Qt3 features are not being ported to Mac/64bit.
Three categories of changes have be made:
1. Remove use of qt3support library (Q3 classes).
2. Remove use of qt3 compatibility routines in qt4 classes.
3. Remove automatic cast of QString to char*.
Classes and places with non-trivial changes are:
Q3Table to QtableWidget (qgsattributeactiondialog, qgsattributetable, qgsmeasure)
Q3ListView to QTreeWidget (qgsbookmarks, qgsrasterlayerproperties, qgsgeomtypedialog, qgsserversourceselect)
Q3Dict to QHash (qgsprojectproperty)
Q3Process to QProcess (qgsgpsplugin)
The most complex change involved handling selections in the item view classes (tables, trees and lists) so this should be tested the most.
In spite of its name, QTreeWidget also handles multicolumn lists which are not trees; just set rootIsDecoated to false. Qt4 QListWidget is for lists with one column and no header.
Qt4 has two classes for each item view: QTable/Tree/ListWidget and QTable/Tree/ListView. The Widget classes contain a backing store and the View classes don't. The Widget classes correspond more closely to the Q3 classes.
qgsattributetable, which can take a while to load large tables, should probably be rewritten as a QTableView with an QAbstractTableModel subclass to pull individual cells directly for the provider as needed. It has been ported as a QTableWidget to keep the port straightforward and not introduce additional refactoring into this edit.
Removing automatic casts of QString to char* also uncovered some odd code. Defining QT_NO_CAST_TO_ASCII will produce a compile error whenever an implicit QString cast occurs. Based on these two examples, this macro serves as 'lint' for QStrings.
QString str; delete str; // compiles due to cast of str.
tr("abc" + def + tr("ghi")) // ought to be tr("abc") + def + tr("ghi")
In most cases, I have used toUtf8() to eliminate implicit casts. If a file already used toAscii(), toLatin1() or toLocal8Bit(), I also used it to keep the file consistent. Implicit casts have also been removed from the GRASS plugin so that QT_NO_CAST_TO_ASCII can be defined for all future builds.
The patch has been tested using Qt4.2, 4.3 and 4.4RC1 as well as Qt4.4-Cocoa-alpha1.
Tom
More information about the Qgis-developer
mailing list