File indexing completed on 2024-04-14 05:35:08

0001 #!/usr/bin/perl
0002 
0003 # Laurent Montel <montel@kde.org> 2006 GPL
0004 # Reinhold Kainhofer <reinhold@kainhofer.com> 2006 GPL
0005 #
0006 # Port the QT3_SUPPORT QLabel constructors to the Qt3 constructors.
0007 #
0008 
0009 use File::Basename;
0010 use lib dirname( $0 );
0011 use functionUtilkde;
0012 use strict;
0013 
0014 open(my $F, "-|", qw(find [ac-z]* -type f));
0015 my $file;
0016 while ($file = <$F>) {
0017     next if $file =~ /\.svn/;
0018     chomp $file;
0019     next if functionUtilkde::excludeFile( $file);
0020 
0021     my $modified;
0022     my @necessaryIncludes = ();
0023     open(my $FILE, "<", $file) or warn "We can't open file $file:$!\n";
0024     my @l = map {
0025       my $orig = $_;
0026       my ($spaces, $trailer, $object, $call, $ws, $params );
0027       if ( ($spaces, $trailer, $object, $call, $ws, $params ) = m!^(\s*)(.*[\s\*]|)([a-zA-Z0-9_]+)(\s*=\s*new QLabel\s*)\((\s*)(.*[^\s])\s*\);$! ) {
0028 print "Spaces: '$spaces', Trailer: '$trailer', Object: '$object', Call: '$call', WS: '$ws', Params: '$params'\n";
0029         my @parms = split( /,\s*/, $params );
0030         my $pws = $ws;
0031 
0032         my $buddy, my $text, my $parent, my $name, my $flags;
0033 
0034 print "Case ";
0035         if ( $parms[0] =~ m/i18n\(.*/ ) {
0036 print "1";
0037           $text=$parms[0];
0038           $parent=$parms[1];
0039           $name=$parms[2] if scalar(@parms)>2;
0040           $flags=$parms[3] if scalar(@parms)>3;
0041       $pws=' ';
0042         } elsif ( scalar(@parms) == 5 ) {
0043           ($buddy, $text, $parent, $name, $flags) = @parms;
0044 print "2";
0045 
0046         } elsif (scalar(@parms) == 4 ) {
0047           if ( $parms[3]=~m/Qt::/ ){
0048             ($text, $parent, $name, $flags) = @parms;
0049            } else {
0050              ($buddy, $text, $parent, $name) = @parms;
0051            }
0052 print "3";
0053 
0054         } elsif (scalar(@parms) == 3) {
0055           if ( $parms[2]=~m/Qt::/ ){
0056             ($parent, $name, $flags) = @parms;
0057           } elsif ( $parms[2]=~m/^".*"$/ ) {
0058             ($text, $parent, $name) = @parms;
0059           } else {
0060             ($buddy, $text, $parent) = @parms;
0061           }
0062 print "4";
0063         } elsif (scalar(@parms) == 2) {
0064           if ( $parms[1] =~ m/this/ ) {
0065             ($text, $parent) = @parms;
0066           } elsif ( $parms[1] =~ m/^".*"$/ ) {
0067             ($parent, $name) = @parms;
0068           } else {
0069             ($buddy, $text) = @parms;
0070           }
0071 print "5";
0072         } elsif ( scalar(@parms) == 1 ) {
0073           $parent = $parms[0];
0074 print "6";
0075         }
0076 print "\n";
0077 
0078         $_ = "$spaces$trailer$object$call(";
0079         my $p="";
0080         $p.= "$text" if ( defined($text) );
0081         if ( defined($parent) ) {
0082           $p.= ",$pws" if ( defined($text) );
0083           $p.= "$parent";
0084           if ( defined($flags) ) { 
0085             $p.=",$ws$flags";
0086           }
0087         }
0088         if (defined($p)) { $_.="$ws$p$ws"; }
0089         $_.=");\n";
0090         if ( defined($name) ) {
0091           $_.="$spaces$object->setObjectName($ws$name$ws);\n";
0092         }
0093         if ( defined($buddy) ) {
0094           $_.="$spaces$object->setBuddy($ws$buddy$ws);\n";
0095         }
0096 print "ORIG: $orig";
0097 print "NEW:  $_";
0098 # print "Original call: $call($ws$params$ws)\n";
0099 print "Buddy: $buddy, Text: $text, Parent: $parent, Name: $name, Flags: $flags\n";
0100 
0101 
0102 # QT4 API:
0103 # QLabel ( QWidget * parent = 0, Qt::WFlags f = 0 )
0104 # QLabel ( const QString & text, QWidget * parent = 0, Qt::WFlags f = 0 )
0105 #
0106 #
0107 # DEPRECATED:
0108 # QLabel ( QWidget * parent, const char * name, Qt::WFlags f = 0 )
0109 # QLabel ( const QString & text, QWidget * parent, const char * name, Qt::WFlags f = 0 )
0110 # QLabel ( QWidget * buddy, const QString & text, QWidget * parent = 0, const char * name = 0, Qt::WFlags f = 0 )
0111 
0112       }
0113       $modified ||= $orig ne $_;
0114       $_;
0115     } <$FILE>;
0116 
0117     if ($modified) {
0118       print "Modified: $file\n";
0119       open (my $OUT, ">", $file);
0120       print $OUT @l;
0121       close $OUT;
0122     }
0123 
0124 }
0125 functionUtilkde::diffFile( <$F> );
0126