| 
									
										
										
										
											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
										 |  |  | ** | 
					
						
							|  |  |  | ** Contact:  Qt Software Information (qt-info@nokia.com) | 
					
						
							|  |  |  | ** | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							|  |  |  | ** contact the sales department at qt-sales@nokia.com. | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | **************************************************************************/ | 
					
						
							| 
									
										
										
										
											2008-12-02 16:19:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #include "qt4projectmanagerplugin.h"
 | 
					
						
							| 
									
										
										
										
											2008-12-02 16:19:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #include "qt4projectmanager.h"
 | 
					
						
							|  |  |  | #include "wizards/consoleappwizard.h"
 | 
					
						
							|  |  |  | #include "wizards/guiappwizard.h"
 | 
					
						
							|  |  |  | #include "wizards/librarywizard.h"
 | 
					
						
							|  |  |  | #include "profileeditorfactory.h"
 | 
					
						
							|  |  |  | #include "qt4projectmanagerconstants.h"
 | 
					
						
							|  |  |  | #include "qt4project.h"
 | 
					
						
							|  |  |  | #include "embeddedpropertiespage.h"
 | 
					
						
							|  |  |  | #include "qt4runconfiguration.h"
 | 
					
						
							|  |  |  | #include "profilereader.h"
 | 
					
						
							| 
									
										
										
										
											2009-04-28 12:43:04 +02:00
										 |  |  | #include "qtversionmanager.h"
 | 
					
						
							|  |  |  | #include "qtoptionspage.h"
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-20 15:31:33 +01:00
										 |  |  | #include <coreplugin/icore.h>
 | 
					
						
							| 
									
										
										
										
											2009-01-20 09:32:59 +01:00
										 |  |  | #include <extensionsystem/pluginmanager.h>
 | 
					
						
							| 
									
										
										
										
											2009-01-14 15:08:46 +01:00
										 |  |  | #include <projectexplorer/buildmanager.h>
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #include <projectexplorer/project.h>
 | 
					
						
							| 
									
										
										
										
											2009-01-14 15:08:46 +01:00
										 |  |  | #include <projectexplorer/projectexplorer.h>
 | 
					
						
							|  |  |  | #include <projectexplorer/projectexplorerconstants.h>
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #include <projectexplorer/projectnodes.h>
 | 
					
						
							|  |  |  | #include <coreplugin/uniqueidmanager.h>
 | 
					
						
							|  |  |  | #include <coreplugin/mimedatabase.h>
 | 
					
						
							| 
									
										
										
										
											2009-01-13 13:39:31 +01:00
										 |  |  | #include <coreplugin/actionmanager/actionmanager.h>
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #include <texteditor/texteditoractionhandler.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-20 15:31:33 +01:00
										 |  |  | #include <QtCore/QDebug>
 | 
					
						
							|  |  |  | #include <QtCore/QtPlugin>
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #include <QtGui/QMenu>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef WITH_TESTS
 | 
					
						
							|  |  |  | #include <QTest>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | using namespace Qt4ProjectManager::Internal; | 
					
						
							|  |  |  | using namespace Qt4ProjectManager; | 
					
						
							|  |  |  | using ProjectExplorer::Project; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Qt4ProjectManagerPlugin::~Qt4ProjectManagerPlugin() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     //removeObject(m_embeddedPropertiesPage);
 | 
					
						
							|  |  |  |     //delete m_embeddedPropertiesPage;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     removeObject(m_proFileEditorFactory); | 
					
						
							|  |  |  |     delete m_proFileEditorFactory; | 
					
						
							|  |  |  |     removeObject(m_qt4ProjectManager); | 
					
						
							|  |  |  |     delete m_qt4ProjectManager; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2009-01-14 13:17:53 +01:00
										 |  |  | static Core::Command *createSeparator(Core::ActionManager *am, | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |                                        QObject *parent, | 
					
						
							|  |  |  |                                        const QString &name, | 
					
						
							|  |  |  |                                        const QList<int> &context) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QAction *tmpaction = new QAction(parent); | 
					
						
							|  |  |  |     tmpaction->setSeparator(true); | 
					
						
							|  |  |  |     return am->registerAction(tmpaction, name, context); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2009-01-20 15:31:33 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *errorMessage) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-01-20 15:31:33 +01:00
										 |  |  |     Q_UNUSED(arguments); | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2009-01-20 11:52:04 +01:00
										 |  |  |     Core::ICore *core = Core::ICore::instance(); | 
					
						
							|  |  |  |     if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":qt4projectmanager/Qt4ProjectManager.mimetypes.xml"), errorMessage)) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-04 09:38:01 +01:00
										 |  |  |     m_projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance(); | 
					
						
							| 
									
										
										
										
											2009-01-20 11:52:04 +01:00
										 |  |  |     Core::ActionManager *am = core->actionManager(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-28 12:43:04 +02:00
										 |  |  |     QtVersionManager::m_self = new QtVersionManager(); | 
					
						
							|  |  |  |     addAutoReleasedObject(QtVersionManager::m_self); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     addAutoReleasedObject(new QtOptionsPage()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     //create and register objects
 | 
					
						
							| 
									
										
										
										
											2009-01-20 15:31:33 +01:00
										 |  |  |     m_qt4ProjectManager = new Qt4Manager(this); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     addObject(m_qt4ProjectManager); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     TextEditor::TextEditorActionHandler *editorHandler | 
					
						
							| 
									
										
										
										
											2009-01-20 15:31:33 +01:00
										 |  |  |             = new TextEditor::TextEditorActionHandler(Constants::C_PROFILEEDITOR); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     m_proFileEditorFactory = new ProFileEditorFactory(m_qt4ProjectManager, editorHandler); | 
					
						
							|  |  |  |     addObject(m_proFileEditorFactory); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-20 15:31:33 +01:00
										 |  |  |     GuiAppWizard *guiWizard = new GuiAppWizard; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     addAutoReleasedObject(guiWizard); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-20 15:31:33 +01:00
										 |  |  |     ConsoleAppWizard *consoleWizard = new ConsoleAppWizard; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     addAutoReleasedObject(consoleWizard); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-20 15:31:33 +01:00
										 |  |  |     LibraryWizard *libWizard = new LibraryWizard; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     addAutoReleasedObject(libWizard); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-20 16:25:48 +02:00
										 |  |  |     addAutoReleasedObject(new QMakeStepFactory); | 
					
						
							|  |  |  |     addAutoReleasedObject(new MakeStepFactory); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     addAutoReleasedObject(new Qt4RunConfigurationFactory); | 
					
						
							|  |  |  |     addAutoReleasedObject(new Qt4RunConfigurationFactoryUser); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // TODO reenable
 | 
					
						
							|  |  |  |     //m_embeddedPropertiesPage = new EmbeddedPropertiesPage;
 | 
					
						
							|  |  |  |     //addObject(m_embeddedPropertiesPage);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     //menus
 | 
					
						
							| 
									
										
										
										
											2009-01-14 12:39:59 +01:00
										 |  |  |     Core::ActionContainer *mbuild = | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         am->actionContainer(ProjectExplorer::Constants::M_BUILDPROJECT); | 
					
						
							| 
									
										
										
										
											2009-01-14 12:39:59 +01:00
										 |  |  |     Core::ActionContainer *mproject = | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         am->actionContainer(ProjectExplorer::Constants::M_PROJECTCONTEXT); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     //register actions
 | 
					
						
							| 
									
										
										
										
											2009-01-20 11:52:04 +01:00
										 |  |  |     m_projectContext = core->uniqueIDManager()-> | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         uniqueIdentifier(Qt4ProjectManager::Constants::PROJECT_KIND); | 
					
						
							|  |  |  |     QList<int> context = QList<int>() << m_projectContext; | 
					
						
							| 
									
										
										
										
											2009-01-14 13:17:53 +01:00
										 |  |  |     Core::Command *command; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     QIcon qmakeIcon(QLatin1String(":/qt4projectmanager/images/run_qmake.png")); | 
					
						
							|  |  |  |     qmakeIcon.addFile(QLatin1String(":/qt4projectmanager/images/run_qmake_small.png")); | 
					
						
							|  |  |  |     m_runQMakeAction = new QAction(qmakeIcon, tr("Run qmake"), this); | 
					
						
							|  |  |  |     command = am->registerAction(m_runQMakeAction, Constants::RUNQMAKE, context); | 
					
						
							|  |  |  |     mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_RUN); | 
					
						
							|  |  |  |     connect(m_runQMakeAction, SIGNAL(triggered()), m_qt4ProjectManager, SLOT(runQMake())); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_runQMakeActionContextMenu = new QAction(qmakeIcon, tr("Run qmake"), this); | 
					
						
							|  |  |  |     command = am->registerAction(m_runQMakeActionContextMenu, Constants::RUNQMAKECONTEXTMENU, context); | 
					
						
							|  |  |  |     mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD); | 
					
						
							|  |  |  |     connect(m_runQMakeActionContextMenu, SIGNAL(triggered()), m_qt4ProjectManager, SLOT(runQMakeContextMenu())); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     connect(m_projectExplorer, | 
					
						
							|  |  |  |             SIGNAL(aboutToShowContextMenu(ProjectExplorer::Project*, ProjectExplorer::Node*)), | 
					
						
							|  |  |  |             this, SLOT(updateContextMenu(ProjectExplorer::Project*, ProjectExplorer::Node*))); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     connect(m_projectExplorer->buildManager(), SIGNAL(buildStateChanged(ProjectExplorer::Project *)), | 
					
						
							|  |  |  |             this, SLOT(buildStateChanged(ProjectExplorer::Project *))); | 
					
						
							|  |  |  |     connect(m_projectExplorer, SIGNAL(currentProjectChanged(ProjectExplorer::Project *)), | 
					
						
							|  |  |  |             this, SLOT(currentProjectChanged())); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Qt4ProjectManagerPlugin::extensionsInitialized() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_qt4ProjectManager->init(); | 
					
						
							|  |  |  |     m_proFileEditorFactory->initializeActions(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Qt4ProjectManagerPlugin::updateContextMenu(Project *project, | 
					
						
							|  |  |  |                                                 ProjectExplorer::Node *node) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_qt4ProjectManager->setContextProject(project); | 
					
						
							|  |  |  |     m_qt4ProjectManager->setContextNode(node); | 
					
						
							|  |  |  |     m_runQMakeActionContextMenu->setEnabled(false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (qobject_cast<Qt4Project *>(project)) { | 
					
						
							|  |  |  |         if (!m_projectExplorer->buildManager()->isBuilding(project)) | 
					
						
							|  |  |  |             m_runQMakeActionContextMenu->setEnabled(true); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Qt4ProjectManagerPlugin::currentProjectChanged() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_runQMakeAction->setEnabled(!m_projectExplorer->buildManager()->isBuilding(m_projectExplorer->currentProject())); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Qt4ProjectManagerPlugin::buildStateChanged(ProjectExplorer::Project *pro) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ProjectExplorer::Project *currentProject = m_projectExplorer->currentProject(); | 
					
						
							|  |  |  |     if (pro == currentProject) | 
					
						
							|  |  |  |         m_runQMakeAction->setEnabled(!m_projectExplorer->buildManager()->isBuilding(currentProject)); | 
					
						
							|  |  |  |     if (pro == m_qt4ProjectManager->contextProject()) | 
					
						
							|  |  |  |         m_runQMakeActionContextMenu->setEnabled(!m_projectExplorer->buildManager()->isBuilding(pro)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef WITH_TESTS
 | 
					
						
							|  |  |  | void Qt4ProjectManagerPlugin::testBasicProjectLoading() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QString testDirectory = ExtensionSystem::PluginManager::instance()->testDataDirectory() + "/qt4projectmanager/"; | 
					
						
							|  |  |  |     QString test1 = testDirectory + "test1/test1.pro"; | 
					
						
							|  |  |  |     m_projectExplorer->openProject(test1); | 
					
						
							|  |  |  |     QVERIFY(!m_projectExplorer->session()->projects().isEmpty()); | 
					
						
							|  |  |  |     Qt4Project *qt4project = qobject_cast<Qt4Project *>(m_projectExplorer->session()->projects().first()); | 
					
						
							|  |  |  |     QVERIFY(qt4project); | 
					
						
							|  |  |  |     QVERIFY(qt4project->rootProjectNode()->projectType() == ApplicationTemplate); | 
					
						
							|  |  |  |     QVERIFY(m_projectExplorer->currentProject() != 0); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Qt4ProjectManagerPlugin::testNotYetImplemented() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QCOMPARE(1+1, 2); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Q_EXPORT_PLUGIN(Qt4ProjectManagerPlugin) |