Commit ff61f229 authored by dt's avatar dt

Add Clean and rebuild sub dir

Also change the strings slightly.

Task-Nr:   QTCREATORBUG-1295
Task-Nr:   QTCREATORBUG-1296
parent a60d55bd
......@@ -268,6 +268,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);
}
......
......@@ -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;
......
......@@ -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";
......
......@@ -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);
}
}
......
......@@ -91,6 +91,8 @@ private:
QAction *m_runQMakeAction;
QAction *m_runQMakeActionContextMenu;
QAction *m_buildSubProjectContextMenu;
QAction *m_rebuildSubProjectContextMenu;
QAction *m_cleanSubProjectContextMenu;
GettingStartedWelcomePage *m_welcomePage;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment