#!/usr/local/perl/bin/perl
#
# uic3 DialogBase.ui -o qt\DialogBase.h
#
# uic3 -impl DialogBase.h DialogBase.ui -o qt\DialogBase.cpp
#

use strict;
use warnings;

my $uic3 = 'C:\\RiverWare\\tools\\Qt-482\\bin\\uic3.exe';

my @incl = ('datasetdlg::buttonframe.h',
            'datasetdlg::configframe.h',
            'datasetdlg::nameframe.h',
            'rpllistview.h',
            'rplunitcombobox.h',
            'simobjdispatchstatebutton.h');

if ($ARGV[0] ne '-impl') {

    my ($ui, $hpp) = ($ARGV[0], $ARGV[2]);
#    $hpp =~ s/\.h$/.hpp/;

    open(INPUT, "$uic3 $ui |") || die;
    open(OUTPUT, "> $hpp") || die;

    my $re = '^# *include *"(' . join('|', @incl) . ')" *$';

    while (<INPUT>) {
        next if /$re/;
        print OUTPUT;
    }

    close INPUT;
    close OUTPUT;

} else {

    unshift @ARGV, ($uic3);
    system @ARGV;

}

exit 0;
