/**************************************************************************** ** ** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. ** ** This file is part of the Qt Script Generator project on Trolltech Labs. ** ** This file may be used under the terms of the GNU General Public ** License version 2.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 GNU ** General Public Licensing requirements will be met: ** http://www.trolltech.com/products/qt/opensource.html ** ** If you are unsure which license is appropriate for your use, please ** review the following information: ** http://www.trolltech.com/products/qt/licensing.html or contact the ** sales department at sales@trolltech.com. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ****************************************************************************/ #include "docgenerator.h" #include "fileout.h" DocGenerator::DocGenerator() { } QString DocGenerator::fileNameForClass(const AbstractMetaClass *meta_class) const { return QString::fromLatin1("%0.html").arg(meta_class->name().toLower()); } QString DocGenerator::subDirectoryForClass(const AbstractMetaClass *) const { return QString::fromLatin1("doc"); } static void writeDocumentHeader(QTextStream &s, const QString &title) { s << "" << endl << "" << endl << "" << endl << "
" << endl << "" << cls->name() << " |
---|
" << cls->name() << " |
---|
Using the Qt API in Qt Script is very similar to C++." << endl << "
var f = new QFile(\"foo.txt\");" << endl << "C++ enum values are mapped to properties of the script constructor function; e.g. " << endl << "QIODevice::ReadOnly becomes QIODevice.ReadOnly." << endl << "
f.open(new QIODevice.OpenMode(QIODevice.ReadOnly));" << endl << "
Each C++ flag type is mapped to a property of the script constructor function; e.g. " << endl << "QIODevice::OpenMode becomes QIODevice.OpenMode. Such a property is a constructor function " << endl << "that takes one or more enum values and constructs a flags instance by OR'ing the arguments " << endl << "together.
" << endl << "var ts = new QTextStream(f);" << endl << "ts.writeString(\"Boo\");" << endl << "
C++ streaming operators are normally mapped to readT() and writeT() functions.
" << endl << "f.close();" << endl << "
In Qt Script, all objects are allocated on the heap; objects that are no longer " << endl << "referenced are garbage collected sometime in the future; therefore, make sure to " << endl << "explicitly free up resources if you can. (Without the call to close(), the underlying " << endl << "file would remain open until the file object is garbage collected.)
" << endl ; file.stream << "Inherits baseClass()) << "\">" << meta_class->baseClass()->name() << ".
" << endl; } else if (!meta_class->interfaces().isEmpty()) { AbstractMetaClass *iface = meta_class->interfaces().first(); AbstractMetaClass *impl = iface->primaryInterfaceImplementor(); if (impl != meta_class) { s << "Inherits " << impl->name() << ".
" << endl; } } AbstractMetaFunctionList ctors; ctors = meta_class->queryFunctions(AbstractMetaClass::Constructors | AbstractMetaClass::WasPublic | AbstractMetaClass::NotRemovedFromTargetLang); QMapThis class has no public constructors. Calling the constructor function will cause a TypeError.
"; } s << "The " << meta_class->name() << " prototype object inherits properties from the " << "baseClass()) << "\">" << meta_class->baseClass()->name() << " prototype object and " << "also has the following properties.
" << endl; } s << "" << meta_class->name() << " objects inherit properties from the " << meta_class->name() << " prototype object and also have the following properties.
" << endl; s << "" << meta_class->name() << " objects have no special properties beyond those " << "inherited from the " << meta_class->name() << " prototype object.
" << endl; } } } writeDocumentFooter(s); }