Warning, file /sdk/kde-dev-scripts/kf5/convert-klocale-formatdate.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 # Laurent Montel <montel@kde.org> (2014) 0004 # KGlobal::locale().formatDate -> QLocale().toString 0005 # find -iname "*.cpp"|xargs kde-dev-scripts/kf5/convert-klocale-formatdate.pl 0006 0007 use strict; 0008 use File::Basename; 0009 use lib dirname($0); 0010 use functionUtilkde; 0011 0012 foreach my $file (@ARGV) { 0013 0014 my $modified; 0015 open(my $FILE, "<", $file) or warn "We can't open file $file:$!\n"; 0016 my @l = map { 0017 my $orig = $_; 0018 0019 if (/KLocale::global\(\)\-\>formatDate\s*\((.*)\)/) { 0020 my $args = $1; 0021 warn "Found KLocale::global()->formatDate : $args\n"; 0022 my $arg_regexp = qr/ 0023 ^([^,]*)\s* # date 0024 (?:,\s*([^,]*))? # option 0025 (.*)$ # after 0026 /x; 0027 if ( my ($date, $option, $after) = $args =~ $arg_regexp ) { 0028 if ( defined $option) { 0029 warn "Option found $option\n"; 0030 } 0031 warn "Argument ? : $date \n"; 0032 s,KLocale::global\(\)\-\>formatDate\b,QLocale().toString,; 0033 s,KLocale::ShortDate,QLocale::ShortFormat,; 0034 s,KLocale::LongDate,QLocale::LongFormat,; 0035 } 0036 } 0037 my $regexp = qr/ 0038 ^(\s*) # (1) Indentation 0039 (.*?) # (2) Possibly "Classname *" (the ? means non-greedy) 0040 KLocale::global\(\)\-\>formatDateTime 0041 ${functionUtilkde::paren_begin}3${functionUtilkde::paren_end} # (3) (args) 0042 (.*)$ # (4) afterreg 0043 /x; # /x Enables extended whitespace mode 0044 if ( my ($indent, $before, $args, $after) = $_ =~ $regexp) { 0045 warn "Found KLocale::global()->formatDateTime : $args\n"; 0046 my $arg_regexp = qr/ 0047 ^([^,]*)\s* # date 0048 (?:,\s*([^,]*))? # option 0049 (.*)$ # after 0050 /x; 0051 if ( my ($date, $option, $afterargs) = $args =~ $arg_regexp ) { 0052 if ( not defined $option) { 0053 # default option in kde is QLocale::ShortFormat in QLocale it's QLocale::LongFormat 0054 $_ = $indent . $before . "QLocale().toString($date, QLocale::ShortFormat)" . $after . "\n"; 0055 } else { 0056 s,KLocale::global\(\)\-\>formatDateTime\b,QLocale().toString,; 0057 s,KLocale::ShortDate,QLocale::ShortFormat,; 0058 s,KLocale::LongDate,QLocale::LongFormat,; 0059 } 0060 } 0061 } 0062 0063 s,KLocale::global\(\)\-\>weekStartDay\(\),QLocale().firstDayOfWeek(),g; 0064 $modified ||= $orig ne $_; 0065 $_; 0066 } <$FILE>; 0067 0068 if ($modified) { 0069 open (my $OUT, ">", $file); 0070 print $OUT @l; 0071 close ($OUT); 0072 functionUtilkde::addIncludeInFile($file, "QLocale"); 0073 } 0074 } 0075 0076 functionUtilkde::diffFile( "@ARGV" );