#!/bin/bash

# trivial script to replace add(Row|Col)Spacing with the new Qt4 idioms (addItem( new QSpacerItem(.,.), .,. )).
# If the arguments to addRowSpacing are complex expressions, this script fails (and replaces a mess). So you better look at the diff that is generated by this script!
# CAUTION: Use at your own risk.
# I do not assert any rights on these few trivial lines of code, Reinhold Kainhofer

for i in `grep -le addRowSpacing -e addColSpacing -r [ac-z]* | grep -v '\.svn'`; do
  sed "
      s/addRowSpacing\ *(\ *\([^,]*\),\(.*\));/addItem( new QSpacerItem( 0,\2), \1, 0 );/g;
      s/addColSpacing\ *(\ *\([^,]*\),\(.*[^ ]\)\ *);/addItem( new QSpacerItem(\2, 0 ), 0, \1 );/g" $i > $i.new;
	echo $i;
	diff $i $i.new;
	mv $i.new $i
done
