summaryrefslogtreecommitdiffstats
path: root/examples/distributor
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-08 12:31:36 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-08 12:31:36 -0600
commitd796c9dd933ab96ec83b9a634feedd5d32e1ba3f (patch)
tree6e3dcca4f77e20ec8966c666aac7c35bd4704053 /examples/distributor
downloadtqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz
tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'examples/distributor')
-rw-r--r--examples/distributor/distributor.doc41
-rw-r--r--examples/distributor/distributor.pro10
-rw-r--r--examples/distributor/distributor.ui427
-rw-r--r--examples/distributor/distributor.ui.h383
-rw-r--r--examples/distributor/main.cpp11
5 files changed, 872 insertions, 0 deletions
diff --git a/examples/distributor/distributor.doc b/examples/distributor/distributor.doc
new file mode 100644
index 000000000..addcacecd
--- /dev/null
+++ b/examples/distributor/distributor.doc
@@ -0,0 +1,41 @@
+/*! \page distributor-example.html
+ \ingroup examples
+
+ \title Qt Distribution Example
+
+ This example program modifies the hard-coded paths that are
+ compiled into the Qt library.
+
+ When distributing the Qt library, the final installation prefix is
+ very rarely the same as the prefix used when doing development.
+ You can use the code from this example to modify the following
+ hard-coded paths in Qt library:
+
+ \list
+
+ \i Prefix - Normally, all other paths are relative to the \e
+ Prefix.
+
+ \i Binaries - Location of binaries distributed with Qt (for
+ example, \e{Qt Assistant}).
+
+ \i Documentation - Location of the Qt documentation.
+
+ \i Headers - Location of the Qt headers.
+
+ \i Libraries - Location of addition libraries distributed with Qt
+ (for example, the \e tqui library).
+
+ \i Plugins - Location of the Qt plugins.
+
+ \i Data - Location of applicaton specific data for all programs
+ distributed with Qt.
+
+ \endlist
+
+ <hr>
+
+ Implementation:
+
+ \include distributor/distributor.ui.h
+*/
diff --git a/examples/distributor/distributor.pro b/examples/distributor/distributor.pro
new file mode 100644
index 000000000..81d0ec5c0
--- /dev/null
+++ b/examples/distributor/distributor.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+LANGUAGE = C++
+TARGET = distributor
+
+CONFIG += qt warn_on
+
+REQUIRES = full-config
+
+SOURCES += main.cpp
+FORMS = distributor.ui
diff --git a/examples/distributor/distributor.ui b/examples/distributor/distributor.ui
new file mode 100644
index 000000000..8deff8107
--- /dev/null
+++ b/examples/distributor/distributor.ui
@@ -0,0 +1,427 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>Distributor</class>
+<widget class="TQWizard">
+ <property name="name">
+ <cstring>Distributor</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>522</width>
+ <height>422</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>TQt Distribution Wizard</string>
+ </property>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>selectLibrary</cstring>
+ </property>
+ <attribute name="title">
+ <string>&lt;b&gt;Select TQt Library File&lt;/b&gt;</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLineEdit" row="1" column="0">
+ <property name="name">
+ <cstring>libFilename</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>LineEditPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="1" column="1">
+ <property name="name">
+ <cstring>libBrowseButton</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Browse...</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;p&gt;Enter the filename of the TQt library to modify, or use the &lt;i&gt;Browse&lt;/i&gt; button to browse for the library.&lt;/p&gt;
+&lt;p&gt;This wizard will allow you to modify the installation paths stored in the library.&lt;/p&gt;</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>modifyPaths</cstring>
+ </property>
+ <attribute name="title">
+ <string>&lt;b&gt;Modify Installation Paths&lt;/b&gt;</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="11" column="1">
+ <property name="name">
+ <cstring>spacer2_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLabel" row="1" column="0">
+ <property name="name">
+ <cstring>prefixBuddy</cstring>
+ </property>
+ <property name="text">
+ <string>Installation &amp;Prefix</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>prefixPath</cstring>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="8" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>libPath</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="maxLength">
+ <number>255</number>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>prefixPath</cstring>
+ </property>
+ <property name="maxLength">
+ <number>255</number>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="9" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>plgPath</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="maxLength">
+ <number>255</number>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="1" column="2">
+ <property name="name">
+ <cstring>prefixBrowseButton</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Browse...</string>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="10" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>datPath</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="maxLength">
+ <number>255</number>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;p&gt;Enter the new &lt;i&gt;Installation Prefix&lt;/i&gt; for the selected TQt library, or use the &lt;i&gt;Browse&lt;/i&gt; button to browse for the desired directory.&lt;/p&gt;
+&lt;p&gt;Use the &lt;i&gt;Next&lt;/i&gt; button to review your choices and perform the modification.&lt;/p&gt;</string>
+ </property>
+ </widget>
+ <widget class="Line" row="2" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>line1</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="6" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>docPath</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="maxLength">
+ <number>255</number>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="7" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>hdrPath</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="maxLength">
+ <number>255</number>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="3" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;p&gt;The various paths below are set automatically according to the chosen &lt;i&gt;Installation Prefix&lt;/i&gt;. Uncheck the &lt;i&gt;Set paths from Installation Prefix&lt;/i&gt; box to enter custom values.&lt;/p&gt;</string>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="5" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>binPath</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="maxLength">
+ <number>255</number>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="4" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>autoSet</cstring>
+ </property>
+ <property name="text">
+ <string>Set paths from Installation Prefix</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="6" column="0">
+ <property name="name">
+ <cstring>docBuddy</cstring>
+ </property>
+ <property name="text">
+ <string>Documentation</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="10" column="0">
+ <property name="name">
+ <cstring>datBuddy</cstring>
+ </property>
+ <property name="text">
+ <string>Data</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="7" column="0">
+ <property name="name">
+ <cstring>hdrBuddy</cstring>
+ </property>
+ <property name="text">
+ <string>Headers</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="8" column="0">
+ <property name="name">
+ <cstring>libBuddy</cstring>
+ </property>
+ <property name="text">
+ <string>Libraries</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="9" column="0">
+ <property name="name">
+ <cstring>plgBuddy</cstring>
+ </property>
+ <property name="text">
+ <string>Plugins</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="5" column="0">
+ <property name="name">
+ <cstring>binBuddy</cstring>
+ </property>
+ <property name="text">
+ <string>Binaries</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>verifyMods</cstring>
+ </property>
+ <attribute name="title">
+ <string>&lt;b&gt;Verify Modifications&lt;/b&gt;</string>
+ </attribute>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel4</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;p&gt;&lt;b&gt;Current Library File:&lt;/b&gt; %1&lt;/p&gt;
+&lt;table border=0&gt;
+ &lt;tr&gt;&lt;td&gt;&lt;b&gt;New Installation Prefix:&lt;/b&gt;&lt;/td&gt;&lt;td&gt;%2&lt;/td&gt;&lt;/tr&gt;
+ &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
+ &lt;tr&gt;&lt;td&gt;&lt;b&gt;Binaries Path:&lt;/b&gt;&lt;/td&gt;&lt;td&gt;%3&lt;/td&gt;&lt;/tr&gt;
+ &lt;tr&gt;&lt;td&gt;&lt;b&gt;Documentation Path:&lt;/b&gt;&lt;/td&gt;&lt;td&gt;%4&lt;/td&gt;&lt;/tr&gt;
+ &lt;tr&gt;&lt;td&gt;&lt;b&gt;Headers Path:&lt;/b&gt;&lt;/td&gt;&lt;td&gt;%5&lt;/td&gt;&lt;/tr&gt;
+ &lt;tr&gt;&lt;td&gt;&lt;b&gt;Libraries Path:&lt;/b&gt;&lt;/td&gt;&lt;td&gt;%6&lt;/td&gt;&lt;/tr&gt;
+ &lt;tr&gt;&lt;td&gt;&lt;b&gt;Plugins Path:&lt;/b&gt;&lt;/td&gt;&lt;td&gt;%7&lt;/td&gt;&lt;/tr&gt;
+ &lt;tr&gt;&lt;td&gt;&lt;b&gt;Data Path:&lt;/b&gt;&lt;/td&gt;&lt;td&gt;%8&lt;/td&gt;&lt;/tr&gt;
+&lt;/table&gt;
+&lt;p&gt;Please verify that these options are correct. Press the &lt;i&gt;Finish&lt;/i&gt; button to apply these modifications to the TQt library. Use the &lt;i&gt;Back&lt;/i&gt; button to make corrections. Use the &lt;i&gt;Cancel&lt;/i&gt; button to abort.&lt;/p&gt;</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop</set>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+</widget>
+<connections>
+ <connection>
+ <sender>autoSet</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>binPath</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>autoSet</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>docPath</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>autoSet</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>hdrPath</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>autoSet</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>libPath</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>autoSet</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>plgPath</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>autoSet</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>datPath</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>libFilename</sender>
+ <signal>textChanged(const TQString&amp;)</signal>
+ <receiver>Distributor</receiver>
+ <slot>checkLibFilename(const TQString&amp;)</slot>
+ </connection>
+ <connection>
+ <sender>libBrowseButton</sender>
+ <signal>clicked()</signal>
+ <receiver>Distributor</receiver>
+ <slot>browseLibFilename()</slot>
+ </connection>
+ <connection>
+ <sender>prefixPath</sender>
+ <signal>textChanged(const TQString&amp;)</signal>
+ <receiver>Distributor</receiver>
+ <slot>checkInstallationPrefix(const TQString&amp;)</slot>
+ </connection>
+ <connection>
+ <sender>prefixBrowseButton</sender>
+ <signal>clicked()</signal>
+ <receiver>Distributor</receiver>
+ <slot>browseInstallationPrefix()</slot>
+ </connection>
+ <connection>
+ <sender>autoSet</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>Distributor</receiver>
+ <slot>toggleAutoSet(bool)</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>libFilename</tabstop>
+ <tabstop>libBrowseButton</tabstop>
+ <tabstop>prefixPath</tabstop>
+ <tabstop>prefixBrowseButton</tabstop>
+ <tabstop>autoSet</tabstop>
+ <tabstop>binPath</tabstop>
+ <tabstop>docPath</tabstop>
+ <tabstop>hdrPath</tabstop>
+ <tabstop>libPath</tabstop>
+ <tabstop>plgPath</tabstop>
+ <tabstop>datPath</tabstop>
+</tabstops>
+<includes>
+ <include location="local" impldecl="in implementation">distributor.ui.h</include>
+</includes>
+<variables>
+ <variable access="private">TQTimer *timer;</variable>
+</variables>
+<slots>
+ <slot>checkLibFilename( const TQString &amp; filename )</slot>
+ <slot>browseLibFilename()</slot>
+ <slot>checkLibData()</slot>
+ <slot>checkInstallationPrefix( const TQString &amp;filename )</slot>
+ <slot>browseInstallationPrefix()</slot>
+ <slot>toggleAutoSet( bool autoset )</slot>
+ <slot>accept()</slot>
+</slots>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+ <function>showPage( TQWidget * page )</function>
+</functions>
+<pixmapinproject/>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/examples/distributor/distributor.ui.h b/examples/distributor/distributor.ui.h
new file mode 100644
index 000000000..c927cda5e
--- /dev/null
+++ b/examples/distributor/distributor.ui.h
@@ -0,0 +1,383 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** TQt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+#include <qapplication.h>
+#include <qcursor.h>
+#include <qeventloop.h>
+#include <qfile.h>
+#include <qfiledialog.h>
+#include <qfileinfo.h>
+#include <qlineedit.h>
+#include <qmessagebox.h>
+#include <qpushbutton.h>
+#include <qtimer.h>
+
+
+void Distributor::init()
+{
+ timer = new TQTimer( this );
+ connect( timer, SIGNAL(timeout()), SLOT(checkLibData()) );
+
+ cancelButton()->setAutoDefault( FALSE );
+ backButton()->setAutoDefault( FALSE );
+
+ setNextEnabled( selectLibrary, FALSE );
+
+ setHelpEnabled( selectLibrary, FALSE );
+ setHelpEnabled( modifyPaths, FALSE );
+ setHelpEnabled( verifyMods, FALSE );
+
+ setFinishEnabled( verifyMods, TRUE );
+}
+
+void Distributor::showPage( TQWidget *page )
+{
+ if ( page == selectLibrary ) {
+ nextButton()->setDefault( TRUE );
+ libFilename->setFocus();
+ } else if ( page == modifyPaths ) {
+ nextButton()->setDefault( TRUE );
+ prefixPath->selectAll();
+ prefixPath->setFocus();
+ } else if ( page == verifyMods ) {
+ finishButton()->setDefault( TRUE );
+ finishButton()->setFocus();
+
+ TQString labeltext =
+ tr("<p><b>Current Library File:</b> %1</p>"
+ "<table border=0>"
+ "<tr><td><b>New Installation Prefix:</b></td><td>%2</td></tr>"
+ "<tr><td></td><td></td></tr>"
+ "<tr><td><b>Binaries Path:</b></td><td>%3</td></tr>"
+ "<tr><td><b>Documentation Path:</b></td><td>%4</td></tr>"
+ "<tr><td><b>Headers Path:</b></td><td>%5</td></tr>"
+ "<tr><td><b>Libraries Path:</b></td><td>%6</td></tr>"
+ "<tr><td><b>Plugins Path:</b></td><td>%7</td></tr>"
+ "<tr><td><b>Data Path:</b></td><td>%8</td></tr>"
+ "</table>"
+ "<p>Please verify that these options are correct. Press the "
+ "<i>Finish</i> button to apply these modifications to the TQt "
+ "library. Use the <i>Back</i> button to make corrections. Use "
+ "the <i>Cancel</i> button to abort.</p>")
+ .arg( libFilename->text() )
+ .arg( prefixPath->text() )
+ .arg( binPath->text() )
+ .arg( docPath->text() )
+ .arg( hdrPath->text() )
+ .arg( libPath->text() )
+ .arg( plgPath->text() )
+ .arg( datPath->text() );
+ textLabel4->setText( labeltext );
+ }
+
+ TQWizard::showPage( page );
+}
+
+void Distributor::checkLibFilename( const TQString &filename )
+{
+ setNextEnabled( selectLibrary, FALSE );
+
+ TQFileInfo fileinfo( filename );
+ if ( ! filename.isEmpty() && fileinfo.exists() &&
+ fileinfo.isReadable() && fileinfo.isWritable() &&
+ fileinfo.isFile() && !fileinfo.isSymLink() )
+ timer->start( 500, TRUE );
+}
+
+void Distributor::browseLibFilename()
+{
+ TQString filename =
+ TQFileDialog::getOpenFileName( TQString::null, TQString::null, this );
+ libFilename->setText( filename );
+}
+
+static char *find_pattern( char *h, const char *n, ulong hlen )
+{
+ if ( ! h || ! n || hlen == 0 )
+ return 0;
+
+#ifdef Q_OS_UNIX
+ size_t nlen;
+#else
+ ulong nlen;
+#endif
+
+ char nc = *n++;
+ nlen = strlen( n );
+ char hc;
+
+ do {
+ do {
+ hc = *h++;
+ if ( hlen-- < 1 )
+ return 0;
+ } while ( hc != nc );
+
+ if ( nlen > hlen )
+ return 0;
+ } while ( qstrncmp( h, n, nlen ) != 0 );
+ return h + nlen;
+}
+
+void Distributor::checkLibData()
+{
+ struct step {
+ const char *key;
+ TQCString value;
+ bool done;
+ } steps[7];
+
+ steps[0].key = "qt_nstpath=";
+ steps[0].done = FALSE;
+
+ steps[1].key = "qt_binpath=";
+ steps[1].done = FALSE;
+
+ steps[2].key = "qt_docpath=";
+ steps[2].done = FALSE;
+
+ steps[3].key = "qt_hdrpath=";
+ steps[3].done = FALSE;
+
+ steps[4].key = "qt_libpath=";
+ steps[4].done = FALSE;
+
+ steps[5].key = "qt_plgpath=";
+ steps[5].done = FALSE;
+
+ steps[6].key = "qt_datpath=";
+ steps[6].done = FALSE;
+
+ uint completed = 0;
+ uint total_steps = sizeof(steps) / sizeof(step);
+
+ TQFile file( libFilename->text() );
+ if ( file.open( IO_ReadOnly ) ) {
+ TQApplication::setOverrideCursor( WaitCursor );
+
+ // instead of reading in the entire file, do the search in chunks
+ char data[60000];
+ ulong offset = 0;
+
+ while ( ! file.atEnd() && completed < total_steps ) {
+ TQApplication::eventLoop()->processEvents( TQEventLoop::ExcludeUserInput );
+
+ ulong len = file.readBlock( data, sizeof(data) );
+ if ( len < 267 ) {
+ // not enough room to make any modifications... stop
+ break;
+ }
+
+ for ( uint x = 0; x < total_steps; ++x ) {
+ if ( steps[x].done ) continue;
+
+ char *s = find_pattern( data, steps[x].key, len );
+ if ( s ) {
+ ulong where = s - data;
+ if ( len - where < 256 ) {
+ // not enough space left to write the full
+ // path... move the file pointer back to just
+ // before the pattern and continue
+ offset += where - 11;
+ file.at( offset );
+ len = file.readBlock( data, sizeof(data) );
+ --x; // retry the current step
+ continue;
+ }
+
+ steps[x].value = s;
+ steps[x].done = TRUE;
+
+ ++completed;
+ }
+ }
+
+ // move to the new read position
+ offset += len - 11;
+ file.at( offset );
+ }
+
+ file.close();
+
+ TQApplication::restoreOverrideCursor();
+ }
+
+ if ( completed == total_steps ) {
+ setNextEnabled( selectLibrary, TRUE );
+
+ TQString prefix = TQFile::decodeName( steps[0].value );
+ prefixPath->setText( prefix );
+
+ TQString def_bin = prefix + TQString::fromLatin1( "/bin" );
+ TQString def_doc = prefix + TQString::fromLatin1( "/doc" );
+ TQString def_hdr = prefix + TQString::fromLatin1( "/include" );
+ TQString def_lib = prefix + TQString::fromLatin1( "/lib" );
+ TQString def_plg = prefix + TQString::fromLatin1( "/plugins" );
+ TQString def_dat = prefix;
+
+ TQString bin = TQFile::decodeName( steps[1].value );
+ TQString doc = TQFile::decodeName( steps[2].value );
+ TQString hdr = TQFile::decodeName( steps[3].value );
+ TQString lib = TQFile::decodeName( steps[4].value );
+ TQString plg = TQFile::decodeName( steps[5].value );
+ TQString dat = TQFile::decodeName( steps[6].value );
+
+ autoSet->setChecked( def_bin == bin &&
+ def_doc == doc &&
+ def_hdr == hdr &&
+ def_lib == lib &&
+ def_plg == plg &&
+ def_dat == dat );
+
+ if ( ! autoSet->isChecked() ) {
+ binPath->setText( bin );
+ docPath->setText( doc );
+ hdrPath->setText( hdr );
+ libPath->setText( lib );
+ plgPath->setText( plg );
+ datPath->setText( dat );
+ }
+ }
+}
+
+void Distributor::checkInstallationPrefix( const TQString &prefix )
+{
+ if ( autoSet->isChecked() ) {
+ binPath->setText( prefix + TQString::fromLatin1( "/bin" ) );
+ docPath->setText( prefix + TQString::fromLatin1( "/doc" ) );
+ hdrPath->setText( prefix + TQString::fromLatin1( "/include" ) );
+ libPath->setText( prefix + TQString::fromLatin1( "/lib" ) );
+ plgPath->setText( prefix + TQString::fromLatin1( "/plugins" ) );
+ datPath->setText( prefix );
+ }
+}
+
+void Distributor::browseInstallationPrefix()
+{
+ TQString prefix =
+ TQFileDialog::getOpenFileName( TQString::null, TQString::null, this );
+ prefixPath->setText( prefix );
+}
+
+
+void Distributor::toggleAutoSet( bool autoset )
+{
+ if ( autoset ) checkInstallationPrefix( prefixPath->text() );
+}
+
+void Distributor::accept()
+{
+ struct step {
+ const char *key;
+ TQCString value;
+ bool done;
+ } steps[7];
+
+ steps[0].key = "qt_nstpath=";
+ steps[0].value = TQFile::encodeName( prefixPath->text() );
+ steps[0].done = FALSE;
+
+ steps[1].key = "qt_binpath=";
+ steps[1].value = TQFile::encodeName( binPath->text() );
+ steps[1].done = FALSE;
+
+ steps[2].key = "qt_docpath=";
+ steps[2].value = TQFile::encodeName( docPath->text() );
+ steps[2].done = FALSE;
+
+ steps[3].key = "qt_hdrpath=";
+ steps[3].value = TQFile::encodeName( hdrPath->text() );
+ steps[3].done = FALSE;
+
+ steps[4].key = "qt_libpath=";
+ steps[4].value = TQFile::encodeName( libPath->text() );
+ steps[4].done = FALSE;
+
+ steps[5].key = "qt_plgpath=";
+ steps[5].value = TQFile::encodeName( plgPath->text() );
+ steps[5].done = FALSE;
+
+ steps[6].key = "qt_datpath=";
+ steps[6].value = TQFile::encodeName( datPath->text() );
+ steps[6].done = FALSE;
+
+ uint completed = 0;
+ uint total_steps = sizeof(steps) / sizeof(step);
+
+ TQFile file( libFilename->text() );
+ if ( file.open( IO_ReadWrite ) ) {
+ TQApplication::setOverrideCursor( WaitCursor );
+
+ // instead of reading in the entire file, do the search in chunks
+ char data[60000];
+ ulong offset = 0;
+
+ while ( ! file.atEnd() && completed < total_steps ) {
+ TQApplication::eventLoop()->processEvents( TQEventLoop::ExcludeUserInput );
+
+ ulong len = file.readBlock( data, sizeof(data) );
+ if ( len < 267 ) {
+ // not enough room to make any modifications... stop
+ break;
+ }
+
+ uint completed_save = completed;
+ for ( uint x = 0; x < total_steps; ++x ) {
+ if ( steps[x].done ) continue;
+
+ char *s = find_pattern( data, steps[x].key, len );
+ if ( s ) {
+ ulong where = s - data;
+ if ( len - where < 256 ) {
+ // not enough space left to write the full
+ // path... move the file pointer back to just
+ // before the pattern and continue
+ offset += where - 11;
+ file.at( offset );
+ len = file.readBlock( data, sizeof(data) );
+ --x; // retry the current step
+ continue;
+ }
+
+ qstrcpy( s, steps[x].value );
+ steps[x].done = TRUE;
+
+ ++completed;
+ }
+ }
+
+ if ( completed != completed_save ) {
+ // something changed... move file pointer back to
+ // where the data was read and write the new data
+ file.at( offset );
+ file.writeBlock( data, len );
+ }
+
+ // move to the new read position
+ offset += len - 11;
+ file.at( offset );
+ }
+
+ file.close();
+
+ TQApplication::restoreOverrideCursor();
+ }
+
+ if ( completed != total_steps ) {
+ TQMessageBox::information( this,
+ tr("TQt Distribution Wizard"),
+ tr("<p><h3>Modifications failed.</h3></p>"
+ "<p>Please make sure that you have permission "
+ "to write the selected file, and that the library "
+ "is properly built.</p>") );
+ return;
+ }
+
+ TQWizard::accept();
+}
diff --git a/examples/distributor/main.cpp b/examples/distributor/main.cpp
new file mode 100644
index 000000000..2a8a30cbe
--- /dev/null
+++ b/examples/distributor/main.cpp
@@ -0,0 +1,11 @@
+#include <qapplication.h>
+#include "distributor.h"
+
+int main( int argc, char ** argv )
+{
+ TQApplication a( argc, argv );
+ Distributor w;
+ w.show();
+ a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( tquit() ) );
+ return a.exec();
+}