forked from qt-creator/qt-creator
ProjectExplorer: Add option to import existing builds
Add option to import existing builds back into Projects mode. Click an "Add Kit" to get the entry (for projects that actually support importing builds). Task-number: QTCREATORBUG-7836 Change-Id: I43cf0f0ba5f80c88b6ffce1381f34f5591213e05 Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
@@ -29,9 +29,11 @@
|
||||
|
||||
#include "targetsettingspanel.h"
|
||||
|
||||
#include "buildinfo.h"
|
||||
#include "buildsettingspropertiespage.h"
|
||||
#include "kitoptionspage.h"
|
||||
#include "project.h"
|
||||
#include "projectimporter.h"
|
||||
#include "projectwindow.h"
|
||||
#include "runsettingspropertiespage.h"
|
||||
#include "target.h"
|
||||
@@ -48,6 +50,7 @@
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QLabel>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
@@ -69,11 +72,13 @@ namespace Internal {
|
||||
TargetSettingsPanelWidget::TargetSettingsPanelWidget(Project *project) :
|
||||
m_currentTarget(0),
|
||||
m_project(project),
|
||||
m_importer(project->createProjectImporter()),
|
||||
m_selector(0),
|
||||
m_centralWidget(0),
|
||||
m_changeMenu(0),
|
||||
m_duplicateMenu(0),
|
||||
m_lastAction(0)
|
||||
m_lastAction(0),
|
||||
m_importAction(0)
|
||||
{
|
||||
Q_ASSERT(m_project);
|
||||
|
||||
@@ -83,6 +88,11 @@ TargetSettingsPanelWidget::TargetSettingsPanelWidget(Project *project) :
|
||||
m_addMenu = new QMenu(this);
|
||||
m_targetMenu = new QMenu(this);
|
||||
|
||||
if (m_importer) {
|
||||
m_importAction = new QAction(tr("Import existing build..."), this);
|
||||
connect(m_importAction, SIGNAL(triggered()), this, SLOT(importTarget()));
|
||||
}
|
||||
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
setupUi();
|
||||
@@ -101,6 +111,7 @@ TargetSettingsPanelWidget::TargetSettingsPanelWidget(Project *project) :
|
||||
|
||||
TargetSettingsPanelWidget::~TargetSettingsPanelWidget()
|
||||
{
|
||||
delete m_importer;
|
||||
}
|
||||
|
||||
bool TargetSettingsPanelWidget::event(QEvent *event)
|
||||
@@ -551,6 +562,11 @@ void TargetSettingsPanelWidget::updateTargetButtons()
|
||||
m_addMenu->clear();
|
||||
m_targetMenu->clear();
|
||||
|
||||
if (m_importAction) {
|
||||
m_addMenu->addAction(m_importAction);
|
||||
m_addMenu->addSeparator();
|
||||
}
|
||||
|
||||
m_changeMenu = m_targetMenu->addMenu(tr("Change Kit"));
|
||||
m_duplicateMenu = m_targetMenu->addMenu(tr("Copy to Kit"));
|
||||
QAction *removeAction = m_targetMenu->addAction(tr("Remove Kit"));
|
||||
@@ -605,6 +621,37 @@ void TargetSettingsPanelWidget::openTargetPreferences()
|
||||
Constants::KITS_SETTINGS_PAGE_ID);
|
||||
}
|
||||
|
||||
void TargetSettingsPanelWidget::importTarget()
|
||||
{
|
||||
QString toImport = QFileDialog::getExistingDirectory(this, tr("Import directory"), m_project->projectDirectory());
|
||||
importTarget(Utils::FileName::fromString(toImport));
|
||||
}
|
||||
|
||||
void TargetSettingsPanelWidget::importTarget(const Utils::FileName &path)
|
||||
{
|
||||
if (!m_importer)
|
||||
return;
|
||||
|
||||
Target *target = 0;
|
||||
BuildConfiguration *bc = 0;
|
||||
QList<BuildInfo *> toImport = m_importer->import(path, false);
|
||||
foreach (BuildInfo *info, toImport) {
|
||||
target = m_project->target(info->kitId);
|
||||
if (!target) {
|
||||
target = new Target(m_project, KitManager::find(info->kitId));
|
||||
m_project->addTarget(target);
|
||||
}
|
||||
bc = info->factory()->create(target, info);
|
||||
QTC_ASSERT(bc, continue);
|
||||
target->addBuildConfiguration(bc);
|
||||
}
|
||||
m_project->setActiveTarget(target);
|
||||
if (target && bc)
|
||||
target->setActiveBuildConfiguration(bc);
|
||||
|
||||
qDeleteAll(toImport);
|
||||
}
|
||||
|
||||
int TargetSettingsPanelWidget::currentSubIndex() const
|
||||
{
|
||||
return m_selector->currentSubIndex();
|
||||
|
||||
@@ -38,10 +38,13 @@ class QMenu;
|
||||
class QStackedWidget;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Utils { class FileName; }
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
class Target;
|
||||
class Project;
|
||||
class ProjectImporter;
|
||||
class Kit;
|
||||
class PanelsWidget;
|
||||
|
||||
@@ -72,6 +75,7 @@ private slots:
|
||||
void updateTargetButtons();
|
||||
void renameTarget();
|
||||
void openTargetPreferences();
|
||||
void importTarget();
|
||||
|
||||
void removeTarget();
|
||||
void menuShown(int targetIndex);
|
||||
@@ -81,10 +85,12 @@ private slots:
|
||||
private:
|
||||
Target *cloneTarget(Target *sourceTarget, Kit *k);
|
||||
void removeTarget(Target *t);
|
||||
void importTarget(const Utils::FileName &path);
|
||||
void createAction(Kit *k, QMenu *menu);
|
||||
|
||||
Target *m_currentTarget;
|
||||
Project *m_project;
|
||||
ProjectImporter *m_importer;
|
||||
TargetSettingsWidget *m_selector;
|
||||
QStackedWidget *m_centralWidget;
|
||||
QWidget *m_noTargetLabel;
|
||||
@@ -95,6 +101,7 @@ private:
|
||||
QMenu *m_duplicateMenu;
|
||||
QMenu *m_addMenu;
|
||||
QAction *m_lastAction;
|
||||
QAction *m_importAction;
|
||||
int m_menuTargetIndex;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user