Difference between revisions of "Development/Tutorials/Qt3Support Porting Scripts"

Jump to: navigation, search
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
</code>
+
</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
</code>
+
</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
</code>
+
</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
</code>
+
</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:

  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 </syntaxhighlight>


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 </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:

  1. !/bin/bash

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


Content is available under Creative Commons License SA 4.0 unless otherwise noted.