Development/Tutorials/Qt3Support Porting Scripts

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Here are some sed scripts which tries to convert some qt3 support classes to their qt4 ones.


port-q3listview:

#!/bin/bash
# [QK]3ListView -> QTreeWidget
sed -e 's/k3listviewsearchline.h/ktreewidgetsearchline/g' $* -i && # for includes
sed -e 's/K3ListViewSearchLine/KTreeWidgetSearchLine/g' $* -i &&
sed -e 's/[qk]3listview.h/QTreeWidget/g' $* -i && # for includes
sed -e 's/[QK]3ListView/QTreeWidget/g' $* -i &&
# drop indicator
sed -e 's/setDropVisualizer/setDropIndicatorShown/g' $* -i &&
# resize mode
sed -e 's/setResizeMode/header()->resizeSections/g' $* -i &&
sed -e 's/QTreeWidget::AllColumns/QHeaderView::Stretch/g' $* -i &&
# selection mode
sed -e 's/setSelectionModeExt[ ]*([ ]*QTreeWidget::/setSelectionMode(QAbstractItemView::/g' $* -i &&
sed -e 's/QAbstractItemView::Single/QAbstractItemView::SingleSelection/g' $* -i &&
sed -e 's/QAbstractItemView::Multi/QAbstractItemView::MultiSelection/g' $* -i &&
sed -e 's/QAbstractItemView::Extended/QAbstractItemView::ExtendedSelection/g' $* -i &&
# columns
sed -e 's/addColumn[ ]*([ ]*/headerItem()->setText(0, /g' $* -i &&
# item{Above, Below}
sed -e 's/\([A-Za-z0-9_]*[ ()]*\)->itemBelow[ ]*([ ]*)/this->itemBelow(\1)/g'  $* -i &&
sed -e 's/\([A-Za-z0-9_]*[ ()]*\).itemBelow[ ]*([ ]*)/this->itemBelow(&\1)/g'  $* -i &&
sed -e 's/\([A-Za-z0-9_]*[ ()]*\)->itemAbove[ ]*([ ]*)/this->itemAbove(\1)/g'  $* -i &&
sed -e 's/\([A-Za-z0-9_]*[ ()]*\).itemAbove[ ]*([ ]*)/this->itemAbove(&\1)/g'  $* -i &&
# setSelected
sed -e 's/setSelected(\([A-Za-z0-9_]*[ ()]*\)[ ]*,[ ]*false[ ]*)/\1->setSelected(false)/g'  $* -i &&
sed -e 's/setSelected(\([A-Za-z0-9_]*[ ()]*\)[ ]*,[ ]*true[ ]*)/\1->setSelected(true)/g'  $* -i


port-q3listviewitem:

#!/bin/bash
# [QK]3ListView -> QTreeWidget
sed -e 's/[qk]3listview/QTreeWidget/g' $* -i && # for includes
sed -e 's/[QK]3ListView/QTreeWidget/g' $* -i &&
sed -e 's/listview[ ]*([ ]*)/treeWidget()/g' $* -i &&
sed -e 's/setOpen/setExpanded/g' $* -i &&
sed -e 's/setDragEnabled[ ]*([ ]*true)/setFlags(flags() | Qt::ItemIsDragEnabled)/g' $* -i &&
sed -e 's/setDragEnabled[ ]*([ ]*false)/setFlags(flags() ^ Qt::ItemIsDragEnabled)/g' $* -i &&
sed -e 's/sort(/sortChildren/g' $* -i

port-q3scrollview:

sed -e 's/contentsToViewport[ ]*([ ]*\(.*\)[ ]*)/\1/g' $* -i &&
sed -e 's/setHScrollBarMode[ ]*([ ]*Q3ScrollView::/setHorizontalScrollBarPolicy(Qt::ScrollBar/g' $* -i &&
sed -e 's/setVScrollBarMode[ ]*([ ]*Q3ScrollView::/setVerticalScrollBarPolicy(Qt::ScrollBar/g' $* -i &&
sed -e 's/Q3ScrollView/QScrollArea/g' $* -i &&
sed -e 's/contentsM/m/g' $* -i # formouse{Move,Press,Release}Event

port-qcolorgroup:

#!/bin/bash
sed -e 's/QColorGroup/QPalette/g' $* -i &&
sed -e 's/colorGroup[ ]*([ ]*)/palette()/g' $* -i

This page was last edited on 29 June 2011, at 21:13. Content is available under Creative Commons License SA 4.0 unless otherwise noted.