Add Clean and rebuild sub dir

Also change the strings slightly.

Task-Nr:   QTCREATORBUG-1295
Task-Nr:   QTCREATORBUG-1296
This commit is contained in:
dt
2010-04-30 11:50:04 +02:00
parent a60d55bdad
commit ff61f2295d
5 changed files with 58 additions and 8 deletions

View File

@@ -268,6 +268,21 @@ void Qt4Manager::runQMake(ProjectExplorer::Project *p, ProjectExplorer::Node *no
} }
void Qt4Manager::buildSubDirContextMenu() 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); Qt4Project *qt4pro = qobject_cast<Qt4Project *>(m_contextProject);
QTC_ASSERT(qt4pro, return); QTC_ASSERT(qt4pro, return);
@@ -281,8 +296,16 @@ void Qt4Manager::buildSubDirContextMenu()
if (Qt4ProFileNode *profile = qobject_cast<Qt4ProFileNode *>(m_contextNode)) if (Qt4ProFileNode *profile = qobject_cast<Qt4ProFileNode *>(m_contextNode))
bc->setSubNodeBuild(profile); bc->setSubNodeBuild(profile);
if (projectExplorer()->saveModifiedFiles()) if (projectExplorer()->saveModifiedFiles()) {
if (action == BUILD)
projectExplorer()->buildManager()->buildProject(bc); 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); bc->setSubNodeBuild(0);
} }

View File

@@ -90,10 +90,14 @@ public:
// Return the id string of a file // Return the id string of a file
static QString fileTypeId(ProjectExplorer::FileType type); static QString fileTypeId(ProjectExplorer::FileType type);
enum Action { BUILD, REBUILD, CLEAN };
public slots: public slots:
void runQMake(); void runQMake();
void runQMakeContextMenu(); void runQMakeContextMenu();
void buildSubDirContextMenu(); void buildSubDirContextMenu();
void rebuildSubDirContextMenu();
void cleanSubDirContextMenu();
private slots: private slots:
void editorAboutToClose(Core::IEditor *editor); void editorAboutToClose(Core::IEditor *editor);
@@ -102,6 +106,7 @@ private slots:
private: private:
QList<Qt4Project *> m_projects; QList<Qt4Project *> m_projects;
void handleSubDirContexMenu(Action action);
void runQMake(ProjectExplorer::Project *p, ProjectExplorer::Node *node); void runQMake(ProjectExplorer::Project *p, ProjectExplorer::Node *node);
Internal::Qt4ProjectManagerPlugin *m_plugin; Internal::Qt4ProjectManagerPlugin *m_plugin;

View File

@@ -58,6 +58,8 @@ const char * const ADDTOPROJECT = "Qt4.AddToProject";
const char * const RUNQMAKE = "Qt4Builder.RunQMake"; const char * const RUNQMAKE = "Qt4Builder.RunQMake";
const char * const RUNQMAKECONTEXTMENU = "Qt4Builder.RunQMakeContextMenu"; const char * const RUNQMAKECONTEXTMENU = "Qt4Builder.RunQMakeContextMenu";
const char * const BUILDSUBDIR = "Qt4Builder.BuildSubDir"; const char * const BUILDSUBDIR = "Qt4Builder.BuildSubDir";
const char * const REBUILDSUBDIR = "Qt4Builder.RebuildSubDir";
const char * const CLEANSUBDIR = "Qt4Builder.CleanSubDir";
//configurations //configurations
const char * const CONFIG_DEBUG = "debug"; const char * const CONFIG_DEBUG = "debug";

View File

@@ -185,7 +185,6 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *
m_runQMakeActionContextMenu = new QAction(qmakeIcon, tr("Run qmake"), this); m_runQMakeActionContextMenu = new QAction(qmakeIcon, tr("Run qmake"), this);
command = am->registerAction(m_runQMakeActionContextMenu, Constants::RUNQMAKECONTEXTMENU, context); command = am->registerAction(m_runQMakeActionContextMenu, Constants::RUNQMAKECONTEXTMENU, context);
command->setAttribute(Core::Command::CA_Hide); command->setAttribute(Core::Command::CA_Hide);
command->setAttribute(Core::Command::CA_UpdateText);
mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD); mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD); msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
connect(m_runQMakeActionContextMenu, SIGNAL(triggered()), m_qt4ProjectManager, SLOT(runQMakeContextMenu())); 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); m_buildSubProjectContextMenu = new QAction(buildIcon, tr("Build"), this);
command = am->registerAction(m_buildSubProjectContextMenu, Constants::BUILDSUBDIR, context); command = am->registerAction(m_buildSubProjectContextMenu, Constants::BUILDSUBDIR, context);
command->setAttribute(Core::Command::CA_Hide); command->setAttribute(Core::Command::CA_Hide);
command->setAttribute(Core::Command::CA_UpdateText);
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD); msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
connect(m_buildSubProjectContextMenu, SIGNAL(triggered()), m_qt4ProjectManager, SLOT(buildSubDirContextMenu())); 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, connect(m_projectExplorer,
SIGNAL(aboutToShowContextMenu(ProjectExplorer::Project*, ProjectExplorer::Node*)), SIGNAL(aboutToShowContextMenu(ProjectExplorer::Project*, ProjectExplorer::Node*)),
this, SLOT(updateContextMenu(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_qt4ProjectManager->setContextNode(node);
m_runQMakeActionContextMenu->setEnabled(false); m_runQMakeActionContextMenu->setEnabled(false);
m_buildSubProjectContextMenu->setEnabled(false); m_buildSubProjectContextMenu->setEnabled(false);
m_rebuildSubProjectContextMenu->setEnabled(false);
m_cleanSubProjectContextMenu->setEnabled(false);
Qt4ProFileNode *proFileNode = qobject_cast<Qt4ProFileNode *>(node); Qt4ProFileNode *proFileNode = qobject_cast<Qt4ProFileNode *>(node);
if (qobject_cast<Qt4Project *>(project) && proFileNode) { if (qobject_cast<Qt4Project *>(project) && proFileNode) {
m_runQMakeActionContextMenu->setVisible(true); m_runQMakeActionContextMenu->setVisible(true);
m_buildSubProjectContextMenu->setVisible(true); m_buildSubProjectContextMenu->setVisible(true);
m_rebuildSubProjectContextMenu->setVisible(true);
const QString nativeBuildDir = QDir::toNativeSeparators(proFileNode->buildDir()); m_cleanSubProjectContextMenu->setVisible(true);
m_runQMakeActionContextMenu->setText(tr("Run qmake in %1").arg(nativeBuildDir));
m_buildSubProjectContextMenu->setText(tr("Build in %1").arg(nativeBuildDir));
if (!m_projectExplorer->buildManager()->isBuilding(project)) { if (!m_projectExplorer->buildManager()->isBuilding(project)) {
m_runQMakeActionContextMenu->setEnabled(true); m_runQMakeActionContextMenu->setEnabled(true);
m_buildSubProjectContextMenu->setEnabled(true); m_buildSubProjectContextMenu->setEnabled(true);
m_rebuildSubProjectContextMenu->setEnabled(true);
m_cleanSubProjectContextMenu->setEnabled(true);
} }
} else { } else {
m_runQMakeActionContextMenu->setVisible(false); m_runQMakeActionContextMenu->setVisible(false);
m_buildSubProjectContextMenu->setVisible(false); m_buildSubProjectContextMenu->setVisible(false);
m_rebuildSubProjectContextMenu->setVisible(false);
m_cleanSubProjectContextMenu->setVisible(false);
} }
} }

View File

@@ -91,6 +91,8 @@ private:
QAction *m_runQMakeAction; QAction *m_runQMakeAction;
QAction *m_runQMakeActionContextMenu; QAction *m_runQMakeActionContextMenu;
QAction *m_buildSubProjectContextMenu; QAction *m_buildSubProjectContextMenu;
QAction *m_rebuildSubProjectContextMenu;
QAction *m_cleanSubProjectContextMenu;
GettingStartedWelcomePage *m_welcomePage; GettingStartedWelcomePage *m_welcomePage;
}; };