Commit 7c7477ee authored by Eike Ziller's avatar Eike Ziller
Browse files

Show target page (in project mode) even if project only has one target.



The distinction doesn't really make sense anymore.
This is also a prerequisite for
1. adding a "manage" button for managing targets to the target page, and
2. using the "add" button to import builds even for "configured"
projects

Change-Id: Ib8287dc7d11efa84c54933a591ef15a76042318f
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent 35086852
......@@ -294,7 +294,7 @@ void ProjectWindow::handleProfilesChanges()
int index = m_tabWidget->currentIndex();
QList<Project *> projects = m_tabIndexToProject;
foreach (ProjectExplorer::Project *project, projects) {
if (m_usesTargetPage.value(project) != useTargetPage(project)) {
if (m_hasTarget.value(project) != hasTarget(project)) {
changed = true;
deregisterProject(project);
registerProject(project);
......@@ -304,21 +304,9 @@ void ProjectWindow::handleProfilesChanges()
m_tabWidget->setCurrentIndex(index);
}
bool ProjectWindow::useTargetPage(ProjectExplorer::Project *project)
bool ProjectWindow::hasTarget(ProjectExplorer::Project *project)
{
if (project->targets().isEmpty())
return false;
if (project->targets().size() > 1)
return true;
int count = 0;
QList<Profile *> profiles = ProfileManager::instance()->profiles();
foreach (Profile *p, profiles) {
if (project->supportsProfile(p))
++count;
if (count > 1)
return true;
}
return false;
return !project->targets().isEmpty();
}
void ProjectWindow::registerProject(ProjectExplorer::Project *project)
......@@ -338,25 +326,11 @@ void ProjectWindow::registerProject(ProjectExplorer::Project *project)
QStringList subtabs;
bool usesTargetPage = useTargetPage(project);
m_usesTargetPage.insert(project, usesTargetPage);
if (!usesTargetPage){
// Show the target specific pages directly
if (project->activeTarget()) {
QList<ITargetPanelFactory *> factories =
ExtensionSystem::PluginManager::getObjects<ITargetPanelFactory>();
qSort(factories.begin(), factories.end(), &IPanelFactory::prioritySort);
bool projectHasTarget = hasTarget(project);
m_hasTarget.insert(project, projectHasTarget);
foreach (ITargetPanelFactory *factory, factories)
if (factory->supports(project->activeTarget()))
subtabs << factory->displayName();
}
} else {
// Use the Targets page
if (projectHasTarget) // Use the Targets page
subtabs << QCoreApplication::translate("TargetSettingsPanelFactory", "Targets");
}
// Add the project specific pages
QList<IProjectPanelFactory *> factories = ExtensionSystem::PluginManager::getObjects<IProjectPanelFactory>();
......@@ -410,7 +384,7 @@ void ProjectWindow::showProperties(int index, int subIndex)
m_previousTargetSubIndex = previousPanelWidget->currentSubIndex();
}
if (m_usesTargetPage.value(project)) {
if (m_hasTarget.value(project)) {
if (subIndex == 0) {
// Targets page
removeCurrentWidget();
......@@ -422,32 +396,17 @@ void ProjectWindow::showProperties(int index, int subIndex)
m_centralWidget->setCurrentWidget(m_currentWidget);
}
++pos;
} else if (project->activeTarget()) {
// No Targets page, target specific pages are first in the list
QList<ITargetPanelFactory *> factories = ExtensionSystem::PluginManager::getObjects<ITargetPanelFactory>();
qSort(factories.begin(), factories.end(), &ITargetPanelFactory::prioritySort);
foreach (ITargetPanelFactory *panelFactory, factories) {
if (panelFactory->supports(project->activeTarget())) {
if (subIndex == pos) {
fac = panelFactory;
break;
}
++pos;
}
}
}
if (!fac) {
QList<IProjectPanelFactory *> factories = ExtensionSystem::PluginManager::getObjects<IProjectPanelFactory>();
qSort(factories.begin(), factories.end(), &IPanelFactory::prioritySort);
foreach (IProjectPanelFactory *panelFactory, factories) {
if (panelFactory->supports(project)) {
if (subIndex == pos) {
fac = panelFactory;
break;
}
++pos;
QList<IProjectPanelFactory *> factories = ExtensionSystem::PluginManager::getObjects<IProjectPanelFactory>();
qSort(factories.begin(), factories.end(), &IPanelFactory::prioritySort);
foreach (IProjectPanelFactory *panelFactory, factories) {
if (panelFactory->supports(project)) {
if (subIndex == pos) {
fac = panelFactory;
break;
}
++pos;
}
}
......
......@@ -93,14 +93,14 @@ private slots:
void removedTarget(ProjectExplorer::Target*);
private:
bool useTargetPage(ProjectExplorer::Project *project);
bool hasTarget(ProjectExplorer::Project *project);
void removeCurrentWidget();
DoubleTabWidget *m_tabWidget;
QStackedWidget *m_centralWidget;
QWidget *m_currentWidget;
QList<ProjectExplorer::Project *> m_tabIndexToProject;
QMap<ProjectExplorer::Project *, bool> m_usesTargetPage;
QMap<ProjectExplorer::Project *, bool> m_hasTarget;
int m_previousTargetSubIndex;
};
......
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