Development/Tutorials/Qt3Support Porting Scripts: Difference between revisions

From KDE TechBase
m (Text replace - "</code>" to "</syntaxhighlight>")
m (Text replace - "<code bash=" to "<syntaxhighlight lang=")
 
Line 3: Line 3:


{{path|port-q3listview}}:
{{path|port-q3listview}}:
<code bash="bash">
<syntaxhighlight lang="bash">
#!/bin/bash
#!/bin/bash
# [QK]3ListView -> QTreeWidget
# [QK]3ListView -> QTreeWidget
Line 34: Line 34:


{{path|port-q3listviewitem}}:
{{path|port-q3listviewitem}}:
<code bash="bash">
<syntaxhighlight lang="bash">
#!/bin/bash
#!/bin/bash
# [QK]3ListView -> QTreeWidget
# [QK]3ListView -> QTreeWidget
Line 47: Line 47:


{{path|port-q3scrollview}}:
{{path|port-q3scrollview}}:
<code bash="bash">
<syntaxhighlight lang="bash">
sed -e 's/contentsToViewport[ ]*([ ]*\(.*\)[ ]*)/\1/g' $* -i &&
sed -e 's/contentsToViewport[ ]*([ ]*\(.*\)[ ]*)/\1/g' $* -i &&
sed -e 's/setHScrollBarMode[ ]*([ ]*Q3ScrollView::/setHorizontalScrollBarPolicy(Qt::ScrollBar/g' $* -i &&
sed -e 's/setHScrollBarMode[ ]*([ ]*Q3ScrollView::/setHorizontalScrollBarPolicy(Qt::ScrollBar/g' $* -i &&
Line 56: Line 56:


{{path|port-qcolorgroup}}:
{{path|port-qcolorgroup}}:
<code bash="bash">
<syntaxhighlight lang="bash">
#!/bin/bash
#!/bin/bash
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>
</syntaxhighlight>

Latest revision as of 21:13, 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


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