diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch) | |
tree | acaf47eb0fa12142d3896416a69e74cbf5a72242 /languages/lib | |
download | tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.tar.gz tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'languages/lib')
19 files changed, 1666 insertions, 0 deletions
diff --git a/languages/lib/Makefile.am b/languages/lib/Makefile.am new file mode 100644 index 00000000..2bb7ebfa --- /dev/null +++ b/languages/lib/Makefile.am @@ -0,0 +1,6 @@ +INCLUDES = +METASOURCES = AUTO +SUBDIRS = interfaces debugger designer_integration + +DOXYGEN_EMPTY = YES +include ../../Doxyfile.am diff --git a/languages/lib/debugger/Mainpage.dox b/languages/lib/debugger/Mainpage.dox new file mode 100644 index 00000000..2e141fd3 --- /dev/null +++ b/languages/lib/debugger/Mainpage.dox @@ -0,0 +1,36 @@ +/** +@mainpage The KDevelop %Debugger Support Library + +This library contains classes to implement debugger support for a programming language. + +<b>Link with</b>: -llang_debugger + +<b>Include path</b>: -I\$(kde_includes)/kdevelop/languages/debugger + +\section usingdebugger Where to use this library + +Each debugger support plugin must interact with an editor to set breakpoints, +jump to execution points, etc. This kind of interaction is implemented in +@ref Debugger class. Your debugger support plugin just need to create +an instance of @ref Debugger class and connect its signals, for example: +@code +m_debugger = new Debugger( partController() ); + +connect( m_debugger, SIGNAL(toggledBreakpoint(const QString &, int)), + debuggerBreakpointWidget, SLOT(slotToggleBreakpoint(const QString &, int)) ); +connect( m_debugger, SIGNAL(editedBreakpoint(const QString &, int)), + debuggerBreakpointWidget, SLOT(slotEditBreakpoint(const QString &, int)) ); +connect( m_debugger, SIGNAL(toggledBreakpointEnabled(const QString &, int)), + debuggerBreakpointWidget, SLOT(slotToggleBreakpointEnabled(const QString &, int)) ); +@endcode +Then m_debugger instance can be used for example, to jump to the execution point: +@code +m_debugger->gotoExecutionPoint(fileUrl, lineNumber); +@endcode +or to set a breakpoint: +@code +m_debugger->setBreakpoint(fileName, lineNumber, id, enabled, pending); +@endcode + +*/ + diff --git a/languages/lib/debugger/Makefile.am b/languages/lib/debugger/Makefile.am new file mode 100644 index 00000000..cdeee852 --- /dev/null +++ b/languages/lib/debugger/Makefile.am @@ -0,0 +1,13 @@ +INCLUDES = -I$(top_srcdir)/lib/interfaces $(all_includes) +METASOURCES = AUTO +lib_LTLIBRARIES = liblang_debugger.la +liblang_debugger_la_LDFLAGS = $(all_libraries) +liblang_debugger_la_LIBADD = $(LIB_QT) $(LIB_KDECORE) $(LIB_KPARTS) -lktexteditor +liblang_debugger_la_SOURCES = kdevdebugger.cpp debugger.cpp +langincludedirdir = $(includedir)/kdevelop/languages/debugger +langincludedir_HEADERS = debugger.h kdevdebugger.h + +DOXYGEN_REFERENCES = dcop interfaces kdecore kdefx kdeui khtml kmdi kio kjs kparts kutils kdevinterfaces kdevutil +DOXYGEN_PROJECTNAME = KDevelop Debugger Support Library +DOXYGEN_DOCDIRPREFIX = kdevlang +include ../../../Doxyfile.am diff --git a/languages/lib/debugger/debugger.cpp b/languages/lib/debugger/debugger.cpp new file mode 100644 index 00000000..92765efe --- /dev/null +++ b/languages/lib/debugger/debugger.cpp @@ -0,0 +1,209 @@ + +#include "debugger.h" + +#include <kdebug.h> +#include <klocale.h> +#include <ktexteditor/document.h> + +// #include "editorproxy.h" +#include <kdevpartcontroller.h> + + +using namespace KTextEditor; + +Debugger *Debugger::s_instance = 0; + +Debugger::Debugger(KDevPartController *partController) + :m_partController(partController) +{ + connect( m_partController, SIGNAL(partAdded(KParts::Part*)), + this, SLOT(partAdded(KParts::Part*)) ); +} + + +Debugger::~Debugger() +{} + + +// Debugger *Debugger::getInstance() +// { +// if (!s_instance) +// s_instance = new Debugger; +// +// return s_instance; +// } + + +void Debugger::setBreakpoint(const QString &fileName, int lineNum, int id, bool enabled, bool pending) +{ + KParts::Part *part = m_partController->partForURL(KURL(fileName)); + if( !part ) + return; + + MarkInterface *iface = dynamic_cast<MarkInterface*>(part); + if (!iface) + return; + + // Temporarily disconnect so we don't get confused by receiving extra + // marksChanged signals + disconnect( part, SIGNAL(marksChanged()), this, SLOT(marksChanged()) ); + iface->removeMark( lineNum, Breakpoint | ActiveBreakpoint | ReachedBreakpoint | DisabledBreakpoint ); + + BPItem bpItem(fileName, lineNum); + QValueList<BPItem>::Iterator it = BPList.find(bpItem); + if (it != BPList.end()) + { +// kdDebug(9012) << "Removing BP=" << fileName << ":" << lineNum << endl; + BPList.remove(it); + } + + // An id of -1 means this breakpoint should be hidden from the user. + // I believe this functionality is not used presently. + if( id != -1 ) + { + uint markType = Breakpoint; + if( !pending ) + markType |= ActiveBreakpoint; + if( !enabled ) + markType |= DisabledBreakpoint; + iface->addMark( lineNum, markType ); +// kdDebug(9012) << "Appending BP=" << fileName << ":" << lineNum << endl; + BPList.append(BPItem(fileName, lineNum)); + } + + connect( part, SIGNAL(marksChanged()), this, SLOT(marksChanged()) ); +} + + +void Debugger::clearExecutionPoint() +{ + QPtrListIterator<KParts::Part> it(*m_partController->parts()); + for ( ; it.current(); ++it) + { + MarkInterface *iface = dynamic_cast<MarkInterface*>(it.current()); + if (!iface) + continue; + + QPtrList<Mark> list = iface->marks(); + QPtrListIterator<Mark> markIt(list); + for( ; markIt.current(); ++markIt ) + { + Mark* mark = markIt.current(); + if( mark->type & ExecutionPoint ) + iface->removeMark( mark->line, ExecutionPoint ); + } + } +} + + +void Debugger::gotoExecutionPoint(const KURL &url, int lineNum) +{ + clearExecutionPoint(); + + m_partController->editDocument(url, lineNum); + + KParts::Part *part = m_partController->partForURL(url); + if( !part ) + return; + MarkInterface *iface = dynamic_cast<MarkInterface*>(part); + if( !iface ) + return; + + iface->addMark( lineNum, ExecutionPoint ); +} + +void Debugger::marksChanged() +{ + if(sender()->inherits("KTextEditor::Document") ) + { + KTextEditor::Document* doc = (KTextEditor::Document*) sender(); + MarkInterface* iface = KTextEditor::markInterface( doc ); + + if (iface) + { + if( !m_partController->partForURL( doc->url() ) ) + return; // Probably means the document is being closed. + + KTextEditor::Mark *m; + QValueList<BPItem> oldBPList = BPList; + QPtrList<KTextEditor::Mark> newMarks = iface->marks(); + + // Compare the oldBPlist to the new list from the editor. + // + // If we don't have some of the old breakpoints in the new list + // then they have been moved by the user adding or removing source + // code. Remove these old breakpoints + // + // If we _can_ find these old breakpoints in the newlist then + // nothing has happened to them. We can just ignore these and to + // do that we must remove them from the new list. + + bool bpchanged = false; + + for (uint i = 0; i < oldBPList.count(); i++) + { + if (oldBPList[i].fileName() != doc->url().path()) + continue; + + bool found=false; + for (uint newIdx=0; newIdx < newMarks.count(); newIdx++) + { + m = newMarks.at(newIdx); + if ((m->type & Breakpoint) && + m->line == oldBPList[i].lineNum() && + doc->url().path() == oldBPList[i].fileName()) + { + newMarks.remove(newIdx); + found=true; + break; + } + } + + if (!found) + { + emit toggledBreakpoint( doc->url().path(), oldBPList[i].lineNum() ); + bpchanged = true; + } + } + + // Any breakpoints left in the new list are the _new_ position of + // the moved breakpoints. So add these as new breakpoints via + // toggling them. + for (uint i = 0; i < newMarks.count(); i++) + { + m = newMarks.at(i); + if (m->type & Breakpoint) + { + emit toggledBreakpoint( doc->url().path(), m->line ); + bpchanged = true; + } + } + + if ( bpchanged && m_partController->activePart() == doc ) + { + //bring focus back to the editor + m_partController->activatePart( doc ); + } + } + } +} + + +void Debugger::partAdded( KParts::Part* part ) +{ + MarkInterfaceExtension *iface = dynamic_cast<MarkInterfaceExtension*>(part); + if( !iface ) + return; + + iface->setDescription((MarkInterface::MarkTypes)Breakpoint, i18n("Breakpoint")); + iface->setPixmap((MarkInterface::MarkTypes)Breakpoint, *inactiveBreakpointPixmap()); + iface->setPixmap((MarkInterface::MarkTypes)ActiveBreakpoint, *activeBreakpointPixmap()); + iface->setPixmap((MarkInterface::MarkTypes)ReachedBreakpoint, *reachedBreakpointPixmap()); + iface->setPixmap((MarkInterface::MarkTypes)DisabledBreakpoint, *disabledBreakpointPixmap()); + iface->setPixmap((MarkInterface::MarkTypes)ExecutionPoint, *executionPointPixmap()); + iface->setMarksUserChangable( Bookmark | Breakpoint ); + + connect( part, SIGNAL(marksChanged()), this, SLOT(marksChanged()) ); +} + +#include "debugger.moc" diff --git a/languages/lib/debugger/debugger.h b/languages/lib/debugger/debugger.h new file mode 100644 index 00000000..ed545f28 --- /dev/null +++ b/languages/lib/debugger/debugger.h @@ -0,0 +1,132 @@ +#ifndef __DEBUGGER_H__ +#define __DEBUGGER_H__ + +#include <qvaluelist.h> + +#include "kdevdebugger.h" + +#include <kparts/part.h> +#include <ktexteditor/markinterface.h> + +#include <kdeversion.h> +#include <ktexteditor/markinterfaceextension.h> + +class KDevPartController; + +/** +* Describes a single breakpoint in the system +* +* This is used so that we can track the breakpoints and move them appropriately +* as the user adds or removes lines of code before breakpoints. +*/ + +class BPItem +{ +public: + /** + * default ctor - required from QValueList + */ + BPItem() : m_fileName(""), m_lineNum(0) + {} + + BPItem( const QString& fileName, const uint lineNum) + : m_fileName(fileName), + m_lineNum(lineNum) + {} + + uint lineNum() const { return m_lineNum; } + QString fileName() const { return m_fileName; } + + bool operator==( const BPItem& rhs ) const + { + return (m_fileName == rhs.m_fileName + && m_lineNum == rhs.m_lineNum); + } + +private: + QString m_fileName; + uint m_lineNum; +}; + + +/** +* Handles signals from the editor that relate to breakpoints and the execution +* point of the debugger. +* We may change, add or remove breakpoints in this class. +*/ +class Debugger : public KDevDebugger +{ + Q_OBJECT + +public: + + /** + */ +// static Debugger *getInstance(); + + /** + * Controls the breakpoint icon being displayed in the editor through the + * markinterface + * + * @param fileName The breakpoint is added or removed from this file + * @param lineNum ... at this line number + * @param id This is an internal id. which has a special number + * that prevents us changing the mark icon. (why?) + * @param enabled The breakpoint could be enabled, disabled + * @param pending pending or active. Each state has a different icon. + */ + void setBreakpoint(const QString &fileName, int lineNum, + int id, bool enabled, bool pending); + + /** + * Displays an icon in the file at the line that the debugger has stoped + * at. + * @param url The file the debugger has stopped at. + * @param lineNum The line number to display. Note: We may not know it. + */ + void gotoExecutionPoint(const KURL &url, int lineNum=-1); + + /** + * Remove the executution point being displayed. + */ + void clearExecutionPoint(); + +// protected: + + Debugger(KDevPartController *partController); + ~Debugger(); + +private slots: + + /** + * Whenever a new part is added this slot gets triggered and we then + * look for a MarkInterfaceExtension part. When it is a + * MarkInterfaceExtension part we set the various pixmaps of the + * breakpoint icons. + */ + void partAdded( KParts::Part* part ); + + /** + * Called by the TextEditor interface when the marks have changed position + * because the user has added or removed source. + * In here we figure out if we need to reset the breakpoints due to + * these source changes. + */ + void marksChanged(); + +private: + enum MarkType { + Bookmark = KTextEditor::MarkInterface::markType01, + Breakpoint = KTextEditor::MarkInterface::markType02, + ActiveBreakpoint = KTextEditor::MarkInterface::markType03, + ReachedBreakpoint = KTextEditor::MarkInterface::markType04, + DisabledBreakpoint = KTextEditor::MarkInterface::markType05, + ExecutionPoint = KTextEditor::MarkInterface::markType06 + }; + + static Debugger *s_instance; + KDevPartController *m_partController; + QValueList<BPItem> BPList; +}; + +#endif diff --git a/languages/lib/debugger/kdevdebugger.cpp b/languages/lib/debugger/kdevdebugger.cpp new file mode 100644 index 00000000..01b4d4f7 --- /dev/null +++ b/languages/lib/debugger/kdevdebugger.cpp @@ -0,0 +1,182 @@ +/* This file is part of the KDE project + Copyright (C) 2002 Matthias Hoelzer-Kluepfel <hoelzer@kde.org> + Copyright (C) 2002 John Firebaugh <jfirebaugh@kde.org> + + This library 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 library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ +#include "kdevdebugger.h" + +KDevDebugger::KDevDebugger(QObject *parent, const char *name) + : QObject(parent, name) +{ +} + + +KDevDebugger::~KDevDebugger() +{ +} + +const QPixmap* KDevDebugger::inactiveBreakpointPixmap() +{ + const char*breakpoint_gr_xpm[]={ + "11 16 6 1", + "c c #c6c6c6", + "d c #2c2c2c", + "# c #000000", + ". c None", + "a c #ffffff", + "b c #555555", + "...........", + "...........", + "...#####...", + "..#aaaaa#..", + ".#abbbbbb#.", + "#abbbbbbbb#", + "#abcacacbd#", + "#abbbbbbbb#", + "#abcacacbd#", + "#abbbbbbbb#", + ".#bbbbbbb#.", + "..#bdbdb#..", + "...#####...", + "...........", + "...........", + "..........."}; + static QPixmap pixmap( breakpoint_gr_xpm ); + return &pixmap; +} + +const QPixmap* KDevDebugger::activeBreakpointPixmap() +{ + const char* breakpoint_xpm[]={ + "11 16 6 1", + "c c #c6c6c6", + ". c None", + "# c #000000", + "d c #840000", + "a c #ffffff", + "b c #ff0000", + "...........", + "...........", + "...#####...", + "..#aaaaa#..", + ".#abbbbbb#.", + "#abbbbbbbb#", + "#abcacacbd#", + "#abbbbbbbb#", + "#abcacacbd#", + "#abbbbbbbb#", + ".#bbbbbbb#.", + "..#bdbdb#..", + "...#####...", + "...........", + "...........", + "..........."}; + static QPixmap pixmap( breakpoint_xpm ); + return &pixmap; +} + +const QPixmap* KDevDebugger::reachedBreakpointPixmap() +{ + const char*breakpoint_bl_xpm[]={ + "11 16 7 1", + "a c #c0c0ff", + "# c #000000", + "c c #0000c0", + "e c #0000ff", + "b c #dcdcdc", + "d c #ffffff", + ". c None", + "...........", + "...........", + "...#####...", + "..#ababa#..", + ".#bcccccc#.", + "#acccccccc#", + "#bcadadace#", + "#acccccccc#", + "#bcadadace#", + "#acccccccc#", + ".#ccccccc#.", + "..#cecec#..", + "...#####...", + "...........", + "...........", + "..........."}; + static QPixmap pixmap( breakpoint_bl_xpm ); + return &pixmap; +} + +const QPixmap* KDevDebugger::disabledBreakpointPixmap() +{ + const char*breakpoint_wh_xpm[]={ + "11 16 7 1", + "a c #c0c0ff", + "# c #000000", + "c c #0000c0", + "e c #0000ff", + "b c #dcdcdc", + "d c #ffffff", + ". c None", + "...........", + "...........", + "...#####...", + "..#ddddd#..", + ".#ddddddd#.", + "#ddddddddd#", + "#ddddddddd#", + "#ddddddddd#", + "#ddddddddd#", + "#ddddddddd#", + ".#ddddddd#.", + "..#ddddd#..", + "...#####...", + "...........", + "...........", + "..........."}; + static QPixmap pixmap( breakpoint_wh_xpm ); + return &pixmap; +} + +const QPixmap* KDevDebugger::executionPointPixmap() +{ + const char*exec_xpm[]={ + "11 16 4 1", + "a c #00ff00", + "b c #000000", + ". c None", + "# c #00c000", + "...........", + "...........", + "...........", + "#a.........", + "#aaa.......", + "#aaaaa.....", + "#aaaaaaa...", + "#aaaaaaaaa.", + "#aaaaaaa#b.", + "#aaaaa#b...", + "#aaa#b.....", + "#a#b.......", + "#b.........", + "...........", + "...........", + "..........."}; + static QPixmap pixmap( exec_xpm ); + return &pixmap; +} + +#include "kdevdebugger.moc" diff --git a/languages/lib/debugger/kdevdebugger.h b/languages/lib/debugger/kdevdebugger.h new file mode 100644 index 00000000..24bd2c7b --- /dev/null +++ b/languages/lib/debugger/kdevdebugger.h @@ -0,0 +1,88 @@ +/* This file is part of the KDE project + Copyright (C) 2002 Matthias Hoelzer-Kluepfel <hoelzer@kde.org> + Copyright (C) 2002 John Firebaugh <jfirebaugh@kde.org> + + This library 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 library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ +#ifndef _KDEVDEBUGGER_H_ +#define _KDEVDEBUGGER_H_ + + +#include <qobject.h> +#include <qpixmap.h> + + +#include <kurl.h> + +/** +* Base class to handle signals from the editor that relate to breakpoints +* and the execution point of the debugger. +*/ +class KDevDebugger : public QObject +{ + Q_OBJECT + +public: + + KDevDebugger(QObject *parent=0, const char *name=0); + ~KDevDebugger(); + + /** + * Sets a breakpoint in the editor document belong to fileName. + * If id==-1, the breakpoint is deleted. + */ + virtual void setBreakpoint(const QString &fileName, int lineNum, + int id, bool enabled, bool pending) = 0; + + /** + * Goes to a given location in a source file and marks the line. + * This is used by the debugger to mark the location where the + * the debugger has stopped. + */ + virtual void gotoExecutionPoint(const KURL &url, int lineNum=0) = 0; + + /** + * Clear the execution point. Usefull if debugging has ended. + */ + virtual void clearExecutionPoint() = 0; + + static const QPixmap* inactiveBreakpointPixmap(); + static const QPixmap* activeBreakpointPixmap(); + static const QPixmap* reachedBreakpointPixmap(); + static const QPixmap* disabledBreakpointPixmap(); + static const QPixmap* executionPointPixmap(); + +signals: + + /** + * The user has toggled a breakpoint. + */ + void toggledBreakpoint(const QString &fileName, int lineNum); + + /* + * The user wants to edit the properties of a breakpoint. + */ + void editedBreakpoint(const QString &fileName, int lineNum); + + /** + * The user wants to enable/disable a breakpoint. + */ + void toggledBreakpointEnabled(const QString &fileName, int lineNum); + +}; + + +#endif diff --git a/languages/lib/designer_integration/Mainpage.dox b/languages/lib/designer_integration/Mainpage.dox new file mode 100644 index 00000000..1f2db949 --- /dev/null +++ b/languages/lib/designer_integration/Mainpage.dox @@ -0,0 +1,48 @@ +/** +@mainpage The KDevelop Designer Integration Support Library + +This library contains base classes to implement GUI designer integration in language support plugins. + +<b>Link with</b>: -ldesignerintegration + +<b>Include path</b>: -I\$(kde_includes)/languages/designer_integration + +\section usingintegration Using designer integration support library +Each language support which wants to use integrated designer, must reimplement +@code +virtual KDevDesignerIntegration *KDevLanguageSupport::designer(KInterfaceDesigner::DesignerType type) +@endcode +method and return designer integration object (@ref KDevLanguageSupport base class returns 0). + +Qt designer integration can be easily implemented by reusing @ref QtDesignerIntegration +base class. + +For example, designer method of a language support could look like: +@code +KDevDesignerIntegration * MyLanguageSupportPart::designer(KInterfaceDesigner::DesignerType type) +{ + KDevDesignerIntegration *des = 0; + switch (type) + { + case KInterfaceDesigner::QtDesigner: + des = m_designers[type]; + if (des == 0) + { + MyLanguageImplementationWidget *impl = new MyLanguageImplementationWidget(this); + des = new MyLanguageQtDesignerIntegration(this, impl); + m_designers[type] = des; + } + break; + } + return des; +} +return des; +@endcode +In the code above m_designers is a designer cache declared as: +@code +QMap<KInterfaceDesigner::DesignerType, KDevDesignerIntegration*> m_designers; +@endcode +MyLanguageImplementationWidget and MyLanguageQtDesignerIntegration classes are subclasses +of @ref QtDesignerIntegration and @ref ImplementationWidget base classes. +*/ + diff --git a/languages/lib/designer_integration/Makefile.am b/languages/lib/designer_integration/Makefile.am new file mode 100644 index 00000000..cab66420 --- /dev/null +++ b/languages/lib/designer_integration/Makefile.am @@ -0,0 +1,16 @@ +INCLUDES = -I$(top_srcdir)/lib/interfaces \ + -I$(top_srcdir)/lib/interfaces/extensions -I$(top_srcdir)/lib/interfaces/external -I$(top_srcdir)/lib/util \ + $(all_includes) +METASOURCES = AUTO +libdesignerintegration_la_LDFLAGS = $(all_libraries) +lib_LTLIBRARIES = libdesignerintegration.la +libdesignerintegration_la_LIBADD = $(top_builddir)/lib/interfaces/libkdevinterfaces.la $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) +libdesignerintegration_la_SOURCES = implementationwidgetbase.ui \ + implementationwidget.cpp qtdesignerintegration.cpp + +langincludedirdir = $(includedir)/kdevelop/languages/designer_integration +langincludedir_HEADERS = qtdesignerintegration.h implementationwidget.h implementationwidgetbase.h + +DOXYGEN_REFERENCES = dcop interfaces kdecore kdefx kdeui khtml kmdi kio kjs kparts kutils kdevinterfaces kdevutil +DOXYGEN_PROJECTNAME = KDevelop Designer Integration Support Library +include ../../../Doxyfile.am diff --git a/languages/lib/designer_integration/implementationwidget.cpp b/languages/lib/designer_integration/implementationwidget.cpp new file mode 100644 index 00000000..7c561e7c --- /dev/null +++ b/languages/lib/designer_integration/implementationwidget.cpp @@ -0,0 +1,158 @@ +/*************************************************************************** + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "implementationwidget.h" + +#include <qfileinfo.h> +#include <qtextstream.h> +#include <qfile.h> +#include <qdir.h> +#include <qregexp.h> +#include <qdom.h> +#include <qradiobutton.h> + +#include <klineedit.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <klistview.h> + +#include <kdevproject.h> +#include <domutil.h> +#include <filetemplate.h> +#include <kdevlanguagesupport.h> + +namespace ImplUtils{ +class ClassItem: public KListViewItem{ +public: + ClassItem(KListViewItem *parent, ClassDom dom) + :KListViewItem(parent, dom->name(), dom->fileName()), m_dom(dom) { setOpen(true); } + ClassItem(KListView *parent, ClassDom dom) + :KListViewItem(parent, dom->name(), dom->fileName()), m_dom(dom) { setOpen(true); } + ClassDom dom() const { return m_dom; } +private: + ClassDom m_dom; +}; + +class NamespaceItem: public KListViewItem{ +public: + NamespaceItem(KListViewItem *parent, NamespaceDom dom) + :KListViewItem(parent, dom->name(), dom->fileName()), m_dom(dom) { setOpen(true); } + NamespaceItem(KListView *parent, NamespaceDom dom) + :KListViewItem(parent, dom->name(), dom->fileName()), m_dom(dom) { setOpen(true); } + NamespaceDom dom() const { return m_dom; } +private: + NamespaceDom m_dom; +}; +} + +ImplementationWidget::ImplementationWidget(KDevLanguageSupport *part, QWidget* parent, const char* name, bool modal) + :CreateImplemenationWidgetBase(parent, name, modal), m_part(part) +{ +} + +void ImplementationWidget::init(const QString &formName) +{ + m_formName = formName; + + classView->clear(); + fileNameEdit->clear(); + classNameEdit->clear(); + + QDomDocument doc; + DomUtil::openDOMFile(doc, m_formName); + m_baseClassName = DomUtil::elementByPathExt(doc, "class").text(); + setCaption(i18n("Create or Select Implementation Class for: %1").arg(m_baseClassName)); + + KListViewItem *item = new KListViewItem(classView, i18n("Namespaces && Classes")); + item->setOpen(true); + processNamespaces(m_part->codeModel()->globalNamespace(), item); +} + +void ImplementationWidget::processNamespaces(NamespaceDom dom, KListViewItem *parent) +{ + const NamespaceList nslist = dom->namespaceList(); + for (NamespaceList::const_iterator it = nslist.begin(); it != nslist.end(); ++it) + processNamespaces(*it, new ImplUtils::NamespaceItem(parent, *it)); + const ClassList cllist = dom->classList(); + for (ClassList::ConstIterator it = cllist.begin(); it != cllist.end(); ++it) + processClasses(*it, new ImplUtils::ClassItem(parent, *it)); +} + +void ImplementationWidget::processClasses(ClassDom dom, KListViewItem *parent) +{ + const ClassList cllist = dom->classList(); + for (ClassList::ConstIterator it = cllist.begin(); it != cllist.end(); ++it) + processClasses(*it, new ImplUtils::ClassItem(parent, *it)); +} + +ImplementationWidget::~ImplementationWidget() +{ +} + +/*$SPECIALIZATION$*/ +void ImplementationWidget::classNameChanged(const QString &text) +{ + fileNameEdit->setText(text.lower()); +} + +void ImplementationWidget::accept() +{ + if (createButton->isOn()) + { + if (classNameEdit->text().isEmpty()) + return; + if (!createClass()) + return; + ClassList cllist = m_part->codeModel()->globalNamespace()->classByName(classNameEdit->text()); + if (cllist.count() > 0) + m_selectedClass = cllist.first(); + else + KMessageBox::error(0, i18n("Class was created but not found in class store.")); + } + else if (useButton->isOn()) + { + if (!classView->currentItem()) + return; + ImplUtils::ClassItem *item = dynamic_cast<ImplUtils::ClassItem*>(classView->currentItem()); + if (!item) + return; + m_selectedClass = item->dom(); + } + QDialog::accept(); +} + +ClassDom ImplementationWidget::selectedClass() +{ + return m_selectedClass; +} + +bool ImplementationWidget::createClass() +{ + m_part->project()->addFiles(createClassFiles()); + return true; +} + +int ImplementationWidget::exec(const QString &formName) +{ + init(formName); + return QDialog::exec(); +} + +#include "implementationwidget.moc" + diff --git a/languages/lib/designer_integration/implementationwidget.h b/languages/lib/designer_integration/implementationwidget.h new file mode 100644 index 00000000..3200c877 --- /dev/null +++ b/languages/lib/designer_integration/implementationwidget.h @@ -0,0 +1,86 @@ +/*************************************************************************** + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef IMPLEMENTATIONWIDGET_H +#define IMPLEMENTATIONWIDGET_H + +#include "implementationwidgetbase.h" + +#include <codemodel.h> + +class KListViewItem; +class KDevLanguageSupport; + +/** +Base class for implementation creation widgets. +Contains language-independent implementation widget that can be used +to create or select an implementation of a form in designer. + +Implementations could be subclasses or simple files with callbacks, etc. + +Subclasses of this class should reimplement only pure virtual functions in the common case. +*/ +class ImplementationWidget : public CreateImplemenationWidgetBase +{ +Q_OBJECT +public: + ImplementationWidget(KDevLanguageSupport *part, QWidget* parent = 0, const char* name = 0, bool modal = false); + virtual ~ImplementationWidget(); + /*$PUBLIC_FUNCTIONS$*/ + + /**@returns The %DOM of selected (or created) class.*/ + ClassDom selectedClass(); + + /**Executes implementation widget for a form @p formName.*/ + int exec(const QString &formName); + +public slots: + /*$PUBLIC_SLOTS$*/ + +protected: + /*$PROTECTED_FUNCTIONS$*/ + /**Sets up the dialog. No need to reimplement unless you want to restrict + the number of classes being displayed as possible implementation classes.*/ + void init(const QString &formName); + + void processNamespaces(NamespaceDom dom, KListViewItem *parent); + void processClasses(ClassDom dom, KListViewItem *parent); + + /**Creates a class and adds it to a project. No need to reimplement.*/ + bool createClass(); + + /**Reimplement to create actual files with the form implementation. + @return The list of absolute paths to a files created.*/ + virtual QStringList createClassFiles() = 0; + +protected slots: + /*$PROTECTED_SLOTS$*/ + virtual void classNameChanged(const QString &text); + virtual void accept(); + +protected: + KDevLanguageSupport *m_part; + ClassDom m_selectedClass; + QString m_formName; + QString m_baseClassName; +}; + +#endif + diff --git a/languages/lib/designer_integration/implementationwidgetbase.ui b/languages/lib/designer_integration/implementationwidgetbase.ui new file mode 100644 index 00000000..1a39d39e --- /dev/null +++ b/languages/lib/designer_integration/implementationwidgetbase.ui @@ -0,0 +1,267 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>CreateImplemenationWidgetBase</class> +<widget class="QDialog"> + <property name="name"> + <cstring>CreateImplemenationWidgetBase</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>518</width> + <height>353</height> + </rect> + </property> + <property name="caption"> + <string>Create or Select Implementation Class</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget" row="1" column="0"> + <property name="name"> + <cstring>layout4</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer> + <property name="name"> + <cstring>spacer4</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>okButton</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>&OK</string> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>cancelButton</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>&Cancel</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QButtonGroup" row="0" column="0"> + <property name="name"> + <cstring>buttonGroup1</cstring> + </property> + <property name="title"> + <string></string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QRadioButton" row="0" column="0"> + <property name="name"> + <cstring>createButton</cstring> + </property> + <property name="text"> + <string>Create &new class</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="KListView" row="4" column="0"> + <column> + <property name="text"> + <string>Class Name</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>File</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <property name="name"> + <cstring>classView</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + <widget class="QLayoutWidget" row="1" column="0"> + <property name="name"> + <cstring>layout2</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>classNameLabel</cstring> + </property> + <property name="text"> + <string>C&lass name:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>classNameEdit</cstring> + </property> + </widget> + <widget class="KLineEdit"> + <property name="name"> + <cstring>classNameEdit</cstring> + </property> + </widget> + </vbox> + </widget> + <widget class="QRadioButton" row="3" column="0"> + <property name="name"> + <cstring>useButton</cstring> + </property> + <property name="text"> + <string>Use &existing class</string> + </property> + </widget> + <widget class="QLayoutWidget" row="2" column="0"> + <property name="name"> + <cstring>layout2_2</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>fileNameLabel</cstring> + </property> + <property name="text"> + <string>&File name:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>fileNameEdit</cstring> + </property> + </widget> + <widget class="KLineEdit"> + <property name="name"> + <cstring>fileNameEdit</cstring> + </property> + </widget> + </vbox> + </widget> + </grid> + </widget> + </grid> +</widget> +<customwidgets> +</customwidgets> +<connections> + <connection> + <sender>cancelButton</sender> + <signal>clicked()</signal> + <receiver>CreateImplemenationWidgetBase</receiver> + <slot>reject()</slot> + </connection> + <connection> + <sender>okButton</sender> + <signal>clicked()</signal> + <receiver>CreateImplemenationWidgetBase</receiver> + <slot>accept()</slot> + </connection> + <connection> + <sender>createButton</sender> + <signal>toggled(bool)</signal> + <receiver>classNameLabel</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>createButton</sender> + <signal>toggled(bool)</signal> + <receiver>classNameEdit</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>useButton</sender> + <signal>toggled(bool)</signal> + <receiver>classView</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>createButton</sender> + <signal>toggled(bool)</signal> + <receiver>fileNameLabel</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>createButton</sender> + <signal>toggled(bool)</signal> + <receiver>fileNameEdit</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>classNameEdit</sender> + <signal>textChanged(const QString&)</signal> + <receiver>CreateImplemenationWidgetBase</receiver> + <slot>classNameChanged(const QString&)</slot> + </connection> +</connections> +<tabstops> + <tabstop>createButton</tabstop> + <tabstop>classNameEdit</tabstop> + <tabstop>fileNameEdit</tabstop> + <tabstop>classView</tabstop> + <tabstop>okButton</tabstop> + <tabstop>cancelButton</tabstop> +</tabstops> +<slots> + <slot access="protected">classNameChanged(const QString &)</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>klistview.h</includehint> +</includehints> +</UI> diff --git a/languages/lib/designer_integration/qtdesignerintegration.cpp b/languages/lib/designer_integration/qtdesignerintegration.cpp new file mode 100644 index 00000000..32dc16ca --- /dev/null +++ b/languages/lib/designer_integration/qtdesignerintegration.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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "qtdesignerintegration.h" + +#include <qpair.h> +#include <qregexp.h> +#include <qfileinfo.h> + +#include <klocale.h> +#include <kdebug.h> +#include <kmessagebox.h> +#include <kurl.h> + +#include <rurl.h> +#include <domutil.h> +#include <kdevpartcontroller.h> +#include <kdevcreatefile.h> +#include <kdevlanguagesupport.h> +#include <kdevproject.h> + +#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 QString& 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 QString& formName, KInterfaceDesigner::Function oldFunction, KInterfaceDesigner::Function function) +{ + kdDebug() << "QtDesignerIntegration::editFunction: form: " << formName + << ", old function: " << oldFunction.function + << ", function: " << function.function << endl; +} + +void QtDesignerIntegration::removeFunction(const QString& formName, KInterfaceDesigner::Function function) +{ + kdDebug() << "QtDesignerIntegration::removeFunction: form: " << formName << ", function: " << function.function << endl; +} + +bool QtDesignerIntegration::selectImplementation(const QString &formName) +{ + QFileInfo 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(QDomDocument dom, QString path) +{ + QDomElement el = DomUtil::elementByPath(dom, path + "/qtdesigner"); + if (el.isNull()) + return; + QDomNodeList impls = el.elementsByTagName("implementation"); + for (uint i = 0; i < impls.count(); ++i) + { + QDomElement el = impls.item(i).toElement(); + if (el.isNull()) + continue; + QString 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")); + QString uiPath = Relative::File(m_part->project()->projectDirectory(), + el.attribute("path"), true).urlPath(); + if (cllist.count() > 0) + m_implementations[uiPath] = cllist.first(); + } +} + +void QtDesignerIntegration::saveSettings(QDomDocument dom, QString path) +{ + kdDebug() << "QtDesignerIntegration::saveSettings" << endl; + QDomElement el = DomUtil::createElementByPath(dom, path + "/qtdesigner"); + for (QMap<QString, ClassDom>::const_iterator it = m_implementations.begin(); + it != m_implementations.end(); ++it) + { + QDomElement 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 QString &formName, const QString &functionName) +{ + kdDebug() << "QtDesignerIntegration::openFunction, formName = " << formName + << ", functionName = " << functionName << endl; + QString fn = functionName; + if (fn.find("(") > 0) + fn.remove(fn.find("("), fn.length()); + + if (!m_implementations[formName]) + return; + + int line = -1, col = -1; + + QString 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(QString &// name + ) +{ +} + +void QtDesignerIntegration::openSource(const QString &formName) +{ + if (!m_implementations.contains(formName)) + if (!selectImplementation(formName)) + return; + QString impl = m_implementations[formName]->fileName(); + processImplementationName(impl); + m_part->partController()->editDocument(KURL(impl), -1, -1); +} + +#include "qtdesignerintegration.moc" diff --git a/languages/lib/designer_integration/qtdesignerintegration.h b/languages/lib/designer_integration/qtdesignerintegration.h new file mode 100644 index 00000000..fd8b512f --- /dev/null +++ b/languages/lib/designer_integration/qtdesignerintegration.h @@ -0,0 +1,80 @@ +/*************************************************************************** + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef QTDESIGNERINTEGRATION_H +#define QTDESIGNERINTEGRATION_H + +#include <qmap.h> + +#include <codemodel.h> +#include "kdevdesignerintegration.h" + +class KDevLanguageSupport; +class ImplementationWidget; + +/** +Qt 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 QString& formName, KInterfaceDesigner::Function function); + virtual void editFunction(const QString& formName, KInterfaceDesigner::Function oldFunction, KInterfaceDesigner::Function function); + virtual void removeFunction(const QString& formName, KInterfaceDesigner::Function function); + + virtual void openFunction(const QString &formName, const QString &functionName); + + virtual void openSource(const QString &formName); + + virtual void saveSettings(QDomDocument dom, QString path); + virtual void loadSettings(QDomDocument dom, QString path); + + bool selectImplementation(const QString &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(QString &name); + + //Form file - derived class name + QMap<QString, ClassDom> m_implementations; + + KDevLanguageSupport *m_part; + ImplementationWidget *m_impl; + bool m_classHasDefinitions; +}; + +#endif diff --git a/languages/lib/interfaces/Mainpage.dox b/languages/lib/interfaces/Mainpage.dox new file mode 100644 index 00000000..f31c4bfc --- /dev/null +++ b/languages/lib/interfaces/Mainpage.dox @@ -0,0 +1,10 @@ +/** +@mainpage The KDevelop Language Support Interfaces Library + +This library contains interfaces for KDevelop language support facilities. + +<b>Link with</b>: -llang_interfaces + +<b>Include path</b>: -I\$(kde_includes)/kdevelop/languages/interfaces +*/ + diff --git a/languages/lib/interfaces/Makefile.am b/languages/lib/interfaces/Makefile.am new file mode 100644 index 00000000..2ccbac75 --- /dev/null +++ b/languages/lib/interfaces/Makefile.am @@ -0,0 +1,16 @@ + +METASOURCES = AUTO +langincludedirdir = $(includedir)/kdevelop/languages/interfaces +lib_LTLIBRARIES = liblang_interfaces.la +liblang_interfaces_la_LDFLAGS = $(all_libraries) +liblang_interfaces_la_SOURCES = kdevpcsimporter.cpp +liblang_interfaces_la_LIBADD = $(LIB_QT) +langincludedir_HEADERS = kdevpcsimporter.h +INCLUDES = $(all_includes) +servicetypedir = $(kde_servicetypesdir) +servicetype_DATA = kdeveloppcsimporter.desktop + +DOXYGEN_REFERENCES = dcop interfaces kdecore kdefx kdeui khtml kmdi kio kjs kparts kutils kdevinterfaces kdevutil +DOXYGEN_PROJECTNAME = KDevelop Language Support Interfaces Library +DOXYGEN_DOCDIRPREFIX = kdevlang +include ../../../Doxyfile.am diff --git a/languages/lib/interfaces/kdeveloppcsimporter.desktop b/languages/lib/interfaces/kdeveloppcsimporter.desktop new file mode 100644 index 00000000..bbf0f490 --- /dev/null +++ b/languages/lib/interfaces/kdeveloppcsimporter.desktop @@ -0,0 +1,39 @@ +[Desktop Entry] +Type=ServiceType +X-KDE-ServiceType=KDevelop/PCSImporter +X-KDE-Derived=KDevelop/Plugin +Name=KDevelop PCS Importer +Name[ca]=Importador PCS per a KDevelop +Name[da]=KDevelop PCS importør +Name[de]=PCS-Importierer (KDevelop) +Name[el]=Εισαγωγέας PCS KDevelop +Name[es]=Importación PCS de KDevelop +Name[et]=KDevelopi PCS importija +Name[eu]=KDevelop PCS inportatzailea +Name[fa]=واردکنندۀ KDevelop PCS +Name[fr]=Importation PCS pour KDevelop +Name[ga]=Iompórtálaí PCS KDevelop +Name[gl]=Importador PCS de KDevelop +Name[hi]=के-डेवलप पीसीएस आयातक +Name[hu]=KDevelop PCS-importáló +Name[ja]=KDevelop PCS インポータ +Name[nds]=PCS-Import (KDevelop) +Name[ne]=केडीई विकास PCS आयातकर्ता +Name[nl]=KDevelop PCS importeren +Name[pl]=KDevelop: import PCS +Name[pt]=Importador de PCS do KDevelop +Name[pt_BR]=Importador PCS para o KDevelop +Name[ru]=Загрузчик в хранилище классов +Name[sk]=KDevelop PCS import +Name[sl]=Uvažanje PCS za KDevelop +Name[sr]=KDevelop-ов PCS увозник +Name[sr@Latn]=KDevelop-ov PCS uvoznik +Name[sv]=KDevelop PCS-import +Name[ta]=KDevelop pcs ஏற்றுமதியாளர் +Name[tg]=Пурборкунанда дар анбори синфӣ +Name[tr]=KDevelop PCS Aktarıcısı +Name[zh_CN]=KDevelop PCS导入器 +Name[zh_TW]=KDevelop PCS 匯入器 + +[PropertyDef::X-KDevelop-PCSImporter] +Type=QString diff --git a/languages/lib/interfaces/kdevpcsimporter.cpp b/languages/lib/interfaces/kdevpcsimporter.cpp new file mode 100644 index 00000000..de8a8632 --- /dev/null +++ b/languages/lib/interfaces/kdevpcsimporter.cpp @@ -0,0 +1,36 @@ +/* This file is part of KDevelop + Copyright (C) 2003 Roberto Raggi <roberto@kdevelop.org> + + This library 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 library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include "kdevpcsimporter.h" +#include "kdevpcsimporter.moc" + +KDevPCSImporter::KDevPCSImporter( QObject * parent, const char * name ) + : QObject( parent, name ) +{ +} + +KDevPCSImporter::~ KDevPCSImporter( ) +{ +} + +QWidget * KDevPCSImporter::createSettingsPage( QWidget * /*parent*/, const char * /*name*/ ) +{ + return 0; +} + diff --git a/languages/lib/interfaces/kdevpcsimporter.h b/languages/lib/interfaces/kdevpcsimporter.h new file mode 100644 index 00000000..8493b9e3 --- /dev/null +++ b/languages/lib/interfaces/kdevpcsimporter.h @@ -0,0 +1,49 @@ +/* This file is part of KDevelop + Copyright (C) 2003 Roberto Raggi <roberto@kdevelop.org> + + This library 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 library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef KDEVPCSIMPORTER_H +#define KDEVPCSIMPORTER_H + +#include <qobject.h> +#include <qstringlist.h> + +class QWidget; + +/** +KDevelop persistent class store importer plugin. + +These plugins are used by language support plugins to fill symbol stores +with symbol information from certain files. The purpose of the importer +is to provide file selection wizard. +*/ +class KDevPCSImporter: public QObject +{ + Q_OBJECT +public: + KDevPCSImporter( QObject* parent=0, const char* name=0 ); + virtual ~KDevPCSImporter(); + + virtual QString dbName() const = 0; + virtual QStringList includePaths() = 0; + virtual QStringList fileList() = 0; + + virtual QWidget* createSettingsPage( QWidget* parent, const char* name=0 ); +}; + +#endif // KDEVPCSIMPORTER_H |