Development/Tutorials/Qt3Support Porting Scripts: Difference between revisions
Neverendingo (talk | contribs) m (Text replace - "</code>" to "</syntaxhighlight>") |
|||
Line 30: | Line 30: | ||
sed -e 's/setSelected(\([A-Za-z0-9_]*[ ()]*\)[ ]*,[ ]*false[ ]*)/\1->setSelected(false)/g' $* -i && | 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 | sed -e 's/setSelected(\([A-Za-z0-9_]*[ ()]*\)[ ]*,[ ]*true[ ]*)/\1->setSelected(true)/g' $* -i | ||
</ | </syntaxhighlight> | ||
Line 44: | Line 44: | ||
sed -e 's/setDragEnabled[ ]*([ ]*false)/setFlags(flags() ^ Qt::ItemIsDragEnabled)/g' $* -i && | sed -e 's/setDragEnabled[ ]*([ ]*false)/setFlags(flags() ^ Qt::ItemIsDragEnabled)/g' $* -i && | ||
sed -e 's/sort(/sortChildren/g' $* -i | sed -e 's/sort(/sortChildren/g' $* -i | ||
</ | </syntaxhighlight> | ||
{{path|port-q3scrollview}}: | {{path|port-q3scrollview}}: | ||
Line 53: | Line 53: | ||
sed -e 's/Q3ScrollView/QScrollArea/g' $* -i && | sed -e 's/Q3ScrollView/QScrollArea/g' $* -i && | ||
sed -e 's/contentsM/m/g' $* -i # formouse{Move,Press,Release}Event | sed -e 's/contentsM/m/g' $* -i # formouse{Move,Press,Release}Event | ||
</ | </syntaxhighlight> | ||
{{path|port-qcolorgroup}}: | {{path|port-qcolorgroup}}: | ||
Line 60: | Line 60: | ||
sed -e 's/QColorGroup/QPalette/g' $* -i && | sed -e 's/QColorGroup/QPalette/g' $* -i && | ||
sed -e 's/colorGroup[ ]*([ ]*)/palette()/g' $* -i | sed -e 's/colorGroup[ ]*([ ]*)/palette()/g' $* -i | ||
</ | </syntaxhighlight> |
Revision as of 20:54, 29 June 2011
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
</syntaxhighlight>
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
</syntaxhighlight>
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
</syntaxhighlight>
port-qcolorgroup:
- !/bin/bash
sed -e 's/QColorGroup/QPalette/g' $* -i &&
sed -e 's/colorGroup[ ]*([ ]*)/palette()/g' $* -i
</syntaxhighlight>