Development/Tutorials/Qt3Support Porting Scripts

From KDE TechBase

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


port-q3listview:

  1. !/bin/bash
  2. [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 &&

  1. drop indicator

sed -e 's/setDropVisualizer/setDropIndicatorShown/g' $* -i &&

  1. resize mode

sed -e 's/setResizeMode/header()->resizeSections/g' $* -i && sed -e 's/QTreeWidget::AllColumns/QHeaderView::Stretch/g' $* -i &&

  1. 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 &&

  1. columns

sed -e 's/addColumn[ ]*([ ]*/headerItem()->setText(0, /g' $* -i &&

  1. 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 &&

  1. 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:

  1. !/bin/bash
  2. [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:

  1. !/bin/bash

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