Warning, file /sdk/kde-dev-scripts/kf5/convert-qt5.pl was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 #!/usr/bin/perl -w 0002 0003 # David Faure <faure@kde.org> 0004 # Qt4 -> Qt5 0005 0006 use strict; 0007 use File::Basename; 0008 use lib dirname($0); 0009 use functionUtilkde; 0010 0011 foreach my $file (@ARGV) { 0012 0013 my $infoVar; 0014 my $urlVar; 0015 0016 # I don't use functionUtilkde::substInFile because it touches all files, even those which were not modified. 0017 my $modified; 0018 open(my $FILE, "<", $file) or warn "We can't open file $file:$!\n"; 0019 my @l = map { 0020 my $orig = $_; 0021 0022 my $regexpqFindChild = qr/ 0023 ^(\s*) # (1) Indentation 0024 (.*?)\s*=\s* # (2) before 0025 qFindChild<([^>]*)> # (3) class name 0026 \(\s*([&\w]+)\s*,\s* # (4) variable 0027 (.*)$ # (5) end 0028 /x; # /x Enables extended whitespace mode 0029 if (my ($indent, $before, $classname, $variable, $end) = $_ =~ $regexpqFindChild) { 0030 warn "found qFindChild \n"; 0031 if ($variable =~ /^&/ ) { 0032 $variable =~ s/^&//; 0033 $_ = $indent . $before . " = " . $variable . ".findChild<$classname>(" . $end . "\n"; 0034 } else { 0035 $_ = $indent . $before . " = " . $variable . "->findChild<$classname>(" . $end . "\n"; 0036 } 0037 } 0038 0039 my $regexpqFindChildren = qr/ 0040 ^(\s*) # (1) Indentation 0041 (.*?) # (2) before 0042 qFindChildren<([^>]*)> # (3) class name 0043 \(\s*([&\w]+)\s*\) # (4) variable 0044 (.*)$ # (5) end 0045 /x; # /x Enables extended whitespace mode 0046 if (my ($indent, $before, $classname, $variable, $end) = $_ =~ $regexpqFindChildren) { 0047 warn "found qFindChildren \n"; 0048 if ($variable =~ /^&/ ) { 0049 $variable =~ s/^&//; 0050 $_ = $indent . $before . $variable . ".findChildren<$classname>()" . $end . "\n"; 0051 } else { 0052 $_ = $indent . $before . $variable . "->findChildren<$classname>()" . $end . "\n"; 0053 } 0054 } 0055 0056 $modified ||= $orig ne $_; 0057 $_; 0058 } <$FILE>; 0059 0060 if ($modified) { 0061 open (my $OUT, ">", $file); 0062 print $OUT @l; 0063 close ($OUT); 0064 } 0065 } 0066 0067 functionUtilkde::diffFile( "@ARGV" );