From e1f0110799282020eba5dac4a1a7bf27a6187f59 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Fri, 28 Sep 2018 20:41:02 +0900 Subject: Fixed FTBFS caused by qt->tqt renaming. Signed-off-by: Michele Calgaro --- languages/cpp/qtdesignercppintegration.cpp | 218 --------------------- languages/cpp/qtdesignercppintegration.h | 41 ---- languages/cpp/tqtdesignercppintegration.cpp | 218 +++++++++++++++++++++ languages/cpp/tqtdesignercppintegration.h | 41 ++++ .../designer_integration/qtdesignerintegration.cpp | 195 ------------------ .../designer_integration/qtdesignerintegration.h | 81 -------- .../tqtdesignerintegration.cpp | 195 ++++++++++++++++++ .../designer_integration/tqtdesignerintegration.h | 81 ++++++++ languages/python/qtdesignerpythonintegration.cpp | 97 --------- languages/python/qtdesignerpythonintegration.h | 38 ---- languages/python/tqtdesignerpythonintegration.cpp | 97 +++++++++ languages/python/tqtdesignerpythonintegration.h | 38 ++++ languages/ruby/qtdesignerrubyintegration.cpp | 93 --------- languages/ruby/qtdesignerrubyintegration.h | 36 ---- languages/ruby/tqtdesignerrubyintegration.cpp | 93 +++++++++ languages/ruby/tqtdesignerrubyintegration.h | 36 ++++ 16 files changed, 799 insertions(+), 799 deletions(-) delete mode 100644 languages/cpp/qtdesignercppintegration.cpp delete mode 100644 languages/cpp/qtdesignercppintegration.h create mode 100644 languages/cpp/tqtdesignercppintegration.cpp create mode 100644 languages/cpp/tqtdesignercppintegration.h delete mode 100644 languages/lib/designer_integration/qtdesignerintegration.cpp delete mode 100644 languages/lib/designer_integration/qtdesignerintegration.h create mode 100644 languages/lib/designer_integration/tqtdesignerintegration.cpp create mode 100644 languages/lib/designer_integration/tqtdesignerintegration.h delete mode 100644 languages/python/qtdesignerpythonintegration.cpp delete mode 100644 languages/python/qtdesignerpythonintegration.h create mode 100644 languages/python/tqtdesignerpythonintegration.cpp create mode 100644 languages/python/tqtdesignerpythonintegration.h delete mode 100644 languages/ruby/qtdesignerrubyintegration.cpp delete mode 100644 languages/ruby/qtdesignerrubyintegration.h create mode 100644 languages/ruby/tqtdesignerrubyintegration.cpp create mode 100644 languages/ruby/tqtdesignerrubyintegration.h diff --git a/languages/cpp/qtdesignercppintegration.cpp b/languages/cpp/qtdesignercppintegration.cpp deleted file mode 100644 index 21db2b63..00000000 --- a/languages/cpp/qtdesignercppintegration.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/*************************************************************************** -* Copyright (C) 2004 by Alexander Dymo * -* adymo@mksat.net * -* Portions Copyright (C) 2003 Roberto Raggi (roberto@kdevelop.org) * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * -***************************************************************************/ -#include "tqtdesignercppintegration.h" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "backgroundparser.h" -#include "cppsupportpart.h" -#include "codemodel_utils.h" -#include "implementationwidget.h" - -QtDesignerCppIntegration::QtDesignerCppIntegration( KDevLanguageSupport *part, - ImplementationWidget *impl ) -: QtDesignerIntegration( part, impl, true, 0 ) -{} - -void QtDesignerCppIntegration::addFunctionToClass( KInterfaceDesigner::Function function, ClassDom klass ) -{ - m_part->partController() ->editDocument( KURL( klass->fileName() ) ); - KTextEditor::EditInterface* editIface = dynamic_cast( m_part->partController() ->activePart() ); - if ( !editIface ) - { - /// @todo show messagebox - // TQDialog::accept(); - return ; - } - - int line, column; - klass->getEndPosition( &line, &column ); - - // compute the insertion point map - TQMap > points; - - const FunctionList functionList = klass->functionList(); - for ( FunctionList::ConstIterator it = functionList.begin(); it != functionList.end(); ++it ) - { - int funEndLine, funEndColumn; - ( *it ) ->getEndPosition( &funEndLine, &funEndColumn ); - TQString access = accessID( *it ); - TQPair funEndPoint = tqMakePair( funEndLine, funEndColumn ); - - if ( !points.contains( access ) || points[ access ] < funEndPoint ) - { - points[ access ] = funEndPoint; - } - } - - int insertedLine = 0; - - TQString access = function.access + ( function.type == KInterfaceDesigner::ftTQtSlot ? " slots" : "" ); - - TQString str = function.returnType + " " + function.function; - if ( function.specifier == "virtual" ) - str = "virtual " + str; - else if ( function.specifier == "pure virtual" ) - str = "virtual " + str + " = 0"; - else if ( function.specifier == "static" ) - str = "static " + str; - str += ";\n"; - str = " " + str; - - TQPair pt; - if ( points.contains( access ) ) - { - pt = points[ access ]; - } - else - { - str.prepend( access + ":\n" ); - points[ access ] = tqMakePair( line - 1, 0 ); - pt = points[ access ]; // end of class declaration - } - - editIface->insertText( pt.first + insertedLine + 1, 0 /*pt.second*/, str ); - insertedLine += str.contains( TQChar( '\n' ) ); - - CppSupportPart *cppPart = dynamic_cast( m_part ); - cppPart->backgroundParser() ->addFile( klass->fileName() ); - - if ( function.specifier == "pure virtual" ) - return ; - - - //implementation - TQString stri = function.returnType + " " + klass->name() + "::" + function.function; - if ( function.specifier == "static" ) - stri = "static " + stri; - stri += "\n{\n}\n"; - stri = "\n" + stri; - - TQFileInfo fi( klass->fileName() ); - TQString implementationFile = fi.absFilePath(); - implementationFile.replace( ".h", ".cpp" ); - - TQFileInfo fileInfo( implementationFile ); - if ( !TQFile::exists( fileInfo.absFilePath() ) ) - { - if ( KDevCreateFile * createFileSupp = m_part->extension( "TDevelop/CreateFile" ) ) - createFileSupp->createNewFile( fileInfo.extension(), fileInfo.dirPath( true ), fileInfo.fileName() ); - } - - m_part->partController() ->editDocument( KURL( implementationFile ) ); - editIface = dynamic_cast( m_part->partController() ->activePart() ); - if ( !editIface ) - return ; - - int atLine = 0, atColumn = 0; - TranslationUnitAST *translationUnit = 0; - ParsedFilePointer p = cppPart->backgroundParser() ->translationUnit( implementationFile ); - if( p ) translationUnit = *p; - if ( translationUnit ) - { - translationUnit->getEndPosition( &atLine, &atColumn ); - kdDebug() << "atLine: " << atLine << endl; - stri = "\n" + stri; - } - else - { - atLine = editIface->numLines(); - line = editIface->numLines(); - while ( line > 0 ) - { - if ( editIface->textLine( line ).isEmpty() ) - { - --line; - continue; - } - else - { - if ( editIface->textLine( line ).contains( TQRegExp( ".*#include .*\\.moc.*" ) ) ) - atLine = line; - break; - } - } - kdDebug() << "atLine (2): " << atLine << endl; - atColumn = 0; - } - - // editIface->insertLine( atLine + 1, TQString::fromLatin1("") ); - kdDebug() << "at line in intg: " << atLine << " atCol: " << atColumn << endl; - kdDebug() << "text: " << stri << endl; - editIface->insertText( atLine, atColumn, stri ); - KTextEditor::View *activeView = dynamic_cast( m_part->partController() ->activePart() ->widget() ); - if ( activeView ) - { - KTextEditor::ViewCursorInterface * cursor = dynamic_cast( activeView ); - if ( cursor ) - cursor->setCursorPositionReal( atLine + 3, 1 ); - } - - cppPart->backgroundParser() ->addFile( implementationFile ); -} - -TQString QtDesignerCppIntegration::accessID( FunctionDom fun ) const -{ - if ( fun->isSignal() ) - return TQString::fromLatin1( "signals" ); - - switch ( fun->access() ) - { - case CodeModelItem::Public: - if ( fun->isSlot() ) - return TQString::fromLatin1( "public slots" ); - return TQString::fromLatin1( "public" ); - - case CodeModelItem::Protected: - if ( fun->isSlot() ) - return TQString::fromLatin1( "protected slots" ); - return TQString::fromLatin1( "protected" ); - - case CodeModelItem::Private: - if ( fun->isSlot() ) - return TQString::fromLatin1( "private slots" ); - return TQString::fromLatin1( "private" ); - } - - return TQString(); -} - -void QtDesignerCppIntegration::processImplementationName( TQString &name ) -{ - name.replace( ".h", ".cpp" ); -} - -#include "tqtdesignercppintegration.moc" - -//kate: indent-mode csands; tab-width 4; space-indent off; diff --git a/languages/cpp/qtdesignercppintegration.h b/languages/cpp/qtdesignercppintegration.h deleted file mode 100644 index 0e63f652..00000000 --- a/languages/cpp/qtdesignercppintegration.h +++ /dev/null @@ -1,41 +0,0 @@ -/*************************************************************************** -* Copyright (C) 2004 by Alexander Dymo * -* adymo@mksat.net * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * -***************************************************************************/ -#ifndef TQTDESIGNERCPPINTEGRATION_H -#define TQTDESIGNERCPPINTEGRATION_H - -#include - -class QtDesignerCppIntegration : public QtDesignerIntegration -{ - Q_OBJECT - -public: - QtDesignerCppIntegration( KDevLanguageSupport *part, ImplementationWidget *impl ); - -protected: - virtual void addFunctionToClass( KInterfaceDesigner::Function function, ClassDom klass ); - TQString accessID( FunctionDom fun ) const; - - virtual void processImplementationName( TQString &name ); -}; - -#endif -// kate: indent-mode csands; tab-width 4; - diff --git a/languages/cpp/tqtdesignercppintegration.cpp b/languages/cpp/tqtdesignercppintegration.cpp new file mode 100644 index 00000000..21db2b63 --- /dev/null +++ b/languages/cpp/tqtdesignercppintegration.cpp @@ -0,0 +1,218 @@ +/*************************************************************************** +* Copyright (C) 2004 by Alexander Dymo * +* adymo@mksat.net * +* Portions Copyright (C) 2003 Roberto Raggi (roberto@kdevelop.org) * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the * +* Free Software Foundation, Inc., * +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * +***************************************************************************/ +#include "tqtdesignercppintegration.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "backgroundparser.h" +#include "cppsupportpart.h" +#include "codemodel_utils.h" +#include "implementationwidget.h" + +QtDesignerCppIntegration::QtDesignerCppIntegration( KDevLanguageSupport *part, + ImplementationWidget *impl ) +: QtDesignerIntegration( part, impl, true, 0 ) +{} + +void QtDesignerCppIntegration::addFunctionToClass( KInterfaceDesigner::Function function, ClassDom klass ) +{ + m_part->partController() ->editDocument( KURL( klass->fileName() ) ); + KTextEditor::EditInterface* editIface = dynamic_cast( m_part->partController() ->activePart() ); + if ( !editIface ) + { + /// @todo show messagebox + // TQDialog::accept(); + return ; + } + + int line, column; + klass->getEndPosition( &line, &column ); + + // compute the insertion point map + TQMap > points; + + const FunctionList functionList = klass->functionList(); + for ( FunctionList::ConstIterator it = functionList.begin(); it != functionList.end(); ++it ) + { + int funEndLine, funEndColumn; + ( *it ) ->getEndPosition( &funEndLine, &funEndColumn ); + TQString access = accessID( *it ); + TQPair funEndPoint = tqMakePair( funEndLine, funEndColumn ); + + if ( !points.contains( access ) || points[ access ] < funEndPoint ) + { + points[ access ] = funEndPoint; + } + } + + int insertedLine = 0; + + TQString access = function.access + ( function.type == KInterfaceDesigner::ftTQtSlot ? " slots" : "" ); + + TQString str = function.returnType + " " + function.function; + if ( function.specifier == "virtual" ) + str = "virtual " + str; + else if ( function.specifier == "pure virtual" ) + str = "virtual " + str + " = 0"; + else if ( function.specifier == "static" ) + str = "static " + str; + str += ";\n"; + str = " " + str; + + TQPair pt; + if ( points.contains( access ) ) + { + pt = points[ access ]; + } + else + { + str.prepend( access + ":\n" ); + points[ access ] = tqMakePair( line - 1, 0 ); + pt = points[ access ]; // end of class declaration + } + + editIface->insertText( pt.first + insertedLine + 1, 0 /*pt.second*/, str ); + insertedLine += str.contains( TQChar( '\n' ) ); + + CppSupportPart *cppPart = dynamic_cast( m_part ); + cppPart->backgroundParser() ->addFile( klass->fileName() ); + + if ( function.specifier == "pure virtual" ) + return ; + + + //implementation + TQString stri = function.returnType + " " + klass->name() + "::" + function.function; + if ( function.specifier == "static" ) + stri = "static " + stri; + stri += "\n{\n}\n"; + stri = "\n" + stri; + + TQFileInfo fi( klass->fileName() ); + TQString implementationFile = fi.absFilePath(); + implementationFile.replace( ".h", ".cpp" ); + + TQFileInfo fileInfo( implementationFile ); + if ( !TQFile::exists( fileInfo.absFilePath() ) ) + { + if ( KDevCreateFile * createFileSupp = m_part->extension( "TDevelop/CreateFile" ) ) + createFileSupp->createNewFile( fileInfo.extension(), fileInfo.dirPath( true ), fileInfo.fileName() ); + } + + m_part->partController() ->editDocument( KURL( implementationFile ) ); + editIface = dynamic_cast( m_part->partController() ->activePart() ); + if ( !editIface ) + return ; + + int atLine = 0, atColumn = 0; + TranslationUnitAST *translationUnit = 0; + ParsedFilePointer p = cppPart->backgroundParser() ->translationUnit( implementationFile ); + if( p ) translationUnit = *p; + if ( translationUnit ) + { + translationUnit->getEndPosition( &atLine, &atColumn ); + kdDebug() << "atLine: " << atLine << endl; + stri = "\n" + stri; + } + else + { + atLine = editIface->numLines(); + line = editIface->numLines(); + while ( line > 0 ) + { + if ( editIface->textLine( line ).isEmpty() ) + { + --line; + continue; + } + else + { + if ( editIface->textLine( line ).contains( TQRegExp( ".*#include .*\\.moc.*" ) ) ) + atLine = line; + break; + } + } + kdDebug() << "atLine (2): " << atLine << endl; + atColumn = 0; + } + + // editIface->insertLine( atLine + 1, TQString::fromLatin1("") ); + kdDebug() << "at line in intg: " << atLine << " atCol: " << atColumn << endl; + kdDebug() << "text: " << stri << endl; + editIface->insertText( atLine, atColumn, stri ); + KTextEditor::View *activeView = dynamic_cast( m_part->partController() ->activePart() ->widget() ); + if ( activeView ) + { + KTextEditor::ViewCursorInterface * cursor = dynamic_cast( activeView ); + if ( cursor ) + cursor->setCursorPositionReal( atLine + 3, 1 ); + } + + cppPart->backgroundParser() ->addFile( implementationFile ); +} + +TQString QtDesignerCppIntegration::accessID( FunctionDom fun ) const +{ + if ( fun->isSignal() ) + return TQString::fromLatin1( "signals" ); + + switch ( fun->access() ) + { + case CodeModelItem::Public: + if ( fun->isSlot() ) + return TQString::fromLatin1( "public slots" ); + return TQString::fromLatin1( "public" ); + + case CodeModelItem::Protected: + if ( fun->isSlot() ) + return TQString::fromLatin1( "protected slots" ); + return TQString::fromLatin1( "protected" ); + + case CodeModelItem::Private: + if ( fun->isSlot() ) + return TQString::fromLatin1( "private slots" ); + return TQString::fromLatin1( "private" ); + } + + return TQString(); +} + +void QtDesignerCppIntegration::processImplementationName( TQString &name ) +{ + name.replace( ".h", ".cpp" ); +} + +#include "tqtdesignercppintegration.moc" + +//kate: indent-mode csands; tab-width 4; space-indent off; diff --git a/languages/cpp/tqtdesignercppintegration.h b/languages/cpp/tqtdesignercppintegration.h new file mode 100644 index 00000000..0e63f652 --- /dev/null +++ b/languages/cpp/tqtdesignercppintegration.h @@ -0,0 +1,41 @@ +/*************************************************************************** +* Copyright (C) 2004 by Alexander Dymo * +* adymo@mksat.net * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the * +* Free Software Foundation, Inc., * +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * +***************************************************************************/ +#ifndef TQTDESIGNERCPPINTEGRATION_H +#define TQTDESIGNERCPPINTEGRATION_H + +#include + +class QtDesignerCppIntegration : public QtDesignerIntegration +{ + Q_OBJECT + +public: + QtDesignerCppIntegration( KDevLanguageSupport *part, ImplementationWidget *impl ); + +protected: + virtual void addFunctionToClass( KInterfaceDesigner::Function function, ClassDom klass ); + TQString accessID( FunctionDom fun ) const; + + virtual void processImplementationName( TQString &name ); +}; + +#endif +// kate: indent-mode csands; tab-width 4; + diff --git a/languages/lib/designer_integration/qtdesignerintegration.cpp b/languages/lib/designer_integration/qtdesignerintegration.cpp deleted file mode 100644 index c401bed1..00000000 --- a/languages/lib/designer_integration/qtdesignerintegration.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2004 by Alexander Dymo * - * adymo@kdevelop.org * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Library General Public License as * - * published by the Free Software Foundation; either version 2 of the * - * License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ -#include "tqtdesignerintegration.h" - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "codemodel_utils.h" -#include "implementationwidget.h" - -QtDesignerIntegration::QtDesignerIntegration(KDevLanguageSupport *part, ImplementationWidget *impl, bool classHasDefinitions, const char* name) - :KDevDesignerIntegration(part, name), m_part(part), m_impl(impl), - m_classHasDefinitions(classHasDefinitions) -{ -} - -QtDesignerIntegration::~QtDesignerIntegration() -{ - delete m_impl; -} - -void QtDesignerIntegration::addFunction(const TQString& formName, KInterfaceDesigner::Function function) -{ - kdDebug() << "QtDesignerIntegration::addFunction: form: " << formName << ", function: " << function.function << endl; - - if (!m_implementations.contains(formName)) - if (!selectImplementation(formName)) - return; - - ClassDom klass = m_implementations[formName]; - if (!klass) - { - KMessageBox::error(0, i18n("Cannot find implementation class for form: %1").arg(formName)); - return; - } - - addFunctionToClass(function, klass); -} - -void QtDesignerIntegration::editFunction(const TQString& formName, KInterfaceDesigner::Function oldFunction, KInterfaceDesigner::Function function) -{ - kdDebug() << "QtDesignerIntegration::editFunction: form: " << formName - << ", old function: " << oldFunction.function - << ", function: " << function.function << endl; -} - -void QtDesignerIntegration::removeFunction(const TQString& formName, KInterfaceDesigner::Function function) -{ - kdDebug() << "QtDesignerIntegration::removeFunction: form: " << formName << ", function: " << function.function << endl; -} - -bool QtDesignerIntegration::selectImplementation(const TQString &formName) -{ - TQFileInfo fi(formName); - if (!fi.exists()) - return false; - - if (m_impl->exec(formName)) - { - m_implementations[formName] = m_impl->selectedClass(); - return true; - } - return false; -} - -void QtDesignerIntegration::loadSettings(TQDomDocument dom, TQString path) -{ - TQDomElement el = DomUtil::elementByPath(dom, path + "/tqtdesigner"); - if (el.isNull()) - return; - TQDomNodeList impls = el.elementsByTagName("implementation"); - for (uint i = 0; i < impls.count(); ++i) - { - TQDomElement el = impls.item(i).toElement(); - if (el.isNull()) - continue; - TQString implementationPath = Relative::File(m_part->project()->projectDirectory(), - el.attribute("implementationpath"), true).urlPath(); - FileDom file = m_part->codeModel()->fileByName(implementationPath); - if (!file) - continue; - ClassList cllist = file->classByName(el.attribute("class")); - TQString uiPath = Relative::File(m_part->project()->projectDirectory(), - el.attribute("path"), true).urlPath(); - if (cllist.count() > 0) - m_implementations[uiPath] = cllist.first(); - } -} - -void QtDesignerIntegration::saveSettings(TQDomDocument dom, TQString path) -{ - kdDebug() << "QtDesignerIntegration::saveSettings" << endl; - TQDomElement el = DomUtil::createElementByPath(dom, path + "/tqtdesigner"); - for (TQMap::const_iterator it = m_implementations.begin(); - it != m_implementations.end(); ++it) - { - TQDomElement il = dom.createElement("implementation"); - el.appendChild(il); - il.setAttribute("path", - Relative::File(m_part->project()->projectDirectory(), it.key()).rurl()); - il.setAttribute("implementationpath", - Relative::File(m_part->project()->projectDirectory(), it.data()->fileName()).rurl()); - il.setAttribute("class", it.data()->name()); - } -} - -void QtDesignerIntegration::openFunction(const TQString &formName, const TQString &functionName) -{ - kdDebug() << "QtDesignerIntegration::openFunction, formName = " << formName - << ", functionName = " << functionName << endl; - TQString fn = functionName; - if (fn.find("(") > 0) - fn.remove(fn.find("("), fn.length()); - - if (!m_implementations[formName]) - return; - - int line = -1, col = -1; - - TQString impl = m_implementations[formName]->fileName(); - processImplementationName(impl); - - if (m_part->codeModel()->hasFile(impl)) - { - if (m_classHasDefinitions) - { - FunctionDefinitionList list = - m_part->codeModel()->fileByName(impl)->functionDefinitionList(); - for (FunctionDefinitionList::const_iterator it = list.begin(); it != list.end(); ++it) - { - if ((*it)->name() == fn) - (*it)->getStartPosition(&line, &col); - } - } - else - { - FunctionList list = - m_part->codeModel()->fileByName(impl)->functionList(); - for (FunctionList::const_iterator it = list.begin(); it != list.end(); ++it) - { - if ((*it)->name() == fn) - (*it)->getStartPosition(&line, &col); - } - } - } - - m_part->partController()->editDocument(KURL(impl), line, col); -} - -void QtDesignerIntegration::processImplementationName(TQString &// name - ) -{ -} - -void QtDesignerIntegration::openSource(const TQString &formName) -{ - if (!m_implementations.contains(formName)) - if (!selectImplementation(formName)) - return; - TQString impl = m_implementations[formName]->fileName(); - processImplementationName(impl); - m_part->partController()->editDocument(KURL(impl), -1, -1); -} - -#include "tqtdesignerintegration.moc" diff --git a/languages/lib/designer_integration/qtdesignerintegration.h b/languages/lib/designer_integration/qtdesignerintegration.h deleted file mode 100644 index f76eecba..00000000 --- a/languages/lib/designer_integration/qtdesignerintegration.h +++ /dev/null @@ -1,81 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2004 by Alexander Dymo * - * adymo@kdevelop.org * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Library General Public License as * - * published by the Free Software Foundation; either version 2 of the * - * License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ -#ifndef TQTDESIGNERINTEGRATION_H -#define TQTDESIGNERINTEGRATION_H - -#include - -#include -#include "kdevdesignerintegration.h" - -class KDevLanguageSupport; -class ImplementationWidget; - -/** -TQt Designer integration base class. -Contains language-independent implementation part of a @ref KDevDesignerIntegration interface. -Ready to use in KDevelop language support plugins. - -Subclasses of this class should reimplement only pure virtual functions in the common case. -*/ -class QtDesignerIntegration : public KDevDesignerIntegration -{ -Q_OBJECT - -public: - QtDesignerIntegration(KDevLanguageSupport *part, ImplementationWidget *impl, - bool classHasDefinitions, const char* name = 0); - virtual ~QtDesignerIntegration(); - -public slots: - virtual void addFunction(const TQString& formName, KInterfaceDesigner::Function function); - virtual void editFunction(const TQString& formName, KInterfaceDesigner::Function oldFunction, KInterfaceDesigner::Function function); - virtual void removeFunction(const TQString& formName, KInterfaceDesigner::Function function); - - virtual void openFunction(const TQString &formName, const TQString &functionName); - - virtual void openSource(const TQString &formName); - - virtual void saveSettings(TQDomDocument dom, TQString path); - virtual void loadSettings(TQDomDocument dom, TQString path); - - bool selectImplementation(const TQString &formName); - -protected: - /**Reimplement this to add a function to a class. This means you need to modify - the source file and add actual code of a function.*/ - virtual void addFunctionToClass(KInterfaceDesigner::Function function, ClassDom klass) = 0; - /**Modifies name to be a name of a implementation file for languages that have - separate files for interface and implementation parts of a class. For example, - C++ language support plugin will do: - @code - name.replace(".h", ".cpp"); - @endcode*/ - virtual void processImplementationName(TQString &name); - - //Form file - derived class name - TQMap m_implementations; - - KDevLanguageSupport *m_part; - ImplementationWidget *m_impl; - bool m_classHasDefinitions; -}; - -#endif diff --git a/languages/lib/designer_integration/tqtdesignerintegration.cpp b/languages/lib/designer_integration/tqtdesignerintegration.cpp new file mode 100644 index 00000000..c401bed1 --- /dev/null +++ b/languages/lib/designer_integration/tqtdesignerintegration.cpp @@ -0,0 +1,195 @@ +/*************************************************************************** + * Copyright (C) 2004 by Alexander Dymo * + * adymo@kdevelop.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 2 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +#include "tqtdesignerintegration.h" + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "codemodel_utils.h" +#include "implementationwidget.h" + +QtDesignerIntegration::QtDesignerIntegration(KDevLanguageSupport *part, ImplementationWidget *impl, bool classHasDefinitions, const char* name) + :KDevDesignerIntegration(part, name), m_part(part), m_impl(impl), + m_classHasDefinitions(classHasDefinitions) +{ +} + +QtDesignerIntegration::~QtDesignerIntegration() +{ + delete m_impl; +} + +void QtDesignerIntegration::addFunction(const TQString& formName, KInterfaceDesigner::Function function) +{ + kdDebug() << "QtDesignerIntegration::addFunction: form: " << formName << ", function: " << function.function << endl; + + if (!m_implementations.contains(formName)) + if (!selectImplementation(formName)) + return; + + ClassDom klass = m_implementations[formName]; + if (!klass) + { + KMessageBox::error(0, i18n("Cannot find implementation class for form: %1").arg(formName)); + return; + } + + addFunctionToClass(function, klass); +} + +void QtDesignerIntegration::editFunction(const TQString& formName, KInterfaceDesigner::Function oldFunction, KInterfaceDesigner::Function function) +{ + kdDebug() << "QtDesignerIntegration::editFunction: form: " << formName + << ", old function: " << oldFunction.function + << ", function: " << function.function << endl; +} + +void QtDesignerIntegration::removeFunction(const TQString& formName, KInterfaceDesigner::Function function) +{ + kdDebug() << "QtDesignerIntegration::removeFunction: form: " << formName << ", function: " << function.function << endl; +} + +bool QtDesignerIntegration::selectImplementation(const TQString &formName) +{ + TQFileInfo fi(formName); + if (!fi.exists()) + return false; + + if (m_impl->exec(formName)) + { + m_implementations[formName] = m_impl->selectedClass(); + return true; + } + return false; +} + +void QtDesignerIntegration::loadSettings(TQDomDocument dom, TQString path) +{ + TQDomElement el = DomUtil::elementByPath(dom, path + "/tqtdesigner"); + if (el.isNull()) + return; + TQDomNodeList impls = el.elementsByTagName("implementation"); + for (uint i = 0; i < impls.count(); ++i) + { + TQDomElement el = impls.item(i).toElement(); + if (el.isNull()) + continue; + TQString implementationPath = Relative::File(m_part->project()->projectDirectory(), + el.attribute("implementationpath"), true).urlPath(); + FileDom file = m_part->codeModel()->fileByName(implementationPath); + if (!file) + continue; + ClassList cllist = file->classByName(el.attribute("class")); + TQString uiPath = Relative::File(m_part->project()->projectDirectory(), + el.attribute("path"), true).urlPath(); + if (cllist.count() > 0) + m_implementations[uiPath] = cllist.first(); + } +} + +void QtDesignerIntegration::saveSettings(TQDomDocument dom, TQString path) +{ + kdDebug() << "QtDesignerIntegration::saveSettings" << endl; + TQDomElement el = DomUtil::createElementByPath(dom, path + "/tqtdesigner"); + for (TQMap::const_iterator it = m_implementations.begin(); + it != m_implementations.end(); ++it) + { + TQDomElement il = dom.createElement("implementation"); + el.appendChild(il); + il.setAttribute("path", + Relative::File(m_part->project()->projectDirectory(), it.key()).rurl()); + il.setAttribute("implementationpath", + Relative::File(m_part->project()->projectDirectory(), it.data()->fileName()).rurl()); + il.setAttribute("class", it.data()->name()); + } +} + +void QtDesignerIntegration::openFunction(const TQString &formName, const TQString &functionName) +{ + kdDebug() << "QtDesignerIntegration::openFunction, formName = " << formName + << ", functionName = " << functionName << endl; + TQString fn = functionName; + if (fn.find("(") > 0) + fn.remove(fn.find("("), fn.length()); + + if (!m_implementations[formName]) + return; + + int line = -1, col = -1; + + TQString impl = m_implementations[formName]->fileName(); + processImplementationName(impl); + + if (m_part->codeModel()->hasFile(impl)) + { + if (m_classHasDefinitions) + { + FunctionDefinitionList list = + m_part->codeModel()->fileByName(impl)->functionDefinitionList(); + for (FunctionDefinitionList::const_iterator it = list.begin(); it != list.end(); ++it) + { + if ((*it)->name() == fn) + (*it)->getStartPosition(&line, &col); + } + } + else + { + FunctionList list = + m_part->codeModel()->fileByName(impl)->functionList(); + for (FunctionList::const_iterator it = list.begin(); it != list.end(); ++it) + { + if ((*it)->name() == fn) + (*it)->getStartPosition(&line, &col); + } + } + } + + m_part->partController()->editDocument(KURL(impl), line, col); +} + +void QtDesignerIntegration::processImplementationName(TQString &// name + ) +{ +} + +void QtDesignerIntegration::openSource(const TQString &formName) +{ + if (!m_implementations.contains(formName)) + if (!selectImplementation(formName)) + return; + TQString impl = m_implementations[formName]->fileName(); + processImplementationName(impl); + m_part->partController()->editDocument(KURL(impl), -1, -1); +} + +#include "tqtdesignerintegration.moc" diff --git a/languages/lib/designer_integration/tqtdesignerintegration.h b/languages/lib/designer_integration/tqtdesignerintegration.h new file mode 100644 index 00000000..f76eecba --- /dev/null +++ b/languages/lib/designer_integration/tqtdesignerintegration.h @@ -0,0 +1,81 @@ +/*************************************************************************** + * Copyright (C) 2004 by Alexander Dymo * + * adymo@kdevelop.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 2 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +#ifndef TQTDESIGNERINTEGRATION_H +#define TQTDESIGNERINTEGRATION_H + +#include + +#include +#include "kdevdesignerintegration.h" + +class KDevLanguageSupport; +class ImplementationWidget; + +/** +TQt Designer integration base class. +Contains language-independent implementation part of a @ref KDevDesignerIntegration interface. +Ready to use in KDevelop language support plugins. + +Subclasses of this class should reimplement only pure virtual functions in the common case. +*/ +class QtDesignerIntegration : public KDevDesignerIntegration +{ +Q_OBJECT + +public: + QtDesignerIntegration(KDevLanguageSupport *part, ImplementationWidget *impl, + bool classHasDefinitions, const char* name = 0); + virtual ~QtDesignerIntegration(); + +public slots: + virtual void addFunction(const TQString& formName, KInterfaceDesigner::Function function); + virtual void editFunction(const TQString& formName, KInterfaceDesigner::Function oldFunction, KInterfaceDesigner::Function function); + virtual void removeFunction(const TQString& formName, KInterfaceDesigner::Function function); + + virtual void openFunction(const TQString &formName, const TQString &functionName); + + virtual void openSource(const TQString &formName); + + virtual void saveSettings(TQDomDocument dom, TQString path); + virtual void loadSettings(TQDomDocument dom, TQString path); + + bool selectImplementation(const TQString &formName); + +protected: + /**Reimplement this to add a function to a class. This means you need to modify + the source file and add actual code of a function.*/ + virtual void addFunctionToClass(KInterfaceDesigner::Function function, ClassDom klass) = 0; + /**Modifies name to be a name of a implementation file for languages that have + separate files for interface and implementation parts of a class. For example, + C++ language support plugin will do: + @code + name.replace(".h", ".cpp"); + @endcode*/ + virtual void processImplementationName(TQString &name); + + //Form file - derived class name + TQMap m_implementations; + + KDevLanguageSupport *m_part; + ImplementationWidget *m_impl; + bool m_classHasDefinitions; +}; + +#endif diff --git a/languages/python/qtdesignerpythonintegration.cpp b/languages/python/qtdesignerpythonintegration.cpp deleted file mode 100644 index e1a4f0b1..00000000 --- a/languages/python/qtdesignerpythonintegration.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Alexander Dymo * - * adymo@kdevelop.org * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ -#include "tqtdesignerpythonintegration.h" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "codemodel_utils.h" -#include "implementationwidget.h" - -QtDesignerPythonIntegration::QtDesignerPythonIntegration(KDevLanguageSupport* part, ImplementationWidget* impl) - :QtDesignerIntegration(part, impl, false, 0) -{ -} - - -QtDesignerPythonIntegration::~QtDesignerPythonIntegration() -{ -} - - -void QtDesignerPythonIntegration::addFunctionToClass(KInterfaceDesigner::Function function, ClassDom klass) -{ - m_part->partController()->editDocument( KURL( klass->fileName() ) ); - KTextEditor::EditInterface* editIface = dynamic_cast( m_part->partController()->activePart() ); - if( !editIface ){ - /// @todo show messagebox -// TQDialog::accept(); - return; - } - - kdDebug(9014) << "===============" << endl; - - int line, column; - klass->getStartPosition( &line, &column ); - - // compute the insertion point - TQPair point; - point.first = line + 1; - point.second = column; - - const FunctionList functionList = klass->functionList(); - if (functionList.count() > 0) - { - int funEndLine, funEndColumn; - functionList.first()->getEndPosition(&funEndLine, &funEndColumn); - point.second = funEndColumn; - } - - TQString func = function.function; - func.replace("()", ""); - TQString str = " def " + func + "(self):\n\n"; - - kdDebug(9014) << "insert " << str << " into " << point.first << endl; - - editIface->insertText(point.first, 0 /*pt.second*/, str ); - - KTextEditor::View *activeView = dynamic_cast( m_part->partController()->activePart()->widget() ); - if (activeView) - { - KTextEditor::ViewCursorInterface* cursor = dynamic_cast(activeView ); - if (cursor) - cursor->setCursorPositionReal(point.first, 4); - } -} - -#include "tqtdesignerpythonintegration.moc" diff --git a/languages/python/qtdesignerpythonintegration.h b/languages/python/qtdesignerpythonintegration.h deleted file mode 100644 index 9878acad..00000000 --- a/languages/python/qtdesignerpythonintegration.h +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Alexander Dymo * - * adymo@kdevelop.org * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ -#ifndef TQTDESIGNERPYTHONINTEGRATION_H -#define TQTDESIGNERPYTHONINTEGRATION_H - -#include - -class QtDesignerPythonIntegration : public QtDesignerIntegration -{ -Q_OBJECT - -public: - QtDesignerPythonIntegration(KDevLanguageSupport* part, ImplementationWidget* impl); - - ~QtDesignerPythonIntegration(); - - virtual void addFunctionToClass(KInterfaceDesigner::Function function, ClassDom klass); - -}; - -#endif diff --git a/languages/python/tqtdesignerpythonintegration.cpp b/languages/python/tqtdesignerpythonintegration.cpp new file mode 100644 index 00000000..e1a4f0b1 --- /dev/null +++ b/languages/python/tqtdesignerpythonintegration.cpp @@ -0,0 +1,97 @@ +/*************************************************************************** + * Copyright (C) 2005 by Alexander Dymo * + * adymo@kdevelop.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +#include "tqtdesignerpythonintegration.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "codemodel_utils.h" +#include "implementationwidget.h" + +QtDesignerPythonIntegration::QtDesignerPythonIntegration(KDevLanguageSupport* part, ImplementationWidget* impl) + :QtDesignerIntegration(part, impl, false, 0) +{ +} + + +QtDesignerPythonIntegration::~QtDesignerPythonIntegration() +{ +} + + +void QtDesignerPythonIntegration::addFunctionToClass(KInterfaceDesigner::Function function, ClassDom klass) +{ + m_part->partController()->editDocument( KURL( klass->fileName() ) ); + KTextEditor::EditInterface* editIface = dynamic_cast( m_part->partController()->activePart() ); + if( !editIface ){ + /// @todo show messagebox +// TQDialog::accept(); + return; + } + + kdDebug(9014) << "===============" << endl; + + int line, column; + klass->getStartPosition( &line, &column ); + + // compute the insertion point + TQPair point; + point.first = line + 1; + point.second = column; + + const FunctionList functionList = klass->functionList(); + if (functionList.count() > 0) + { + int funEndLine, funEndColumn; + functionList.first()->getEndPosition(&funEndLine, &funEndColumn); + point.second = funEndColumn; + } + + TQString func = function.function; + func.replace("()", ""); + TQString str = " def " + func + "(self):\n\n"; + + kdDebug(9014) << "insert " << str << " into " << point.first << endl; + + editIface->insertText(point.first, 0 /*pt.second*/, str ); + + KTextEditor::View *activeView = dynamic_cast( m_part->partController()->activePart()->widget() ); + if (activeView) + { + KTextEditor::ViewCursorInterface* cursor = dynamic_cast(activeView ); + if (cursor) + cursor->setCursorPositionReal(point.first, 4); + } +} + +#include "tqtdesignerpythonintegration.moc" diff --git a/languages/python/tqtdesignerpythonintegration.h b/languages/python/tqtdesignerpythonintegration.h new file mode 100644 index 00000000..9878acad --- /dev/null +++ b/languages/python/tqtdesignerpythonintegration.h @@ -0,0 +1,38 @@ +/*************************************************************************** + * Copyright (C) 2005 by Alexander Dymo * + * adymo@kdevelop.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +#ifndef TQTDESIGNERPYTHONINTEGRATION_H +#define TQTDESIGNERPYTHONINTEGRATION_H + +#include + +class QtDesignerPythonIntegration : public QtDesignerIntegration +{ +Q_OBJECT + +public: + QtDesignerPythonIntegration(KDevLanguageSupport* part, ImplementationWidget* impl); + + ~QtDesignerPythonIntegration(); + + virtual void addFunctionToClass(KInterfaceDesigner::Function function, ClassDom klass); + +}; + +#endif diff --git a/languages/ruby/qtdesignerrubyintegration.cpp b/languages/ruby/qtdesignerrubyintegration.cpp deleted file mode 100644 index 0b227c30..00000000 --- a/languages/ruby/qtdesignerrubyintegration.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2004 by Alexander Dymo * - * adymo@mksat.net * - * Portions Copyright (C) 2003 Roberto Raggi (roberto@kdevelop.org) * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ -#include "tqtdesignerrubyintegration.h" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "codemodel_utils.h" -#include "implementationwidget.h" - -QtDesignerRubyIntegration::QtDesignerRubyIntegration(KDevLanguageSupport *part, - ImplementationWidget *impl) - :QtDesignerIntegration(part, impl, false, 0) -{ -} - -void QtDesignerRubyIntegration::addFunctionToClass(KInterfaceDesigner::Function function, ClassDom klass) -{ - m_part->partController()->editDocument( KURL( klass->fileName() ) ); - KTextEditor::EditInterface* editIface = dynamic_cast( m_part->partController()->activePart() ); - if( !editIface ){ - /// @todo show messagebox -// TQDialog::accept(); - return; - } - - kdDebug() << "===============" << endl; - - int line, column; - klass->getStartPosition( &line, &column ); - - // compute the insertion point - TQPair point; - point.first = line + 1; - point.second = column; - - const FunctionList functionList = klass->functionList(); - if (functionList.count() > 0) - { - int funEndLine, funEndColumn; - functionList.first()->getEndPosition(&funEndLine, &funEndColumn); - point.second = funEndColumn; - } - - TQString str = function.function; - str += "\n \n end\n\n"; - str = " def " + str; - - kdDebug() << "insert " << str << " into " << point.first << endl; - - editIface->insertText(point.first, 0 /*pt.second*/, str ); - - KTextEditor::View *activeView = dynamic_cast( m_part->partController()->activePart()->widget() ); - if (activeView) - { - KTextEditor::ViewCursorInterface* cursor = dynamic_cast(activeView ); - if (cursor) - cursor->setCursorPositionReal(point.first, 4); - } -} - -#include "tqtdesignerrubyintegration.moc" diff --git a/languages/ruby/qtdesignerrubyintegration.h b/languages/ruby/qtdesignerrubyintegration.h deleted file mode 100644 index be89e490..00000000 --- a/languages/ruby/qtdesignerrubyintegration.h +++ /dev/null @@ -1,36 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2004 by Alexander Dymo * - * adymo@mksat.net * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ -#ifndef TQTDESIGNERRUBYINTEGRATION_H -#define TQTDESIGNERRUBYINTEGRATION_H - -#include - -class QtDesignerRubyIntegration : public QtDesignerIntegration -{ -Q_OBJECT - -public: - QtDesignerRubyIntegration(KDevLanguageSupport *part, ImplementationWidget *impl); - -protected: - void addFunctionToClass(KInterfaceDesigner::Function function, ClassDom klass); -}; - -#endif diff --git a/languages/ruby/tqtdesignerrubyintegration.cpp b/languages/ruby/tqtdesignerrubyintegration.cpp new file mode 100644 index 00000000..0b227c30 --- /dev/null +++ b/languages/ruby/tqtdesignerrubyintegration.cpp @@ -0,0 +1,93 @@ +/*************************************************************************** + * Copyright (C) 2004 by Alexander Dymo * + * adymo@mksat.net * + * Portions Copyright (C) 2003 Roberto Raggi (roberto@kdevelop.org) * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +#include "tqtdesignerrubyintegration.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "codemodel_utils.h" +#include "implementationwidget.h" + +QtDesignerRubyIntegration::QtDesignerRubyIntegration(KDevLanguageSupport *part, + ImplementationWidget *impl) + :QtDesignerIntegration(part, impl, false, 0) +{ +} + +void QtDesignerRubyIntegration::addFunctionToClass(KInterfaceDesigner::Function function, ClassDom klass) +{ + m_part->partController()->editDocument( KURL( klass->fileName() ) ); + KTextEditor::EditInterface* editIface = dynamic_cast( m_part->partController()->activePart() ); + if( !editIface ){ + /// @todo show messagebox +// TQDialog::accept(); + return; + } + + kdDebug() << "===============" << endl; + + int line, column; + klass->getStartPosition( &line, &column ); + + // compute the insertion point + TQPair point; + point.first = line + 1; + point.second = column; + + const FunctionList functionList = klass->functionList(); + if (functionList.count() > 0) + { + int funEndLine, funEndColumn; + functionList.first()->getEndPosition(&funEndLine, &funEndColumn); + point.second = funEndColumn; + } + + TQString str = function.function; + str += "\n \n end\n\n"; + str = " def " + str; + + kdDebug() << "insert " << str << " into " << point.first << endl; + + editIface->insertText(point.first, 0 /*pt.second*/, str ); + + KTextEditor::View *activeView = dynamic_cast( m_part->partController()->activePart()->widget() ); + if (activeView) + { + KTextEditor::ViewCursorInterface* cursor = dynamic_cast(activeView ); + if (cursor) + cursor->setCursorPositionReal(point.first, 4); + } +} + +#include "tqtdesignerrubyintegration.moc" diff --git a/languages/ruby/tqtdesignerrubyintegration.h b/languages/ruby/tqtdesignerrubyintegration.h new file mode 100644 index 00000000..be89e490 --- /dev/null +++ b/languages/ruby/tqtdesignerrubyintegration.h @@ -0,0 +1,36 @@ +/*************************************************************************** + * Copyright (C) 2004 by Alexander Dymo * + * adymo@mksat.net * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +#ifndef TQTDESIGNERRUBYINTEGRATION_H +#define TQTDESIGNERRUBYINTEGRATION_H + +#include + +class QtDesignerRubyIntegration : public QtDesignerIntegration +{ +Q_OBJECT + +public: + QtDesignerRubyIntegration(KDevLanguageSupport *part, ImplementationWidget *impl); + +protected: + void addFunctionToClass(KInterfaceDesigner::Function function, ClassDom klass); +}; + +#endif -- cgit v1.2.3