| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | /**************************************************************************
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | ** | 
					
						
							|  |  |  | ** This file is part of Qt Creator | 
					
						
							|  |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-06-17 00:01:27 +10:00
										 |  |  | ** Contact: Nokia Corporation (qt-info@nokia.com) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | ** Commercial Usage | 
					
						
							| 
									
										
										
										
											2008-12-02 14:17:16 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | ** Licensees holding valid Qt Commercial licenses may use this file in | 
					
						
							|  |  |  | ** accordance with the Qt Commercial License Agreement provided with the | 
					
						
							|  |  |  | ** Software or, alternatively, in accordance with the terms contained in | 
					
						
							|  |  |  | ** a written agreement between you and Nokia. | 
					
						
							| 
									
										
										
										
											2008-12-02 14:17:16 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | ** GNU Lesser General Public License Usage | 
					
						
							| 
									
										
										
										
											2008-12-02 14:17:16 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
					
						
							|  |  |  | ** General Public License version 2.1 as published by the Free Software | 
					
						
							|  |  |  | ** Foundation and appearing in the file LICENSE.LGPL included in the | 
					
						
							|  |  |  | ** packaging of this file.  Please review the following information to | 
					
						
							|  |  |  | ** ensure the GNU Lesser General Public License version 2.1 requirements | 
					
						
							|  |  |  | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 | 
					
						
							| 
									
										
										
										
											2008-12-02 14:17:16 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | ** If you are unsure which license is appropriate for your use, please | 
					
						
							| 
									
										
										
										
											2009-08-14 09:30:56 +02:00
										 |  |  | ** contact the sales department at http://qt.nokia.com/contact.
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | **************************************************************************/ | 
					
						
							| 
									
										
										
										
											2008-12-02 15:08:31 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #include "cppplugin.h"
 | 
					
						
							| 
									
										
										
										
											2008-12-16 12:22:08 +01:00
										 |  |  | #include "cppclasswizard.h"
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #include "cppeditor.h"
 | 
					
						
							|  |  |  | #include "cppeditorconstants.h"
 | 
					
						
							|  |  |  | #include "cppeditorenums.h"
 | 
					
						
							|  |  |  | #include "cppfilewizard.h"
 | 
					
						
							| 
									
										
										
										
											2008-12-16 12:22:08 +01:00
										 |  |  | #include "cpphoverhandler.h"
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-20 15:31:33 +01:00
										 |  |  | #include <coreplugin/icore.h>
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #include <coreplugin/coreconstants.h>
 | 
					
						
							|  |  |  | #include <coreplugin/mimedatabase.h>
 | 
					
						
							|  |  |  | #include <coreplugin/uniqueidmanager.h>
 | 
					
						
							|  |  |  | #include <coreplugin/fileiconprovider.h>
 | 
					
						
							| 
									
										
										
										
											2009-01-13 13:39:31 +01:00
										 |  |  | #include <coreplugin/actionmanager/actionmanager.h>
 | 
					
						
							| 
									
										
										
										
											2009-01-14 13:17:53 +01:00
										 |  |  | #include <coreplugin/actionmanager/command.h>
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #include <coreplugin/editormanager/editormanager.h>
 | 
					
						
							|  |  |  | #include <texteditor/completionsupport.h>
 | 
					
						
							|  |  |  | #include <texteditor/fontsettings.h>
 | 
					
						
							|  |  |  | #include <texteditor/storagesettings.h>
 | 
					
						
							| 
									
										
										
										
											2009-03-17 17:38:16 +01:00
										 |  |  | #include <texteditor/texteditoractionhandler.h>
 | 
					
						
							| 
									
										
										
										
											2009-03-17 18:17:51 +01:00
										 |  |  | #include <texteditor/texteditorplugin.h>
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #include <texteditor/texteditorsettings.h>
 | 
					
						
							| 
									
										
										
										
											2009-07-22 15:32:52 +02:00
										 |  |  | #include <texteditor/texteditorconstants.h>
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #include <cpptools/cpptoolsconstants.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QtCore/QFileInfo>
 | 
					
						
							|  |  |  | #include <QtCore/QSettings>
 | 
					
						
							|  |  |  | #include <QtGui/QMenu>
 | 
					
						
							|  |  |  | #include <QtGui/QAction>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | using namespace CppEditor::Internal; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-17 17:43:51 +01:00
										 |  |  | //////////////////////////// CppEditorFactory /////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-17 17:43:51 +01:00
										 |  |  | CppEditorFactory::CppEditorFactory(CppPlugin *owner) : | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     m_kind(QLatin1String(CppEditor::Constants::CPPEDITOR_KIND)), | 
					
						
							|  |  |  |     m_owner(owner) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_mimeTypes << QLatin1String(CppEditor::Constants::C_SOURCE_MIMETYPE) | 
					
						
							| 
									
										
										
										
											2009-07-15 11:20:24 +02:00
										 |  |  |             << QLatin1String(CppEditor::Constants::C_HEADER_MIMETYPE) | 
					
						
							|  |  |  |             << QLatin1String(CppEditor::Constants::CPP_SOURCE_MIMETYPE) | 
					
						
							|  |  |  |             << QLatin1String(CppEditor::Constants::CPP_HEADER_MIMETYPE); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-14 16:37:26 +02:00
										 |  |  | #ifndef Q_WS_MAC
 | 
					
						
							| 
									
										
										
										
											2009-07-15 11:20:24 +02:00
										 |  |  |     Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance(); | 
					
						
							|  |  |  |     Core::MimeDatabase *mimeDatabase = Core::ICore::instance()->mimeDatabase(); | 
					
						
							|  |  |  |     iconProvider->registerIconOverlayForMimeType(QIcon(":/cppeditor/images/qt_cpp.png"), | 
					
						
							|  |  |  |                                                  mimeDatabase->findByType(QLatin1String(CppEditor::Constants::CPP_SOURCE_MIMETYPE))); | 
					
						
							|  |  |  |     iconProvider->registerIconOverlayForMimeType(QIcon(":/cppeditor/images/qt_c.png"), | 
					
						
							|  |  |  |                                                  mimeDatabase->findByType(QLatin1String(CppEditor::Constants::C_SOURCE_MIMETYPE))); | 
					
						
							|  |  |  |     iconProvider->registerIconOverlayForMimeType(QIcon(":/cppeditor/images/qt_h.png"), | 
					
						
							|  |  |  |                                                  mimeDatabase->findByType(QLatin1String(CppEditor::Constants::CPP_HEADER_MIMETYPE))); | 
					
						
							| 
									
										
										
										
											2009-07-14 16:37:26 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-17 17:43:51 +01:00
										 |  |  | QString CppEditorFactory::kind() const | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     return m_kind; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-17 17:43:51 +01:00
										 |  |  | Core::IFile *CppEditorFactory::open(const QString &fileName) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-01-21 15:52:34 +01:00
										 |  |  |     Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, kind()); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     return iface ? iface->file() : 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-17 17:43:51 +01:00
										 |  |  | Core::IEditor *CppEditorFactory::createEditor(QWidget *parent) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     CPPEditor *editor = new CPPEditor(parent); | 
					
						
							|  |  |  |     editor->setRevisionsVisible(true); | 
					
						
							|  |  |  |     editor->setMimeType(CppEditor::Constants::CPP_SOURCE_MIMETYPE); | 
					
						
							|  |  |  |     m_owner->initializeEditor(editor); | 
					
						
							|  |  |  |     return editor->editableInterface(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-17 17:43:51 +01:00
										 |  |  | QStringList CppEditorFactory::mimeTypes() const | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     return m_mimeTypes; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ///////////////////////////////// CppPlugin //////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | CppPlugin *CppPlugin::m_instance = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | CppPlugin::CppPlugin() : | 
					
						
							|  |  |  |     m_actionHandler(0), | 
					
						
							| 
									
										
										
										
											2009-04-27 17:22:49 +02:00
										 |  |  |     m_sortedMethodOverview(false) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     m_instance = this; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | CppPlugin::~CppPlugin() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     delete m_actionHandler; | 
					
						
							|  |  |  |     m_instance = 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | CppPlugin *CppPlugin::instance() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_instance; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void CppPlugin::initializeEditor(CPPEditor *editor) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_actionHandler->setupActions(editor); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-17 18:17:51 +01:00
										 |  |  |     TextEditor::TextEditorSettings::instance()->initializeEditor(editor); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // auto completion
 | 
					
						
							|  |  |  |     connect(editor, SIGNAL(requestAutoCompletion(ITextEditable*, bool)), | 
					
						
							| 
									
										
										
										
											2009-01-20 11:52:04 +01:00
										 |  |  |             TextEditor::Internal::CompletionSupport::instance(), SLOT(autoComplete(ITextEditable*, bool))); | 
					
						
							| 
									
										
										
										
											2009-06-09 13:52:27 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // quick fix
 | 
					
						
							|  |  |  |     connect(editor, SIGNAL(requestQuickFix(ITextEditable*)), | 
					
						
							|  |  |  |             TextEditor::Internal::CompletionSupport::instance(), SLOT(quickFix(ITextEditable*))); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-27 17:22:49 +02:00
										 |  |  |     // method combo box sorting
 | 
					
						
							|  |  |  |     connect(this, SIGNAL(methodOverviewSortingChanged(bool)), | 
					
						
							|  |  |  |             editor, SLOT(setSortedMethodOverview(bool))); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void CppPlugin::setSortedMethodOverview(bool sorted) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_sortedMethodOverview = sorted; | 
					
						
							|  |  |  |     emit methodOverviewSortingChanged(sorted); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool CppPlugin::sortedMethodOverview() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_sortedMethodOverview; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-01-20 11:52:04 +01:00
										 |  |  |     Core::ICore *core = Core::ICore::instance(); | 
					
						
							| 
									
										
										
										
											2009-07-15 11:20:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-20 11:52:04 +01:00
										 |  |  |     if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/cppeditor/CppEditor.mimetypes.xml"), errorMessage)) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-15 11:20:24 +02:00
										 |  |  |     addAutoReleasedObject(new CppEditorFactory(this)); | 
					
						
							| 
									
										
										
										
											2008-12-16 12:22:08 +01:00
										 |  |  |     addAutoReleasedObject(new CppHoverHandler); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     CppFileWizard::BaseFileWizardParameters wizardParameters(Core::IWizard::FileWizard); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     wizardParameters.setCategory(QLatin1String("C++")); | 
					
						
							|  |  |  |     wizardParameters.setTrCategory(tr("C++")); | 
					
						
							| 
									
										
										
										
											2009-05-25 13:45:00 +02:00
										 |  |  |     wizardParameters.setDescription(tr("Creates a C++ header file.")); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     wizardParameters.setName(tr("C++ Header File")); | 
					
						
							| 
									
										
										
										
											2009-01-20 11:52:04 +01:00
										 |  |  |     addAutoReleasedObject(new CppFileWizard(wizardParameters, Header, core)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-25 13:45:00 +02:00
										 |  |  |     wizardParameters.setDescription(tr("Creates a C++ source file.")); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     wizardParameters.setName(tr("C++ Source File")); | 
					
						
							| 
									
										
										
										
											2009-01-20 11:52:04 +01:00
										 |  |  |     addAutoReleasedObject(new CppFileWizard(wizardParameters, Source, core)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     wizardParameters.setKind(Core::IWizard::ClassWizard); | 
					
						
							|  |  |  |     wizardParameters.setName(tr("C++ Class")); | 
					
						
							|  |  |  |     wizardParameters.setDescription(tr("Creates a header and a source file for a new class.")); | 
					
						
							| 
									
										
										
										
											2009-01-20 11:52:04 +01:00
										 |  |  |     addAutoReleasedObject(new CppClassWizard(wizardParameters, core)); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     QList<int> context; | 
					
						
							| 
									
										
										
										
											2009-01-20 11:52:04 +01:00
										 |  |  |     context << core->uniqueIDManager()->uniqueIdentifier(CppEditor::Constants::C_CPPEDITOR); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-20 11:52:04 +01:00
										 |  |  |     Core::ActionManager *am = core->actionManager(); | 
					
						
							| 
									
										
										
										
											2009-09-24 14:50:22 +02:00
										 |  |  |     Core::ActionContainer *contextMenu= am->createMenu(CppEditor::Constants::M_CONTEXT); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-14 13:17:53 +01:00
										 |  |  |     Core::Command *cmd; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     QAction *jumpToDefinition = new QAction(tr("Follow Symbol under Cursor"), this); | 
					
						
							|  |  |  |     cmd = am->registerAction(jumpToDefinition, | 
					
						
							|  |  |  |         Constants::JUMP_TO_DEFINITION, context); | 
					
						
							|  |  |  |     cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F2)); | 
					
						
							|  |  |  |     connect(jumpToDefinition, SIGNAL(triggered()), | 
					
						
							|  |  |  |             this, SLOT(jumpToDefinition())); | 
					
						
							| 
									
										
										
										
											2009-09-24 14:50:22 +02:00
										 |  |  |     contextMenu->addAction(cmd); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QAction *switchDeclarationDefinition = new QAction(tr("Switch between Method Declaration/Definition"), this); | 
					
						
							|  |  |  |     cmd = am->registerAction(switchDeclarationDefinition, | 
					
						
							|  |  |  |         Constants::SWITCH_DECLARATION_DEFINITION, context); | 
					
						
							|  |  |  |     cmd->setDefaultKeySequence(QKeySequence("Shift+F2")); | 
					
						
							|  |  |  |     connect(switchDeclarationDefinition, SIGNAL(triggered()), | 
					
						
							|  |  |  |             this, SLOT(switchDeclarationDefinition())); | 
					
						
							| 
									
										
										
										
											2009-09-24 14:50:22 +02:00
										 |  |  |     contextMenu->addAction(cmd); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-04 13:44:54 +02:00
										 |  |  |     QAction *renameSymbolUnderCursorAction = new QAction(tr("Rename Symbol under Cursor"), this); | 
					
						
							|  |  |  |     cmd = am->registerAction(renameSymbolUnderCursorAction, | 
					
						
							|  |  |  |         Constants::RENAME_SYMBOL_UNDER_CURSOR, context); | 
					
						
							|  |  |  |     cmd->setDefaultKeySequence(QKeySequence("CTRL+SHIFT+R")); | 
					
						
							|  |  |  |     connect(renameSymbolUnderCursorAction, SIGNAL(triggered()), this, SLOT(renameSymbolUnderCursor())); | 
					
						
							| 
									
										
										
										
											2009-09-24 14:50:22 +02:00
										 |  |  |     contextMenu->addAction(cmd); | 
					
						
							| 
									
										
										
										
											2009-08-04 13:44:54 +02:00
										 |  |  |     am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-17 17:38:16 +01:00
										 |  |  |     m_actionHandler = new TextEditor::TextEditorActionHandler(CppEditor::Constants::C_CPPEDITOR, | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         TextEditor::TextEditorActionHandler::Format | 
					
						
							|  |  |  |         | TextEditor::TextEditorActionHandler::UnCommentSelection | 
					
						
							|  |  |  |         | TextEditor::TextEditorActionHandler::UnCollapseAll); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-22 15:32:52 +02:00
										 |  |  |     m_actionHandler->initializeActions(); | 
					
						
							| 
									
										
										
										
											2009-09-24 14:50:22 +02:00
										 |  |  |      | 
					
						
							|  |  |  |     QAction *separator = new QAction(this); | 
					
						
							|  |  |  |     separator->setSeparator(true); | 
					
						
							|  |  |  |     cmd = am->registerAction(separator, CppEditor::Constants::SEPARATOR, context); | 
					
						
							|  |  |  |     contextMenu->addAction(cmd); | 
					
						
							| 
									
										
										
										
											2009-07-22 15:32:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     cmd = am->command(TextEditor::Constants::AUTO_INDENT_SELECTION); | 
					
						
							| 
									
										
										
										
											2009-09-24 14:50:22 +02:00
										 |  |  |     contextMenu->addAction(cmd); | 
					
						
							| 
									
										
										
										
											2009-07-22 15:32:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     cmd = am->command(TextEditor::Constants::UN_COMMENT_SELECTION); | 
					
						
							| 
									
										
										
										
											2009-09-24 14:50:22 +02:00
										 |  |  |     contextMenu->addAction(cmd); | 
					
						
							| 
									
										
										
										
											2009-07-22 15:32:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-27 17:22:49 +02:00
										 |  |  |     readSettings(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-27 17:22:49 +02:00
										 |  |  | void CppPlugin::readSettings() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_sortedMethodOverview = Core::ICore::instance()->settings()->value("CppTools/SortedMethodOverview", false).toBool(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void CppPlugin::writeSettings() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Core::ICore::instance()->settings()->setValue("CppTools/SortedMethodOverview", m_sortedMethodOverview); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | void CppPlugin::extensionsInitialized() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-27 17:22:49 +02:00
										 |  |  | void CppPlugin::shutdown() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     writeSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | void CppPlugin::switchDeclarationDefinition() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-01-21 15:52:34 +01:00
										 |  |  |     Core::EditorManager *em = Core::EditorManager::instance(); | 
					
						
							|  |  |  |     CPPEditor *editor = qobject_cast<CPPEditor*>(em->currentEditor()->widget()); | 
					
						
							|  |  |  |     if (editor) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         editor->switchDeclarationDefinition(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void CppPlugin::jumpToDefinition() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-01-21 15:52:34 +01:00
										 |  |  |     Core::EditorManager *em = Core::EditorManager::instance(); | 
					
						
							|  |  |  |     CPPEditor *editor = qobject_cast<CPPEditor*>(em->currentEditor()->widget()); | 
					
						
							|  |  |  |     if (editor) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         editor->jumpToDefinition(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-04 13:44:54 +02:00
										 |  |  | void CppPlugin::renameSymbolUnderCursor() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Core::EditorManager *em = Core::EditorManager::instance(); | 
					
						
							|  |  |  |     CPPEditor *editor = qobject_cast<CPPEditor*>(em->currentEditor()->widget()); | 
					
						
							|  |  |  |     if (editor) | 
					
						
							|  |  |  |         editor->renameSymbolUnderCursor(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | Q_EXPORT_PLUGIN(CppPlugin) |