summaryrefslogtreecommitdiffstats
path: root/PerlQt/bin/pqtapi
blob: 9c5eadfb92e9703913f7f981453162d7d02e1ac6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/perl

# Note: this program is part of PerlQt and makes use of its internal functions.
#       You should not rely on those in your own programs.

use Getopt::Std;
use strict 'vars';

our (%o, @x, $h);
getopts('r:hvimp', \%o);

package Qt::_internal;
use Qt;

exists $o{'v'} and do{ print "PerlQt-$Qt::VERSION using Qt-".&Qt::version."\n" and exit 0 };
exists $o{'h'} and do{ print $h and exit 0 };
exists $o{'m'} and do{      # interactive mode for driving the Qt Designer Plugin
    select(STDOUT); $| = 1; # unbuffered
    while(<STDIN>)
    {
        chomp;
        s/^Q(?=[A-Z])/Qt::/;
        my $i = find_pclassid( $_ );
        print "__START__\n";
        if ($i)
        {
            my $a = findAllMethods( $i );
            my $t = dumpCandidates( [map {@{ $$a{$_} }} sort keys %$a] );
            getAllParents($i, \my @sup);
            for my $s(@sup)
            {
                $a = findAllMethods( $s );
                $t.= dumpCandidates( [map {@{ $$a{$_} }} sort keys %$a] );
            }
            $t =~ s/\t//gs;
            print $t;
        }
        print "__END__\n";
    }
};
(my $c = $ARGV[0]) =~ s/^Q(?=[A-Z])/Qt::/;
my $i = $c ? find_pclassid( $c ) : 1;
my $r = exists $o{'r'} ? (exists $o{'i'} ? qr|$o{'r'}|i : qr|$o{'r'}|) : 0;
my $d = "";

while ($i)
{
   my $a=findAllMethods($i);
   last unless keys %$a;
   @x=map {@{ $$a{$_} }} sort keys %$a;
   $d = dumpCandidates(\@x);
   if($c and $i and exists $o{'p'})
   {
        getAllParents($i, \my @sup);
        for my $s(@sup)
        {
            $a = findAllMethods( $s );
            $d.= dumpCandidates( [map {@{ $$a{$_} }} sort keys %$a] );
        }
   }
   if($r)
   {
       map { print "$_\n" if $_=~$r } split("\n", $d);
   }
   else
   {
       print $d
   }
   $c and last;
   $i++
}

BEGIN {
    $h = "pqtapi - a PerlQt introspection tool\t(c) Germain Garand 2003 <germain\@ebooksfrance.org>\n\n".
         "usage: pqtapi [-r <re>] [<class>]\n\n".
         "options:\n". 
         "\t-r <re> : find all functions matching regular expression/keyword <re>\n".
         "\t-i : together with -r, performs a case insensitive search\n".
         "\t-p : display also inherited methods for <class>.\n".
         "\t-v : print PerlQt and Qt versions\n".
         "\t-h : print this help message\n";
}