summaryrefslogtreecommitdiffstats
path: root/tools/designer/tools
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 /tools/designer/tools
downloadtqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz
tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'tools/designer/tools')
-rw-r--r--tools/designer/tools/conv2ui/conv2ui.pro10
-rw-r--r--tools/designer/tools/conv2ui/main.cpp220
-rw-r--r--tools/designer/tools/createcw/README18
-rw-r--r--tools/designer/tools/createcw/createcw.pro8
-rw-r--r--tools/designer/tools/createcw/main.cpp190
5 files changed, 446 insertions, 0 deletions
diff --git a/tools/designer/tools/conv2ui/conv2ui.pro b/tools/designer/tools/conv2ui/conv2ui.pro
new file mode 100644
index 00000000..015ad94a
--- /dev/null
+++ b/tools/designer/tools/conv2ui/conv2ui.pro
@@ -0,0 +1,10 @@
+######################################################################
+# Automatically generated by qmake (1.04a) Tue Oct 1 18:34:56 2002
+######################################################################
+TEMPLATE = app
+CONFIG -= moc
+
+# Input
+INCLUDEPATH += ../../interfaces
+SOURCES += main.cpp
+DESTDIR = $$QT_BUILD_TREE/bin
diff --git a/tools/designer/tools/conv2ui/main.cpp b/tools/designer/tools/conv2ui/main.cpp
new file mode 100644
index 00000000..1c28e2aa
--- /dev/null
+++ b/tools/designer/tools/conv2ui/main.cpp
@@ -0,0 +1,220 @@
+/**********************************************************************
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of TQt GUI Designer.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** Licensees holding valid TQt Commercial licenses may use this file in
+** accordance with the TQt Commercial License Agreement provided with
+** the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#include <qapplication.h>
+#include <private/qpluginmanager_p.h>
+#include <qstringlist.h>
+#include <qdir.h>
+#include <stdio.h>
+#include "filterinterface.h"
+#include <qfileinfo.h>
+
+class Conv2ui {
+public:
+ Conv2ui();
+ ~Conv2ui();
+ bool reinit();
+ bool convert( const TQString & filename, const TQDir & dest );
+ TQStringList featureList();
+private:
+ TQString getTag( const TQString & filename );
+ TQString absName( const TQString & filename );
+ TQPluginManager<ImportFilterInterface> * importFiltersManager;
+};
+
+Conv2ui::Conv2ui() : importFiltersManager( 0 )
+{
+ reinit();
+}
+
+Conv2ui::~Conv2ui()
+{
+ if ( importFiltersManager )
+ delete importFiltersManager;
+}
+
+bool Conv2ui::reinit()
+{
+ if ( importFiltersManager )
+ delete importFiltersManager;
+ importFiltersManager = new TQPluginManager<ImportFilterInterface>( IID_ImportFilter,
+ TQApplication::libraryPaths(),
+ "/designer");
+ return !!importFiltersManager;
+}
+
+bool Conv2ui::convert( const TQString & filename, const TQDir & dest )
+{
+ if ( !importFiltersManager ) {
+ qWarning( "Conv2ui: no TQPluginManager was found" );
+ return FALSE;
+ }
+
+ if ( !TQFile::exists( absName( filename ) ) ) {
+ qWarning( "Conv2ui: can not find file %s", filename.latin1() );
+ return FALSE;
+ }
+
+ TQString tag = getTag( filename );
+ TQStringList lst = importFiltersManager->featureList();
+
+ for ( TQStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) {
+
+ ImportFilterInterface * interface = 0;
+ importFiltersManager->queryInterface( *it, &interface );
+
+ if ( !interface ) continue;
+
+ if ( (*it).contains( tag, FALSE ) ) {
+ // Make sure we output the files in the destination dir
+ TQString absfile = absName( filename );
+ TQString current = TQDir::currentDirPath();
+ TQDir::setCurrent( dest.absPath() );
+ interface->import( *it, absfile ); // resulting files go into the current dir
+ TQDir::setCurrent( current );
+ }
+
+ interface->release();
+
+ }
+
+ return TRUE;
+}
+
+TQStringList Conv2ui::featureList()
+{
+ if ( !importFiltersManager ) {
+ return 0;
+ }
+ return importFiltersManager->featureList();
+}
+
+TQString Conv2ui::getTag( const TQString & filename )
+{
+ TQFileInfo info( filename );
+ return info.extension();
+}
+
+TQString Conv2ui::absName( const TQString & filename )
+{
+ TQString absFileName = TQDir::isRelativePath( filename ) ?
+ TQDir::currentDirPath() +
+ TQDir::separator() +
+ filename :
+ filename;
+ return absFileName;
+}
+
+void printHelpMessage( TQStringList & formats )
+{
+ printf( "Usage: conv2ui [options] <file> <destination directory>\n\n" );
+ printf( "Options:\n");
+ printf( "\t-help\t\tDisplay this information\n" );
+ printf( "\t-silent\t\tDon't write any messages\n");
+ printf( "\t-version\tDisplay version of conv2ui\n");
+ printf( "Supported file formats:\n" );
+ for ( TQStringList::Iterator it = formats.begin(); it != formats.end(); ++it )
+ printf( "\t%s\n", (*it).latin1() );
+}
+
+void printVersion()
+{
+ printf( "TQt user interface file converter for TQt version %s\n", QT_VERSION_STR );
+}
+
+int main( int argc, char ** argv )
+{
+ Conv2ui conv;
+
+ bool help = TRUE;
+ bool silent = FALSE;
+ bool version = FALSE;
+ bool unrecognized = FALSE;
+
+ // parse options
+ int argi = 1;
+ while ( argi < argc && argv[argi][0] == '-' ) {
+ int i = 1;
+ while ( argv[argi][i] != '\0' ) {
+
+ if ( argv[argi][i] == 's' ) {
+ silent = TRUE;
+ break;
+ } else if ( argv[argi][i] == 'h' ) {
+ help = TRUE;
+ break;
+ } else if ( argv[argi][i] == 'v' ) {
+ version = TRUE;
+ silent = TRUE;
+ break;
+ } else {
+ unrecognized = TRUE;
+ }
+ i++;
+ }
+ argi++;
+ }
+
+ // get source file
+ TQString src;
+ if ( argv[argi] ) {
+ src = argv[argi++];
+ }
+
+ // get destination directory
+ TQDir dst;
+ if ( argv[argi] ) {
+ dst.setPath( argv[argi++] );
+ help = FALSE;
+ }
+
+ if ( !silent ) {
+ printf( "TQt user interface file converter.\n" );
+ if ( unrecognized ) {
+ printf( "conv2ui: Unrecognized option\n" );
+ }
+ }
+ if ( version ) {
+ printVersion();
+ return 0;
+ } else if ( help ) {
+ TQStringList formats = conv.featureList();
+ printHelpMessage( formats );
+ return 0;
+ }
+
+ // do the magic
+ if ( conv.convert( src, dst ) )
+ return 0;
+ return -1;
+}
diff --git a/tools/designer/tools/createcw/README b/tools/designer/tools/createcw/README
new file mode 100644
index 00000000..cc48234e
--- /dev/null
+++ b/tools/designer/tools/createcw/README
@@ -0,0 +1,18 @@
+This small application makes it much easier to create custom widget
+descriptions for Qt Designer. Using them you can use custom widgets
+in Qt Designer including their signals, slots and properties.
+
+The usual way to do this is to enter all the information in the custom
+widget dialog in Qt Designer for each widget. But this small tool can
+create these description files for your custom widgets which you then
+can simply import into Qt Designer. So you can use your custom widgets
+without any additional work in your forms in Qt Designer.
+
+To do this you must modify the sourcecode (main.cpp) a bit and
+recompile it afterwards. For further instructions how to use it see
+the comments starting with STEP1 and STEP2 in main.cpp.
+
+Note that Qt Designer now supports widget plugins which are more
+versatile and work just like built-in widgets, so you may prefer to
+make your custom widgets into plugins. See the designer manual for
+more information.
diff --git a/tools/designer/tools/createcw/createcw.pro b/tools/designer/tools/createcw/createcw.pro
new file mode 100644
index 00000000..415c0be7
--- /dev/null
+++ b/tools/designer/tools/createcw/createcw.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+CONFIG += qt warn_on release
+HEADERS =
+SOURCES = main.cpp
+TARGET = createcw
+
+target.path = $$bins.path
+INSTALLS += target
diff --git a/tools/designer/tools/createcw/main.cpp b/tools/designer/tools/createcw/main.cpp
new file mode 100644
index 00000000..351f0b21
--- /dev/null
+++ b/tools/designer/tools/createcw/main.cpp
@@ -0,0 +1,190 @@
+/**********************************************************************
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of TQt GUI Designer.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing retquirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** Licensees holding valid TQt Commercial licenses may use this file in
+** accordance with the TQt Commercial License Agreement provided with
+** the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#include <qfile.h>
+#include <qtextstream.h>
+#include <qvaluelist.h>
+#include <qstrlist.h>
+#include <qmetaobject.h>
+#include <qapplication.h>
+
+// STEP1: Include header files of the widgets for which a description
+// should be created here. If you have a widget which is defined in
+// the file mycustomwidget.h in /home/joedeveloper/src, write here
+//
+// #include "/home/joedeveloper/src/mycustomwidget.h"
+//
+// Now go on to STEP2!
+
+// -----------------------------
+
+struct Widget
+{
+ TQWidget *w; // the widget
+ TQString include; // header file
+ TQString location; // "global" for include <...> or "local" include "..."
+};
+
+static TQString makeIndent( int indent )
+{
+ TQString s;
+ s.fill( ' ', indent * 4 );
+ return s;
+}
+
+static TQString entitize( const TQString &s )
+{
+ TQString s2 = s;
+ s2 = s2.replace( "\"", "&quot;" );
+ s2 = s2.replace( "&", "&amp;" );
+ s2 = s2.replace( ">", "&gt;" );
+ s2 = s2.replace( "<", "&lt;" );
+ s2 = s2.replace( "'", "&apos;" );
+ return s2;
+}
+
+static TQString convert_type( const TQString &s )
+{
+ TQString str( s );
+ if (( str[ 0 ] == 'T' ) && ( str[ 1 ] == 'Q' ))
+ str.remove( 0, 2 );
+ str[ 0 ] = str[ 0 ].upper();
+ return str;
+}
+
+static void createDescription( const TQValueList<Widget> &l, TQTextStream &ts )
+{
+ int indent = 0;
+ ts << "<!DOCTYPE CW><CW>" << endl;
+ ts << makeIndent( indent ) << "<customwidgets>" << endl;
+ indent++;
+
+ for ( TQValueList<Widget>::ConstIterator it = l.begin(); it != l.end(); ++it ) {
+ Widget w = *it;
+ ts << makeIndent( indent ) << "<customwidget>" << endl;
+ indent++;
+ ts << makeIndent( indent ) << "<class>" << w.w->className() << "</class>" << endl;
+ ts << makeIndent( indent ) << "<header location=\"" << w.location << "\">" << w.include << "</header>" << endl;
+ ts << makeIndent( indent ) << "<sizehint>" << endl;
+ indent++;
+ ts << makeIndent( indent ) << "<width>" << w.w->sizeHint().width() << "</width>" << endl;
+ ts << makeIndent( indent ) << "<height>" << w.w->sizeHint().height() << "</height>" << endl;
+ indent--;
+ ts << makeIndent( indent ) << "</sizehint>" << endl;
+ ts << makeIndent( indent ) << "<container>" << ( w.w->inherits( "TQGroupBox" ) || w.w->inherits( "TQWidgetStack" ) ) << "</container>" << endl;
+ ts << makeIndent( indent ) << "<sizepolicy>" << endl;
+ indent++;
+ ts << makeIndent( indent ) << "<hordata>" << (int)w.w->sizePolicy().horData() << "</hordata>" << endl;
+ ts << makeIndent( indent ) << "<verdata>" << (int)w.w->sizePolicy().verData() << "</verdata>" << endl;
+ indent--;
+ ts << makeIndent( indent ) << "</sizepolicy>" << endl;
+
+ TQStrList sigs = w.w->metaObject()->signalNames( TRUE );
+ if ( !sigs.isEmpty() ) {
+ for ( int i = 0; i < (int)sigs.count(); ++i )
+ ts << makeIndent( indent ) << "<signal>" << entitize( sigs.at( i ) ) << "</signal>" << endl;
+ }
+ TQStrList slts = w.w->metaObject()->slotNames( TRUE );
+ if ( !slts.isEmpty() ) {
+ for ( int i = 0; i < (int)slts.count(); ++i ) {
+ TQMetaData::Access data = w.w->metaObject()->slot( i, TRUE )->access;
+ if ( data == TQMetaData::Private )
+ continue;
+ ts << makeIndent( indent ) << "<slot access=\""
+ << ( data == TQMetaData::Protected ? "protected" : "public" )
+ << "\">" << entitize( slts.at( i ) ) << "</slot>" << endl;
+ }
+ }
+ TQStrList props = w.w->metaObject()->propertyNames( TRUE );
+ if ( !props.isEmpty() ) {
+ for ( int i = 0; i < (int)props.count(); ++i ) {
+ const TQMetaProperty *p = w.w->metaObject()->
+ property( w.w->metaObject()->
+ findProperty( props.at( i ), TRUE ), TRUE );
+ if ( !p )
+ continue;
+ if ( !p->writable() || !p->designable( w.w ) )
+ continue;
+ ts << makeIndent( indent ) << "<property type=\"" << convert_type( p->type() ) << "\">" << entitize( p->name() ) << "</property>" << endl;
+ }
+ }
+ indent--;
+ ts << makeIndent( indent ) << "</customwidget>" << endl;
+ }
+
+ indent--;
+ ts << makeIndent( indent ) << "</customwidgets>" << endl;
+ ts << "</CW>" << endl;
+}
+
+int main( int argc, char **argv )
+{
+ if ( argc < 2 )
+ return -1;
+ TQString fn = argv[1];
+ TQFile f( fn );
+ if ( !f.open( IO_WriteOnly ) )
+ return -1;
+ TQTextStream ts( &f );
+ TQApplication a( argc, argv );
+
+ TQValueList<Widget> wl;
+
+ // STEP2: Instantiate all widgets for which a description should
+ // be created here and add them to the list wl. If your custom widget
+ // is e.g. called MyCustomWidget you would write here
+ //
+ // Widget w;
+ // w.w = new MyCustomWidget( 0, 0 );
+ // w.include = "mycustomwidget.h";
+ // w.location = "global";
+ // wl.append( w );
+ //
+ // After that compile the program, link it with your custom widget
+ // (library or object file) and run it like this:
+ // (unix): ./createcw mywidgets.cw
+ // (win32): createcw mywidgets.cw
+ //
+ // After that you can import this description file into the TQt
+ // Designer using the Custom-Widget Dialog (See
+ // Tools->Custom->Edit Custom Widgets... in the TQt Designer)
+ // and use these custom widget there in your forms.
+
+
+
+ // ----------------------------------------------
+
+ createDescription( wl, ts );
+ f.close();
+ return 0;
+}