summaryrefslogtreecommitdiffstats
path: root/util/install/win/setupwizardimpl.cpp
blob: 909d9864eedea26aec7458b50a8d5cf860912976 (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the utils of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the either Technology Preview License Agreement or the
** Beta Release License Agreement.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#include "setupwizardimpl.h"
#include "environment.h"
#include <qfiledialog.h>
#include <qlineedit.h>
#include <qlabel.h>
#include <qprogressbar.h>
#include <qtextview.h>
#include <qmultilineedit.h>
#include <qbuttongroup.h>
#include <qsettings.h>
#include <qlistview.h>
#include <qlistbox.h>
#include <qapplication.h>
#include <qcheckbox.h>
#include <qtextstream.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qcombobox.h>
#include <qmessagebox.h>
#include <qregexp.h>
#include <qtabwidget.h>
#include <qarchive.h>
#include <qvalidator.h>
#include <qdatetime.h>
#include <qlayout.h>

#include <keyinfo.h>
#if defined(Q_OS_WIN32)

#include <process.h>
#endif

#if defined(EVAL) || defined(EDU) || defined(NON_COMMERCIAL)
#include <check-and-patch.h>
#endif

#if defined(EVAL)
#  define LICENSE_DEST "LICENSE.EVAL"
#elif defined(EDU)
#  define LICENSE_DEST "LICENSE.EDU"
#elif defined(NON_COMMERCIAL)
#  define LICENSE_DEST "LICENSE.NON_COMMERCIAL"
#else
#  define LICENSE_DEST "LICENSE"
#endif

#include "resource.h"
#include "pages/sidedecorationimpl.h"

#define FILESTOCOPY 4582

static const char* const logo_data[] = {
"32 32 238 2",
"Qt c None",
"#u c #000000",
".# c #020204",
"a. c #102322",
"af c #282500",
"as c #292e26",
"a8 c #2c686a",
"ae c #307072",
"#C c #322a0c",
"#s c #36320c",
"am c #3b3d3f",
"#3 c #3c8082",
"#f c #3e3a0c",
"## c #423e0c",
"#9 c #434341",
"ad c #438888",
"aU c #458d8e",
"#g c #46420c",
"aM c #46494a",
"ay c #474948",
"#D c #4a4328",
".W c #4a4611",
"az c #4a4641",
"a1 c #4a4a49",
"aH c #4b9e9e",
"au c #4d9a9f",
"aS c #4e9a9a",
"an c #4f4e4a",
".X c #504e0c",
"a7 c #51a4a9",
"#0 c #525250",
"aT c #55a6a3",
".Y c #56520c",
"#a c #5a5604",
".Z c #5e5a0c",
".V c #5e5e5c",
"a0 c #5e5e60",
"a6 c #5ea0a6",
".J c #625e0c",
"bB c #64aaa9",
"#m c #665e2c",
"aL c #686867",
"bw c #68acb2",
"bo c #696928",
"ba c #696967",
"aE c #69aeb2",
"#z c #6a5614",
".K c #6a660c",
"aZ c #6a6a65",
"bG c #6db4b4",
".9 c #6e5e24",
"#. c #6e6a5c",
"bv c #6fb6b9",
"bC c #706d28",
"br c #70bcc5",
"aQ c #71b7ba",
".I c #726234",
".L c #726e0c",
".0 c #72720c",
"#w c #746d44",
"be c #747028",
"bH c #747428",
".M c #76720a",
"aR c #78c1c2",
"#Z c #797977",
"a2 c #7a5d3d",
"#H c #7a6614",
"#I c #7a760a",
"#l c #7a7634",
".1 c #7a7a0c",
"#e c #7a7a5c",
"bL c #7bc0c2",
"b. c #7c7d82",
"#d c #7e6e34",
".N c #7e7a0a",
"bP c #816c20",
".8 c #82763c",
"#h c #827a3c",
".x c #827e0c",
"#t c #827f4b",
".O c #828204",
"#v c #828384",
".P c #868604",
"bq c #87d4d9",
"#k c #89864b",
"#c c #8a8244",
".y c #8a8604",
"#j c #8d8652",
"al c #8d8d8a",
"#b c #8e8644",
".z c #8e8e04",
"aW c #8f9094",
"#i c #908952",
"#Q c #909021",
"ag c #90d0d2",
"bO c #916f34",
"bQ c #91cdd3",
".7 c #928a44",
"#p c #928e6c",
"#P c #947f2f",
".A c #949204",
"bh c #949495",
".6 c #968e4c",
"aC c #999721",
".w c #9a8a44",
"#M c #9a9a99",
"ap c #9b9b21",
".5 c #9c924c",
"#R c #9c9a04",
"#7 c #9d9d9b",
"ao c #9e7641",
".4 c #9e964c",
"#J c #9e9b21",
".B c #9e9e04",
"ac c #9e9e9d",
"#S c #a09e21",
"ax c #a0a0a3",
"aK c #a1a1a2",
"aX c #a1a1a4",
".r c #a2a204",
"#1 c #a2a221",
"aF c #a2e1dd",
".3 c #a49a54",
".2 c #a69e54",
"bR c #a78446",
"#6 c #a9a9a8",
".T c #aaa254",
".s c #aaaa04",
"#W c #abaaa6",
"aN c #ac8861",
".S c #aea25c",
".R c #aea65c",
".t c #aeae04",
"#L c #b0b0b0",
"#o c #b2ae94",
".u c #b2b204",
"aI c #b2b2b4",
"b# c #b3b3b2",
"#X c #b4b4b6",
"#V c #b5b4b4",
".Q c #b6aa5c",
".n c #b6b604",
"aY c #b6b6b7",
"bN c #b79658",
"ah c #b7e5e3",
"aG c #b7ebe9",
"ar c #b9d9dc",
"#8 c #bcbcbe",
"ab c #bdbdbe",
".m c #beae5c",
".F c #beb264",
"aq c #bef6f6",
"aB c #c1a470",
"#F c #c1c1c3",
".E c #c2b664",
"at c #c2e9eb",
"bI c #c39c6a",
"bs c #c3a366",
"#U c #c3c3c0",
"aw c #c3c3c1",
"#G c #c3c3c7",
"aD c #c3f1f2",
"a# c #c6c6c3",
"#2 c #c7edf3",
".D c #c8ba6c",
"bM c #c9a470",
"#N c #c9c9c4",
".C c #cabe6c",
"ak c #cacaca",
"bx c #cbb076",
"aa c #cbcbc9",
"a3 c #ccac7f",
".H c #ceba54",
"#E c #ceced0",
"bi c #cfaf7e",
"#Y c #cfcfcb",
"bK c #d1ac80",
"#5 c #d1d1cf",
"bu c #d2ae83",
"bm c #d3b180",
"bD c #d3b384",
"bF c #d4b589",
"aJ c #d4d4d3",
".j c #d6c664",
".v c #d6c674",
"#K c #d6d6d5",
"bJ c #d7b588",
"bd c #d8b289",
"bz c #d8b78d",
".q c #d8ca74",
"aj c #d8d8d9",
"bb c #dabd97",
"a5 c #dcba91",
"bE c #dcc097",
"aA c #ddc292",
"aP c #dec491",
".p c #dece75",
"bk c #dfc79c",
"av c #e0e0e0",
"#A c #e2dabc",
"#O c #e2e2e4",
"aO c #e3c898",
"by c #e4c7a1",
".l c #e6da84",
"a4 c #e7c7a2",
"bt c #eacaa5",
".o c #eede84",
".G c #eee284",
".i c #eee294",
"bn c #efd7b4",
".k c #f2e69c",
".e c #f2eaa4",
"bc c #f3d8b8",
"bj c #f5e2c8",
"#r c #f6eea4",
".f c #f6eeb8",
".g c #f6f2cc",
".c c #faf6d4",
".d c #fafae4",
".U c #feee95",
"bA c #fef26c",
"#q c #fef2ac",
"#x c #fef2b8",
"bp c #fef684",
"bl c #fef690",
"bg c #fef69c",
"bf c #fef6a4",
".a c #fef6b4",
"#B c #fef6c4",
"#y c #fef6ce",
"a9 c #fefaac",
"aV c #fefab7",
"ai c #fefac4",
"#4 c #fefad1",
"#n c #fefadf",
".h c #fefaec",
"#T c #fefee6",
".b c #fefefa",
"QtQtQtQtQtQtQtQtQtQtQtQt.#QtQtQtQtQtQt.#QtQtQtQtQtQtQtQtQtQtQtQt",
"QtQtQtQtQtQtQtQtQtQt.#.#.a.#QtQtQtQt.#.b.#.#QtQtQtQtQtQtQtQtQtQt",
"QtQtQtQtQtQtQtQt.#.#.a.a.a.a.#QtQt.#.c.d.b.b.#.#QtQtQtQtQtQtQtQt",
"QtQtQtQtQtQt.#.#.e.e.e.e.e.e.e.#.#.f.f.g.g.c.h.b.#.#QtQtQtQtQtQt",
"QtQtQtQt.#.#.i.i.i.i.i.i.i.i.j.j.b.b.k.e.f.f.g.g.c.d.#.#QtQtQtQt",
"QtQt.#.#.l.l.l.l.l.l.l.l.m.m.n.n.o.o.b.b.k.k.e.f.f.g.g.c.#.#QtQt",
"Qt.#.p.p.q.p.p.p.p.p.m.m.r.s.t.u.p.q.v.v.b.b.i.i.k.e.f.f.g.g.#Qt",
"QtQt.#.j.j.j.j.j.w.w.x.y.z.A.B.r.C.C.D.E.E.F.b.b.o.G.k.k.e.#QtQt",
"QtQtQt.#.H.H.I.I.J.K.L.M.N.O.P.z.Q.Q.Q.R.R.R.S.T.b.b.G.G.#QtQtQt",
"Qt.#.#.U.V.W.W.W.X.Y.Z.J.K.L.0.1.2.3.3.4.5.5.6.6.7.8.9#..b.#.#Qt",
"QtQtQt.#.U.U.U.W.W##.W.X.Y#a.J.K.7.7#b#b#b#c#c#d#d.h.h.b.#QtQtQt",
"QtQtQtQt.##e.U.U.U.W.W#f#g.W.X.Y#h#i#j#k#l#m#m#n#n.h#g.#QtQtQtQt",
"QtQtQtQt.##o#p#e#q#q#r#f#f#s#f#g#t#u#v#u#w#x#y#y#g#g#z.#QtQtQtQt",
"QtQtQtQt.#.b#A#o#p#e#B#B#B#C#C#D#u#E#F#G#u#y#g#g#H#I#J#uQtQtQtQt",
"QtQtQtQt.#.b.h.b#A#o#p#e.d.d.d#u#K#L#M#N#O#u#P#Q#R#S#u#u#uQtQtQt",
"QtQtQtQt.#.b#T.h#T#n#A#o#p#e#u#U#V#W#X#Y#Z#0#u#1#S#u#2#3#uQtQtQt",
"QtQtQtQt.##T.h#T#n#T#n#4#A#u#5#6#7#6#8#Z#0#9#u#S#u#2#3a.Qt#u#uQt",
"QtQtQtQt.##T#n#T#4#4#4#4#u#Oa#aaabac#Z#9#9#u#S#u#2adaeaf#uagah#u",
"QtQtQtQt.##n#n#4#4#4ai#u#Oajak#Yalamanao#u#Sap#uaqar#3asagatau#u",
"QtQtQtQt.##T#4#4#4ai#uav#O#OawaxayazaAaB#uapaC#uaDaEaFaGataH#uQt",
"QtQtQtQt.##4#4aiaiai#uaIaJ#OaKaLaMaNaOaPao#u#uaDaQaRaSaTaU#uQtQt",
"QtQtQtQt.##4aiaV.aaV#uaWaXaYaZa0a1a2a3a4a5ao#ua6a7a8#u#u#uQtQtQt",
"QtQtQtQt.#aiaiaiaV.aa9#ub.b#baa0#u#1#ubbbcbdao#ua8#ube.#.#.#.#Qt",
"QtQtQtQt.#aV.aaVaVbfbfbg#ubhba#u#1.AaC#ubibjbkao#ube#a.#.#.#.#.#",
"QtQtQtQt.#.aa9.abfa9bgbgbg#u#ubl.AaC#uaD#ubmbna5ao#ubo.#.#.#.#Qt",
"QtQtQtQt.#.aa9a9bgbgblblblblbpbpaC#uaDbqbr#ubsbtbuao#u.#.#QtQtQt",
"QtQtQtQtQt.#.#bgbgbgblblbpbpbpbp#uatbvbwa8#u#ubxbybzao#uQtQtQtQt",
"QtQtQtQtQtQtQt.#.#blblbpbpbAbp#uaDbBbwa8#ubebC#ubDbEbFao#uQtQtQt",
"QtQtQtQtQtQtQtQtQt.#.#bAbpbA#uaDbGbwa8#ubH.#.#Qt#ubIbJbKao#uQtQt",
"QtQtQtQtQtQtQtQtQtQtQt.#.##uaDbLbwa8#u.#.#QtQtQtQt#ubMbNbObP#uQt",
"QtQtQtQtQtQtQtQtQtQtQtQtQt#ubQbwa8#u.#QtQtQtQtQtQtQt#ubRbO#uQtQt",
"QtQtQtQtQtQtQtQtQtQtQtQtQtQt#u#u#uQtQtQtQtQtQtQtQtQtQt#u#uQtQtQt"};

static bool findFileInPaths( const QString &fileName, const QStringList &paths )
{
	QDir d;
	for( QStringList::ConstIterator it = paths.begin(); it != paths.end(); ++it ) {
	    // Remove any leading or trailing ", this is commonly used in the environment
	    // variables
	    QString path = (*it);
	    if ( path.startsWith( "\"" ) )
		path = path.right( path.length() - 1 );
	    if ( path.endsWith( "\"" ) )
		path = path.left( path.length() - 1 );
	    if( d.exists( path + QDir::separator() + fileName ) )
		return true;
	}
	return false;
}

bool findFile( const QString &fileName )
{
    QString file = fileName.lower();
    QStringList paths;
#if defined(Q_OS_WIN32)
    QRegExp split( "[;,]" );
#else
    QRegExp split( "[:]" );
#endif
    if ( file.endsWith( ".h" ) ) {
	if ( globalInformation.sysId() == GlobalInformation::Borland )
	    return true;
	paths = QStringList::split( split, QEnvironment::getEnv( "INCLUDE" ) );
    } else if ( file.endsWith( ".lib" ) ) {
	if ( globalInformation.sysId() == GlobalInformation::Borland )
	    return true;
	paths = QStringList::split( split, QEnvironment::getEnv( "LIB" ) );
    } else {
	paths = QStringList::split( split, QEnvironment::getEnv( "PATH" ) );
    }
    return findFileInPaths( file, paths );
}

static bool createDir( const QString& fullPath )
{
    QStringList hierarchy = QStringList::split( QDir::separator(), fullPath );
    QString pathComponent, tmpPath;
    QDir dirTmp;
    bool success = true;

    for( QStringList::Iterator it = hierarchy.begin(); it != hierarchy.end(); ++it ) {
	pathComponent = *it + QDir::separator();
	tmpPath += pathComponent;
#if defined(Q_OS_WIN32)
	success = dirTmp.mkdir( tmpPath );
#else
	success = dirTmp.mkdir( QDir::separator() + tmpPath );
#endif
    }
    return success;
}

SetupWizardImpl::SetupWizardImpl( QWidget* parent, const char* name, bool modal, WindowFlags flag ) :
    QWizard( parent, name, modal, flag ),
    tmpPath( QEnvironment::getTempPath() ),
    fixedPath(false),
    filesCopied( false ),
    filesToCompile( 0 ),
    filesCompiled( 0 ),
    licensePage( 0 ),
    licenseAgreementPage( 0 ),
    licenseAgreementPageQsa( 0 ),
    optionsPage( 0 ),
    optionsPageQsa( 0 ),
    foldersPage( 0 ),
    configPage( 0 ),
    progressPage( 0 ),
    buildPage( 0 ),
    finishPage( 0 )
{
    // initialize
    if ( !name )
	setName( "SetupWizard" );
    resize( 600, 390 );
#if defined(QSA)
    setCaption( trUtf8( "QSA Installation Wizard" ) );
#else
    setCaption( trUtf8( "Qt Installation Wizard" ) );
#endif
    QPixmap logo( ( const char** ) logo_data );
    setIcon( logo );
#if defined(QSA)
    setIconText( trUtf8( "QSA Installation Wizard" ) );
#else
    setIconText( trUtf8( "Qt Installation Wizard" ) );
#endif
    QFont f( font() );
    f.setFamily( "Arial" );
    f.setPointSize( 12 );
    f.setBold( true );
    setTitleFont( f );

    totalFiles = 0;

    // try to read the archive header information and use them instead of
    // QT_VERSION_STR if possible
    QArchiveHeader *archiveHeader = 0;
    ResourceLoader rcLoader( "QT_ARQ", 500 );
    if ( rcLoader.isValid() ) {
	// First, try to find qt.arq as a binary resource to the file.
	QArchive ar;
	QDataStream ds( rcLoader.data(), IO_ReadOnly );
	archiveHeader = ar.readArchiveHeader( &ds );
    } else {
	// If the resource could not be loaded or is smaller than 500
	// bytes, we have the dummy qt.arq: try to find and install
	// from qt.arq in the current directory instead.
	QArchive ar;
	QString archiveName = "qt.arq";
# if defined(Q_OS_MAC)
	QString appDir = qApp->argv()[0];
	int truncpos = appDir.findRev( "/Contents/MacOS/" );
	if (truncpos != -1)
	    appDir.truncate( truncpos );
	archiveName  = appDir + "/Contents/Qt/qtmac.arq";
# endif
	ar.setPath( archiveName );
	if( ar.open( IO_ReadOnly ) )  {
	    archiveHeader = ar.readArchiveHeader();
	}
    }

#if defined(QSA)
    ResourceLoader rcLoaderQsa( "QSA_ARQ", 500 );
    if ( rcLoaderQsa.isValid() ) {
	// First, try to find qt.arq as a binary resource to the file.
	QArchive ar;
	QDataStream ds( rcLoaderQsa.data(), IO_ReadOnly );
	QArchiveHeader *archiveHeaderQsa = ar.readArchiveHeader( &ds );
	if ( archiveHeaderQsa ) {
	    QString qsa_version_str = archiveHeaderQsa->description();
	    if ( !qsa_version_str.isEmpty() )
		globalInformation.setQsaVersionStr( qsa_version_str );
	    delete archiveHeaderQsa;
	}
    }
#endif

#if defined(Q_OS_WIN32)
    // First check for MSVC 6.0
    QString regValue = QEnvironment::getRegistryString( "Software\\Microsoft\\VisualStudio\\6.0\\Setup\\Microsoft Visual C++", "ProductDir", QEnvironment::LocalMachine );
    if (!regValue.isEmpty())
	globalInformation.setSysId(GlobalInformation::MSVC);

    // MSVC.NET 7.0 & 7.1 takes presedence over 6.0
    regValue = QEnvironment::getRegistryString( "Software\\Microsoft\\VisualStudio\\7.0", "InstallDir", QEnvironment::LocalMachine );
    if (regValue.isEmpty())
	regValue = QEnvironment::getRegistryString( "Software\\Microsoft\\VisualStudio\\7.1", "InstallDir", QEnvironment::LocalMachine );
    if (!regValue.isEmpty())
	globalInformation.setSysId(GlobalInformation::MSVCNET);

    while (globalInformation.sysId() == GlobalInformation::Other) {
 	globalInformation.setSysId(GlobalInformation::Borland);
 	if (findFile(globalInformation.text(GlobalInformation::MakeTool)))
 	    break;
 	globalInformation.setSysId(GlobalInformation::MSVCNET);
 	if (findFile(globalInformation.text(GlobalInformation::MakeTool)))
 	    break;
 	globalInformation.setSysId(GlobalInformation::MinGW);
 	if (findFile(globalInformation.text(GlobalInformation::MakeTool)))
 	    break;
 	globalInformation.setSysId(GlobalInformation::Watcom);
 	if (findFile(globalInformation.text(GlobalInformation::MakeTool)))
 	    break;
     }
#endif

    if ( archiveHeader ) {
	QString qt_version_str = archiveHeader->description();
	if ( !qt_version_str.isEmpty() )
	    globalInformation.setQtVersionStr( qt_version_str );

#if defined(EVAL) || defined(EDU) || defined(NON_COMMERCIAL)
	if ( archiveHeader->findExtraData( "compiler" ) == "borland" )
	    globalInformation.setSysId(GlobalInformation::Borland);
#endif
	delete archiveHeader;
    }

    initPages();
    initConnections();

    if (optionsPage) {
#if defined(QSA)
	optionsPage->installPath->setText(
	    QString( "C:\\Qt_QSA\\Qt" ) +
	    QString( globalInformation.qtVersionStr() ).replace( QRegExp("\\s"), "" ).replace( QRegExp("-"), "" )
	    );
#endif
    }
    if ( optionsPageQsa ) {
#if defined(QSA)
	optionsPageQsa->installPath->setText(
	    QString( "C:\\Qt_QSA\\QSA" ) +
	    QString( globalInformation.qsaVersionStr() ).replace( QRegExp("\\s"), "" ).replace( QRegExp("-"), "" )
	    );
#endif
    }
    readLicense( QDir::homeDirPath() + "/.qt-license" );
}

static bool copyFile( const QString& src, const QString& dest )
{
#ifdef Q_WS_WIN
    QT_WA( {
	return CopyFileW( (const wchar_t*)src.ucs2(), (const wchar_t*)dest.ucs2(), false );
    }, {
	return CopyFileA( src.local8Bit(), dest.local8Bit(), false );
    } );
#else
    int len;
    const int buflen = 4096;
    char buf[buflen];
    QFileInfo info( src );
    QFile srcFile( src ), destFile( dest );
    if (!srcFile.open( IO_ReadOnly ))
	return false;
    destFile.remove();
    if (!destFile.open( IO_WriteOnly ))
	return false;

    while (!srcFile.atEnd()) {
	len = srcFile.readBlock( buf, buflen );
	if (len <= 0)
	    break;
	if (destFile.writeBlock( buf, len ) != len)
	    return false;
    }
    destFile.flush();
    return true;
#endif
}

void SetupWizardImpl::initPages()
{
#define ADD_PAGE( var, Class ) \
    { \
    var = new Class( this, #var ); \
    SideDecorationImpl *sideDeco = new SideDecorationImpl( var ); \
    \
    Q_ASSERT( var->layout() != 0 ); \
    if ( var->layout()->inherits("QBoxLayout") ) { \
	((QBoxLayout*)var->layout())->insertWidget( 0, sideDeco ); \
	((QBoxLayout*)var->layout())->insertSpacing( 1, 10 ); \
    } \
    \
    pages.append( var ); \
    addPage( var, var->title() ); \
    setHelpEnabled( var, false ); \
    \
    connect( this, SIGNAL(wizardPages(const QPtrList<Page>&)), \
	    sideDeco, SLOT(wizardPages(const QPtrList<Page>&)) ); \
    connect( this, SIGNAL(wizardPageShowed(int)), \
	    sideDeco, SLOT(wizardPageShowed(int)) ); \
    connect( this, SIGNAL(wizardPageFailed(int)), \
	    sideDeco, SLOT(wizardPageFailed(int)) ); \
    connect( this, SIGNAL(editionString(const QString&)), \
	    sideDeco->editionLabel, SLOT(setText(const QString&)) ); \
    }

    QPtrList<Page> pages;
    if( globalInformation.reconfig() ) {
	ADD_PAGE( configPage,	ConfigPageImpl  )
	ADD_PAGE( buildPage,	BuildPageImpl   )
	ADD_PAGE( finishPage,	FinishPageImpl  )
    } else {
#if defined(Q_OS_WIN32)
	ADD_PAGE( winIntroPage,		WinIntroPageImpl	)
#endif
#if !defined(EVAL_CD) && !defined(NON_COMMERCIAL)
	ADD_PAGE( licensePage,		LicensePageImpl		)
#endif
	ADD_PAGE( licenseAgreementPage, LicenseAgreementPageImpl)
#if defined(QSA)
	ADD_PAGE( licenseAgreementPageQsa, LicenseAgreementPageImpl)
#endif
	ADD_PAGE( optionsPage,		OptionsPageImpl		)
#if defined(QSA)
	ADD_PAGE( optionsPageQsa,	OptionsPageImpl		)
#endif
#if !defined(Q_OS_UNIX)
	ADD_PAGE( foldersPage,		FoldersPageImpl		)
#endif
	ADD_PAGE( configPage,		ConfigPageImpl		)
	ADD_PAGE( progressPage,		ProgressPageImpl	)
	ADD_PAGE( buildPage,		BuildPageImpl		)
	ADD_PAGE( finishPage,		FinishPageImpl		)
    }
#undef ADD_PAGE

    if ( licensePage ) {
	setNextEnabled( licensePage, false );
    }
    if ( licenseAgreementPage ) {
	setNextEnabled( licenseAgreementPage, false );
    }
    if ( licenseAgreementPageQsa ) {
	setNextEnabled( licenseAgreementPageQsa, false );
	licenseAgreementPage->titleStr = "License agreement Qt";
	licenseAgreementPageQsa->titleStr = "License agreement QSA";
    }
    if ( optionsPage ) {
	setBackEnabled( optionsPage, false );
    }
    if ( optionsPageQsa ) {
	optionsPageQsa->installExamples->hide();
	optionsPageQsa->installTools->hide();
	optionsPageQsa->installExtensions->hide();
	optionsPageQsa->installTutorials->hide();
	optionsPageQsa->skipBuild->hide();
	optionsPageQsa->installDocs->hide();
	optionsPageQsa->sysGroup->hide();
	optionsPageQsa->pathLabel->setText("QSA destination &path");

	optionsPage->titleStr = "Options for Qt";
	optionsPage->shortTitleStr = "Choose options for Qt";
	optionsPageQsa->titleStr = "Options for QSA";
	optionsPageQsa->shortTitleStr = "Choose options for QSA";
    }
    if ( configPage )
	setBackEnabled( configPage, false );
    if ( progressPage ) {
	setBackEnabled( progressPage, false );
	setNextEnabled( progressPage, false );
    }
    if ( buildPage ) {
	setBackEnabled( buildPage, false );
	setNextEnabled( buildPage, false );
    }
    if ( finishPage ) {
	setBackEnabled( finishPage, false );
	setFinishEnabled( finishPage, true );
    }
    emit wizardPages( pages );
}

void SetupWizardImpl::initConnections()
{
    connect( &autoContTimer, SIGNAL( timeout() ), this, SLOT( timerFired() ) );

    if ( optionsPage ) {
	connect( optionsPage->sysGroup, SIGNAL(clicked(int)), SLOT(clickedSystem(int)));
	connect( optionsPage->sysOtherCombo, SIGNAL(activated(int)), SLOT(sysOtherComboChanged(int)));
    }
    if ( foldersPage ) {
	connect( foldersPage->folderPathButton, SIGNAL(clicked()), SLOT(clickedFolderPath()));
	connect( foldersPage->devSysPathButton, SIGNAL(clicked()), SLOT(clickedDevSysPath()));
    }
    if ( licensePage ) {
	connect( licensePage->readLicenseButton, SIGNAL(clicked()), SLOT(clickedLicenseFile()));
	connect( licensePage->customerID, SIGNAL(textChanged(const QString&)), SLOT(licenseChanged()));
	connect( licensePage->licenseID, SIGNAL(textChanged(const QString&)), SLOT(licenseChanged()));
	connect( licensePage->licenseeName, SIGNAL(textChanged(const QString&)), SLOT(licenseChanged()));
	connect( licensePage->expiryDate, SIGNAL(textChanged(const QString&)), SLOT(licenseChanged()));
	connect( licensePage->productsString, SIGNAL(activated(int)), SLOT(licenseChanged()));
	connect( licensePage->key, SIGNAL(textChanged(const QString&)), SLOT(licenseChanged()));
    }
    if ( configPage ) {
	connect( configPage->configTabs, SIGNAL(currentChanged(QWidget*)), SLOT(configPageChanged()));
    }
    if ( buildPage ) {
	connect( &configure, SIGNAL( processExited() ), this, SLOT( configDone() ) );
	connect( &configure, SIGNAL( readyReadStdout() ), this, SLOT( readConfigureOutput() ) );
	connect( &configure, SIGNAL( readyReadStderr() ), this, SLOT( readConfigureError() ) );
	connect( &make, SIGNAL( processExited() ), this, SLOT( makeDone() ) );
	connect( &make, SIGNAL( readyReadStdout() ), this, SLOT( readMakeOutput() ) );
	connect( &make, SIGNAL( readyReadStderr() ), this, SLOT( readMakeError() ) );
	connect( buildPage->restartBuild, SIGNAL(clicked()), this, SLOT(restartBuild()) );
    }
}

void SetupWizardImpl::stopProcesses()
{
    if( cleaner.isRunning() )
	cleaner.kill();
    if( configure.isRunning() )
	configure.kill();
    if( make.isRunning() )
	make.kill();
}

void SetupWizardImpl::clickedFolderPath()
{
    foldersPage->folderPath->setText( shell.selectFolder( foldersPage->folderPath->text(), ( foldersPage->folderGroups->currentItem() == 0 ) ) );
}

void SetupWizardImpl::clickedDevSysPath()
{
    QDir dir( foldersPage->devSysPath->text() );
    if( !dir.exists() )
	dir.setPath( devSysFolder );

    QString dest = QFileDialog::getExistingDirectory( dir.absPath(), this, 0, "Select the path to Microsoft Visual Studio" );
    if (!dest.isNull())
	foldersPage->devSysPath->setText( dest );
}

void SetupWizardImpl::sysOtherComboChanged(int)
{
    clickedSystem(GlobalInformation::Other);
}

static QString getDirectoryList(const char *envvar)
{
    QString environment;
    const char *cpath = getenv(envvar);
    if (cpath) {
	environment = QString::fromLocal8Bit(cpath);
	environment = QStringList::split(QRegExp("[;,]"), environment).join("\n");
    } else {
	environment = "<Environment variable empty>";
    }
    return environment;
}

void SetupWizardImpl::clickedSystem( int sys )
{
#ifndef Q_OS_MACX
    if (sys == 99) // This is the Integrate with IDE checkbox
	return;
    globalInformation.setSysId( GlobalInformation::SysId(sys) );
    if (sys == GlobalInformation::Other) {
	if (optionsPage->sysOtherCombo->currentText() == "win32-watcom")
	    globalInformation.setSysId(GlobalInformation::Watcom);
    }
    if (!isVisible())
	return;
    QString makeCmd = globalInformation.text(GlobalInformation::MakeTool);
    QString environment;
    fixedPath = false;
    if ( !optionsPage->skipBuild->isChecked() && optionsPage->skipBuild->isEnabled() ) {
        QString commandTool;
	environment = getenv("COMSPEC");
        if( qWinVersion() & WV_DOS_based )
            commandTool = "command.com";
        else
            commandTool = "cmd.exe";
        if (!environment.isEmpty() && !environment.endsWith(commandTool, false)) {
	    if (QMessageBox::critical(this, "Environment problems",
                                        "The 'COMSPEC' environment variable is not set to use\n"
                                        "'" + commandTool + "'. This could cause some problems when building.\n"
                                        "If you have difficulty then change it to use '" + commandTool + "'\n"
                                        "and restart the installation\n\n"
                                        "Please contact your local system administration if you have\n"
                                        "difficulties finding the file, or if you don't know how to\n"
                                        "modify the environment settings on your system.\n\n"
					"Alternatively, by clicking yes, the installer will try to set\n"
					"these for you.",
					 QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
		fixEnvironment("COMSPEC", commandTool);
        }
        if( !findFile( makeCmd ) ) {
	    environment = getDirectoryList("PATH");
	    // ### try to adjust environment
	    if (QMessageBox::critical(this, "Environment problems",
					 "The make tool '" + makeCmd + "' could not be located in any\n"
					 "directory listed in the 'PATH' environment variable:"
					 "\n\n" + environment + "\n\n"
					 "Make sure the path to this file is present in the PATH environment\n"
					 "variable and restart the installation.\n"
					 "\n"
					 "You can find the path to the tool using the 'Find' tool\n"
					 "and add the location to the environment settings of your\n"
					 "system. Please contact your local system administration if\n"
					 "you have difficulties finding the files, or if you don't\n"
					 "know how to modifiy the environment settings of your system.\n\n"
					 "Alternatively, by clicking yes, the installer will try to set\n"
					 "these for you.",
					 QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
		fixEnvironment("PATH", makeCmd);
	}
	if (globalInformation.sysId() != GlobalInformation::Borland && globalInformation.sysId() != GlobalInformation::MinGW) {
	    if (!findFile( "string.h" ) ) {
		environment = getDirectoryList("INCLUDE");
		// ### try to adjust environment
		if (QMessageBox::critical(this, "Environment problems",
				      "The file 'string.h' could not be located in any directory\n"
				      "listed in the 'INCLUDE' environment variable:\n\n" + environment + "\n\n"
				      "You might have to install the platform headers, or adjust\n"
				      "the environment variables of your system, and restart the\n"
				      "installation.\n\n"
				      "Please contact your local system administration if you have\n"
				      "difficulties finding the file, or if you don't know how to\n"
				      "modify the environment settings on your system.\n\n"
				      "Alternatively, by clicking yes, the installer will try to set\n"
				      "these for you.",
    				      QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
		fixEnvironment("INCLUDE", "string.h");

	    }
	    if (!findFile("ole32.lib")) {
		environment = getDirectoryList("LIB");
		// ### try to adjust environment
		if (QMessageBox::critical(this, "Environment problems",
				      "The file 'ole32.lib' could not be located in any directory\n"
				      "listed in the 'LIB' environment variable:\n\n" + environment + "\n\n"
				      "You might have to install the platform libraries, or adjust\n"
				      "the environment variables of your system, and restart the\n"
				      "installation.\n\n"
				      "Please contact your local system administration if you have\n"
				      "difficulties finding the file, or if you don't know how to\n"
				      "modify the environment settings on your system.\n\n"
				      "Alternatively, by clicking yes, the installer will try to set\n"
				      "these for you.",
  				      QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
		fixEnvironment("LIB", "ole32.lib");

	    }
	    bool foundCommonDll = false;
	    QString commonDll;
	    QString commonDllText;
	    QString presentFileText = "Make sure the path to this file is present in the PATH environment\n";
	    if (globalInformation.sysId() == GlobalInformation::MSVC) {
		commonDll = "mspdb60.dll";
		foundCommonDll = findFile(commonDll);
		commonDllText = "The file 'mspdb60.dll' ";
	    } else if(globalInformation.sysId() == GlobalInformation::MSVCNET) {
		commonDll = "mspdb70.dll";
		foundCommonDll = findFile(commonDll);
		if (!foundCommonDll) {
		    commonDll = "mspdb71.dll";
		    foundCommonDll = findFile(commonDll);
		    commonDllText = "The files 'mspdb70.dll' and 'mspdb71.dll' "; // VC 7.0 or VC 7.1
		    presentFileText = "Make sure the path to one of these files is present in the PATH environment\n";
		}
	    } else {
		foundCommonDll = true;
	    }
	    if(!foundCommonDll && !fixedPath) {
		environment = getDirectoryList("PATH");
		// ### try to adjust environment
		if (QMessageBox::critical(this, "Environment problems",
				       commonDllText + "could not be located in any\n"
				       "directory listed in the 'PATH' environment variable:"
				       "\n\n" + environment + "\n\n"
				       + presentFileText +
				       "variable and restart the installation.\n"
				       "\n"
				       "You can find the path to the tool using the 'Find' tool\n"
				       "and add the location to the environment settings of your\n"
				       "system. Please contact your local system administration if\n"
				       "you have difficulties finding the files, or if you don't\n"
				       "know how to modifiy the environment settings of your system.\n\n"
				       "Alternatively, by clicking yes, the installer will try to set\n"
				       "these for you.",
    				       QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
		fixEnvironment("PATH", commonDllText);

	    }
	}
	if (globalInformation.sysId() == GlobalInformation::Intel && !findFile("icl.exe")) {
	    environment = getDirectoryList("PATH");
	    if (QMessageBox::critical(this, "Environment problems",
				  "The Intel C++ compiler (icl.exe) could not be found\n"
				  "in your PATH:\n\n" + environment + "\n\n"
				  "Make sure the path to this file is present in the PATH environment\n"
				  "variable and restart the installation.\n"
				  "\n"
				  "You can find the path to the tool using the 'Find' tool\n"
				  "and add the location to the environment settings of your\n"
				  "system. Please contact your local system administration if\n"
				  "you have difficulties finding the files, or if you don't\n"
				  "know how to modifiy the environment settings of your system.\n\n"
				  "Alternatively, by clicking yes, the installer will try to set\n"
				  "these for you.",
 				  QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
		fixEnvironment("PATH", "icl.exe");

	}
    }
#endif
}

void SetupWizardImpl::fixEnvironment(const QString &var, const QString &file)
{
    if (var == "COMSPEC" || !(globalInformation.sysId() == GlobalInformation::MSVC || 
	globalInformation.sysId() == GlobalInformation::MSVCNET)) {
	QString fn = QDir::toNativeSeparators(QFileDialog::getOpenFileName(QString(), QString(), this, 0,
						  "Please find " + file));
	QString envs = getenv(var);
	if (var != "COMSPEC") {
	    fn.truncate(fn.findRev("\\") - 1);
	    fn += ";" + envs;
	}
	if (!fn.isEmpty())
	    QEnvironment::putEnv(var, fn, QEnvironment::PersistentEnv | QEnvironment::LocalEnv);
    } else if (globalInformation.sysId() == GlobalInformation::MSVC) {
	QString visualStudio = 
	    QEnvironment::getRegistryString("Software\\Microsoft\\VisualStudio\\6.0\\Setup\\Microsoft Visual Studio", 
	 				    "ProductDir", QEnvironment::LocalMachine);
	if (var == "PATH" && !fixedPath) {
	    QString newPaths = visualStudio + "\\vc98\\bin;";
	    newPaths += visualStudio + "\\Common\\MSDev98\\Bin;";
	    if (qWinVersion() & Qt::WV_NT_based)
		newPaths += visualStudio + "\\Common\\Tools\\WinNT;";
	    else
		newPaths += visualStudio + "\\Common\\Tools\\Win95;";
	    QEnvironment::putEnv("PATH", newPaths + getenv("PATH"), 
				 QEnvironment::PersistentEnv | QEnvironment::LocalEnv);
	    fixedPath = true;
	} else if (var == "LIB") {
	    QString newPaths = visualStudio + "\\vc98\\lib;";
	    newPaths += visualStudio + "\\vc98\\mfc\\lib;";
	    QEnvironment::putEnv("LIB", newPaths + getenv("LIB"), 
				 QEnvironment::PersistentEnv | QEnvironment::LocalEnv);
	} else if (var == "INCLUDE") {
	    QString newPaths = visualStudio + "\\vc98\\atl\\include;";
	    newPaths += visualStudio + "\\vc98\\include;";
	    newPaths += visualStudio + "\\vc98\\mfc\\include;";
	    QEnvironment::putEnv("INCLUDE", newPaths + getenv("INCLUDE"), 
				 QEnvironment::PersistentEnv | QEnvironment::LocalEnv);
	}
    } else if (globalInformation.sysId() == GlobalInformation::MSVCNET) {
	QString visualStudio = QEnvironment::getRegistryString("Software\\Microsoft\\VisualStudio\\7.1\\Setup\\VS", 
							       "ProductDir", QEnvironment::LocalMachine);
	if (visualStudio.isEmpty())
	    visualStudio = QEnvironment::getRegistryString("Software\\Microsoft\\VisualStudio\\7.0\\Setup\\VS", 
							   "ProductDir", QEnvironment::LocalMachine);
	// With .NET this isn't so easily done, we need to read in the vsvars32.bat file 
	// to get this right
	QFile f(visualStudio + "\\Common7\\Tools\\vsvars32.bat");
	QString contents;
	if (f.open(IO_ReadOnly)) {
	    contents = QString(f.readAll());
	}
	int vsinstall = contents.find("VSINSTALLDIR=")+13;
	QString VSINSTALLDIR = contents.mid(vsinstall, contents.find("\n", vsinstall) - vsinstall);
	int vcinstall = contents.find("VCINSTALLDIR=")+13;
	QString VCINSTALLDIR = contents.mid(vcinstall, contents.find("\n", vcinstall) - vcinstall);
	int framework = contents.find("FrameworkDir=")+13;
	QString FrameworkDir = contents.mid(framework, contents.find("\n", framework) - framework);
	int frameworkVer = contents.find("FrameworkVersion=")+17;
	QString FrameworkVer = contents.mid(frameworkVer, contents.find("\n", frameworkVer) - frameworkVer);
	int frameworkSDK = contents.find("FrameworkSDKDir=")+16;
	QString FrameworkSDK = contents.mid(frameworkSDK, contents.find("\n", frameworkSDK) - frameworkSDK);
	if (var == "PATH" && !fixedPath) {
	    QString newPaths = VSINSTALLDIR + ";";
	    newPaths += VCINSTALLDIR + "\\Bin;";
	    newPaths += VCINSTALLDIR + "\\Common7\\Tools;";
	    newPaths += VCINSTALLDIR + "\\Common7\\Tools\\bin\\prerelease;";
	    newPaths += VCINSTALLDIR + "\\Common7\\Tools\\bin;";
	    newPaths += FrameworkSDK + "\\bin;";
	    newPaths += FrameworkSDK + "\\" + FrameworkVer + ";";
	    QEnvironment::putEnv("PATH", newPaths + getenv("PATH"), 
				 QEnvironment::PersistentEnv | QEnvironment::LocalEnv);
	    fixedPath = true;
	} else if (var == "LIB") {
	    QString newPaths = VCINSTALLDIR + "\\ATLMFC\\LIB;";
	    newPaths += VCINSTALLDIR + "\\LIB;";
	    newPaths += VCINSTALLDIR + "\\PlatformSDK\\lib\\prerelease;";
	    newPaths += VCINSTALLDIR + "\\PlatformSDK\\lib;";
	    newPaths += FrameworkSDK + "\\lib;";
	    QEnvironment::putEnv("LIB", newPaths + getenv("LIB"), 
				 QEnvironment::PersistentEnv | QEnvironment::LocalEnv);
	} else if (var == "INCLUDE") {
	    QString newPaths = VCINSTALLDIR + "\\ATLMFC\\INCLUDE;";
	    newPaths += VCINSTALLDIR + "\\INCLUDE;";
	    newPaths += VCINSTALLDIR + "\\PlatformSDK\\include\\prerelease;";
	    newPaths += VCINSTALLDIR + "\\PlatformSDK\\include;";
	    newPaths += FrameworkSDK + "\\include;";
	    QEnvironment::putEnv("INCLUDE", newPaths + getenv("INCLUDE"), 
				 QEnvironment::PersistentEnv | QEnvironment::LocalEnv);
	}

    }
}

void SetupWizardImpl::readCleanerOutput()
{
    updateDisplay( cleaner.readStdout(), currentOLine );
}

void SetupWizardImpl::readConfigureOutput()
{
    updateDisplay( configure.readStdout(), currentOLine );
}

void SetupWizardImpl::readMakeOutput()
{
    updateDisplay( make.readStdout(), currentOLine );
}

void SetupWizardImpl::readAssistantOutput()
{
#if defined(QSA)
    updateDisplay( assistant.readStdout(), currentOLine );
#endif
}

void SetupWizardImpl::readCleanerError()
{
    updateDisplay( cleaner.readStderr(), currentELine  );
}

void SetupWizardImpl::readConfigureError()
{
    updateDisplay( configure.readStderr(), currentELine );
}

void SetupWizardImpl::readMakeError()
{
    updateDisplay( make.readStderr(), currentELine  );
}

void SetupWizardImpl::readAssistantError()
{
#if defined(QSA)
    updateDisplay( assistant.readStderr(), currentELine );
#endif
}

void SetupWizardImpl::updateDisplay( const QString &input, QString &output)
{
    const QChar *c = input.unicode();
    for( int i = 0; i < (int)input.length(); ++i, ++c ) {
	switch( char( *c ) ) {
	case '\r':
	case 0x00:
	    break;
	case '\t':
	    currentOLine += "    ";  // Simulate a TAB by using 4 spaces
	    break;
	case '\n':
	    if( output.length() ) {
		if ( !globalInformation.reconfig() ) {
		    if ( output.right( 4 ) == ".cpp" ||
			 output.right( 2 ) == ".c" ||
			 output.right( 4 ) == ".pro" ||
			 output.right( 3 ) == ".ui" ) {
			buildPage->compileProgress->setProgress( ++filesCompiled );
		    }
		}
		logOutput( output );
		output = "";
	    }
	    break;
	default:
	    output += *c;
	    break;
	}
    }
}

#if defined(Q_OS_WIN32)
void SetupWizardImpl::installIcons( const QString& iconFolder, const QString& dirName, bool common )
{
    QDir dir( dirName );

    dir.setSorting( QDir::Name | QDir::IgnoreCase );
    const QFileInfoList* filist = dir.entryInfoList();
    if ( !filist )
	return;
    QFileInfoListIterator it( *filist );
    QFileInfo* fi;
    while( ( fi = it.current() ) ) {
	if( fi->fileName()[0] != '.' && // Exclude dot-dirs
	    fi->fileName() != "sql" ) { // Exclude SQL-dir
	    if( fi->isDir() ) {
		installIcons( iconFolder, fi->absFilePath(), common );
	    } else if( fi->fileName().right( 4 ) == ".exe" ) {
		shell.createShortcut( iconFolder, common, fi->baseName(), fi->absFilePath() );
	    }
	}
	++it;
    }
}
#endif

void SetupWizardImpl::assistantDone()
{
#if defined(QSA)
    QString contentFile;
    static int count = 0;
    if ( count == 0 ) {
	connect( &assistant, SIGNAL( processExited() ), this, SLOT( assistantDone() ) );
	connect( &assistant, SIGNAL( readyReadStdout() ), this, SLOT( readAssistantOutput() ) );
	connect( &assistant, SIGNAL( readyReadStderr() ), this, SLOT( readAssistantError() ) );
	contentFile = "qsa.xml";
    } else if ( count == 1 ) {
	contentFile = "qt-script-for-applications.xml";
    } else {
	doIDEIntegration();
	return;
    }
    ++count;

    // install documentation
    QDir html( optionsPageQsa->installPath->text() );
    html.cd( "doc/html/" );

    QStringList lst;
    lst << "assistant";
    lst << "-addContentFile";
    lst << QDir::toNativeSeparators( html.filePath( contentFile ) );
    assistant.setArguments( lst );
    if( !assistant.start() ) {
	logOutput( "Installing QSA documentation failed\n" );
	assistantDone();
    }
#else
    doIDEIntegration();
#endif
}

void SetupWizardImpl::doIDEIntegration()
{
#if defined(Q_OS_WIN32)
    QDir installDir( optionsPage->installPath->text() );
    if ( optionsPage->installIDEIntegration->isChecked() && optionsPage->installIDEIntegration->isEnabled()
	 && !foldersPage->devSysPath->text().isEmpty() ) {
	// install the precompiled MS integration
	if ( globalInformation.sysId() == GlobalInformation::MSVC ) {
	    QDir addinsDir( foldersPage->devSysPath->text() );
	    addinsDir.cd( "Common/MSDev98/Addins" );
	    if ( copyFile( installDir.filePath("qmsdev.dll"), addinsDir.filePath("qmsdev.dll") ) ) {
		installDir.remove( "qmsdev.dll" );
	    }
	} else if ( globalInformation.sysId() == GlobalInformation::MSVCNET 
	            || globalInformation.sysId() == GlobalInformation::Intel){
	    QString filepath = installDir.filePath("QMsNetSetup.msi");
	    filepath = filepath.replace( '/', '\\' );

	    int res = _spawnlp( _P_NOWAIT, "msiexec.exe", "msiexec.exe", "-i", filepath.latin1(), NULL );
	    if ( res == -1 ) {
		//MSIExec is not in path, look up in registry (only works for NT machines)
		QString msiexec = QEnvironment::getRegistryString( "SYSTEM\\CurrentControlSet\\Services\\MSIServer",
								   "ImagePath",
								   QEnvironment::LocalMachine );
		if ( !msiexec.isEmpty() )
		    msiexec.remove( " /V" );
		res = _spawnl( _P_NOWAIT, msiexec.latin1(), msiexec.latin1(), "-i", filepath.latin1(), NULL );
	    }

	    if ( res == -1 ) {
		QMessageBox::warning( this, "Couldn't execute .NET addin installer script",
				      "Microsoft Installer (MSI) was not found on your system.\n"
				      "Please install MSI, then execute the .NET addin installer "
				      "script,\nlocated at " + filepath );
	    }
	}

	QFile *autoexp  = 0;
	QFile *usertype = 0;
	switch( globalInformation.sysId() ) {
	    case GlobalInformation::MSVC:
		autoexp = new QFile( foldersPage->devSysPath->text() + "\\Common\\MsDev98\\bin\\autoexp.dat" );
		usertype = new QFile( foldersPage->devSysPath->text() + "\\Common\\MsDev98\\bin\\usertype.dat" );
		break;
	    case GlobalInformation::MSVCNET:
		autoexp = new QFile( foldersPage->devSysPath->text() + "\\Common7\\Packages\\Debugger\\autoexp.dat" );
		usertype = new QFile( foldersPage->devSysPath->text() + "\\Common7\\Packages\\Debugger\\usertype.dat" );
		break;
	}

	if ( autoexp ) {
	    QString autoExpContents;
	    if ( !autoexp->exists() ) {
		autoexp->open( IO_WriteOnly );
	    } else {
		// First try to open the file to search for existing installations
		autoexp->open( IO_ReadOnly );
		QByteArray bytes = autoexp->readAll();
		autoExpContents = QString::fromLatin1(bytes.data(), bytes.size());
		autoexp->close();
		if ( autoExpContents.find( "; Trolltech Qt" ) == -1 )
		    autoexp->open(IO_WriteOnly | IO_Translate);
	    }
	    if( autoexp->isOpen() ) {
		bool written = false;
		QTextStream outstream( autoexp );
		QStringList entries = QStringList::split("\r\n", autoExpContents, true);
		for (QStringList::Iterator entry = entries.begin(); entry != entries.end(); ++entry) {
		    QString e(*entry);
		    outstream << e << endl;
		    if (!written && e.startsWith("[AutoExpand]")) {
			outstream << endl;
			outstream << "; Trolltech Qt" << endl;
			outstream << "QString=<d->unicode,su> len=<d->len,u>" << endl;
			outstream << "QCString =<shd->data, s>" << endl;
			outstream << "QPoint =x=<xp> y=<yp>" << endl;
			outstream << "QRect =x1=<x1> y1=<y1> x2=<x2> y2=<y2>" << endl;
			outstream << "QSize =width=<wd> height=<ht>" << endl;
			outstream << "QWMatrix =m11=<_m11> m12=<_m12> m21=<_m21> m22=<_m22> dx=<_dx> dy=<_dy>" << endl;
			outstream << "QVariant =Type=<d->typ> value=<d->value>" << endl;
			outstream << "QValueList<*> =Count=<sh->nodes>" << endl;
			outstream << "QPtrList<*> =Count=<numNodes>" << endl;
			outstream << "QGuardedPtr<*> =ptr=<priv->obj>" << endl;
			outstream << "QEvent =type=<t>" << endl;
			outstream << "QObject =class=<metaObj->classname,s> name=<objname,s>" << endl;
			written = true;
		    }
		}
		autoexp->close();
	    }
	    delete autoexp;
	}

	if ( usertype ) {
	    if ( !usertype->exists() ) {
		usertype->open( IO_WriteOnly | IO_Translate );
	    } else {
		usertype->open( IO_ReadOnly );
		QString existingUserType = usertype->readAll();
		usertype->close();
		if ( existingUserType.find( "Q_OBJECT" ) == -1 )
		    usertype->open(IO_WriteOnly | IO_Append | IO_Translate);
	    }
	    if ( usertype->isOpen() ) {
		QTextStream outstream( usertype );
		outstream << endl;
		outstream << "Q_OBJECT" << endl;
		outstream << "Q_PROPERTY" << endl;
		outstream << "Q_ENUMS" << endl;
		outstream << "Q_SETS" << endl;
		outstream << "Q_CLASSINFO" << endl;
		outstream << "emit" << endl;
		outstream << "TRUE" << endl;
		outstream << "FALSE" << endl;
		outstream << "SIGNAL" << endl;
		outstream << "SLOT" << endl;
		outstream << "signals:" << endl;
		outstream << "slots:" << endl;
		usertype->close();
	    }
	    delete usertype;
	}
    }

    if ( globalInformation.sysId() != GlobalInformation::MinGW )
	installDir.remove( "Makefile.win32-g++" );
    if (globalInformation.sysId() != GlobalInformation::MSVC)
	installDir.remove( "qmsdev.dll" );
    if (globalInformation.sysId() != GlobalInformation::MSVCNET)
	installDir.remove( "QMsNetSetup.msi" );
#endif

    doStartMenuIntegration();
}

void SetupWizardImpl::doStartMenuIntegration()
{
#if defined(Q_OS_WIN32)
    /*
    ** Set up our icon folder and populate it with shortcuts.
    ** Then move to the next page.
    */
    QString dirName, examplesName, tutorialsName;
    bool common( foldersPage->folderGroups->currentItem() == 0 );
    QString qtDir = QEnvironment::getEnv( "QTDIR" );

    dirName = shell.createFolder( foldersPage->folderPath->text(), common );
    shell.createShortcut( dirName, common, "Qt Designer", qtDir + "\\bin\\designer.exe", "GUI designer", "", qtDir );
#if !defined(EVAL) && !defined(EDU) && !defined(NON_COMMERCIAL)
    shell.createShortcut( dirName, common, "Reconfigure Qt",
	    qtDir + "\\bin\\install.exe",
	    "Reconfigure the Qt library",
	    QString("-reconfig \"%1\"").arg(globalInformation.qtVersionStr()),
	    qtDir );
#endif
#if defined(QSA)
    shell.createShortcut( dirName, common, "License agreement for Qt", "notepad.exe", "Review the license agreement",
	    "\"" + qtDir + "\\" LICENSE_DEST "\"" );
    shell.createShortcut( dirName, common, "Readme for Qt", "notepad.exe", "Important information",
	    "\"" + qtDir + "\\README\"" );
    shell.createShortcut( dirName, common, "License agreement for QSA", "notepad.exe", "Review the license agreement",
	    "\"" + optionsPageQsa->installPath->text() + "\\" LICENSE_DEST "\"" );
    shell.createShortcut( dirName, common, "Readme for QSA", "notepad.exe", "Important information",
	    "\"" + optionsPageQsa->installPath->text() + "\\README\"" );
#else
    shell.createShortcut( dirName, common, "License agreement", "notepad.exe", "Review the license agreement", "\"" + qtDir + "\\" LICENSE_DEST "\"" );
    shell.createShortcut( dirName, common, "Readme", "notepad.exe", "Important information", QString( "\"" ) + qtDir + "\\README\"" );
#endif
    shell.createShortcut( dirName, common, "Qt Assistant", qtDir + "\\bin\\assistant.exe", "Browse the On-line documentation", "", qtDir );
    shell.createShortcut( dirName, common, "Qt Linguist", qtDir + "\\bin\\linguist.exe", "Qt translation utility", "", qtDir );
    shell.createInternetShortcut( dirName, common, "Trolltech.com", "http://qtsoftware.com/" );
#if defined(EVAL_CD)
    shell.createInternetShortcut( dirName, common, "Register for Support", "http://qtsoftware.com/products/qt/evaluate.html" );
#endif

    if ( ( ( !globalInformation.reconfig() && optionsPage->skipBuild->isChecked() )
	 || ( globalInformation.reconfig() && !configPage->rebuildInstallation->isChecked() ) )
	|| qWinVersion() & WV_DOS_based ) {
	QString description;
#if defined(EVAL) || defined(EDU) || defined(NON_COMMERCIAL)
	buildQtShortcutText = "Build Qt Examples and Tutorials";
	description = "Build the Qt Examples and Tutorials";
#else
	buildQtShortcutText = "Build Qt " + globalInformation.qtVersionStr();
	description = "Build the Qt library";
#endif
	shell.createShortcut( dirName, common,
	    buildQtShortcutText,
	    QEnvironment::getEnv( "QTDIR" ) + "\\build.bat",
	    description );
    }

#if defined(QSA)
    QString qsaExamplesName;
    if( qWinVersion() & WV_DOS_based ) {
	shell.createShortcut( dirName, common,
		"QSA Examples",
		optionsPageQsa->installPath->text() + "\\examples" );
    } else {
	qsaExamplesName = shell.createFolder( foldersPage->folderPath->text() + "\\QSA Examples", common );
	installIcons( qsaExamplesName, optionsPageQsa->installPath->text() + "\\examples", common );
    }
#endif
    if( optionsPage->installTutorials->isChecked() ) {
	if( qWinVersion() & WV_DOS_based ) {
	    shell.createShortcut( dirName, common,
#if defined(QSA)
		"Qt Tutorials",
#else
		"Tutorials",
#endif
		QEnvironment::getEnv( "QTDIR" ) + "\\tutorial" );
	} else {
#if defined(QSA)
	    tutorialsName = shell.createFolder( foldersPage->folderPath->text() + "\\Qt Tutorials", common );
#else
	    tutorialsName = shell.createFolder( foldersPage->folderPath->text() + "\\Tutorials", common );
#endif
	    installIcons( tutorialsName, QEnvironment::getEnv( "QTDIR" ) + "\\tutorial", common );
	}
    }
    if( optionsPage->installExamples->isChecked() ) {
	if( qWinVersion() & WV_DOS_based ) {
	    shell.createShortcut( dirName, common,
#if defined(QSA)
		"Qt Examples",
#else
		"Examples",
#endif
		QEnvironment::getEnv( "QTDIR" ) + "\\examples" );
	} else {
#if defined(QSA)
	    examplesName = shell.createFolder( foldersPage->folderPath->text() + "\\Qt Examples", common );
#else
	    examplesName = shell.createFolder( foldersPage->folderPath->text() + "\\Examples", common );
#endif
	    installIcons( examplesName, QEnvironment::getEnv( "QTDIR" ) + "\\examples", common );
	}
    }
#endif
#if defined(QSA)
#endif
    buildPage->compileProgress->setProgress( buildPage->compileProgress->totalSteps() );
    setNextEnabled( buildPage, true );
    logOutput( "The build was successful", true );
}

void SetupWizardImpl::makeDone()
{
    makeDone( !make.normalExit() || make.exitStatus() );
}

void SetupWizardImpl::makeDone( bool error )
{
    if( error ) {
	if (!backButton()->isEnabled()) {
	    logOutput( "The build process failed!\n" );
	    emit wizardPageFailed( indexOf(currentPage()) );
	    QMessageBox::critical( this, "Error", "The build process failed!\nSee the log for details." );
	    buildPage->restartBuild->setText( "Restart compile" );
	    backButton()->setEnabled(true);
	}
	setAppropriate( progressPage, false );
#if defined(QSA)
    } else if ( make.workingDirectory() == QEnvironment::getEnv( "QTDIR" ) ) {
	QStringList args;
	args << globalInformation.text(GlobalInformation::MakeTool);
	args << "sub-examples";

	make.setWorkingDirectory( optionsPageQsa->installPath->text() );
	make.setArguments( args );

	if( !make.start() ) {
	    logOutput( "Could not start make process.\n"
		       "Make sure that your compiler tools are installed\n"
		       "and registered correctly in your PATH environment." );
	    emit wizardPageFailed( indexOf(currentPage()) );
	    backButton()->setEnabled( true );
	}
#endif
    } else {
	// We still have some more items to do in order to finish all the
	// integration stuff.
	if ( !globalInformation.reconfig() ) {
	    logOutput( "Doing the final integration steps..." );
	    assistantDone();
	} else {
	    setNextEnabled( buildPage, true );
	    logOutput( "The build was successful", true );
	}
	buildPage->restartBuild->setText( "Success" );
	buildPage->restartBuild->setEnabled( false );
    }
}

void SetupWizardImpl::configDone()
{
    QStringList args;

    if( globalInformation.reconfig() && !configPage->rebuildInstallation->isChecked() )
	showPage( finishPage );

#if !defined(EVAL) && !defined(EDU) && !defined(NON_COMMERCIAL)
    if( !configure.normalExit() || configure.exitStatus() ) {
	logOutput( "The configure process failed.\n" );
	emit wizardPageFailed( indexOf(currentPage()) );
	buildPage->restartBuild->setText( "Restart configure" );
	setAppropriate( progressPage, false );
	backButton()->setEnabled(true);
    } else
#endif
    {
	args << globalInformation.text(GlobalInformation::MakeTool);
#if !defined(EVAL) && !defined(EDU) && !defined(NON_COMMERCIAL)
	args << "sub-src";
	args << "sub-plugins";
	if ( optionsPage ) {
	    if ( optionsPage->installTools->isChecked() )
		args << "sub-tools";
	    if ( optionsPage->installTutorials->isChecked() )
		args << "sub-tutorial";
	    if ( optionsPage->installExamples->isChecked() )
		args << "sub-examples";
	    if ( optionsPage->installExtensions->isChecked() )
		args << "sub-extensions";
	} else if (globalInformation.reconfig()) {
	    args << "sub-tools"; // We want to make sure it rebuilds uic etc
	}
#elif defined(Q_OS_WIN32)
	if ( optionsPage ) {
	    if ( optionsPage->installTutorials->isChecked() )
		args << "sub-tutorial";
	    if ( optionsPage->installExamples->isChecked() )
		args << "sub-examples";
#if !defined(NON_COMMERCIAL)
	    if ( optionsPage->installExtensions->isChecked() )
		args << "sub-extensions";
#endif
	}
	if ( args.count() == 1 ) {
	    make.setWorkingDirectory( QEnvironment::getEnv( "QTDIR" ) );
	    makeDone( false );
	    return;
	}
#endif
	if ( globalInformation.sysId() == GlobalInformation::MinGW ) {
	    args << "-fMakefile.win32-g++";
	}

	make.setWorkingDirectory( QEnvironment::getEnv( "QTDIR" ) );
	make.setArguments( args );

	if( !make.start() ) {
	    logOutput( "Could not start make process.\n"
		       "Make sure that your compiler tools are installed\n"
		       "and registered correctly in your PATH environment." );
	    emit wizardPageFailed( indexOf(currentPage()) );
	    backButton()->setEnabled( true );
	} else {
	    buildPage->restartBuild->setText( "Stop compilation" );
	}
    }
}

void SetupWizardImpl::restartBuild()
{
    if ( configure.isRunning() ||
       (!configure.isRunning() && (!configure.normalExit() || configure.exitStatus())) ) {
	if ( configure.isRunning() ) {	// Stop configure
	    configure.kill();
	    buildPage->restartBuild->setText( "Restart configure" );
	    logOutput( "\n*** Configure stopped by user...\n" );
	    backButton()->setEnabled( true );
	} else {			// Restart configure
	    emit wizardPageShowed( indexOf(currentPage()) );
	    backButton()->setEnabled( false );
	    cleanDone();
	    buildPage->restartBuild->setText( "Stop configure" );
	    logOutput( "\n*** Configure restarted by user...\n" );
	}
    } else if ( make.isRunning() ||
	      (!make.isRunning() && (!make.normalExit() || make.exitStatus())) ) {
	if ( make.isRunning() ) {	// Stop compile
	    buildPage->restartBuild->setText( "Restart compile" );
	    logOutput( "\n*** Compilation stopped by user...\n" );
	    backButton()->setEnabled( true );
	    make.kill();
	} else {			// Restart compile
	    wizardPageShowed( indexOf(currentPage()) );
	    backButton()->setEnabled( false );
	    configDone();
	    buildPage->restartBuild->setText( "Stop compile" );
	    logOutput( "\n*** Compilation restarted by user...\n" );
	}
    }
}

void SetupWizardImpl::saveSettings()
{
#if !defined(EVAL) && !defined(EDU) && !defined(NON_COMMERCIAL)
    QApplication::setOverrideCursor( Qt::waitCursor );
    saveSet( configPage->configList );
    saveSet( configPage->advancedList );
    QApplication::restoreOverrideCursor();
#endif
}

void SetupWizardImpl::saveSet( QListView* list )
{
    QSettings settings;
    settings.writeEntry( "/Trolltech/Qt/ResetDefaults", "FALSE" );

    QListViewItemIterator it( list );
    while ( it.current() ) {
	QListViewItem *itm = it.current();
	++it;
	if ( itm->rtti() != CheckListItem::RTTI )
	    continue;
	CheckListItem *item = (CheckListItem*)itm;
	if ( item->type() == QCheckListItem::RadioButton ) {
	    if ( item->isOn() ) {
		QString folder;
		QListViewItem *pItem = item;
		while ( (pItem = pItem->parent() ) ) {
		    if ( folder.isEmpty() )
			folder = pItem->text( 0 );
		    else
			folder = pItem->text(0) + "/" + folder;
		}

		settings.writeEntry( "/Trolltech/Qt/" + folder, item->text() );
	    }
	} else if ( item->type() == QCheckListItem::CheckBox ) {
	    QStringList lst;
	    QListViewItem *p = item->parent();
	    if ( p )
		--it;
	    QString c = p->text( 0 );
	    while ( ( itm = it.current() ) &&
		itm->rtti() == CheckListItem::RTTI &&
		item->type() == CheckListItem::CheckBox ) {
		item = (CheckListItem*)itm;
		++it;
		if ( item->isOn() )
		    lst << item->text( 0 );
	    }
	    if ( lst.count() )
		settings.writeEntry( "/Trolltech/Qt/" + p->text(0), lst, ',' );
	    else
		settings.writeEntry( "/Trolltech/Qt/" + p->text(0), "Nothing selected" );
	}
    }
}

void SetupWizardImpl::showPage( QWidget* newPage )
{
    if ( currentPage() == configPage && newPage == progressPage && !verifyConfig() ) {
	if (QMessageBox::warning( this, "Configuration with Warnings",
			      "One or more of the selected options could not be verified by the installer.\n"
			      "Do you want to continue?", "Yes", "No" ))
	    return;
    }

    QWizard::showPage( newPage );
    setInstallStep( indexOf(newPage) + 1 );

    if( newPage == licensePage ) {
	showPageLicense();
    } else if( newPage == licenseAgreementPage ) {
	readLicenseAgreement();
    } else if( newPage == licenseAgreementPageQsa ) {
	readLicenseAgreement();
    } else if( newPage == optionsPage ) {
	showPageOptions();
    } else if( newPage == foldersPage ) {
	showPageFolders();
    } else if( newPage == configPage ) {
	showPageConfig();
    } else if( newPage == progressPage ) {
	showPageProgress();
    } else if( newPage == buildPage ) {
	showPageBuild();
    } else if( newPage == finishPage ) {
	showPageFinish();
    }
}

void SetupWizardImpl::showPageLicense()
{
    licenseChanged();
}

void SetupWizardImpl::showPageOptions()
{
    static bool done = false;
    if (done)
	return;

    done = true;

    // First make sure that the current license information is saved
    if( !globalInformation.reconfig() )
	writeLicense( QDir::homeDirPath() + "/.qt-license" );

    // ### unsupported
    optionsPage->installDocs->hide();

    bool enterprise = licenseInfo[ "PRODUCTS" ] == "qt-enterprise";
    optionsPage->installExtensions->setChecked( enterprise );
    optionsPage->installExtensions->setEnabled( enterprise );

#if defined(EVAL) || defined(EDU) || defined(NON_COMMERCIAL)
    optionsPage->installDocs->setEnabled( false );
    optionsPage->skipBuild->setEnabled( false );
    if ( globalInformation.sysId()==GlobalInformation::Borland ) {
	optionsPage->sysMsvcNet->setEnabled( false );
	optionsPage->sysMsvc->setEnabled( false );
	optionsPage->sysBorland->setEnabled( true );
	optionsPage->sysMinGW->setEnabled( false );
	optionsPage->sysIntel->setEnabled( false );
	optionsPage->sysOther->setEnabled( false );
    } else {
	optionsPage->sysMsvcNet->setEnabled( true );
	optionsPage->sysMsvc->setEnabled( true );
	optionsPage->sysBorland->setEnabled( false );
	optionsPage->sysOther->setEnabled( false );
	optionsPage->sysIntel->setEnabled( false );
	optionsPage->sysMinGW->setEnabled( false );
    }
#  if defined(Q_OS_WIN32)
    optionsPage->installExamples->setEnabled( true );
    optionsPage->installTutorials->setEnabled( true );
    optionsPage->installTools->setEnabled( false );
#    if defined(NON_COMMERCIAL)
    optionsPage->installExtensions->hide();
#    else
    optionsPage->installExtensions->setChecked( true );
    optionsPage->installExtensions->setEnabled( true );
#    endif
#  else
    optionsPage->installExamples->setEnabled( false );
    optionsPage->installTutorials->setEnabled( false );
    optionsPage->installExtensions->setChecked( false );
    optionsPage->installExtensions->setEnabled( false );
#  endif
#else
#  if defined(Q_OS_WIN32)
    // No need to offer the option of skipping the build on 9x, it's skipped anyway
    if ( qWinVersion() & WV_DOS_based )
	optionsPage->skipBuild->setEnabled( false );
#  endif
#endif

    // trigger environment test
    clickedSystem(globalInformation.sysId());
}

void SetupWizardImpl::showPageFolders()
{
    QString ideName = globalInformation.text(GlobalInformation::IDE);
    foldersPage->devSysLabel->setText( ideName + " path");
    foldersPage->devSysLabel->setShown(!ideName.isEmpty());
    foldersPage->devSysPath->setShown(!ideName.isEmpty());
    foldersPage->devSysPathButton->setShown(!ideName.isEmpty());
#if defined(Q_OS_WIN32)
    if( globalInformation.sysId() == GlobalInformation::MSVC ) {
	QString devPath = QEnvironment::getRegistryString( "Software\\Microsoft\\VisualStudio\\6.0\\Setup\\Microsoft Visual Studio", "ProductDir", QEnvironment::LocalMachine );
	if ( devPath.isEmpty() ) {
	    // fallback for Windows 9x
	    QDir msdevDir( QEnvironment::getEnv("MSDEVDIR") );
	    msdevDir.cdUp();
	    msdevDir.cdUp();
	    devPath = QDir::toNativeSeparators( msdevDir.absPath() );
	}
	foldersPage->devSysPath->setText( devPath );
    } else if ( globalInformation.sysId() == GlobalInformation::MSVCNET ) {
	QString devPath = QEnvironment::getRegistryString( "Software\\Microsoft\\VisualStudio\\7.1\\Setup\\VS", "ProductDir", QEnvironment::LocalMachine );
	if ( !devPath.length() )
	    devPath = QEnvironment::getRegistryString( "Software\\Microsoft\\VisualStudio\\7.0\\Setup\\VS", "ProductDir", QEnvironment::LocalMachine );
	foldersPage->devSysPath->setText( devPath );
    }
#endif
}

void SetupWizardImpl::showPageProgress()
{
    saveSettings();
    int totalSize = 0;
    QFileInfo fi;
    totalRead = 0;
    bool copySuccessful = true;

    if( !filesCopied ) {
	createDir( optionsPage->installPath->text() );
	if (optionsPageQsa)
	    createDir( optionsPageQsa->installPath->text() );
	progressPage->filesDisplay->append( "Installing files...\n" );

	// install the right LICENSE file
	QDir installDir( optionsPage->installPath->text() );
	QFile licenseFile( installDir.filePath( LICENSE_DEST ) );
	if ( licenseFile.open( IO_WriteOnly ) ) {
	    ResourceLoader *rcLoader;
#if defined(EVAL) || defined(EDU)
	    rcLoader = new ResourceLoader( "LICENSE" );
#elif defined(NON_COMMERCIAL)
	    if ( licenseAgreementPage->countryCombo->currentItem() == 0 )
		rcLoader = new ResourceLoader( "LICENSE-US" );
	    else
		rcLoader = new ResourceLoader( "LICENSE" );
#else
	    if ( usLicense ) {
		rcLoader = new ResourceLoader( "LICENSE-US" );
	    } else {
		rcLoader = new ResourceLoader( "LICENSE" );
	    }
#endif
	    if ( rcLoader->isValid() ) {
		licenseFile.writeBlock( rcLoader->data() );
	    } else {
		emit wizardPageFailed( indexOf(currentPage()) );
		QMessageBox::critical( this, tr("Package corrupted"),
			tr("Could not find the LICENSE file in the package.\nThe package might be corrupted.") );
	    }
	    delete rcLoader;
	    licenseFile.close();
	} else {
	    // ### error handling -- we could not write the LICENSE file
	}
#if defined(QSA)
	QDir installDirQsa( optionsPageQsa->installPath->text() );
	QFile licenseFileQsa( installDirQsa.filePath( LICENSE_DEST ) );
	if ( licenseFileQsa.open( IO_WriteOnly ) ) {
	    ResourceLoader *rcLoader;
	    rcLoader = new ResourceLoader( "LICENSE_QSA" );
	    if ( rcLoader->isValid() ) {
		licenseFileQsa.writeBlock( rcLoader->data() );
	    } else {
		emit wizardPageFailed( indexOf(currentPage()) );
		QMessageBox::critical( this, tr("Package corrupted"),
			tr("Could not find the LICENSE file in the package.\nThe package might be corrupted.") );
	    }
	    delete rcLoader;
	    licenseFileQsa.close();
	} else {
	    // ### error handling -- we could not write the LICENSE file
	}
#endif

	// Install the files -- use different fallbacks if one method failed.
	QArchive ar;
	QString licenseKey;
#if !defined(EVAL_CD) && !defined(NON_COMMERCIAL)
	licenseKey = licensePage->key->text();
#endif
	ar.setVerbosity( QArchive::Destination | QArchive::Verbose | QArchive::Progress );
	connect( &ar, SIGNAL( operationFeedback( const QString& ) ), this, SLOT( archiveMsg( const QString& ) ) );
	connect( &ar, SIGNAL( operationFeedback( int ) ), progressPage->operationProgress, SLOT( setProgress( int ) ) );
	// First, try to find qt.arq as a binary resource to the file.
	ResourceLoader rcLoader( "QT_ARQ", 500 );
	if ( rcLoader.isValid() ) {
	    progressPage->operationProgress->setTotalSteps( rcLoader.data().count() );
	    QDataStream ds( rcLoader.data(), IO_ReadOnly );
	    ar.readArchive( &ds, optionsPage->installPath->text(), licenseKey );
	} else {
	    // If the resource could not be loaded or is smaller than 500
	    // bytes, we have the dummy qt.arq: try to find and install
	    // from qt.arq in the current directory instead.
	    QString archiveName = "qt.arq";
#if defined(Q_OS_MAC)
	    QString appDir = qApp->argv()[0];
	    int truncpos = appDir.findRev( "/Contents/MacOS/" );
	    if (truncpos != -1)
	    appDir.truncate( truncpos );
	    archiveName  = appDir + "/Contents/Qt/qtmac.arq";
#endif
	    fi.setFile( archiveName );
	    if( fi.exists() )
		totalSize = fi.size();
	    progressPage->operationProgress->setTotalSteps( totalSize );

	    ar.setPath( archiveName );
	    if( ar.open( IO_ReadOnly ) )  {
		ar.readArchive( optionsPage->installPath->text(), licenseKey );
	    } else {
		// We were not able to find any qt.arq -- so assume we have
		// the old fashioned zip archive and simply copy the files
		// instead.
		progressPage->operationProgress->setTotalSteps( FILESTOCOPY );
		copySuccessful = copyFiles( QDir::currentDirPath(), optionsPage->installPath->text(), true );

		/*These lines are only to be used when changing the filecount estimate
		  QString tmp( "%1" );
		  tmp = tmp.arg( totalFiles );
		  QMessageBox::information( this, tmp, tmp );
		 */
		progressPage->operationProgress->setProgress( FILESTOCOPY );
	    }
	}

#if defined(QSA)
	QArchive arQsa;
	arQsa.setVerbosity( QArchive::Destination | QArchive::Verbose | QArchive::Progress );
	connect( &arQsa, SIGNAL( operationFeedback( const QString& ) ), this, SLOT( archiveMsg( const QString& ) ) );
	connect( &arQsa, SIGNAL( operationFeedback( int ) ), progressPage->operationProgress, SLOT( setProgress( int ) ) );
	ResourceLoader rcLoaderQsa( "QSA_ARQ", 500 );
	if ( rcLoaderQsa.isValid() ) {
	    progressPage->operationProgress->setTotalSteps( rcLoaderQsa.data().count() );
	    QDataStream ds( rcLoaderQsa.data(), IO_ReadOnly );
	    arQsa.readArchive( &ds, optionsPageQsa->installPath->text(), licenseKey );
	} else {
	    // ### error handling
	}
#endif
	filesCopied = copySuccessful;

	timeCounter = 30;
	if( copySuccessful ) {
	    QDir installDir( optionsPage->installPath->text() );
#if defined(Q_OS_WIN32)
	    QDir windowsFolderDir( shell.windowsFolderName );
#  if !defined(EVAL) && !defined(EDU) && !defined(NON_COMMERCIAL)
	    {
		// move $QTDIR/install.exe to $QTDIR/bin/install.exe
		// This is done because install.exe is also used to reconfigure Qt
		// (and this expects install.exe in bin). We can't move install.exe
		// to bin in first place, since for the snapshots, we don't have
		// the .arq archives.
		QString inFile( installDir.filePath("install.exe") );
		copyFile(inFile, installDir.filePath("bin/install.exe"));
		QFile::remove(inFile);
	    }
#  endif
	    {
		// move the uninstaller to the Windows directory
		// This is necessary since the uninstaller deletes all files in
		// the installation directory (and therefore can't delete
		// itself).
		QString inFile( installDir.filePath("bin/quninstall.exe") );
		copyFile(inFile, windowsFolderDir.filePath("quninstall.exe"));
		QFile::remove(inFile);
	    }
#endif
#if defined(EVAL) || defined(EDU) || defined(NON_COMMERCIAL)
	    QStringList::Iterator it;
	    QDir lib( optionsPage->installPath->text() );
	    lib.cd( "lib" );
#  if !defined(EVAL_CD)
	    // patch qt*.dll
#	if !defined(Q_OS_MAC)
	    QStringList qtDlls = lib.entryList( "qt*.dll" );
#	else
	    QStringList qtDlls = lib.entryList( "libqt-mt-eval.dylib" );
#	endif
	    if ( qtDlls.count() == 0 ) {
		copySuccessful = false;
		QMessageBox::critical( this,
			tr( "Error patching Qt library" ),
#    if defined(EVAL)
			tr( "Could not patch the Qt library with the evaluation\n"
			    "license information - no Qt DLL was found." )
#    elif defined(EDU)
			tr( "Could not patch the Qt library with the educational\n"
			    "edition license information - no Qt DLL was found." )
#    else
			tr( "Could not patch the Qt library the installation\n"
			    "path information - no Qt DLL was found." )
#    endif
			);
	    }
	    for ( it=qtDlls.begin(); it!=qtDlls.end(); ++it ) {
		//### add serial number etc. to log
		logFiles( tr("Patching the Qt library %1.").arg(*it) );
		int ret = trDoIt( lib.absFilePath(*it),
#    if defined(EVAL)
			licensePage->evalName->text().latin1(),
			licensePage->evalCompany->text().latin1(),
			licensePage->serialNumber->text().latin1(),
#    elif defined(EDU)
			"",
			licensePage->university->text().latin1(),
			licensePage->serialNumber->text().latin1(),
#    endif
			installDir.absPath()
			);
		if ( ret != 0 ) {
		    copySuccessful = false;
		    QMessageBox::critical( this,
			    tr( "Error patching Qt library" ),
#    if defined(EVAL)
			    tr( "Could not patch the Qt library with the evaluation\n"
				"license information. You will not be able to execute\n"
				"any program linked against %1. Error %2" ).arg( *it ).arg(ret)
#    elif defined(EDU)
			    tr( "Could not patch the Qt library with the educational\n"
				"edition license information. You will not be able to\n"
				"execute any program linked against %1." ).arg( *it )
#    else
			    tr( "Could not patch the Qt library with the installation\n"
				"path information. You will not be able to execute\n"
				"some programs linked against %1." ).arg( *it )
#    endif
			    );
		}
	    }
#  endif
#  if !defined(Q_OS_MAC)
	    // copy lib/*.dll bin/
	    QStringList dlls = lib.entryList( "*.dll" );
	    for ( it=dlls.begin(); it!=dlls.end(); ++it ) {
		copyFile( lib.absFilePath(*it), QDir::cleanDirPath(lib.absFilePath("../bin/"+*it)) );
	    }
	    // delete the non-wanted database drivers
	    QDir plugins( optionsPage->installPath->text() );
	    plugins.cd( "plugins" );
	    plugins.cd( "sqldrivers" );
	    QDir bin( optionsPage->installPath->text() );
	    bin.cd( "bin" );
#if defined(NON_COMMERCIAL)
	    if ( sqlitePluginInstall && !sqlitePluginInstall->isOn() ) {
		plugins.remove( "qsqlite.dll" );
	    }
#else
	    if ( mysqlPluginInstall && !mysqlPluginInstall->isOn() ) {
		plugins.remove( "qsqlmysql.dll" );
		bin.remove( "libmySQL.dll" );
	    }
	    if ( ociPluginInstall && !ociPluginInstall->isOn() ) {
		plugins.remove( "qsqloci.dll" );
	    }
	    if ( odbcPluginInstall && !odbcPluginInstall->isOn() ) {
		plugins.remove( "qsqlodbc.dll" );
	    }
	    if ( psqlPluginInstall && !psqlPluginInstall->isOn() ) {
		plugins.remove( "qsqlpsql.dll" );
		bin.remove( "libpq.dll" );
	    }
	    if ( tdsPluginInstall && !tdsPluginInstall->isOn() ) {
		plugins.remove( "qsqltds.dll" );
	    }
	    if ( db2PluginInstall && !db2PluginInstall->isOn() ) {
		plugins.remove( "qsqldb2.dll" );
	    }
#endif
	    // patch the .qmake.cache with the correct paths
	    QFile cacheFile( installDir.filePath(".qmake.cache") );
	    if ( cacheFile.open( IO_ReadOnly | IO_Translate ) ) {
		QTextStream tsIn( &cacheFile );
		QString cache = tsIn.read();
		cacheFile.close();
		if ( cacheFile.open( IO_WriteOnly | IO_Translate ) ) {
		    QTextStream tsOut( &cacheFile );
		    if ( globalInformation.sysId() == GlobalInformation::Borland )
			tsOut << cache.replace( "C:/QtEvaluation/qtborland", installDir.absPath() );
		    else
			tsOut << cache.replace( "C:/QtEvaluation/qtmsvc", installDir.absPath() );
		    cacheFile.close();
		}
	    }
#  endif
#endif
	    logFiles( tr("All files have been installed.\n"
			 "This log has been saved to the installation directory.\n"
			 "The build will start automatically in 30 seconds."), true );
	} else {
	    logFiles( tr("One or more errors occurred during file installation.\n"
			 "Please review the log and try to amend the situation.\n"), true );
	}
    }
    if ( copySuccessful ) {
#if defined(Q_OS_WIN32)
	/*
	** Then record the installation in the registry, and set up the uninstallation
	*/
	QStringList uninstaller;
	uninstaller << ( QString("\"") + shell.windowsFolderName + "\\quninstall.exe" + QString("\"") );
	uninstaller << optionsPage->installPath->text();

	if( foldersPage->folderGroups->currentItem() == 0 )
	    uninstaller << ( QString("\"") + shell.commonProgramsFolderName + QString("\\") + foldersPage->folderPath->text() + QString("\"") );
	else
	    uninstaller << ( QString("\"") + shell.localProgramsFolderName + QString("\\") + foldersPage->folderPath->text() + QString("\"") );

	uninstaller << ( QString("\"") + globalInformation.qtVersionStr() + QString("\"") );

	QEnvironment::recordUninstall( QString( "Qt " ) + globalInformation.qtVersionStr(), uninstaller.join( " " ) );
#endif
	autoContTimer.start( 1000 );
    }
    else
	emit wizardPageFailed( indexOf(currentPage()) );
    setNextEnabled( progressPage, copySuccessful );
}

void SetupWizardImpl::showPageFinish()
{
    autoContTimer.stop();
    nextButton()->setText( "Next >" );
    QString finishMsg;
    if ( ( ( !globalInformation.reconfig() && !optionsPage->skipBuild->isChecked() )
	    || ( globalInformation.reconfig() && configPage->rebuildInstallation->isChecked() ) )
#if defined(Q_OS_WIN32)
    && qWinVersion() & WV_NT_based ) {
#else
    ) {
#endif
	if( globalInformation.reconfig() ) {
	    finishMsg = "Qt has been reconfigured and rebuilt, and is ready for use.";
	} else {
#if defined(Q_OS_MAC)
            finishMsg = QString( "Qt has been installed to " ) + optionsPage->installPath->text() +
                        " and is ready to use.\n\nPlease try out the developer tools in the bin folder and example "
                        "programs in the examples folder.\n\nFor further information please consult the "
			"README.txt file included in the installation folder.";
#else
	    finishMsg = QString( "Qt has been installed to %1 and is ready to use.\n"
		        "You might have to logoff and logon for changes to the environment to have an effect.").
			arg(optionsPage->installPath->text());
#  if defined(QSA)
	    finishMsg = QString( "\nQSA has been installed to " ) + optionsPageQsa->installPath->text() + " and is ready to use.";
#  endif
#endif
	}
    } else {
	if( globalInformation.reconfig() ) {
		finishMsg = "The new configuration has been written.\nThe library needs to be rebuilt to activate the ";
		finishMsg += "new configuration.";
#if defined(Q_OS_WIN32)
                finishMsg += "To rebuild it, use the \"Build Qt ";
		finishMsg += globalInformation.qtVersionStr();
		finishMsg += "\" icon in the Qt program group in the start menu.";
#endif
	} else {
	    finishMsg = QString( "The Qt files have been installed to " ) + optionsPage->installPath->text() + " and is ready to be compiled.\n";
#if defined(Q_OS_WIN32)
	    if( persistentEnv && qWinVersion() & WV_DOS_based ) {
		finishMsg += "The environment variables needed to use Qt have been recorded into your AUTOEXEC.BAT file.\n";
		finishMsg += "Please review this file, and take action as appropriate depending on your operating system to get them into the persistent environment. (Windows Me users, run MsConfig)\n\n";
	    }
#  if defined(EVAL) || defined(EDU) || defined(NON_COMMERCIAL)
	    finishMsg += QString( "To build the examples and tutorials, use the "
				  "\"Build the Qt Examples and Tutorials\""
				  " icon which has been installed into your Start-Menu." );
#  else
	    finishMsg += QString( "To build Qt, use the "
				  "\"Build Qt " ) + globalInformation.qtVersionStr() + "\""
				  " icon which has been installed into your Start-Menu.";
#  endif
#endif
	}
    }
#if defined(EVAL_CD)
    finishMsg += "\n\n"
		 "The Trolltech technical support service is available to "
		 "Qt Professional and Enterprise Edition licensees. As an "
		 "evaluation user, you can register for 30 days of evaluation "
		 "support at\n"
		 "http://qtsoftware.com/products/qt/evaluate.html";
#endif
    finishPage->finishText->setText( finishMsg );
}

void SetupWizardImpl::licenseChanged()
{
#if defined(EVAL) || defined(EDU) || defined(NON_COMMERCIAL)
    int ret = trCheckIt(
#  if defined(EVAL)
	    licensePage->evalName->text().latin1(),
	    licensePage->evalCompany->text().latin1(),
	    licensePage->serialNumber->text().latin1()
#  elif defined(EDU)
	    "",
	    licensePage->university->text().latin1(),
	    licensePage->serialNumber->text().latin1()
#  else
	    "",
	    "",
	    ""
#  endif
	    );

    if ( ret == 0 )
	setNextEnabled( licensePage, true );
    else
	setNextEnabled( licensePage, false );
    return;
#else
    QDate date;
    uint features;
    uint testFeature;
    QString platformString;
    QString licenseKey = licensePage->key->text().stripWhiteSpace();
    if ( licenseKey.length() != 14 ) {
	goto rejectLicense;
    }
    features = featuresForKey( licenseKey.upper() );
    date = decodedExpiryDate( licenseKey.mid(9) );
    if ( !date.isValid() ) {
	goto rejectLicense;
    }
#  if defined(Q_OS_MAC)
    testFeature = Feature_Mac;
    platformString = "Mac OS X";
#  elif defined(Q_OS_WIN32)
    testFeature = Feature_Windows;
    platformString = "Windows";
#  else
    testFeature = Feature_Unix;
    platformString = "UNIX";
#    ifdef Q_CC_GNU
#    warning "What about Qtopia Core?"
#    endif
#  endif
    if ( !(features&testFeature) && currentPage() == licensePage ) {
	if ( features & (Feature_Unix|Feature_Windows|Feature_Mac|Feature_Embedded) ) {
	    int ret = QMessageBox::information( this,
		    tr("No %1 license").arg(platformString),
		    tr("You are not licensed for the %1 platform.\n"
		       "Please contact sales@trolltech.com to upgrade\n"
		       "your license to include the Windows platform.").arg(platformString),
		    tr("Try again"),
		    tr("Abort installation")
		    );
	    if ( ret == 1 ) {
		QApplication::exit();
	    } else {
		licensePage->key->setText( "" );
	    }
	}
	goto rejectLicense;
    }
    if ( date < QDate::currentDate() && currentPage() == licensePage ) {
	static bool alreadyShown = false;
	if ( !alreadyShown ) {
	    QMessageBox::warning( this,
		    tr("Support and upgrade period has expired"),
		    tr("Your support and upgrade period has expired.\n"
			"\n"
			"You may continue to use your last licensed release\n"
			"of Qt under the terms of your existing license\n"
			"agreement. But you are not entitled to technical\n"
			"support, nor are you entitled to use any more recent\n"
			"Qt releases.\n"
			"\n"
			"Please contact sales@trolltech.com to renew your\n"
			"support and upgrades for this license.")
		    );
	    alreadyShown = true;
	}
    }
    if ( features & Feature_US )
	usLicense = true;
    else
	usLicense = false;

    licensePage->expiryDate->setText( date.toString( Qt::ISODate ) );
    if( features & Feature_Enterprise ) {
	licensePage->productsString->setCurrentItem( 1 );
	emit editionString( "Enterprise Edition" );
    } else {
	licensePage->productsString->setCurrentItem( 0 );
	emit editionString( "Professional Edition" );
    }
    setNextEnabled( licensePage, true );
    return;

rejectLicense:
    licensePage->expiryDate->setText( "" );
#  if defined(Q_OS_WIN32)
    //TODO: Is this a bug? It bus errors on MACX, ask rms.
    // it should work -- if it doesn't this seems to be a bug in the MACX code,
    // I guess (rms)
    licensePage->productsString->setCurrentItem( -1 );
#  endif
    emit editionString( "" );
    setNextEnabled( licensePage, false );
    return;
#endif
}

void SetupWizardImpl::logFiles( const QString& entry, bool close )
{
    if( !fileLog.isOpen() ) {
	fileLog.setName( optionsPage->installPath->text() + QDir::separator() + "install.log" );
	if( !fileLog.open( IO_WriteOnly | IO_Translate ) )
	    return;
    }

#if 1
    progressPage->filesDisplay->append(entry);
#else
    progressPage->filesDisplay->setText( "Installing files...\n" + entry + "\n" );
#endif

    static QTextStream outstream;
    outstream.setDevice( &fileLog );
    outstream << ( entry + "\n" );

    if( close )
	fileLog.close();
}

void SetupWizardImpl::logOutput( const QString& entry, bool close )
{
    if( !outputLog.isOpen() ) {
	QDir installDir;
	if ( optionsPage )
	    installDir.setPath( optionsPage->installPath->text() );
	else
	    installDir.setPath( QEnvironment::getEnv( "QTDIR" ) );
	outputLog.setName( installDir.filePath("build.log") );
	if( !outputLog.open( IO_WriteOnly | IO_Translate ) )
	    return;
    }

    buildPage->outputDisplay->append(entry);

    static QTextStream outstream;
    outstream.setDevice( &outputLog );
    outstream << ( entry + "\n" );

    if( close )
	outputLog.close();
}

void SetupWizardImpl::archiveMsg( const QString& msg )
{
    if( msg.right( 7 ) == ".cpp..." || msg.right( 5 ) == ".c..." || msg.right( 7 ) == ".pro..." || msg.right( 6 ) == ".ui..." )
	filesToCompile++;
    qApp->processEvents();
    if ( msg.startsWith("Expanding") )
	// only show the "Expanding" entries to avoid flickering
	logFiles( msg );
}

#ifdef Q_WS_WIN
static HANDLE createFile( const QString &entryName, DWORD attr1, DWORD attr2 )
{
    QT_WA({
    	return ::CreateFileW( entryName.ucs2(), attr1, attr2, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
    }, {
	return ::CreateFileA( entryName.local8Bit(), attr1, attr2, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
    })
}
#endif

bool SetupWizardImpl::copyFiles( const QString& sourcePath, const QString& destPath, bool topLevel )
{
    QDir dir( sourcePath );
    const QFileInfoList* list = dir.entryInfoList();
    QFileInfoListIterator it( *list );
    QFileInfo* fi;
    bool doCopy;

    while( ( fi = it.current() ) ) {
	if( fi->fileName()[ 0 ] != '.' ) {
	    QString entryName = sourcePath + QDir::separator() + fi->fileName();
	    QString targetName = destPath + QDir::separator() + fi->fileName();
	    doCopy = true;
	    if( fi->isDir() ) {
		if( !dir.exists( targetName ) )
		    createDir( targetName );
		if( topLevel ) {
		    if ( fi->fileName() == "doc" )
			doCopy = optionsPage->installDocs->isChecked();
		    else if ( fi->fileName() == "tools" )
			doCopy = optionsPage->installTools->isChecked();
		    else if ( fi->fileName() == "tutorial" )
			doCopy = optionsPage->installTutorials->isChecked();
		    else if ( fi->fileName() == "examples" )
			doCopy = optionsPage->installExamples->isChecked();
		}
		if( doCopy )
		    if( !copyFiles( entryName, targetName, false ) )
			return false;
	    } else {
		if( qApp && isShown() ) {
		    qApp->processEvents();
		    progressPage->operationProgress->setProgress( totalFiles );
		    logFiles( targetName );
		} else {
		    return false;
		}
		if( entryName.right( 4 ) == ".cpp" ||
		    entryName.right( 2 ) == ".c" ||
		    entryName.right( 4 ) == ".pro" ||
		    entryName.right( 3 ) == ".ui" )
		    filesToCompile++;
		bool res = true;
		if ( !QFile::exists( targetName ) )
		    res = copyFile( entryName, targetName );
#if defined(Q_OS_WIN32)
		if ( res ) {
		    totalFiles++;
		    HANDLE inFile, outFile;
		    if( inFile = createFile( entryName, GENERIC_READ, FILE_SHARE_READ ) ){
			if( outFile = createFile( targetName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE ) ){
			    FILETIME createTime, accessTime, writeTime;
			    ::GetFileTime( inFile, &createTime, &accessTime, &writeTime );
			    ::SetFileTime( outFile, &createTime, &accessTime, &writeTime );
			    ::CloseHandle( outFile );
			}
			::CloseHandle( inFile );
		    }
		} else {
		    QString error = QEnvironment::getLastError();
		    logFiles( QString( "   ERROR: " ) + error + "\n" );
		    if( QMessageBox::warning( this, "File copy error", entryName + ": " + error, "Continue", "Cancel", QString(), 0 ) )
			return false;
		}
#elif defined( Q_OS_UNIX )
		// ### TODO: keep file date the same, handle errors
#endif
	    }
	}
	++it;
    }
    return true;
}

void SetupWizardImpl::setInstallStep( int step )
{
    QString captionTxt;
#if defined(QSA)
    captionTxt = tr("QSA Evaluation Version Installation Wizard");
#elif defined(EVAL)
    captionTxt = tr("Qt Evaluation Version Installation Wizard");
#elif defined(EDU)
    captionTxt = tr("Qt Educational Edition Installation Wizard");
#elif defined(NON_COMMERCIAL)
    captionTxt = tr("Qt Non-Commercial Edition Installation Wizard");
#else
    if( globalInformation.reconfig() )
	captionTxt = tr("Qt Configuration Wizard");
    else
	captionTxt = tr("Qt Installation Wizard");
#endif
    setCaption( tr("%1 - Step %2 of %3").arg( captionTxt ).arg( step ).arg( pageCount() ) );
    emit wizardPageShowed( step-1 );
}

void SetupWizardImpl::timerFired()
{
    QString tmp( "Next %1 >" );

    timeCounter--;

    if( timeCounter )
	nextButton()->setText( tmp.arg( timeCounter ) );
    else {
	next();
	autoContTimer.stop();
    }
}

void SetupWizardImpl::readLicense( QString filePath)
{
#if !defined(EVAL) && !defined(EDU) && !defined(NON_COMMERCIAL)
    QFile licenseFile( filePath );

    if( licenseFile.open( IO_ReadOnly ) ) {
	QString buffer;

	while( licenseFile.readLine( buffer, 1024 ) != -1 ) {
	    if( buffer[ 0 ] != '#' ) {
		QStringList components = QStringList::split( '=', buffer );
		QStringList::Iterator it = components.begin();
		QString keyString = (*it++).stripWhiteSpace().replace( QRegExp( QString( "\"" ) ), QString() ).upper();
		QString value = (*it++).stripWhiteSpace().replace( QRegExp( QString( "\"" ) ), QString() );

		licenseInfo[ keyString ] = value;
	    }
	}
	licenseFile.close();

	if ( licensePage ) {
	    licensePage->customerID->setText( licenseInfo[ "CUSTOMERID" ] );
	    licensePage->licenseID->setText( licenseInfo[ "LICENSEID" ] );
	    licensePage->licenseeName->setText( licenseInfo[ "LICENSEE" ] );
	    if( licenseInfo[ "PRODUCTS" ] == "qt-enterprise" ) {
		licensePage->productsString->setCurrentItem( 1 );
		emit editionString( "Enterprise Edition" );
	    } else {
		licensePage->productsString->setCurrentItem( 0 );
		emit editionString( "Professional Edition" );
	    }
	    licensePage->expiryDate->setText( licenseInfo[ "EXPIRYDATE" ] );
	    licensePage->key->setText( licenseInfo[ "LICENSEKEY" ] );
	}
    }
#endif
}

void SetupWizardImpl::writeLicense( QString filePath )
{
#if !defined(EVAL) && !defined(EDU) && !defined(NON_COMMERCIAL)
    QFile licenseFile( filePath );

    if( licenseFile.open( IO_WriteOnly | IO_Translate ) ) {
	QTextStream licStream( &licenseFile );

	licenseInfo[ "CUSTOMERID" ] = licensePage->customerID->text();
	licenseInfo[ "LICENSEID" ] = licensePage->licenseID->text();
	licenseInfo[ "LICENSEE" ] = licensePage->licenseeName->text();
	if( licensePage->productsString->currentItem() == 0 ) {
	    licenseInfo[ "PRODUCTS" ] = "qt-professional";
	    emit editionString( "Professional Edition" );
	} else {
	    licenseInfo[ "PRODUCTS" ] = "qt-enterprise";
	    emit editionString( "Enterprise Edition" );
	}

	licenseInfo[ "EXPIRYDATE" ] = licensePage->expiryDate->text();
	licenseInfo[ "LICENSEKEY" ] = licensePage->key->text();

	licStream << "# Toolkit license file" << endl;
	licStream << "CustomerID=\"" << licenseInfo[ "CUSTOMERID" ].latin1() << "\"" << endl;
	licStream << "LicenseID=\"" << licenseInfo[ "LICENSEID" ].latin1() << "\"" << endl;
	licStream << "Licensee=\"" << licenseInfo[ "LICENSEE" ].latin1() << "\"" << endl;
	licStream << "Products=\"" << licenseInfo[ "PRODUCTS" ].latin1() << "\"" << endl;
	licStream << "ExpiryDate=" << licenseInfo[ "EXPIRYDATE" ].latin1() << endl;
	licStream << "LicenseKey=" << licenseInfo[ "LICENSEKEY" ].latin1() << endl;

	licenseFile.close();
    }
#endif
}

void SetupWizardImpl::clickedLicenseFile()
{
    QString licensePath = QFileDialog::getOpenFileName( optionsPage->installPath->text(), QString(), this, NULL, "Browse for license file" );

    if( !licensePath.isEmpty() )
	readLicense( licensePath );

}

void SetupWizardImpl::readLicenseAgreement()
{
    // Intropage
    ResourceLoader *rcLoader;
#if defined(QSA)
    LicenseAgreementPageImpl *lap;
    if ( currentPage() == licenseAgreementPageQsa ) {
	lap = licenseAgreementPageQsa;
	rcLoader = new ResourceLoader( "LICENSE_QSA" );
    } else {
	lap = licenseAgreementPage;
	rcLoader = new ResourceLoader( "LICENSE" );
    }
#elif defined(EVAL) || defined(EDU)
    LicenseAgreementPageImpl *lap = licenseAgreementPage;
    rcLoader = new ResourceLoader( "LICENSE" );
#elif defined(NON_COMMERCIAL)
    LicenseAgreementPageImpl *lap = licenseAgreementPage;
    if ( lap->countryCombo->currentItem() == 0 )
	rcLoader = new ResourceLoader( "LICENSE-US" );
    else
	rcLoader = new ResourceLoader( "LICENSE" );
#else
    LicenseAgreementPageImpl *lap = licenseAgreementPage;
    if ( usLicense ) {
	rcLoader = new ResourceLoader( "LICENSE-US" );
    } else {
	rcLoader = new ResourceLoader( "LICENSE" );
    }
#endif
    if ( rcLoader->isValid() ) {
	lap->introText->setText( rcLoader->data() );
	lap->acceptLicense->setEnabled( true );
    } else {
	emit wizardPageFailed( indexOf(currentPage()) );
	QMessageBox::critical( this, tr("Package corrupted"),
		tr("Could not find the LICENSE file in the package.\nThe package might be corrupted.") );
	lap->acceptLicense->setEnabled( false );
    }
    delete rcLoader;
}

void SetupWizardImpl::accept()
{
#if defined(Q_OS_WIN32)
    if ( finishPage->showReadmeCheck->isChecked() ) {
	QProcess proc( QString("notepad.exe") );
#if defined(QSA)
	QString qsaDir = optionsPageQsa->installPath->text();
	proc.addArgument( qsaDir + "\\README" );
#else
	QString qtDir = QEnvironment::getEnv( "QTDIR" );
	proc.addArgument( qtDir + "\\README" );
#endif
	proc.start();
    }
#endif
    QDialog::accept();
}