OSDN Git Service

Add Clean and rebuild sub dir
authordt <qtc-committer@nokia.com>
Fri, 30 Apr 2010 09:50:04 +0000 (11:50 +0200)
committerdt <qtc-committer@nokia.com>
Fri, 30 Apr 2010 09:55:04 +0000 (11:55 +0200)
Also change the strings slightly.

Task-Nr:   QTCREATORBUG-1295
Task-Nr:   QTCREATORBUG-1296

src/plugins/qt4projectmanager/qt4projectmanager.cpp
src/plugins/qt4projectmanager/qt4projectmanager.h
src/plugins/qt4projectmanager/qt4projectmanagerconstants.h
src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp
src/plugins/qt4projectmanager/qt4projectmanagerplugin.h

index 1ec86aa..ce83712 100644 (file)
@@ -269,6 +269,21 @@ void Qt4Manager::runQMake(ProjectExplorer::Project *p, ProjectExplorer::Node *no
 
 void Qt4Manager::buildSubDirContextMenu()
 {
+    handleSubDirContexMenu(BUILD);
+}
+
+void Qt4Manager::cleanSubDirContextMenu()
+{
+    handleSubDirContexMenu(CLEAN);
+}
+
+void Qt4Manager::rebuildSubDirContextMenu()
+{
+    handleSubDirContexMenu(REBUILD);
+}
+
+void Qt4Manager::handleSubDirContexMenu(Qt4Manager::Action action)
+{
     Qt4Project *qt4pro = qobject_cast<Qt4Project *>(m_contextProject);
     QTC_ASSERT(qt4pro, return);
 
@@ -281,8 +296,16 @@ void Qt4Manager::buildSubDirContextMenu()
         if (Qt4ProFileNode *profile = qobject_cast<Qt4ProFileNode *>(m_contextNode))
             bc->setSubNodeBuild(profile);
 
-    if (projectExplorer()->saveModifiedFiles())
-        projectExplorer()->buildManager()->buildProject(bc);
+    if (projectExplorer()->saveModifiedFiles()) {
+        if (action == BUILD)
+            projectExplorer()->buildManager()->buildProject(bc);
+        else if (action == CLEAN)
+            projectExplorer()->buildManager()->cleanProject(bc);
+        else if (action == REBUILD) {
+            projectExplorer()->buildManager()->cleanProject(bc);
+            projectExplorer()->buildManager()->buildProject(bc);
+        }
+    }
 
     bc->setSubNodeBuild(0);
 }
index 199c4b9..21c316d 100644 (file)
@@ -90,10 +90,14 @@ public:
     // Return the id string of a file
     static QString fileTypeId(ProjectExplorer::FileType type);
 
+    enum Action { BUILD, REBUILD, CLEAN };
+
 public slots:
     void runQMake();
     void runQMakeContextMenu();
     void buildSubDirContextMenu();
+    void rebuildSubDirContextMenu();
+    void cleanSubDirContextMenu();
 
 private slots:
     void editorAboutToClose(Core::IEditor *editor);
@@ -102,6 +106,7 @@ private slots:
 
 private:
     QList<Qt4Project *> m_projects;
+    void handleSubDirContexMenu(Action action);
     void runQMake(ProjectExplorer::Project *p, ProjectExplorer::Node *node);
 
     Internal::Qt4ProjectManagerPlugin *m_plugin;
index 98fb572..9518165 100644 (file)
@@ -58,6 +58,8 @@ const char * const ADDTOPROJECT        = "Qt4.AddToProject";
 const char * const RUNQMAKE            = "Qt4Builder.RunQMake";
 const char * const RUNQMAKECONTEXTMENU = "Qt4Builder.RunQMakeContextMenu";
 const char * const BUILDSUBDIR         = "Qt4Builder.BuildSubDir";
+const char * const REBUILDSUBDIR       = "Qt4Builder.RebuildSubDir";
+const char * const CLEANSUBDIR         = "Qt4Builder.CleanSubDir";
 
 //configurations
 const char * const CONFIG_DEBUG     = "debug";
index 8339feb..6a1f08e 100644 (file)
@@ -185,7 +185,6 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *
     m_runQMakeActionContextMenu = new QAction(qmakeIcon, tr("Run qmake"), this);
     command = am->registerAction(m_runQMakeActionContextMenu, Constants::RUNQMAKECONTEXTMENU, context);
     command->setAttribute(Core::Command::CA_Hide);
-    command->setAttribute(Core::Command::CA_UpdateText);
     mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
     msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
     connect(m_runQMakeActionContextMenu, SIGNAL(triggered()), m_qt4ProjectManager, SLOT(runQMakeContextMenu()));
@@ -195,10 +194,25 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *
     m_buildSubProjectContextMenu = new QAction(buildIcon, tr("Build"), this);
     command = am->registerAction(m_buildSubProjectContextMenu, Constants::BUILDSUBDIR, context);
     command->setAttribute(Core::Command::CA_Hide);
-    command->setAttribute(Core::Command::CA_UpdateText);
     msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
     connect(m_buildSubProjectContextMenu, SIGNAL(triggered()), m_qt4ProjectManager, SLOT(buildSubDirContextMenu()));
 
+    QIcon rebuildIcon(ProjectExplorer::Constants::ICON_REBUILD);
+    rebuildIcon.addFile(ProjectExplorer::Constants::ICON_REBUILD_SMALL);
+    m_rebuildSubProjectContextMenu = new QAction(rebuildIcon, tr("Rebuild"), this);
+    command = am->registerAction(m_rebuildSubProjectContextMenu, Constants::REBUILDSUBDIR, context);
+    command->setAttribute(Core::Command::CA_Hide);
+    msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
+    connect(m_rebuildSubProjectContextMenu, SIGNAL(triggered()), m_qt4ProjectManager, SLOT(rebuildSubDirContextMenu()));
+
+    QIcon cleanIcon(ProjectExplorer::Constants::ICON_CLEAN);
+    cleanIcon.addFile(ProjectExplorer::Constants::ICON_CLEAN_SMALL);
+    m_cleanSubProjectContextMenu = new QAction(cleanIcon, tr("Clean"), this);
+    command = am->registerAction(m_cleanSubProjectContextMenu, Constants::CLEANSUBDIR, context);
+    command->setAttribute(Core::Command::CA_Hide);
+    msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
+    connect(m_cleanSubProjectContextMenu, SIGNAL(triggered()), m_qt4ProjectManager, SLOT(cleanSubDirContextMenu()));
+
     connect(m_projectExplorer,
             SIGNAL(aboutToShowContextMenu(ProjectExplorer::Project*, ProjectExplorer::Node*)),
             this, SLOT(updateContextMenu(ProjectExplorer::Project*, ProjectExplorer::Node*)));
@@ -223,23 +237,27 @@ void Qt4ProjectManagerPlugin::updateContextMenu(Project *project,
     m_qt4ProjectManager->setContextNode(node);
     m_runQMakeActionContextMenu->setEnabled(false);
     m_buildSubProjectContextMenu->setEnabled(false);
+    m_rebuildSubProjectContextMenu->setEnabled(false);
+    m_cleanSubProjectContextMenu->setEnabled(false);
 
     Qt4ProFileNode *proFileNode = qobject_cast<Qt4ProFileNode *>(node);
     if (qobject_cast<Qt4Project *>(project) && proFileNode) {
         m_runQMakeActionContextMenu->setVisible(true);
         m_buildSubProjectContextMenu->setVisible(true);
-
-        const QString nativeBuildDir = QDir::toNativeSeparators(proFileNode->buildDir());
-        m_runQMakeActionContextMenu->setText(tr("Run qmake in %1").arg(nativeBuildDir));
-        m_buildSubProjectContextMenu->setText(tr("Build in %1").arg(nativeBuildDir));
+        m_rebuildSubProjectContextMenu->setVisible(true);
+        m_cleanSubProjectContextMenu->setVisible(true);
 
         if (!m_projectExplorer->buildManager()->isBuilding(project)) {
             m_runQMakeActionContextMenu->setEnabled(true);
             m_buildSubProjectContextMenu->setEnabled(true);
+            m_rebuildSubProjectContextMenu->setEnabled(true);
+            m_cleanSubProjectContextMenu->setEnabled(true);
         }
     } else {
         m_runQMakeActionContextMenu->setVisible(false);
         m_buildSubProjectContextMenu->setVisible(false);
+        m_rebuildSubProjectContextMenu->setVisible(false);
+        m_cleanSubProjectContextMenu->setVisible(false);
     }
 }
 
index b8af4cc..b6697d6 100644 (file)
@@ -91,6 +91,8 @@ private:
     QAction *m_runQMakeAction;
     QAction *m_runQMakeActionContextMenu;
     QAction *m_buildSubProjectContextMenu;
+    QAction *m_rebuildSubProjectContextMenu;
+    QAction *m_cleanSubProjectContextMenu;
     GettingStartedWelcomePage *m_welcomePage;
 };