2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "projectwindow.h"
|
2008-12-02 16:19:05 +01:00
|
|
|
|
|
|
|
|
#include "project.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "projectexplorer.h"
|
|
|
|
|
#include "projectexplorerconstants.h"
|
|
|
|
|
#include "iprojectproperties.h"
|
|
|
|
|
#include "session.h"
|
|
|
|
|
#include "projecttreewidget.h"
|
2009-09-17 13:59:10 +02:00
|
|
|
#include "runconfiguration.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include <coreplugin/minisplitter.h>
|
|
|
|
|
#include <coreplugin/fileiconprovider.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
2009-01-19 12:39:20 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2009-07-16 17:34:04 +02:00
|
|
|
#include <utils/styledbar.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include <QtCore/QDebug>
|
2008-12-10 16:48:28 +01:00
|
|
|
#include <QtGui/QApplication>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtGui/QBoxLayout>
|
|
|
|
|
#include <QtGui/QComboBox>
|
2009-07-10 14:54:46 +02:00
|
|
|
#include <QtGui/QScrollArea>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtGui/QTabWidget>
|
|
|
|
|
#include <QtGui/QTreeWidget>
|
|
|
|
|
#include <QtGui/QHeaderView>
|
2009-07-16 15:33:19 +02:00
|
|
|
#include <QtGui/QLabel>
|
2009-09-17 13:59:10 +02:00
|
|
|
#include <QtGui/QPainter>
|
|
|
|
|
#include <QtGui/QPaintEvent>
|
|
|
|
|
#include <utils/stylehelper.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace ProjectExplorer::Internal;
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
bool debug = false;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-16 15:33:19 +02:00
|
|
|
PanelsWidget::PanelsWidget(QWidget *parent)
|
|
|
|
|
: QScrollArea(parent)
|
|
|
|
|
{
|
2009-07-22 11:37:23 +02:00
|
|
|
QWidget *topwidget = new QWidget;
|
|
|
|
|
QHBoxLayout *topwidgetLayout = new QHBoxLayout;
|
|
|
|
|
topwidgetLayout->setMargin(0);
|
|
|
|
|
topwidgetLayout->setSpacing(0);
|
|
|
|
|
topwidget->setLayout(topwidgetLayout);
|
|
|
|
|
|
|
|
|
|
QWidget *verticalWidget = new QWidget;
|
|
|
|
|
verticalWidget->setMaximumWidth(800);
|
|
|
|
|
m_layout = new QVBoxLayout;
|
2009-08-06 15:31:32 +02:00
|
|
|
m_layout->addStretch(10);
|
2009-07-22 11:37:23 +02:00
|
|
|
verticalWidget->setLayout(m_layout);
|
|
|
|
|
topwidgetLayout->addWidget(verticalWidget);
|
|
|
|
|
topwidgetLayout->addStretch(10);
|
2009-07-16 15:33:19 +02:00
|
|
|
|
|
|
|
|
setFrameStyle(QFrame::NoFrame);
|
2009-08-11 16:37:24 +02:00
|
|
|
setWidgetResizable(true);
|
|
|
|
|
|
2009-07-22 11:37:23 +02:00
|
|
|
setWidget(topwidget);
|
2009-07-16 15:33:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PanelsWidget::~PanelsWidget()
|
|
|
|
|
{
|
|
|
|
|
clear();
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-17 13:59:10 +02:00
|
|
|
void PanelsWidget::addWidget(QWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
Panel p;
|
|
|
|
|
p.nameLabel = 0;
|
|
|
|
|
p.panelWidget = widget;
|
|
|
|
|
|
|
|
|
|
p.marginLayout = 0;
|
|
|
|
|
m_layout->insertWidget(m_layout->count() -1, widget);
|
|
|
|
|
m_panels.append(p);
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-16 15:33:19 +02:00
|
|
|
void PanelsWidget::addWidget(const QString &name, QWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
Panel p;
|
|
|
|
|
p.nameLabel = new QLabel(this);
|
|
|
|
|
p.nameLabel->setText(name);
|
|
|
|
|
QFont f = p.nameLabel->font();
|
|
|
|
|
f.setBold(true);
|
|
|
|
|
f.setPointSizeF(f.pointSizeF() * 1.4);
|
|
|
|
|
p.nameLabel->setFont(f);
|
2009-09-17 13:59:10 +02:00
|
|
|
|
2009-07-16 15:33:19 +02:00
|
|
|
p.panelWidget = widget;
|
|
|
|
|
|
2009-09-17 13:59:10 +02:00
|
|
|
m_layout->insertWidget(m_layout->count() - 1, p.nameLabel);
|
2009-08-06 15:31:32 +02:00
|
|
|
QHBoxLayout *hboxLayout = new QHBoxLayout();
|
|
|
|
|
hboxLayout->setContentsMargins(20, 0, 0, 0);
|
|
|
|
|
hboxLayout->addWidget(p.panelWidget);
|
|
|
|
|
p.marginLayout = hboxLayout;
|
|
|
|
|
m_layout->insertLayout(m_layout->count() -1, hboxLayout);
|
|
|
|
|
m_panels.append(p);
|
2009-07-16 15:33:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PanelsWidget::clear()
|
|
|
|
|
{
|
|
|
|
|
foreach(Panel p, m_panels) {
|
|
|
|
|
delete p.nameLabel;
|
|
|
|
|
delete p.panelWidget;
|
2009-08-06 15:31:32 +02:00
|
|
|
delete p.marginLayout;
|
2009-07-16 15:33:19 +02:00
|
|
|
}
|
|
|
|
|
m_panels.clear();
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-17 13:59:10 +02:00
|
|
|
void PanelsWidget::removeWidget(QWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
for(int i=0; i<m_panels.count(); ++i) {
|
|
|
|
|
const Panel & p = m_panels.at(i);
|
|
|
|
|
if (p.panelWidget == widget) {
|
|
|
|
|
if (p.marginLayout)
|
|
|
|
|
p.marginLayout->removeWidget(p.panelWidget);
|
|
|
|
|
else
|
|
|
|
|
m_layout->removeWidget(p.panelWidget);
|
|
|
|
|
delete p.nameLabel;
|
|
|
|
|
delete p.marginLayout;
|
|
|
|
|
m_panels.removeAt(i);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////
|
|
|
|
|
// ActiveConfigurationWidget
|
|
|
|
|
////
|
|
|
|
|
|
|
|
|
|
ActiveConfigurationWidget::ActiveConfigurationWidget(QWidget *parent)
|
|
|
|
|
: QWidget(parent)
|
|
|
|
|
{
|
|
|
|
|
QGridLayout *grid = new QGridLayout(this);
|
2009-09-23 17:16:09 +02:00
|
|
|
grid->setMargin(0);
|
2009-09-17 13:59:10 +02:00
|
|
|
RunConfigurationComboBox *runConfigurationComboBox = new RunConfigurationComboBox(this);
|
2009-09-17 16:10:45 +02:00
|
|
|
grid->addWidget(new QLabel(tr("Active run configuration")), 0, 0);
|
2009-09-17 13:59:10 +02:00
|
|
|
grid->addWidget(runConfigurationComboBox, 0, 1);
|
|
|
|
|
|
|
|
|
|
SessionManager *session = ProjectExplorerPlugin::instance()->session();
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
foreach(Project *p, session->projects()) {
|
|
|
|
|
++i;
|
|
|
|
|
BuildConfigurationComboBox *buildConfigurationComboBox = new BuildConfigurationComboBox(p, this);
|
2009-09-17 16:10:45 +02:00
|
|
|
QLabel *label = new QLabel("Build configuration for <b>" + p->name() + "</b>", this);
|
2009-09-17 13:59:10 +02:00
|
|
|
grid->addWidget(label, i, 0);
|
|
|
|
|
grid->addWidget(buildConfigurationComboBox, i, 1);
|
|
|
|
|
m_buildComboBoxMap.insert(p, qMakePair(buildConfigurationComboBox, label));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
connect(session, SIGNAL(projectAdded(ProjectExplorer::Project*)),
|
|
|
|
|
this, SLOT(projectAdded(ProjectExplorer::Project*)));
|
|
|
|
|
|
|
|
|
|
connect(session, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
|
|
|
|
|
this, SLOT(projectRemoved(ProjectExplorer::Project*)));
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void ActiveConfigurationWidget::projectAdded(Project *p)
|
|
|
|
|
{
|
|
|
|
|
QGridLayout *grid = static_cast<QGridLayout *>(layout());
|
|
|
|
|
BuildConfigurationComboBox *buildConfigurationComboBox = new BuildConfigurationComboBox(p, this);
|
2009-09-17 16:10:45 +02:00
|
|
|
QLabel *label = new QLabel("Build configuration for <b>" + p->name() + "</b>");
|
2009-09-17 13:59:10 +02:00
|
|
|
grid->addWidget(label);
|
|
|
|
|
grid->addWidget(buildConfigurationComboBox);
|
|
|
|
|
m_buildComboBoxMap.insert(p, qMakePair(buildConfigurationComboBox, label));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ActiveConfigurationWidget::projectRemoved(Project *p)
|
|
|
|
|
{
|
|
|
|
|
// Find row
|
|
|
|
|
|
|
|
|
|
// TODO also remove the label...
|
|
|
|
|
QPair<BuildConfigurationComboBox *, QLabel *> pair = m_buildComboBoxMap.value(p);;
|
|
|
|
|
delete pair.first;
|
|
|
|
|
delete pair.second;
|
|
|
|
|
m_buildComboBoxMap.remove(p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ActiveConfigurationWidget::~ActiveConfigurationWidget()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////
|
|
|
|
|
// RunConfigurationComboBox
|
|
|
|
|
////
|
|
|
|
|
|
|
|
|
|
RunConfigurationComboBox::RunConfigurationComboBox(QWidget *parent)
|
|
|
|
|
: QComboBox(parent), m_ignoreChange(false)
|
|
|
|
|
{
|
|
|
|
|
setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
|
|
|
|
|
|
|
|
|
SessionManager *session = ProjectExplorer::ProjectExplorerPlugin::instance()->session();
|
|
|
|
|
|
|
|
|
|
// Setup the treewidget
|
|
|
|
|
rebuildTree();
|
|
|
|
|
|
|
|
|
|
// Connect
|
|
|
|
|
foreach(Project *p, session->projects()) {
|
|
|
|
|
foreach(const QSharedPointer<RunConfiguration> &rc, p->runConfigurations()) {
|
|
|
|
|
connect(rc.data(), SIGNAL(nameChanged()), this, SLOT(rebuildTree()));
|
|
|
|
|
}
|
|
|
|
|
connectToProject(p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(session, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
|
|
|
|
|
this, SLOT(activeRunConfigurationChanged()));
|
|
|
|
|
|
|
|
|
|
connect(session, SIGNAL(projectAdded(ProjectExplorer::Project*)),
|
|
|
|
|
this, SLOT(projectAdded(ProjectExplorer::Project*)));
|
|
|
|
|
connect(session, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
|
|
|
|
|
this, SLOT(projectRemoved(ProjectExplorer::Project*)));
|
|
|
|
|
connect(this, SIGNAL(activated(int)),
|
|
|
|
|
this, SLOT(activeItemChanged(int)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RunConfigurationComboBox::~RunConfigurationComboBox()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int RunConfigurationComboBox::convertTreeIndexToInt(int project, int runconfigurationIndex)
|
|
|
|
|
{
|
|
|
|
|
++runconfigurationIndex;
|
|
|
|
|
++project;
|
|
|
|
|
for(int i=0; i<count(); ++i) {
|
|
|
|
|
if (itemData(i, Qt::UserRole).toInt() == 0) {
|
|
|
|
|
--project;
|
|
|
|
|
} else if (itemData(i, Qt::UserRole).toInt() == 1 && project == 0) {
|
|
|
|
|
--runconfigurationIndex;
|
|
|
|
|
}
|
|
|
|
|
if (runconfigurationIndex == 0) {
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QPair<int, int> RunConfigurationComboBox::convertIntToTreeIndex(int index)
|
|
|
|
|
{
|
|
|
|
|
int projectIndex = -1;
|
|
|
|
|
int runConfigIndex = -1;
|
|
|
|
|
for(int i = 0; i <= index; ++i) {
|
|
|
|
|
if (itemData(i, Qt::UserRole).toInt() == 0) {
|
|
|
|
|
++projectIndex;
|
|
|
|
|
runConfigIndex = -1;
|
|
|
|
|
} else if (itemData(i, Qt::UserRole).toInt() == 1) {
|
|
|
|
|
++runConfigIndex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return qMakePair(projectIndex, runConfigIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunConfigurationComboBox::activeItemChanged(int index)
|
|
|
|
|
{
|
|
|
|
|
if (m_ignoreChange)
|
|
|
|
|
return;
|
|
|
|
|
m_ignoreChange = true;
|
|
|
|
|
SessionManager *session = ProjectExplorer::ProjectExplorerPlugin::instance()->session();
|
|
|
|
|
QPair<int, int> pair = convertIntToTreeIndex(index);
|
|
|
|
|
if (pair.first == -1) {
|
|
|
|
|
setCurrentIndex(-1);
|
|
|
|
|
} else {
|
|
|
|
|
if (pair.second == -1)
|
|
|
|
|
pair.second = 0;
|
|
|
|
|
QList<Project *> projects = session->projects();
|
|
|
|
|
if (pair.first < projects.count()) {
|
|
|
|
|
Project *p = projects.at(pair.first);
|
|
|
|
|
QList<QSharedPointer<RunConfiguration> > runconfigurations = p->runConfigurations();
|
|
|
|
|
if (pair.second < runconfigurations.count()) {
|
|
|
|
|
session->setStartupProject(p);
|
|
|
|
|
p->setActiveRunConfiguration(runconfigurations.at(pair.second));
|
|
|
|
|
if (currentIndex() != convertTreeIndexToInt(pair.first, pair.second))
|
|
|
|
|
setCurrentIndex(convertTreeIndexToInt(pair.first, pair.second));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m_ignoreChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunConfigurationComboBox::activeRunConfigurationChanged()
|
|
|
|
|
{
|
|
|
|
|
if (m_ignoreChange)
|
|
|
|
|
return;
|
|
|
|
|
m_ignoreChange = true;
|
|
|
|
|
SessionManager *session = ProjectExplorer::ProjectExplorerPlugin::instance()->session();
|
|
|
|
|
Project *startupProject = session->startupProject();
|
|
|
|
|
if (startupProject) {
|
|
|
|
|
int projectIndex = session->projects().indexOf(startupProject);
|
|
|
|
|
int runConfigurationIndex = startupProject->runConfigurations().indexOf(startupProject->activeRunConfiguration());
|
|
|
|
|
setCurrentIndex(convertTreeIndexToInt(projectIndex, runConfigurationIndex));
|
|
|
|
|
} else {
|
|
|
|
|
setCurrentIndex(-1);
|
|
|
|
|
}
|
|
|
|
|
m_ignoreChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunConfigurationComboBox::addedRunConfiguration(ProjectExplorer::Project *p, const QString &name)
|
|
|
|
|
{
|
|
|
|
|
QSharedPointer<RunConfiguration> runConfiguration = QSharedPointer<RunConfiguration>(0);
|
|
|
|
|
foreach(QSharedPointer<RunConfiguration> rc, p->runConfigurations()) {
|
|
|
|
|
if (rc->name() == name) {
|
|
|
|
|
runConfiguration = rc;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (runConfiguration) {
|
|
|
|
|
connect(runConfiguration.data(), SIGNAL(nameChanged()),
|
|
|
|
|
this, SLOT(rebuildTree()));
|
|
|
|
|
}
|
|
|
|
|
rebuildTree();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunConfigurationComboBox::removedRunConfiguration(ProjectExplorer::Project *p, const QString &name)
|
|
|
|
|
{
|
|
|
|
|
QSharedPointer<RunConfiguration> runConfiguration = QSharedPointer<RunConfiguration>(0);
|
|
|
|
|
foreach(QSharedPointer<RunConfiguration> rc, p->runConfigurations()) {
|
|
|
|
|
if (rc->name() == name) {
|
|
|
|
|
runConfiguration = rc;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (runConfiguration) {
|
|
|
|
|
disconnect(runConfiguration.data(), SIGNAL(nameChanged()),
|
|
|
|
|
this, SLOT(rebuildTree()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rebuildTree();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunConfigurationComboBox::projectAdded(ProjectExplorer::Project *p)
|
|
|
|
|
{
|
|
|
|
|
rebuildTree();
|
|
|
|
|
foreach(const QSharedPointer<RunConfiguration> &rc, p->runConfigurations())
|
|
|
|
|
connect(rc.data(), SIGNAL(nameChanged()), this, SLOT(rebuildTree()));
|
|
|
|
|
connectToProject(p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunConfigurationComboBox::projectRemoved(ProjectExplorer::Project *p)
|
|
|
|
|
{
|
|
|
|
|
rebuildTree();
|
|
|
|
|
disconnectFromProject(p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunConfigurationComboBox::connectToProject(ProjectExplorer::Project *p)
|
|
|
|
|
{
|
|
|
|
|
connect(p, SIGNAL(activeRunConfigurationChanged()),
|
|
|
|
|
this, SLOT(activeRunConfigurationChanged()));
|
|
|
|
|
connect(p, SIGNAL(addedRunConfiguration(ProjectExplorer::Project *, QString)),
|
|
|
|
|
this, SLOT(addedRunConfiguration(ProjectExplorer::Project *, QString)));
|
|
|
|
|
connect(p, SIGNAL(removedRunConfiguration(ProjectExplorer::Project *, QString)),
|
|
|
|
|
this, SLOT(removedRunConfiguration(ProjectExplorer::Project *, QString)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunConfigurationComboBox::disconnectFromProject(ProjectExplorer::Project *p)
|
|
|
|
|
{
|
|
|
|
|
disconnect(p, SIGNAL(activeRunConfigurationChanged()),
|
|
|
|
|
this, SLOT(activeRunConfigurationChanged()));
|
|
|
|
|
disconnect(p, SIGNAL(addedRunConfiguration(ProjectExplorer::Project *, QString)),
|
|
|
|
|
this, SLOT(addedRunConfiguration(ProjectExplorer::Project *, QString)));
|
|
|
|
|
disconnect(p, SIGNAL(removedRunConfiguration(ProjectExplorer::Project *, QString)),
|
|
|
|
|
this, SLOT(removedRunConfiguration(ProjectExplorer::Project *, QString)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunConfigurationComboBox::rebuildTree()
|
|
|
|
|
{
|
|
|
|
|
m_ignoreChange = true;
|
|
|
|
|
clear();
|
|
|
|
|
|
|
|
|
|
SessionManager *session = ProjectExplorer::ProjectExplorerPlugin::instance()->session();
|
|
|
|
|
Project *startupProject = session->startupProject();
|
|
|
|
|
foreach(Project *p, session->projects()) {
|
|
|
|
|
addItem(p->name(), QVariant(0));
|
|
|
|
|
foreach(QSharedPointer<RunConfiguration> rc, p->runConfigurations()) {
|
|
|
|
|
addItem(" " + rc->name(), QVariant(1));
|
|
|
|
|
if ((startupProject == p) && (p->activeRunConfiguration() == rc)){
|
|
|
|
|
setCurrentIndex(count() - 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Select the right index
|
|
|
|
|
m_ignoreChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////
|
|
|
|
|
// BuildConfigurationComboBox
|
|
|
|
|
////
|
|
|
|
|
|
|
|
|
|
BuildConfigurationComboBox::BuildConfigurationComboBox(Project *p, QWidget *parent)
|
|
|
|
|
: QComboBox(parent), ignoreIndexChange(false), m_project(p)
|
|
|
|
|
{
|
|
|
|
|
setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
|
|
|
|
foreach(const QString &buildConfiguration, p->buildConfigurations())
|
|
|
|
|
addItem(p->displayNameFor(buildConfiguration), buildConfiguration);
|
|
|
|
|
|
|
|
|
|
int index = p->buildConfigurations().indexOf(p->activeBuildConfiguration());
|
|
|
|
|
if (index != -1)
|
|
|
|
|
setCurrentIndex(index);
|
|
|
|
|
|
|
|
|
|
connect(p, SIGNAL(buildConfigurationDisplayNameChanged(QString)),
|
|
|
|
|
this, SLOT(nameChanged(QString)));
|
|
|
|
|
connect(p, SIGNAL(activeBuildConfigurationChanged()),
|
|
|
|
|
this, SLOT(activeConfigurationChanged()));
|
|
|
|
|
connect(p, SIGNAL(addedBuildConfiguration(ProjectExplorer::Project *, QString)),
|
|
|
|
|
this, SLOT(addedBuildConfiguration(ProjectExplorer::Project *, QString)));
|
|
|
|
|
connect(p, SIGNAL(removedBuildConfiguration(ProjectExplorer::Project *, QString)),
|
|
|
|
|
this, SLOT(removedBuildConfiguration(ProjectExplorer::Project *, QString)));
|
|
|
|
|
connect(this, SIGNAL(activated(int)),
|
|
|
|
|
this, SLOT(changedIndex(int)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildConfigurationComboBox::~BuildConfigurationComboBox()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BuildConfigurationComboBox::nameChanged(const QString &buildConfiguration)
|
|
|
|
|
{
|
|
|
|
|
int index = nameToIndex(buildConfiguration);
|
|
|
|
|
if (index == -1)
|
|
|
|
|
return;
|
|
|
|
|
setItemText(index, m_project->displayNameFor(buildConfiguration));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int BuildConfigurationComboBox::nameToIndex(const QString &buildConfiguration)
|
|
|
|
|
{
|
|
|
|
|
for (int i=0; i < count(); ++i)
|
|
|
|
|
if (itemData(i) == buildConfiguration)
|
|
|
|
|
return i;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BuildConfigurationComboBox::activeConfigurationChanged()
|
|
|
|
|
{
|
|
|
|
|
int index = nameToIndex(m_project->activeBuildConfiguration());
|
|
|
|
|
if (index == -1)
|
|
|
|
|
return;
|
|
|
|
|
ignoreIndexChange = true;
|
|
|
|
|
setCurrentIndex(index);
|
|
|
|
|
ignoreIndexChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BuildConfigurationComboBox::addedBuildConfiguration(ProjectExplorer::Project *,const QString &buildConfiguration)
|
|
|
|
|
{
|
|
|
|
|
ignoreIndexChange = true;
|
|
|
|
|
addItem(m_project->displayNameFor(buildConfiguration), buildConfiguration);
|
|
|
|
|
ignoreIndexChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BuildConfigurationComboBox::removedBuildConfiguration(ProjectExplorer::Project *, const QString &buildConfiguration)
|
|
|
|
|
{
|
|
|
|
|
ignoreIndexChange = true;
|
|
|
|
|
int index = nameToIndex(buildConfiguration);
|
|
|
|
|
removeItem(index);
|
|
|
|
|
ignoreIndexChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BuildConfigurationComboBox::changedIndex(int newIndex)
|
|
|
|
|
{
|
|
|
|
|
if (newIndex == -1)
|
|
|
|
|
return;
|
|
|
|
|
m_project->setActiveBuildConfiguration(itemData(newIndex).toString());
|
|
|
|
|
}
|
2009-08-06 15:31:32 +02:00
|
|
|
///
|
2009-09-17 13:59:10 +02:00
|
|
|
// ProjectComboBox
|
2009-08-06 15:31:32 +02:00
|
|
|
///
|
|
|
|
|
|
2009-09-17 13:59:10 +02:00
|
|
|
ProjectComboBox::ProjectComboBox(QWidget *parent)
|
|
|
|
|
: QComboBox(parent), m_lastProject(0)
|
2009-08-06 15:31:32 +02:00
|
|
|
{
|
2009-09-17 13:59:10 +02:00
|
|
|
setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
|
|
|
|
SessionManager *session = ProjectExplorerPlugin::instance()->session();
|
|
|
|
|
|
|
|
|
|
foreach(Project *p, session->projects()) {
|
|
|
|
|
addItem(p->name(), QVariant::fromValue((void *) p));
|
|
|
|
|
}
|
2009-08-06 15:31:32 +02:00
|
|
|
|
2009-09-17 13:59:10 +02:00
|
|
|
connect(session, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
|
|
|
|
|
this, SLOT(projectRemoved(ProjectExplorer::Project*)));
|
|
|
|
|
connect(session, SIGNAL(projectAdded(ProjectExplorer::Project*)),
|
|
|
|
|
this, SLOT(projectAdded(ProjectExplorer::Project*)));
|
|
|
|
|
|
|
|
|
|
connect(this, SIGNAL(activated(int)),
|
|
|
|
|
SLOT(itemActivated(int)));
|
2009-08-06 15:31:32 +02:00
|
|
|
}
|
|
|
|
|
|
2009-09-17 13:59:10 +02:00
|
|
|
ProjectComboBox::~ProjectComboBox()
|
2009-08-06 15:31:32 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-17 13:59:10 +02:00
|
|
|
void ProjectComboBox::projectAdded(ProjectExplorer::Project *p)
|
2009-08-06 15:31:32 +02:00
|
|
|
{
|
2009-09-17 13:59:10 +02:00
|
|
|
addItem(p->name(), QVariant::fromValue((void *) p));
|
|
|
|
|
// Comboboxes don't emit a signal
|
|
|
|
|
if (count() == 1)
|
|
|
|
|
itemActivated(0);
|
2009-08-06 15:31:32 +02:00
|
|
|
}
|
|
|
|
|
|
2009-09-17 13:59:10 +02:00
|
|
|
void ProjectComboBox::projectRemoved(ProjectExplorer::Project *p)
|
2009-08-06 15:31:32 +02:00
|
|
|
{
|
2009-09-17 13:59:10 +02:00
|
|
|
QList<Project *> projects = ProjectExplorerPlugin::instance()->session()->projects();
|
|
|
|
|
for (int i= 0; i<projects.count(); ++i)
|
|
|
|
|
if (itemData(i, Qt::UserRole).value<void *>() == (void *) p) {
|
|
|
|
|
removeItem(i);
|
|
|
|
|
break;
|
2009-08-06 15:31:32 +02:00
|
|
|
}
|
|
|
|
|
|
2009-09-17 13:59:10 +02:00
|
|
|
// Comboboxes don't emit a signal if the index did't actually change
|
|
|
|
|
if (count() == 0) {
|
|
|
|
|
itemActivated(-1);
|
|
|
|
|
} else {
|
|
|
|
|
setCurrentIndex(0);
|
|
|
|
|
itemActivated(0);
|
2009-08-06 15:31:32 +02:00
|
|
|
}
|
2009-09-17 13:59:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProjectComboBox::itemActivated(int index)
|
|
|
|
|
{
|
|
|
|
|
Project *p = 0;
|
|
|
|
|
QList<Project *> projects = ProjectExplorerPlugin::instance()->session()->projects();
|
|
|
|
|
if (index != -1 && index < projects.size())
|
|
|
|
|
p = projects.at(index);
|
|
|
|
|
|
|
|
|
|
if (p != m_lastProject) {
|
|
|
|
|
m_lastProject = p;
|
|
|
|
|
emit projectChanged(p);
|
2009-08-06 15:31:32 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-06 16:48:39 +02:00
|
|
|
///
|
|
|
|
|
// OnePixelBlackLine
|
|
|
|
|
///
|
|
|
|
|
|
|
|
|
|
class OnePixelBlackLine : public QWidget
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
OnePixelBlackLine(QWidget *parent)
|
|
|
|
|
: QWidget(parent)
|
|
|
|
|
{
|
|
|
|
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
|
setMinimumHeight(1);
|
|
|
|
|
setMaximumHeight(1);
|
|
|
|
|
}
|
|
|
|
|
void paintEvent(QPaintEvent *e)
|
|
|
|
|
{
|
|
|
|
|
QPainter p(this);
|
|
|
|
|
p.fillRect(e->rect(), QBrush(StyleHelper::borderColor()));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2009-08-06 15:31:32 +02:00
|
|
|
///
|
|
|
|
|
// ProjectWindow
|
|
|
|
|
///
|
|
|
|
|
|
2009-06-08 19:13:46 +02:00
|
|
|
ProjectWindow::ProjectWindow(QWidget *parent)
|
|
|
|
|
: QWidget(parent), m_currentItemChanged(false)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-03-04 09:38:01 +01:00
|
|
|
m_projectExplorer = ProjectExplorerPlugin::instance();
|
|
|
|
|
m_session = m_projectExplorer->session();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-07-16 15:33:19 +02:00
|
|
|
m_panelsWidget = new PanelsWidget(this);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-09-17 13:59:10 +02:00
|
|
|
m_activeConfigurationWidget = new ActiveConfigurationWidget(m_panelsWidget);
|
|
|
|
|
|
|
|
|
|
m_projectChooser = new QWidget(m_panelsWidget);
|
|
|
|
|
QHBoxLayout *hbox = new QHBoxLayout(m_projectChooser);
|
|
|
|
|
hbox->setMargin(0);
|
|
|
|
|
hbox->addWidget(new QLabel(tr("Edit Configuration for Project:"), m_projectChooser));
|
|
|
|
|
ProjectComboBox *projectComboBox = new ProjectComboBox(m_projectChooser);
|
|
|
|
|
hbox->addWidget(projectComboBox);
|
|
|
|
|
|
|
|
|
|
m_panelsWidget->addWidget(tr("Active Configuration"), m_activeConfigurationWidget);
|
|
|
|
|
|
|
|
|
|
m_spacerBetween = new QWidget(this);
|
|
|
|
|
QVBoxLayout *vbox = new QVBoxLayout(m_spacerBetween);
|
2009-09-23 17:16:09 +02:00
|
|
|
vbox->setMargin(0);
|
2009-09-17 13:59:10 +02:00
|
|
|
m_spacerBetween->setLayout(vbox);
|
|
|
|
|
vbox->addSpacerItem(new QSpacerItem(10, 15, QSizePolicy::Fixed, QSizePolicy::Fixed));
|
|
|
|
|
vbox->addWidget(new OnePixelBlackLine(m_spacerBetween));
|
|
|
|
|
vbox->addSpacerItem(new QSpacerItem(10, 15, QSizePolicy::Fixed, QSizePolicy::Fixed));
|
|
|
|
|
|
|
|
|
|
m_panelsWidget->addWidget(m_spacerBetween);
|
|
|
|
|
|
|
|
|
|
m_panelsWidget->addWidget(tr("Edit Configuration"), m_projectChooser);
|
|
|
|
|
|
2009-08-06 15:31:32 +02:00
|
|
|
QVBoxLayout *topLevelLayout = new QVBoxLayout(this);
|
|
|
|
|
topLevelLayout->setMargin(0);
|
2009-08-06 16:48:39 +02:00
|
|
|
topLevelLayout->setSpacing(0);
|
2009-08-06 15:31:32 +02:00
|
|
|
topLevelLayout->addWidget(new Core::Utils::StyledBar(this));
|
2009-09-17 13:59:10 +02:00
|
|
|
|
2009-08-06 15:31:32 +02:00
|
|
|
topLevelLayout->addWidget(m_panelsWidget);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-09-17 13:59:10 +02:00
|
|
|
connect(projectComboBox, SIGNAL(projectChanged(ProjectExplorer::Project*)),
|
|
|
|
|
this, SLOT(showProperties(ProjectExplorer::Project*)));
|
|
|
|
|
|
2009-03-11 17:36:17 +01:00
|
|
|
connect(m_session, SIGNAL(sessionLoaded()), this, SLOT(restoreStatus()));
|
|
|
|
|
connect(m_session, SIGNAL(aboutToSaveSession()), this, SLOT(saveStatus()));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectWindow::~ProjectWindow()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProjectWindow::restoreStatus()
|
|
|
|
|
{
|
2009-07-16 15:33:19 +02:00
|
|
|
// TODO
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProjectWindow::saveStatus()
|
|
|
|
|
{
|
2009-07-16 15:33:19 +02:00
|
|
|
// TODO
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-09-17 13:59:10 +02:00
|
|
|
void ProjectWindow::showProperties(Project *project)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
if (debug)
|
|
|
|
|
qDebug() << "ProjectWindow - showProperties called";
|
|
|
|
|
|
2009-09-17 13:59:10 +02:00
|
|
|
m_panelsWidget->removeWidget(m_activeConfigurationWidget);
|
|
|
|
|
m_panelsWidget->removeWidget(m_spacerBetween);
|
|
|
|
|
m_panelsWidget->removeWidget(m_projectChooser);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
// Remove the tabs from the tab widget first
|
2009-07-16 15:33:19 +02:00
|
|
|
m_panelsWidget->clear();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-09-17 13:59:10 +02:00
|
|
|
m_panelsWidget->addWidget(tr("Active Configuration"), m_activeConfigurationWidget);
|
|
|
|
|
m_panelsWidget->addWidget(m_spacerBetween);
|
|
|
|
|
m_panelsWidget->addWidget(tr("Edit Configuration"), m_projectChooser);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
if (project) {
|
|
|
|
|
QList<IPanelFactory *> pages =
|
|
|
|
|
ExtensionSystem::PluginManager::instance()->getObjects<IPanelFactory>();
|
|
|
|
|
foreach (IPanelFactory *panelFactory, pages) {
|
|
|
|
|
if (panelFactory->supports(project)) {
|
|
|
|
|
PropertiesPanel *panel = panelFactory->createPanel(project);
|
|
|
|
|
if (debug)
|
|
|
|
|
qDebug() << "ProjectWindow - setting up project properties tab " << panel->name();
|
2009-07-16 15:33:19 +02:00
|
|
|
m_panelsWidget->addWidget(panel->name(), panel->widget());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Project *ProjectWindow::findProject(const QString &path) const
|
|
|
|
|
{
|
|
|
|
|
QList<Project*> projects = m_session->projects();
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (Project* project, projects)
|
2009-03-11 17:36:17 +01:00
|
|
|
if (QFileInfo(project->file()->fileName()).filePath() == path)
|
2008-12-02 12:01:29 +01:00
|
|
|
return project;
|
|
|
|
|
return 0;
|
2008-12-09 11:07:24 +01:00
|
|
|
}
|