[190] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
| 2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/examples/distributor/distributor.doc:1 -->
|
---|
| 3 | <html>
|
---|
| 4 | <head>
|
---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
| 6 | <title>Qt Distribution Example</title>
|
---|
| 7 | <style type="text/css"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { background: #ffffff; color: black; }
|
---|
| 12 | --></style>
|
---|
| 13 | </head>
|
---|
| 14 | <body>
|
---|
| 15 |
|
---|
| 16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
| 17 | <tr bgcolor="#E5E5E5">
|
---|
| 18 | <td valign=center>
|
---|
| 19 | <a href="index.html">
|
---|
| 20 | <font color="#004faf">Home</font></a>
|
---|
| 21 | | <a href="classes.html">
|
---|
| 22 | <font color="#004faf">All Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main Classes</font></a>
|
---|
| 25 | | <a href="annotated.html">
|
---|
| 26 | <font color="#004faf">Annotated</font></a>
|
---|
| 27 | | <a href="groups.html">
|
---|
| 28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
| 29 | | <a href="functions.html">
|
---|
| 30 | <font color="#004faf">Functions</font></a>
|
---|
| 31 | </td>
|
---|
| 32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>Qt Distribution Example</h1>
|
---|
| 33 |
|
---|
| 34 |
|
---|
| 35 |
|
---|
| 36 | <p> This example program modifies the hard-coded paths that are
|
---|
| 37 | compiled into the Qt library.
|
---|
| 38 | <p> When distributing the Qt library, the final installation prefix is
|
---|
| 39 | very rarely the same as the prefix used when doing development.
|
---|
| 40 | You can use the code from this example to modify the following
|
---|
| 41 | hard-coded paths in Qt library:
|
---|
| 42 | <p> <ul>
|
---|
| 43 | <p> <li> Prefix - Normally, all other paths are relative to the <em>Prefix</em>.
|
---|
| 44 | <p> <li> Binaries - Location of binaries distributed with Qt (for
|
---|
| 45 | example, <em>Qt Assistant</em>).
|
---|
| 46 | <p> <li> Documentation - Location of the Qt documentation.
|
---|
| 47 | <p> <li> Headers - Location of the Qt headers.
|
---|
| 48 | <p> <li> Libraries - Location of addition libraries distributed with Qt
|
---|
| 49 | (for example, the <em>qui</em> library).
|
---|
| 50 | <p> <li> Plugins - Location of the Qt plugins.
|
---|
| 51 | <p> <li> Data - Location of applicaton specific data for all programs
|
---|
| 52 | distributed with Qt.
|
---|
| 53 | <p> </ul>
|
---|
| 54 | <p> <hr>
|
---|
| 55 | <p> Implementation:
|
---|
| 56 | <p> <pre>/****************************************************************************
|
---|
| 57 | ** ui.h extension file, included from the uic-generated form implementation.
|
---|
| 58 | **
|
---|
| 59 | ** If you wish to add, delete or rename functions or slots use
|
---|
| 60 | ** Qt Designer which will update this file, preserving your code. Create an
|
---|
| 61 | ** init() function in place of a constructor, and a destroy() function in
|
---|
| 62 | ** place of a destructor.
|
---|
| 63 | *****************************************************************************/
|
---|
| 64 |
|
---|
| 65 | #include <<a href="qapplication-h.html">qapplication.h</a>>
|
---|
| 66 | #include <<a href="qcursor-h.html">qcursor.h</a>>
|
---|
| 67 | #include <<a href="qeventloop-h.html">qeventloop.h</a>>
|
---|
| 68 | #include <<a href="qfile-h.html">qfile.h</a>>
|
---|
| 69 | #include <<a href="qfiledialog-h.html">qfiledialog.h</a>>
|
---|
| 70 | #include <<a href="qfileinfo-h.html">qfileinfo.h</a>>
|
---|
| 71 | #include <<a href="qlineedit-h.html">qlineedit.h</a>>
|
---|
| 72 | #include <<a href="qmessagebox-h.html">qmessagebox.h</a>>
|
---|
| 73 | #include <<a href="qpushbutton-h.html">qpushbutton.h</a>>
|
---|
| 74 | #include <<a href="qtimer-h.html">qtimer.h</a>>
|
---|
| 75 |
|
---|
| 76 |
|
---|
| 77 | void Distributor::init()
|
---|
| 78 | {
|
---|
| 79 | timer = new <a href="qtimer.html">QTimer</a>( this );
|
---|
| 80 | <a name="x2672"></a> connect( timer, SIGNAL(<a href="qtimer.html#timeout">timeout</a>()), SLOT(checkLibData()) );
|
---|
| 81 |
|
---|
| 82 | cancelButton()->setAutoDefault( FALSE );
|
---|
| 83 | backButton()->setAutoDefault( FALSE );
|
---|
| 84 |
|
---|
| 85 | setNextEnabled( selectLibrary, FALSE );
|
---|
| 86 |
|
---|
| 87 | setHelpEnabled( selectLibrary, FALSE );
|
---|
| 88 | setHelpEnabled( modifyPaths, FALSE );
|
---|
| 89 | setHelpEnabled( verifyMods, FALSE );
|
---|
| 90 |
|
---|
| 91 | setFinishEnabled( verifyMods, TRUE );
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | void Distributor::showPage( <a href="qwidget.html">QWidget</a> *page )
|
---|
| 95 | {
|
---|
| 96 | if ( page == selectLibrary ) {
|
---|
| 97 | nextButton()->setDefault( TRUE );
|
---|
| 98 | libFilename->setFocus();
|
---|
| 99 | } else if ( page == modifyPaths ) {
|
---|
| 100 | nextButton()->setDefault( TRUE );
|
---|
| 101 | prefixPath->selectAll();
|
---|
| 102 | prefixPath->setFocus();
|
---|
| 103 | } else if ( page == verifyMods ) {
|
---|
| 104 | finishButton()->setDefault( TRUE );
|
---|
| 105 | finishButton()->setFocus();
|
---|
| 106 |
|
---|
| 107 | <a href="qstring.html">QString</a> labeltext =
|
---|
| 108 | tr("<p><b>Current Library File:</b> %1</p>"
|
---|
| 109 | "<table border=0>"
|
---|
| 110 | "<tr><td><b>New Installation Prefix:</b></td><td>%2</td></tr>"
|
---|
| 111 | "<tr><td></td><td></td></tr>"
|
---|
| 112 | "<tr><td><b>Binaries Path:</b></td><td>%3</td></tr>"
|
---|
| 113 | "<tr><td><b>Documentation Path:</b></td><td>%4</td></tr>"
|
---|
| 114 | "<tr><td><b>Headers Path:</b></td><td>%5</td></tr>"
|
---|
| 115 | "<tr><td><b>Libraries Path:</b></td><td>%6</td></tr>"
|
---|
| 116 | "<tr><td><b>Plugins Path:</b></td><td>%7</td></tr>"
|
---|
| 117 | "<tr><td><b>Data Path:</b></td><td>%8</td></tr>"
|
---|
| 118 | "</table>"
|
---|
| 119 | "<p>Please verify that these options are correct. Press the "
|
---|
| 120 | "<i>Finish</i> button to apply these modifications to the Qt "
|
---|
| 121 | "library. Use the <i>Back</i> button to make corrections. Use "
|
---|
| 122 | "the <i>Cancel</i> button to abort.</p>")
|
---|
| 123 | .arg( libFilename->text() )
|
---|
| 124 | .arg( prefixPath->text() )
|
---|
| 125 | .arg( binPath->text() )
|
---|
| 126 | .arg( docPath->text() )
|
---|
| 127 | .arg( hdrPath->text() )
|
---|
| 128 | .arg( libPath->text() )
|
---|
| 129 | .arg( plgPath->text() )
|
---|
| 130 | .arg( datPath->text() );
|
---|
| 131 | textLabel4->setText( labeltext );
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 | <a name="x2673"></a> QWizard::<a href="qwizard.html#showPage">showPage</a>( page );
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | void Distributor::checkLibFilename( const <a href="qstring.html">QString</a> &filename )
|
---|
| 138 | {
|
---|
| 139 | setNextEnabled( selectLibrary, FALSE );
|
---|
| 140 |
|
---|
| 141 | <a href="qfileinfo.html">QFileInfo</a> fileinfo( filename );
|
---|
| 142 | <a name="x2661"></a> if ( ! filename.<a href="qstring.html#isEmpty">isEmpty</a>() && fileinfo.<a href="qfileinfo.html#exists">exists</a>() &&
|
---|
| 143 | <a name="x2665"></a><a name="x2663"></a> fileinfo.<a href="qfileinfo.html#isReadable">isReadable</a>() && fileinfo.<a href="qfileinfo.html#isWritable">isWritable</a>() &&
|
---|
| 144 | <a name="x2664"></a><a name="x2662"></a> fileinfo.<a href="qfileinfo.html#isFile">isFile</a>() && !fileinfo.<a href="qfileinfo.html#isSymLink">isSymLink</a>() )
|
---|
| 145 | <a name="x2671"></a> timer-><a href="qtimer.html#start">start</a>( 500, TRUE );
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | void Distributor::browseLibFilename()
|
---|
| 149 | {
|
---|
| 150 | <a href="qstring.html">QString</a> filename =
|
---|
| 151 | <a name="x2660"></a> QFileDialog::<a href="qfiledialog.html#getOpenFileName">getOpenFileName</a>( <a href="qstring.html#QString-null">QString::null</a>, QString::null, this );
|
---|
| 152 | libFilename->setText( filename );
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | static char *find_pattern( char *h, const char *n, ulong hlen )
|
---|
| 156 | {
|
---|
| 157 | if ( ! h || ! n || hlen == 0 )
|
---|
| 158 | return 0;
|
---|
| 159 |
|
---|
| 160 | #ifdef Q_OS_UNIX
|
---|
| 161 | size_t nlen;
|
---|
| 162 | #else
|
---|
| 163 | ulong nlen;
|
---|
| 164 | #endif
|
---|
| 165 |
|
---|
| 166 | char nc = *n++;
|
---|
| 167 | nlen = strlen( n );
|
---|
| 168 | char hc;
|
---|
| 169 |
|
---|
| 170 | do {
|
---|
| 171 | do {
|
---|
| 172 | hc = *h++;
|
---|
| 173 | if ( hlen-- < 1 )
|
---|
| 174 | return 0;
|
---|
| 175 | } while ( hc != nc );
|
---|
| 176 |
|
---|
| 177 | if ( nlen > hlen )
|
---|
| 178 | return 0;
|
---|
| 179 | } while ( <a href="qcstring.html#qstrncmp">qstrncmp</a>( h, n, nlen ) != 0 );
|
---|
| 180 | return h + nlen;
|
---|
| 181 | }
|
---|
| 182 |
|
---|
| 183 | void Distributor::checkLibData()
|
---|
| 184 | {
|
---|
| 185 | struct step {
|
---|
| 186 | const char *key;
|
---|
| 187 | <a href="qcstring.html">QCString</a> value;
|
---|
| 188 | bool done;
|
---|
| 189 | } steps[7];
|
---|
| 190 |
|
---|
| 191 | steps[0].key = "qt_nstpath=";
|
---|
| 192 | steps[0].done = FALSE;
|
---|
| 193 |
|
---|
| 194 | steps[1].key = "qt_binpath=";
|
---|
| 195 | steps[1].done = FALSE;
|
---|
| 196 |
|
---|
| 197 | steps[2].key = "qt_docpath=";
|
---|
| 198 | steps[2].done = FALSE;
|
---|
| 199 |
|
---|
| 200 | steps[3].key = "qt_hdrpath=";
|
---|
| 201 | steps[3].done = FALSE;
|
---|
| 202 |
|
---|
| 203 | steps[4].key = "qt_libpath=";
|
---|
| 204 | steps[4].done = FALSE;
|
---|
| 205 |
|
---|
| 206 | steps[5].key = "qt_plgpath=";
|
---|
| 207 | steps[5].done = FALSE;
|
---|
| 208 |
|
---|
| 209 | steps[6].key = "qt_datpath=";
|
---|
| 210 | steps[6].done = FALSE;
|
---|
| 211 |
|
---|
| 212 | uint completed = 0;
|
---|
| 213 | uint total_steps = sizeof(steps) / sizeof(step);
|
---|
| 214 |
|
---|
| 215 | <a href="qfile.html">QFile</a> file( libFilename->text() );
|
---|
| 216 | <a name="x2659"></a> if ( file.<a href="qfile.html#open">open</a>( <a href="qfile.html#open">IO_ReadOnly</a> ) ) {
|
---|
| 217 | <a name="x2653"></a> QApplication::<a href="qapplication.html#setOverrideCursor">setOverrideCursor</a>( WaitCursor );
|
---|
| 218 |
|
---|
| 219 | // instead of reading in the entire file, do the search in chunks
|
---|
| 220 | char data[60000];
|
---|
| 221 | ulong offset = 0;
|
---|
| 222 |
|
---|
| 223 | <a name="x2655"></a> while ( ! file.<a href="qfile.html#atEnd">atEnd</a>() && completed < total_steps ) {
|
---|
| 224 | <a name="x2651"></a> QApplication::<a href="qapplication.html#eventLoop">eventLoop</a>()->processEvents( QEventLoop::ExcludeUserInput );
|
---|
| 225 |
|
---|
| 226 | <a name="x2667"></a> ulong len = file.<a href="qiodevice.html#readBlock">readBlock</a>( data, sizeof(data) );
|
---|
| 227 | if ( len < 267 ) {
|
---|
| 228 | // not enough room to make any modifications... stop
|
---|
| 229 | break;
|
---|
| 230 | }
|
---|
| 231 |
|
---|
| 232 | for ( uint x = 0; x < total_steps; ++x ) {
|
---|
| 233 | if ( steps[x].done ) continue;
|
---|
| 234 |
|
---|
| 235 | char *s = find_pattern( data, steps[x].key, len );
|
---|
| 236 | if ( s ) {
|
---|
| 237 | ulong where = s - data;
|
---|
| 238 | if ( len - where < 256 ) {
|
---|
| 239 | // not enough space left to write the full
|
---|
| 240 | // path... move the file pointer back to just
|
---|
| 241 | // before the pattern and continue
|
---|
| 242 | offset += where - 11;
|
---|
| 243 | <a name="x2666"></a> file.<a href="qiodevice.html#at">at</a>( offset );
|
---|
| 244 | len = file.<a href="qiodevice.html#readBlock">readBlock</a>( data, sizeof(data) );
|
---|
| 245 | --x; // retry the current step
|
---|
| 246 | continue;
|
---|
| 247 | }
|
---|
| 248 |
|
---|
| 249 | steps[x].value = s;
|
---|
| 250 | steps[x].done = TRUE;
|
---|
| 251 |
|
---|
| 252 | ++completed;
|
---|
| 253 | }
|
---|
| 254 | }
|
---|
| 255 |
|
---|
| 256 | // move to the new read position
|
---|
| 257 | offset += len - 11;
|
---|
| 258 | file.<a href="qiodevice.html#at">at</a>( offset );
|
---|
| 259 | }
|
---|
| 260 |
|
---|
| 261 | <a name="x2656"></a> file.<a href="qfile.html#close">close</a>();
|
---|
| 262 |
|
---|
| 263 | <a name="x2652"></a> QApplication::<a href="qapplication.html#restoreOverrideCursor">restoreOverrideCursor</a>();
|
---|
| 264 | }
|
---|
| 265 |
|
---|
| 266 | if ( completed == total_steps ) {
|
---|
| 267 | setNextEnabled( selectLibrary, TRUE );
|
---|
| 268 |
|
---|
| 269 | <a name="x2657"></a> <a href="qstring.html">QString</a> prefix = QFile::<a href="qfile.html#decodeName">decodeName</a>( steps[0].value );
|
---|
| 270 | prefixPath->setText( prefix );
|
---|
| 271 |
|
---|
| 272 | <a href="qstring.html">QString</a> def_bin = prefix + QString::fromLatin1( "/bin" );
|
---|
| 273 | <a href="qstring.html">QString</a> def_doc = prefix + QString::fromLatin1( "/doc" );
|
---|
| 274 | <a href="qstring.html">QString</a> def_hdr = prefix + QString::fromLatin1( "/include" );
|
---|
| 275 | <a href="qstring.html">QString</a> def_lib = prefix + QString::fromLatin1( "/lib" );
|
---|
| 276 | <a href="qstring.html">QString</a> def_plg = prefix + QString::fromLatin1( "/plugins" );
|
---|
| 277 | <a href="qstring.html">QString</a> def_dat = prefix;
|
---|
| 278 |
|
---|
| 279 | <a href="qstring.html">QString</a> bin = QFile::<a href="qfile.html#decodeName">decodeName</a>( steps[1].value );
|
---|
| 280 | <a href="qstring.html">QString</a> doc = QFile::<a href="qfile.html#decodeName">decodeName</a>( steps[2].value );
|
---|
| 281 | <a href="qstring.html">QString</a> hdr = QFile::<a href="qfile.html#decodeName">decodeName</a>( steps[3].value );
|
---|
| 282 | <a href="qstring.html">QString</a> lib = QFile::<a href="qfile.html#decodeName">decodeName</a>( steps[4].value );
|
---|
| 283 | <a href="qstring.html">QString</a> plg = QFile::<a href="qfile.html#decodeName">decodeName</a>( steps[5].value );
|
---|
| 284 | <a href="qstring.html">QString</a> dat = QFile::<a href="qfile.html#decodeName">decodeName</a>( steps[6].value );
|
---|
| 285 |
|
---|
| 286 | autoSet->setChecked( def_bin == bin &&
|
---|
| 287 | def_doc == doc &&
|
---|
| 288 | def_hdr == hdr &&
|
---|
| 289 | def_lib == lib &&
|
---|
| 290 | def_plg == plg &&
|
---|
| 291 | def_dat == dat );
|
---|
| 292 |
|
---|
| 293 | if ( ! autoSet->isChecked() ) {
|
---|
| 294 | binPath->setText( bin );
|
---|
| 295 | docPath->setText( doc );
|
---|
| 296 | hdrPath->setText( hdr );
|
---|
| 297 | libPath->setText( lib );
|
---|
| 298 | plgPath->setText( plg );
|
---|
| 299 | datPath->setText( dat );
|
---|
| 300 | }
|
---|
| 301 | }
|
---|
| 302 | }
|
---|
| 303 |
|
---|
| 304 | void Distributor::checkInstallationPrefix( const <a href="qstring.html">QString</a> &prefix )
|
---|
| 305 | {
|
---|
| 306 | if ( autoSet->isChecked() ) {
|
---|
| 307 | binPath->setText( prefix + QString::fromLatin1( "/bin" ) );
|
---|
| 308 | docPath->setText( prefix + QString::fromLatin1( "/doc" ) );
|
---|
| 309 | hdrPath->setText( prefix + QString::fromLatin1( "/include" ) );
|
---|
| 310 | libPath->setText( prefix + QString::fromLatin1( "/lib" ) );
|
---|
| 311 | plgPath->setText( prefix + QString::fromLatin1( "/plugins" ) );
|
---|
| 312 | datPath->setText( prefix );
|
---|
| 313 | }
|
---|
| 314 | }
|
---|
| 315 |
|
---|
| 316 | void Distributor::browseInstallationPrefix()
|
---|
| 317 | {
|
---|
| 318 | <a href="qstring.html">QString</a> prefix =
|
---|
| 319 | QFileDialog::<a href="qfiledialog.html#getOpenFileName">getOpenFileName</a>( QString::null, QString::null, this );
|
---|
| 320 | prefixPath->setText( prefix );
|
---|
| 321 | }
|
---|
| 322 |
|
---|
| 323 |
|
---|
| 324 | void Distributor::toggleAutoSet( bool autoset )
|
---|
| 325 | {
|
---|
| 326 | if ( autoset ) checkInstallationPrefix( prefixPath->text() );
|
---|
| 327 | }
|
---|
| 328 |
|
---|
| 329 | void Distributor::accept()
|
---|
| 330 | {
|
---|
| 331 | struct step {
|
---|
| 332 | const char *key;
|
---|
| 333 | <a href="qcstring.html">QCString</a> value;
|
---|
| 334 | bool done;
|
---|
| 335 | } steps[7];
|
---|
| 336 |
|
---|
| 337 | steps[0].key = "qt_nstpath=";
|
---|
| 338 | <a name="x2658"></a> steps[0].value = QFile::<a href="qfile.html#encodeName">encodeName</a>( prefixPath->text() );
|
---|
| 339 | steps[0].done = FALSE;
|
---|
| 340 |
|
---|
| 341 | steps[1].key = "qt_binpath=";
|
---|
| 342 | steps[1].value = QFile::<a href="qfile.html#encodeName">encodeName</a>( binPath->text() );
|
---|
| 343 | steps[1].done = FALSE;
|
---|
| 344 |
|
---|
| 345 | steps[2].key = "qt_docpath=";
|
---|
| 346 | steps[2].value = QFile::<a href="qfile.html#encodeName">encodeName</a>( docPath->text() );
|
---|
| 347 | steps[2].done = FALSE;
|
---|
| 348 |
|
---|
| 349 | steps[3].key = "qt_hdrpath=";
|
---|
| 350 | steps[3].value = QFile::<a href="qfile.html#encodeName">encodeName</a>( hdrPath->text() );
|
---|
| 351 | steps[3].done = FALSE;
|
---|
| 352 |
|
---|
| 353 | steps[4].key = "qt_libpath=";
|
---|
| 354 | steps[4].value = QFile::<a href="qfile.html#encodeName">encodeName</a>( libPath->text() );
|
---|
| 355 | steps[4].done = FALSE;
|
---|
| 356 |
|
---|
| 357 | steps[5].key = "qt_plgpath=";
|
---|
| 358 | steps[5].value = QFile::<a href="qfile.html#encodeName">encodeName</a>( plgPath->text() );
|
---|
| 359 | steps[5].done = FALSE;
|
---|
| 360 |
|
---|
| 361 | steps[6].key = "qt_datpath=";
|
---|
| 362 | steps[6].value = QFile::<a href="qfile.html#encodeName">encodeName</a>( datPath->text() );
|
---|
| 363 | steps[6].done = FALSE;
|
---|
| 364 |
|
---|
| 365 | uint completed = 0;
|
---|
| 366 | uint total_steps = sizeof(steps) / sizeof(step);
|
---|
| 367 |
|
---|
| 368 | <a href="qfile.html">QFile</a> file( libFilename->text() );
|
---|
| 369 | if ( file.<a href="qfile.html#open">open</a>( <a href="qfile.html#open">IO_ReadWrite</a> ) ) {
|
---|
| 370 | QApplication::<a href="qapplication.html#setOverrideCursor">setOverrideCursor</a>( WaitCursor );
|
---|
| 371 |
|
---|
| 372 | // instead of reading in the entire file, do the search in chunks
|
---|
| 373 | char data[60000];
|
---|
| 374 | ulong offset = 0;
|
---|
| 375 |
|
---|
| 376 | while ( ! file.<a href="qfile.html#atEnd">atEnd</a>() && completed < total_steps ) {
|
---|
| 377 | QApplication::<a href="qapplication.html#eventLoop">eventLoop</a>()->processEvents( QEventLoop::ExcludeUserInput );
|
---|
| 378 |
|
---|
| 379 | ulong len = file.<a href="qiodevice.html#readBlock">readBlock</a>( data, sizeof(data) );
|
---|
| 380 | if ( len < 267 ) {
|
---|
| 381 | // not enough room to make any modifications... stop
|
---|
| 382 | break;
|
---|
| 383 | }
|
---|
| 384 |
|
---|
| 385 | uint completed_save = completed;
|
---|
| 386 | for ( uint x = 0; x < total_steps; ++x ) {
|
---|
| 387 | if ( steps[x].done ) continue;
|
---|
| 388 |
|
---|
| 389 | char *s = find_pattern( data, steps[x].key, len );
|
---|
| 390 | if ( s ) {
|
---|
| 391 | ulong where = s - data;
|
---|
| 392 | if ( len - where < 256 ) {
|
---|
| 393 | // not enough space left to write the full
|
---|
| 394 | // path... move the file pointer back to just
|
---|
| 395 | // before the pattern and continue
|
---|
| 396 | offset += where - 11;
|
---|
| 397 | file.<a href="qiodevice.html#at">at</a>( offset );
|
---|
| 398 | len = file.<a href="qiodevice.html#readBlock">readBlock</a>( data, sizeof(data) );
|
---|
| 399 | --x; // retry the current step
|
---|
| 400 | continue;
|
---|
| 401 | }
|
---|
| 402 |
|
---|
| 403 | <a href="qcstring.html#qstrcpy">qstrcpy</a>( s, steps[x].value );
|
---|
| 404 | steps[x].done = TRUE;
|
---|
| 405 |
|
---|
| 406 | ++completed;
|
---|
| 407 | }
|
---|
| 408 | }
|
---|
| 409 |
|
---|
| 410 | if ( completed != completed_save ) {
|
---|
| 411 | // something changed... move file pointer back to
|
---|
| 412 | // where the data was read and write the new data
|
---|
| 413 | file.<a href="qiodevice.html#at">at</a>( offset );
|
---|
| 414 | <a name="x2668"></a> file.<a href="qiodevice.html#writeBlock">writeBlock</a>( data, len );
|
---|
| 415 | }
|
---|
| 416 |
|
---|
| 417 | // move to the new read position
|
---|
| 418 | offset += len - 11;
|
---|
| 419 | file.<a href="qiodevice.html#at">at</a>( offset );
|
---|
| 420 | }
|
---|
| 421 |
|
---|
| 422 | file.<a href="qfile.html#close">close</a>();
|
---|
| 423 |
|
---|
| 424 | QApplication::<a href="qapplication.html#restoreOverrideCursor">restoreOverrideCursor</a>();
|
---|
| 425 | }
|
---|
| 426 |
|
---|
| 427 | if ( completed != total_steps ) {
|
---|
| 428 | QMessageBox::<a href="qmessagebox.html#information">information</a>( this,
|
---|
| 429 | tr("Qt Distribution Wizard"),
|
---|
| 430 | tr("<p><h3>Modifications failed.</h3></p>"
|
---|
| 431 | "<p>Please make sure that you have permission "
|
---|
| 432 | "to write the selected file, and that the library "
|
---|
| 433 | "is properly built.</p>") );
|
---|
| 434 | return;
|
---|
| 435 | }
|
---|
| 436 |
|
---|
| 437 | <a name="x2654"></a> QWizard::<a href="qdialog.html#accept">accept</a>();
|
---|
| 438 | }
|
---|
| 439 | </pre>
|
---|
| 440 |
|
---|
| 441 | <p>See also <a href="examples.html">Examples</a>.
|
---|
| 442 |
|
---|
| 443 | <!-- eof -->
|
---|
| 444 | <p><address><hr><div align=center>
|
---|
| 445 | <table width=100% cellspacing=0 border=0><tr>
|
---|
| 446 | <td>Copyright © 2007
|
---|
| 447 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
| 448 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
| 449 | </table></div></address></body>
|
---|
| 450 | </html>
|
---|