File: replaceAddRowSpacing.sh

package info (click to toggle)
kde-dev-scripts 4%3A18.08.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,496 kB
  • sloc: perl: 15,466; lisp: 5,627; sh: 4,157; python: 3,892; ruby: 2,158; makefile: 16; sed: 9
file content (15 lines) | stat: -rwxr-xr-x 763 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/sh

# 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