summaryrefslogtreecommitdiffstats
path: root/umbrello/umbrello/codegenerator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'umbrello/umbrello/codegenerator.cpp')
-rw-r--r--umbrello/umbrello/codegenerator.cpp152
1 files changed, 76 insertions, 76 deletions
diff --git a/umbrello/umbrello/codegenerator.cpp b/umbrello/umbrello/codegenerator.cpp
index a8c2ae23..a5b24cee 100644
--- a/umbrello/umbrello/codegenerator.cpp
+++ b/umbrello/umbrello/codegenerator.cpp
@@ -21,10 +21,10 @@
#include <cstdlib> //to get the user name
// qt includes
-#include <qdatetime.h>
-#include <qregexp.h>
-#include <qdir.h>
-#include <qtextstream.h>
+#include <tqdatetime.h>
+#include <tqregexp.h>
+#include <tqdir.h>
+#include <tqtextstream.h>
// kde includes
#include <kdebug.h>
@@ -55,15 +55,15 @@
//
CodeGenerator::CodeGenerator ()
- : QObject (UMLApp::app()->getDocument())
+ : TQObject (UMLApp::app()->getDocument())
{
initFields();
}
// FIX
// hmm. this should be pure virtual so that implemented in sub-class
-CodeGenerator::CodeGenerator (QDomElement & element )
- : QObject (UMLApp::app()->getDocument()) {
+CodeGenerator::CodeGenerator (TQDomElement & element )
+ : TQObject (UMLApp::app()->getDocument()) {
initFields();
loadFromXMI(element); // hmm. cant call this here.. its 'pure' virtual
}
@@ -85,10 +85,10 @@ CodeGenerator::~CodeGenerator ( ) {
// Accessor methods
//
-QString CodeGenerator::getUniqueID(CodeDocument * codeDoc)
+TQString CodeGenerator::getUniqueID(CodeDocument * codeDoc)
{
- QString id = codeDoc->getID();
+ TQString id = codeDoc->getID();
// does this document already exist? then just return its present id
if (!id.isEmpty() && findCodeDocumentByID(id))
@@ -101,11 +101,11 @@ QString CodeGenerator::getUniqueID(CodeDocument * codeDoc)
id = ID2STR(c->getID()); // this is supposed to be unique already..
} else {
- QString prefix = "doc";
- QString id = prefix + "_0";
+ TQString prefix = "doc";
+ TQString id = prefix + "_0";
int number = lastIDIndex;
for ( ; findCodeDocumentByID(id); number++) {
- id = prefix + '_' + QString::number(number);
+ id = prefix + '_' + TQString::number(number);
}
lastIDIndex = number;
}
@@ -113,7 +113,7 @@ QString CodeGenerator::getUniqueID(CodeDocument * codeDoc)
return id;
}
-CodeDocument * CodeGenerator::findCodeDocumentByID( const QString &tag ) {
+CodeDocument * CodeGenerator::findCodeDocumentByID( const TQString &tag ) {
//if we already know to which file this class was written/should be written, just return it.
CodeDocument * doc = (CodeDocument*)NULL;
if((doc = m_codeDocumentDictionary.find(tag)))
@@ -124,7 +124,7 @@ CodeDocument * CodeGenerator::findCodeDocumentByID( const QString &tag ) {
bool CodeGenerator::addCodeDocument ( CodeDocument * doc )
{
- QString tag = doc->getID();
+ TQString tag = doc->getID();
// assign a tag if one doesn't already exist
if(tag.isEmpty())
@@ -146,7 +146,7 @@ bool CodeGenerator::addCodeDocument ( CodeDocument * doc )
* Remove a CodeDocument object from m_codedocumentVector List
*/
bool CodeGenerator::removeCodeDocument ( CodeDocument * remove_object ) {
- QString tag = remove_object->getID();
+ TQString tag = remove_object->getID();
if(!(tag.isEmpty()))
m_codeDocumentDictionary.remove(tag);
else
@@ -158,7 +158,7 @@ bool CodeGenerator::removeCodeDocument ( CodeDocument * remove_object ) {
/**
* Get the list of CodeDocument objects held by m_codedocumentVector
- * @return QPtrList<CodeDocument *> list of CodeDocument objects held by
+ * @return TQPtrList<CodeDocument *> list of CodeDocument objects held by
* m_codedocumentVector
*/
CodeDocumentList * CodeGenerator::getCodeDocumentList ( ) {
@@ -166,7 +166,7 @@ CodeDocumentList * CodeGenerator::getCodeDocumentList ( ) {
}
// the vanilla version
-CodeViewerDialog * CodeGenerator::getCodeViewerDialog ( QWidget* parent, CodeDocument *doc,
+CodeViewerDialog * CodeGenerator::getCodeViewerDialog ( TQWidget* parent, CodeDocument *doc,
Settings::CodeViewerState state)
{
return new CodeViewerDialog(parent, doc, state);
@@ -175,31 +175,31 @@ CodeViewerDialog * CodeGenerator::getCodeViewerDialog ( QWidget* parent, CodeDoc
// Other methods
//
-void CodeGenerator::loadFromXMI (QDomElement & qElement ) {
+void CodeGenerator::loadFromXMI (TQDomElement & qElement ) {
// don't do anything for simple (compatability) code generators
if(dynamic_cast<SimpleCodeGenerator*>(this))
return;
//now look for our particular child element
- QDomNode node = qElement.firstChild();
- QDomElement element = node.toElement();
- QString langType = Model_Utils::progLangToString( getLanguage() );
+ TQDomNode node = qElement.firstChild();
+ TQDomElement element = node.toElement();
+ TQString langType = Model_Utils::progLangToString( getLanguage() );
if (qElement.tagName() != "codegenerator"
|| qElement.attribute("language", "UNKNOWN") != langType)
return;
// got our code generator element, now load
// codedocuments
- QDomNode codeDocNode = qElement.firstChild();
- QDomElement codeDocElement = codeDocNode.toElement();
+ TQDomNode codeDocNode = qElement.firstChild();
+ TQDomElement codeDocElement = codeDocNode.toElement();
while( !codeDocElement.isNull() ) {
- QString docTag = codeDocElement.tagName();
+ TQString docTag = codeDocElement.tagName();
if( docTag == "codedocument" ||
docTag == "classifiercodedocument"
) {
- QString id = codeDocElement.attribute( "id", "-1" );
+ TQString id = codeDocElement.attribute( "id", "-1" );
CodeDocument * codeDoc = findCodeDocumentByID(id);
if(codeDoc)
codeDoc->loadFromXMI(codeDocElement);
@@ -214,9 +214,9 @@ void CodeGenerator::loadFromXMI (QDomElement & qElement ) {
}
}
-void CodeGenerator::saveToXMI ( QDomDocument & doc, QDomElement & root ) {
- QString langType = Model_Utils::progLangToString( getLanguage() );
- QDomElement docElement = doc.createElement( "codegenerator" );
+void CodeGenerator::saveToXMI ( TQDomDocument & doc, TQDomElement & root ) {
+ TQString langType = Model_Utils::progLangToString( getLanguage() );
+ TQDomElement docElement = doc.createElement( "codegenerator" );
docElement.setAttribute("language",langType);
CodeDocumentList * docList = getCodeDocumentList();
@@ -343,11 +343,11 @@ void CodeGenerator::writeListedCodeDocsToFile ( CodeDocumentList * docs ) {
// we only write the document, if so requested
if(doc->getWriteOutCode())
{
- QString filename = findFileName(doc);
+ TQString filename = findFileName(doc);
// check that we may open that file for writing
- QFile file;
+ TQFile file;
if ( openFile(file,filename) ) {
- QTextStream stream(&file);
+ TQTextStream stream(&file);
stream<<doc->toString()<<endl;
file.close();
codeGenSuccess = true; // we wrote the code OK
@@ -377,7 +377,7 @@ CodeDocument * CodeGenerator::newCodeDocument ( ) {
* @param file
*/
-QString CodeGenerator::getHeadingFile( const QString &file ) {
+TQString CodeGenerator::getHeadingFile( const TQString &file ) {
return UMLApp::app()->getCommonPolicy()->getHeadingFile(file);
}
@@ -386,11 +386,11 @@ QString CodeGenerator::getHeadingFile( const QString &file ) {
* @param codeDoc
* @param name
*/
-QString CodeGenerator::overwritableName(const QString& name, const QString &extension ) {
+TQString CodeGenerator::overwritableName(const TQString& name, const TQString &extension ) {
CodeGenerationPolicy *pol = UMLApp::app()->getCommonPolicy();
- QDir outputDirectory = pol->getOutputDirectory();
- QString filename = name + extension;
+ TQDir outputDirectory = pol->getOutputDirectory();
+ TQString filename = name + extension;
if (!outputDirectory.exists(filename)) {
return filename;
@@ -416,7 +416,7 @@ QString CodeGenerator::overwritableName(const QString& name, const QString &exte
case KDialogBase::No: //generate similar name
suffix = 1;
while (1) {
- filename = name + "__" + QString::number(suffix) + extension;
+ filename = name + "__" + TQString::number(suffix) + extension;
if (!outputDirectory.exists(filename))
break;
suffix++;
@@ -433,7 +433,7 @@ QString CodeGenerator::overwritableName(const QString& name, const QString &exte
} else {
m_applyToAllRemaining = false;
}
- return QString();
+ return TQString();
break;
}
@@ -441,14 +441,14 @@ QString CodeGenerator::overwritableName(const QString& name, const QString &exte
case CodeGenerationPolicy::Never: //generate similar name
suffix = 1;
while (1) {
- filename = name + "__" + QString::number(suffix) + extension;
+ filename = name + "__" + TQString::number(suffix) + extension;
if (!outputDirectory.exists(filename))
break;
suffix++;
}
break;
case CodeGenerationPolicy::Cancel: //don't output anything
- return QString();
+ return TQString();
break;
}
@@ -461,13 +461,13 @@ QString CodeGenerator::overwritableName(const QString& name, const QString &exte
* @param file
* @param name
*/
-bool CodeGenerator::openFile (QFile & file, const QString &fileName ) {
+bool CodeGenerator::openFile (TQFile & file, const TQString &fileName ) {
//open files for writing.
if(fileName.isEmpty()) {
kWarning() << "cannot find a file name" << endl;
return false;
} else {
- QDir outputDirectory = UMLApp::app()->getCommonPolicy()->getOutputDirectory();
+ TQDir outputDirectory = UMLApp::app()->getCommonPolicy()->getOutputDirectory();
file.setName(outputDirectory.absFilePath(fileName));
if(!file.open(IO_WriteOnly)) {
KMessageBox::sorry(0,i18n("Cannot open file %1 for writing. Please make sure the folder exists and you have permissions to write to it.").arg(file.name()),i18n("Cannot Open File"));
@@ -483,23 +483,23 @@ bool CodeGenerator::openFile (QFile & file, const QString &fileName ) {
* @return QString
* @param name
*/
-QString CodeGenerator::cleanName ( const QString &name ) {
- QString retval = name;
- retval.replace(QRegExp("\\W"), "_");
+TQString CodeGenerator::cleanName ( const TQString &name ) {
+ TQString retval = name;
+ retval.replace(TQRegExp("\\W"), "_");
return retval;
}
-QString CodeGenerator::findFileName ( CodeDocument * codeDocument ) {
+TQString CodeGenerator::findFileName ( CodeDocument * codeDocument ) {
//else, determine the "natural" file name
- QString name;
+ TQString name;
// Get the path name
- QString path = codeDocument->getPath();
+ TQString path = codeDocument->getPath();
// if path is given add this as a directory to the file name
if (!path.isEmpty()) {
- path.replace(QRegExp("::"), "/"); // Simple hack!
+ path.replace(TQRegExp("::"), "/"); // Simple hack!
name = path + '/' + codeDocument->getFileName();
path = '/' + path;
} else {
@@ -507,22 +507,22 @@ QString CodeGenerator::findFileName ( CodeDocument * codeDocument ) {
}
// Convert all "::" to "/" : Platform-specific path separator
- name.replace(QRegExp("::"), "/"); // Simple hack!
+ name.replace(TQRegExp("::"), "/"); // Simple hack!
// if a path name exists check the existence of the path directory
if (!path.isEmpty()) {
- QDir outputDirectory = UMLApp::app()->getCommonPolicy()->getOutputDirectory();
- QDir pathDir(outputDirectory.absPath() + path);
+ TQDir outputDirectory = UMLApp::app()->getCommonPolicy()->getOutputDirectory();
+ TQDir pathDir(outputDirectory.absPath() + path);
// does our complete output directory exist yet? if not, try to create it
if (!pathDir.exists())
{
// ugh. dir separator here is UNIX specific..
- QStringList dirs = QStringList::split("/",pathDir.absPath());
- QString currentDir = "";
+ TQStringList dirs = TQStringList::split("/",pathDir.absPath());
+ TQString currentDir = "";
- QStringList::iterator end(dirs.end());
- for (QStringList::iterator dir(dirs.begin()); dir != end; ++dir)
+ TQStringList::iterator end(dirs.end());
+ for (TQStringList::iterator dir(dirs.begin()); dir != end; ++dir)
{
currentDir += '/' + *dir;
if (! (pathDir.exists(currentDir)
@@ -539,7 +539,7 @@ QString CodeGenerator::findFileName ( CodeDocument * codeDocument ) {
}
name.simplifyWhiteSpace();
- name.replace(QRegExp(" "),"_");
+ name.replace(TQRegExp(" "),"_");
return overwritableName( name, codeDocument->getFileExtension() );
}
@@ -627,14 +627,14 @@ void CodeGenerator::findObjectsRelated(UMLClassifier *c, UMLPackageList &cList)
* @param lineprefix
* @param linewidth
*/
-QString CodeGenerator::formatDoc(const QString &text, const QString &linePrefix, int lineWidth) {
- QString output;
-
- const QString endLine = UMLApp::app()->getCommonPolicy()->getNewLineEndingChars();
- QStringList lines = QStringList::split(endLine, text);
- for (QStringList::ConstIterator lit = lines.begin(); lit != lines.end(); ++lit) {
- QString input = *lit;
- input.remove( QRegExp("\\s+$") );
+TQString CodeGenerator::formatDoc(const TQString &text, const TQString &linePrefix, int lineWidth) {
+ TQString output;
+
+ const TQString endLine = UMLApp::app()->getCommonPolicy()->getNewLineEndingChars();
+ TQStringList lines = TQStringList::split(endLine, text);
+ for (TQStringList::ConstIterator lit = lines.begin(); lit != lines.end(); ++lit) {
+ TQString input = *lit;
+ input.remove( TQRegExp("\\s+$") );
if (input.length() < (uint)lineWidth) {
output += linePrefix + input + endLine;
continue;
@@ -669,13 +669,13 @@ void CodeGenerator::initFields() {
void CodeGenerator::connect_newcodegen_slots() {
UMLDoc *doc = UMLApp::app()->getDocument();
- connect(doc, SIGNAL(sigObjectCreated(UMLObject*)),
- this, SLOT(checkAddUMLObject(UMLObject*)));
- connect(doc, SIGNAL(sigObjectRemoved(UMLObject*)),
- this, SLOT(checkRemoveUMLObject(UMLObject*)));
+ connect(doc, TQT_SIGNAL(sigObjectCreated(UMLObject*)),
+ this, TQT_SLOT(checkAddUMLObject(UMLObject*)));
+ connect(doc, TQT_SIGNAL(sigObjectRemoved(UMLObject*)),
+ this, TQT_SLOT(checkRemoveUMLObject(UMLObject*)));
CodeGenerationPolicy *commonPolicy = UMLApp::app()->getCommonPolicy();
- connect(commonPolicy, SIGNAL(modifiedCodeContent()),
- this, SLOT(syncCodeToDocument()));
+ connect(commonPolicy, TQT_SIGNAL(modifiedCodeContent()),
+ this, TQT_SLOT(syncCodeToDocument()));
}
// these are utility methods for accessing the default
@@ -697,20 +697,20 @@ bool CodeGenerator::forceSections() const {
return UMLApp::app()->getCommonPolicy()->getCodeVerboseSectionComments();
}
-QStringList CodeGenerator::defaultDatatypes() {
- return QStringList();
+TQStringList CodeGenerator::defaultDatatypes() {
+ return TQStringList();
//empty by default, override in your code generator
}
-bool CodeGenerator::isReservedKeyword(const QString & keyword) {
+bool CodeGenerator::isReservedKeyword(const TQString & keyword) {
- const QStringList keywords = reservedKeywords();
+ const TQStringList keywords = reservedKeywords();
return keywords.contains(keyword);
}
-const QStringList CodeGenerator::reservedKeywords() const {
- static QStringList emptyList;
+const TQStringList CodeGenerator::reservedKeywords() const {
+ static TQStringList emptyList;
return emptyList;
}