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"
|
2009-09-29 11:39:55 +02:00
|
|
|
#include "environment.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"
|
2009-09-21 17:54:02 +02:00
|
|
|
#include "buildconfiguration.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include <coreplugin/minisplitter.h>
|
|
|
|
|
#include <coreplugin/fileiconprovider.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
2009-09-29 11:39:55 +02:00
|
|
|
#include <coreplugin/ifile.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>
|
2009-09-29 18:06:13 +02:00
|
|
|
#include <utils/stylehelper.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>
|
2009-09-29 18:06:13 +02:00
|
|
|
#include <QtGui/QMenu>
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace ProjectExplorer::Internal;
|
|
|
|
|
|
|
|
|
|
namespace {
|
2009-11-25 16:01:46 +01:00
|
|
|
const int ICON_SIZE(64);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-11-25 15:12:34 +01: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(Utils::StyleHelper::borderColor()));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2009-11-25 15:18:51 +01:00
|
|
|
///
|
|
|
|
|
// PanelsWidget::Panel
|
|
|
|
|
///
|
|
|
|
|
|
|
|
|
|
PanelsWidget::Panel::Panel(QWidget * w) :
|
2009-11-25 16:01:46 +01:00
|
|
|
iconLabel(0), lineWidget(0), nameLabel(0), panelWidget(w), spacer(0)
|
2009-11-25 15:18:51 +01:00
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
PanelsWidget::Panel::~Panel()
|
|
|
|
|
{
|
2009-11-25 16:01:46 +01:00
|
|
|
delete iconLabel;
|
|
|
|
|
delete lineWidget;
|
2009-11-25 15:18:51 +01:00
|
|
|
delete nameLabel;
|
2009-11-25 16:01:46 +01:00
|
|
|
// do not delete panelWidget, we do not own it!
|
|
|
|
|
delete spacer;
|
2009-11-25 15:18:51 +01:00
|
|
|
}
|
|
|
|
|
|
2009-11-25 15:12:34 +01:00
|
|
|
///
|
|
|
|
|
// PanelsWidget
|
|
|
|
|
///
|
|
|
|
|
|
2009-11-25 16:01:46 +01:00
|
|
|
PanelsWidget::PanelsWidget(QWidget *parent) :
|
|
|
|
|
QScrollArea(parent),
|
|
|
|
|
m_root(new QWidget(this))
|
2009-07-16 15:33:19 +02:00
|
|
|
{
|
2009-11-25 16:01:46 +01:00
|
|
|
// We want a 800px wide widget with and the scrollbar at the
|
|
|
|
|
// side of the screen.
|
|
|
|
|
m_root->setMaximumWidth(800);
|
|
|
|
|
// The layout holding the individual panels:
|
|
|
|
|
m_layout = new QGridLayout;
|
|
|
|
|
m_layout->setColumnMinimumWidth(0, ICON_SIZE);
|
|
|
|
|
|
|
|
|
|
// A helper layout to glue some stretch to the button of
|
|
|
|
|
// the panel layout:
|
|
|
|
|
QVBoxLayout * vbox = new QVBoxLayout;
|
|
|
|
|
vbox->addLayout(m_layout);
|
|
|
|
|
vbox->addStretch(10);
|
|
|
|
|
|
|
|
|
|
m_root->setLayout(vbox);
|
|
|
|
|
|
|
|
|
|
// Add horizontal space to the left of our widget:
|
|
|
|
|
QHBoxLayout *hbox = new QHBoxLayout;
|
|
|
|
|
hbox->setMargin(0);
|
|
|
|
|
hbox->setSpacing(0);
|
|
|
|
|
|
|
|
|
|
hbox->addWidget(m_root);
|
|
|
|
|
hbox->addStretch(10);
|
2009-07-22 11:37:23 +02:00
|
|
|
|
2009-11-25 16:01:46 +01:00
|
|
|
// create a widget to hold the scrollarea:
|
|
|
|
|
QWidget * scrollArea = new QWidget();
|
|
|
|
|
scrollArea->setLayout(hbox);
|
2009-07-16 15:33:19 +02:00
|
|
|
|
2009-11-25 16:01:46 +01:00
|
|
|
setWidget(scrollArea);
|
2009-07-16 15:33:19 +02:00
|
|
|
setFrameStyle(QFrame::NoFrame);
|
2009-08-11 16:37:24 +02:00
|
|
|
setWidgetResizable(true);
|
2009-07-16 15:33:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PanelsWidget::~PanelsWidget()
|
|
|
|
|
{
|
|
|
|
|
clear();
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-25 16:01:46 +01:00
|
|
|
/*
|
|
|
|
|
* Add a widget into the grid layout of the PanelsWidget.
|
|
|
|
|
*
|
|
|
|
|
* ...
|
|
|
|
|
* +--------+-------------------------------------------+
|
|
|
|
|
* | | widget |
|
|
|
|
|
* +--------+-------------------------------------------+
|
|
|
|
|
*/
|
2009-09-17 13:59:10 +02:00
|
|
|
void PanelsWidget::addWidget(QWidget *widget)
|
|
|
|
|
{
|
2009-11-25 15:18:51 +01:00
|
|
|
Panel *p = new Panel(widget);
|
2009-11-25 16:01:46 +01:00
|
|
|
m_layout->addWidget(widget, m_layout->rowCount(), 1);
|
2009-09-17 13:59:10 +02:00
|
|
|
m_panels.append(p);
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-25 16:01:46 +01:00
|
|
|
/*
|
|
|
|
|
* Add a widget with heading information into the grid
|
|
|
|
|
* layout of the PanelsWidget.
|
|
|
|
|
*
|
|
|
|
|
* ...
|
|
|
|
|
* +--------+-------------------------------------------+
|
|
|
|
|
* | | spacer |
|
|
|
|
|
* +--------+-------------------------------------------+
|
|
|
|
|
* | icon | name |
|
|
|
|
|
* + +-------------------------------------------+
|
|
|
|
|
* | | Line |
|
|
|
|
|
* + +-------------------------------------------+
|
|
|
|
|
* | | widget |
|
|
|
|
|
* +--------+-------------------------------------------+
|
|
|
|
|
*/
|
|
|
|
|
void PanelsWidget::addWidget(const QString &name, QWidget *widget, const QIcon & icon)
|
2009-07-16 15:33:19 +02:00
|
|
|
{
|
2009-11-25 15:18:51 +01:00
|
|
|
Panel *p = new Panel(widget);
|
2009-11-25 16:01:46 +01:00
|
|
|
|
|
|
|
|
// spacer:
|
|
|
|
|
const int spacerRow(m_layout->rowCount());
|
2009-11-25 15:18:51 +01:00
|
|
|
p->spacer = new QSpacerItem(1, 10, QSizePolicy::Fixed, QSizePolicy::Fixed);
|
2009-11-25 16:01:46 +01:00
|
|
|
m_layout->addItem(p->spacer, spacerRow, 1);
|
|
|
|
|
|
|
|
|
|
// icon:
|
|
|
|
|
const int headerRow(spacerRow + 1);
|
|
|
|
|
if (!icon.isNull()) {
|
|
|
|
|
p->iconLabel = new QLabel(m_root);
|
|
|
|
|
p->iconLabel->setPixmap(icon.pixmap(ICON_SIZE, ICON_SIZE));
|
|
|
|
|
m_layout->addWidget(p->iconLabel, headerRow, 0, 3, 1, Qt::AlignTop | Qt::AlignHCenter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// name:
|
|
|
|
|
p->nameLabel = new QLabel(m_root);
|
2009-11-25 15:18:51 +01:00
|
|
|
p->nameLabel->setText(name);
|
|
|
|
|
QFont f = p->nameLabel->font();
|
2009-07-16 15:33:19 +02:00
|
|
|
f.setBold(true);
|
2009-11-25 16:01:46 +01:00
|
|
|
f.setPointSizeF(f.pointSizeF() * 1.4);
|
2009-11-25 15:18:51 +01:00
|
|
|
p->nameLabel->setFont(f);
|
2009-11-25 16:01:46 +01:00
|
|
|
m_layout->addWidget(p->nameLabel, headerRow, 1);
|
|
|
|
|
|
|
|
|
|
// line:
|
|
|
|
|
const int lineRow(headerRow + 1);
|
|
|
|
|
p->lineWidget = new OnePixelBlackLine(m_root);
|
|
|
|
|
m_layout->addWidget(p->lineWidget, lineRow, 1);
|
|
|
|
|
|
|
|
|
|
// widget:
|
|
|
|
|
const int widgetRow(lineRow + 1);
|
|
|
|
|
m_layout->addWidget(p->panelWidget, widgetRow, 1);
|
2009-07-16 15:33:19 +02:00
|
|
|
|
2009-08-06 15:31:32 +02:00
|
|
|
m_panels.append(p);
|
2009-07-16 15:33:19 +02:00
|
|
|
}
|
|
|
|
|
|
2009-11-25 16:01:46 +01:00
|
|
|
QWidget *PanelsWidget::rootWidget() const
|
|
|
|
|
{
|
|
|
|
|
return m_root;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-16 15:33:19 +02:00
|
|
|
void PanelsWidget::clear()
|
|
|
|
|
{
|
2009-11-25 16:01:46 +01:00
|
|
|
foreach (Panel* p, m_panels) {
|
|
|
|
|
if (p->iconLabel)
|
|
|
|
|
m_layout->removeWidget(p->iconLabel);
|
|
|
|
|
if (p->lineWidget)
|
|
|
|
|
m_layout->removeWidget(p->lineWidget);
|
2009-11-25 15:18:51 +01:00
|
|
|
if (p->nameLabel)
|
|
|
|
|
m_layout->removeWidget(p->nameLabel);
|
2009-11-25 16:01:46 +01:00
|
|
|
if (p->panelWidget)
|
|
|
|
|
m_layout->removeWidget(p->panelWidget);
|
|
|
|
|
if (p->spacer)
|
|
|
|
|
m_layout->removeItem(p->spacer);
|
2009-11-25 15:18:51 +01:00
|
|
|
delete p;
|
2009-07-16 15:33:19 +02:00
|
|
|
}
|
|
|
|
|
m_panels.clear();
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-17 13:59:10 +02:00
|
|
|
////
|
|
|
|
|
// 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()) {
|
2009-10-08 18:37:18 +02:00
|
|
|
foreach(RunConfiguration *rc, p->runConfigurations()) {
|
|
|
|
|
connect(rc, SIGNAL(nameChanged()), this, SLOT(rebuildTree()));
|
2009-09-17 13:59:10 +02:00
|
|
|
}
|
|
|
|
|
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);
|
2009-10-08 18:37:18 +02:00
|
|
|
QList<RunConfiguration *> runconfigurations = p->runConfigurations();
|
2009-09-17 13:59:10 +02:00
|
|
|
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);
|
2009-09-24 16:02:02 +02:00
|
|
|
int runConfigurationIndex = startupProject->runConfigurations().indexOf(startupProject->activeRunConfiguration());
|
2009-09-17 13:59:10 +02:00
|
|
|
setCurrentIndex(convertTreeIndexToInt(projectIndex, runConfigurationIndex));
|
|
|
|
|
} else {
|
|
|
|
|
setCurrentIndex(-1);
|
|
|
|
|
}
|
|
|
|
|
m_ignoreChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunConfigurationComboBox::addedRunConfiguration(ProjectExplorer::Project *p, const QString &name)
|
|
|
|
|
{
|
2009-10-08 18:37:18 +02:00
|
|
|
RunConfiguration *runConfiguration = 0;
|
|
|
|
|
foreach(RunConfiguration *rc, p->runConfigurations()) {
|
2009-09-17 13:59:10 +02:00
|
|
|
if (rc->name() == name) {
|
|
|
|
|
runConfiguration = rc;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (runConfiguration) {
|
2009-10-08 18:37:18 +02:00
|
|
|
connect(runConfiguration, SIGNAL(nameChanged()),
|
2009-09-17 13:59:10 +02:00
|
|
|
this, SLOT(rebuildTree()));
|
|
|
|
|
}
|
|
|
|
|
rebuildTree();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunConfigurationComboBox::removedRunConfiguration(ProjectExplorer::Project *p, const QString &name)
|
|
|
|
|
{
|
2009-10-13 13:44:13 +02:00
|
|
|
Q_UNUSED(p)
|
|
|
|
|
Q_UNUSED(name)
|
2009-09-17 13:59:10 +02:00
|
|
|
rebuildTree();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunConfigurationComboBox::projectAdded(ProjectExplorer::Project *p)
|
|
|
|
|
{
|
|
|
|
|
rebuildTree();
|
2009-10-08 18:37:18 +02:00
|
|
|
foreach(RunConfiguration *rc, p->runConfigurations())
|
|
|
|
|
connect(rc, SIGNAL(nameChanged()), this, SLOT(rebuildTree()));
|
2009-09-17 13:59:10 +02:00
|
|
|
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();
|
2009-09-24 16:02:02 +02:00
|
|
|
|
2009-09-17 13:59:10 +02:00
|
|
|
SessionManager *session = ProjectExplorer::ProjectExplorerPlugin::instance()->session();
|
|
|
|
|
Project *startupProject = session->startupProject();
|
|
|
|
|
foreach(Project *p, session->projects()) {
|
|
|
|
|
addItem(p->name(), QVariant(0));
|
2009-10-08 18:37:18 +02:00
|
|
|
foreach(RunConfiguration *rc, p->runConfigurations()) {
|
2009-09-17 13:59:10 +02:00
|
|
|
addItem(" " + rc->name(), QVariant(1));
|
|
|
|
|
if ((startupProject == p) && (p->activeRunConfiguration() == rc)){
|
|
|
|
|
setCurrentIndex(count() - 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Select the right index
|
|
|
|
|
m_ignoreChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////
|
|
|
|
|
// BuildConfigurationComboBox
|
|
|
|
|
////
|
|
|
|
|
|
2009-09-29 18:06:13 +02:00
|
|
|
|
2009-09-17 13:59:10 +02:00
|
|
|
BuildConfigurationComboBox::BuildConfigurationComboBox(Project *p, QWidget *parent)
|
2009-09-29 18:06:13 +02:00
|
|
|
: QStackedWidget(parent), ignoreIndexChange(false), m_project(p)
|
|
|
|
|
{
|
|
|
|
|
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
|
|
|
|
m_comboBox = new QComboBox(this);
|
|
|
|
|
m_comboBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
|
|
|
|
addWidget(m_comboBox);
|
|
|
|
|
|
|
|
|
|
m_label = new QLabel(this);
|
|
|
|
|
m_label->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
|
|
|
|
addWidget(m_label);
|
|
|
|
|
|
|
|
|
|
//m_comboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
2009-09-24 16:02:02 +02:00
|
|
|
foreach(const BuildConfiguration *buildConfiguration, p->buildConfigurations())
|
2009-11-24 15:36:31 +01:00
|
|
|
m_comboBox->addItem(buildConfiguration->displayName(), buildConfiguration);
|
2009-09-24 16:02:02 +02:00
|
|
|
if (p->buildConfigurations().count() == 1) {
|
2009-09-29 18:06:13 +02:00
|
|
|
m_label->setText(m_comboBox->itemText(0));
|
|
|
|
|
setCurrentWidget(m_label);
|
|
|
|
|
}
|
2009-09-17 13:59:10 +02:00
|
|
|
|
|
|
|
|
int index = p->buildConfigurations().indexOf(p->activeBuildConfiguration());
|
|
|
|
|
if (index != -1)
|
2009-09-29 18:06:13 +02:00
|
|
|
m_comboBox->setCurrentIndex(index);
|
2009-09-17 13:59:10 +02:00
|
|
|
|
2009-11-30 13:56:40 +01:00
|
|
|
// TODO
|
|
|
|
|
// connect(p, SIGNAL(buildConfigurationDisplayNameChanged(ProjectExplorer::BuildConfiguration *)),
|
|
|
|
|
// this, SLOT(nameChanged(ProjectExplorer::BuildConfiguration *)));
|
2009-09-17 13:59:10 +02:00
|
|
|
connect(p, SIGNAL(activeBuildConfigurationChanged()),
|
|
|
|
|
this, SLOT(activeConfigurationChanged()));
|
2009-11-24 15:36:31 +01:00
|
|
|
connect(p, SIGNAL(addedBuildConfiguration(ProjectExplorer::Project *, ProjectExplorer::BuildConfiguration *)),
|
|
|
|
|
this, SLOT(addedBuildConfiguration(ProjectExplorer::Project *, ProjectExplorer::BuildConfiguration *)));
|
|
|
|
|
connect(p, SIGNAL(removedBuildConfiguration(ProjectExplorer::Project *, ProjectExplorer::BuildConfiguration *)),
|
|
|
|
|
this, SLOT(removedBuildConfiguration(ProjectExplorer::Project *, ProjectExplorer::BuildConfiguration *)));
|
2009-09-29 18:06:13 +02:00
|
|
|
connect(m_comboBox, SIGNAL(activated(int)),
|
2009-09-17 13:59:10 +02:00
|
|
|
this, SLOT(changedIndex(int)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildConfigurationComboBox::~BuildConfigurationComboBox()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-24 15:36:31 +01:00
|
|
|
void BuildConfigurationComboBox::nameChanged(BuildConfiguration *bc)
|
2009-09-17 13:59:10 +02:00
|
|
|
{
|
2009-11-24 15:36:31 +01:00
|
|
|
int index = nameToIndex(bc);
|
2009-09-17 13:59:10 +02:00
|
|
|
if (index == -1)
|
|
|
|
|
return;
|
2009-11-24 15:36:31 +01:00
|
|
|
const QString &displayName = bc->displayName();
|
2009-09-29 18:06:13 +02:00
|
|
|
m_comboBox->setItemText(index, displayName);
|
|
|
|
|
if (m_comboBox->count() == 1)
|
|
|
|
|
m_label->setText(displayName);
|
2009-09-17 13:59:10 +02:00
|
|
|
}
|
|
|
|
|
|
2009-11-24 15:36:31 +01:00
|
|
|
int BuildConfigurationComboBox::nameToIndex(BuildConfiguration *bc)
|
2009-09-17 13:59:10 +02:00
|
|
|
{
|
2009-09-29 18:06:13 +02:00
|
|
|
for (int i=0; i < m_comboBox->count(); ++i)
|
2009-11-24 15:36:31 +01:00
|
|
|
if (m_comboBox->itemData(i).value<BuildConfiguration *>() == bc)
|
2009-09-17 13:59:10 +02:00
|
|
|
return i;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BuildConfigurationComboBox::activeConfigurationChanged()
|
|
|
|
|
{
|
2009-11-24 15:36:31 +01:00
|
|
|
int index = nameToIndex(m_project->activeBuildConfiguration());
|
2009-09-17 13:59:10 +02:00
|
|
|
if (index == -1)
|
|
|
|
|
return;
|
|
|
|
|
ignoreIndexChange = true;
|
2009-09-29 18:06:13 +02:00
|
|
|
m_comboBox->setCurrentIndex(index);
|
2009-09-17 13:59:10 +02:00
|
|
|
ignoreIndexChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-24 15:36:31 +01:00
|
|
|
void BuildConfigurationComboBox::addedBuildConfiguration(ProjectExplorer::Project *,BuildConfiguration *bc)
|
2009-09-17 13:59:10 +02:00
|
|
|
{
|
|
|
|
|
ignoreIndexChange = true;
|
2009-11-24 15:36:31 +01:00
|
|
|
m_comboBox->addItem(bc->displayName(), QVariant::fromValue(bc));
|
2009-09-29 18:06:13 +02:00
|
|
|
|
|
|
|
|
if (m_comboBox->count() == 2)
|
|
|
|
|
setCurrentWidget(m_comboBox);
|
2009-09-17 13:59:10 +02:00
|
|
|
ignoreIndexChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-24 15:36:31 +01:00
|
|
|
void BuildConfigurationComboBox::removedBuildConfiguration(ProjectExplorer::Project *, BuildConfiguration *bc)
|
2009-09-17 13:59:10 +02:00
|
|
|
{
|
|
|
|
|
ignoreIndexChange = true;
|
2009-11-24 15:36:31 +01:00
|
|
|
int index = nameToIndex(bc);
|
2009-09-29 18:06:13 +02:00
|
|
|
m_comboBox->removeItem(index);
|
|
|
|
|
if (m_comboBox->count() == 1) {
|
|
|
|
|
m_label->setText(m_comboBox->itemText(0));
|
|
|
|
|
setCurrentWidget(m_label);
|
|
|
|
|
}
|
2009-09-17 13:59:10 +02:00
|
|
|
ignoreIndexChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BuildConfigurationComboBox::changedIndex(int newIndex)
|
|
|
|
|
{
|
|
|
|
|
if (newIndex == -1)
|
|
|
|
|
return;
|
2009-11-24 15:36:31 +01:00
|
|
|
m_project->setActiveBuildConfiguration(m_comboBox->itemData(newIndex).value<BuildConfiguration *>());
|
2009-09-17 13:59:10 +02:00
|
|
|
}
|
2009-09-29 18:06:13 +02:00
|
|
|
|
2009-08-06 15:31:32 +02:00
|
|
|
///
|
2009-09-29 18:06:13 +02:00
|
|
|
// ProjectLabel
|
2009-08-06 15:31:32 +02:00
|
|
|
///
|
|
|
|
|
|
2009-09-29 18:06:13 +02:00
|
|
|
ProjectLabel::ProjectLabel(QWidget *parent)
|
|
|
|
|
: QLabel(parent)
|
2009-08-06 15:31:32 +02:00
|
|
|
{
|
2009-09-29 18:06:13 +02:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectLabel::~ProjectLabel()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProjectLabel::setProject(ProjectExplorer::Project *p)
|
|
|
|
|
{
|
|
|
|
|
if (p)
|
|
|
|
|
setText(tr("Edit Project Settings for Project <b>%1</b>").arg(p->name()));
|
|
|
|
|
else
|
|
|
|
|
setText(tr("No Project loaded"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
// ProjectPushButton
|
|
|
|
|
///
|
|
|
|
|
|
|
|
|
|
ProjectPushButton::ProjectPushButton(QWidget *parent)
|
|
|
|
|
: QPushButton(parent)
|
|
|
|
|
{
|
|
|
|
|
setText(tr("Select Project"));
|
|
|
|
|
m_menu = new QMenu(this);
|
|
|
|
|
setMenu(m_menu);
|
|
|
|
|
|
|
|
|
|
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
|
|
|
|
2009-09-17 13:59:10 +02:00
|
|
|
SessionManager *session = ProjectExplorerPlugin::instance()->session();
|
|
|
|
|
|
|
|
|
|
foreach(Project *p, session->projects()) {
|
2009-09-29 18:06:13 +02:00
|
|
|
QAction *act = m_menu->addAction(p->name());
|
|
|
|
|
act->setData(QVariant::fromValue((void *) p));
|
|
|
|
|
connect(act, SIGNAL(triggered()),
|
|
|
|
|
this, SLOT(actionTriggered()));
|
2009-09-17 13:59:10 +02:00
|
|
|
}
|
2009-08-06 15:31:32 +02:00
|
|
|
|
2009-09-29 18:06:13 +02:00
|
|
|
setEnabled(session->projects().count() > 1);
|
|
|
|
|
|
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*)));
|
2009-08-06 15:31:32 +02:00
|
|
|
}
|
|
|
|
|
|
2009-09-29 18:06:13 +02:00
|
|
|
ProjectPushButton::~ProjectPushButton()
|
2009-08-06 15:31:32 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-29 18:06:13 +02:00
|
|
|
void ProjectPushButton::projectAdded(ProjectExplorer::Project *p)
|
2009-08-06 15:31:32 +02:00
|
|
|
{
|
2009-09-29 18:06:13 +02:00
|
|
|
QAction *act = m_menu->addAction(p->name());
|
|
|
|
|
act->setData(QVariant::fromValue((void *) p));
|
|
|
|
|
connect(act, SIGNAL(triggered()),
|
|
|
|
|
this, SLOT(actionTriggered()));
|
|
|
|
|
|
|
|
|
|
// Activate it
|
|
|
|
|
if (m_menu->actions().count() == 1)
|
|
|
|
|
emit projectChanged(p);
|
|
|
|
|
else if (m_menu->actions().count() > 1)
|
|
|
|
|
setEnabled(true);
|
2009-08-06 15:31:32 +02:00
|
|
|
}
|
|
|
|
|
|
2009-09-29 18:06:13 +02:00
|
|
|
void ProjectPushButton::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();
|
2009-09-29 18:06:13 +02:00
|
|
|
|
|
|
|
|
bool needToChange = false;
|
|
|
|
|
foreach(QAction *act, m_menu->actions()) {
|
|
|
|
|
if (act->data().value<void *>() == (void *) p) {
|
|
|
|
|
delete act;
|
|
|
|
|
needToChange = true;
|
2009-09-17 13:59:10 +02:00
|
|
|
break;
|
2009-09-29 18:06:13 +02:00
|
|
|
}
|
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
|
2009-09-29 18:06:13 +02:00
|
|
|
if (m_menu->actions().isEmpty()) {
|
|
|
|
|
emit projectChanged(0);
|
|
|
|
|
setEnabled(false);
|
|
|
|
|
} else if (needToChange) {
|
|
|
|
|
emit projectChanged((ProjectExplorer::Project *) m_menu->actions().first()->data().value<void *>());
|
2009-08-06 15:31:32 +02:00
|
|
|
}
|
2009-09-17 13:59:10 +02:00
|
|
|
}
|
|
|
|
|
|
2009-09-29 18:06:13 +02:00
|
|
|
void ProjectPushButton::actionTriggered()
|
2009-09-17 13:59:10 +02:00
|
|
|
{
|
2009-09-29 18:06:13 +02:00
|
|
|
QAction *action = qobject_cast<QAction *>(sender());
|
|
|
|
|
emit projectChanged((ProjectExplorer::Project *) action->data().value<void *>());
|
2009-08-06 15:31:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
// ProjectWindow
|
|
|
|
|
///
|
|
|
|
|
|
2009-06-08 19:13:46 +02:00
|
|
|
ProjectWindow::ProjectWindow(QWidget *parent)
|
2009-10-07 15:46:07 +02:00
|
|
|
: QWidget(parent)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-10-07 15:46:07 +02:00
|
|
|
ProjectExplorer::SessionManager *session = ProjectExplorerPlugin::instance()->session();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-11-25 16:01:46 +01:00
|
|
|
// Setup overall layout:
|
|
|
|
|
QVBoxLayout *viewLayout = new QVBoxLayout(this);
|
|
|
|
|
viewLayout->setMargin(0);
|
|
|
|
|
viewLayout->setSpacing(0);
|
2009-09-17 13:59:10 +02:00
|
|
|
|
2009-11-25 16:01:46 +01:00
|
|
|
// Add toolbar used everywhere
|
|
|
|
|
viewLayout->addWidget(new Utils::StyledBar(this));
|
2009-10-07 15:46:07 +02:00
|
|
|
|
2009-11-25 16:01:46 +01:00
|
|
|
// Setup our container for the contents:
|
|
|
|
|
m_panelsWidget = new PanelsWidget(this);
|
|
|
|
|
viewLayout->addWidget(m_panelsWidget);
|
|
|
|
|
|
|
|
|
|
// Run and build configuration selection area:
|
|
|
|
|
m_activeConfigurationWidget = new ActiveConfigurationWidget(m_panelsWidget->rootWidget());
|
|
|
|
|
|
|
|
|
|
// Spacer and line:
|
|
|
|
|
m_spacerBetween = new QWidget(m_panelsWidget->rootWidget());
|
|
|
|
|
QVBoxLayout *spacerVbox = new QVBoxLayout(m_spacerBetween);
|
|
|
|
|
spacerVbox->setMargin(0);
|
|
|
|
|
m_spacerBetween->setLayout(spacerVbox);
|
|
|
|
|
spacerVbox->addSpacerItem(new QSpacerItem(10, 15, QSizePolicy::Fixed, QSizePolicy::Fixed));
|
|
|
|
|
spacerVbox->addWidget(new OnePixelBlackLine(m_spacerBetween));
|
|
|
|
|
spacerVbox->addSpacerItem(new QSpacerItem(10, 15, QSizePolicy::Fixed, QSizePolicy::Fixed));
|
|
|
|
|
|
|
|
|
|
// Project chooser:
|
|
|
|
|
m_projectChooser = new QWidget(m_panelsWidget->rootWidget());
|
2009-09-17 13:59:10 +02:00
|
|
|
QHBoxLayout *hbox = new QHBoxLayout(m_projectChooser);
|
|
|
|
|
hbox->setMargin(0);
|
2009-09-29 18:06:13 +02:00
|
|
|
ProjectLabel *label = new ProjectLabel(m_projectChooser);
|
|
|
|
|
{
|
|
|
|
|
QFont f = label->font();
|
|
|
|
|
f.setPointSizeF(f.pointSizeF() * 1.4);
|
|
|
|
|
f.setBold(true);
|
|
|
|
|
label->setFont(f);
|
|
|
|
|
}
|
|
|
|
|
hbox->addWidget(label);
|
|
|
|
|
ProjectPushButton *changeProject = new ProjectPushButton(m_projectChooser);
|
|
|
|
|
connect(changeProject, SIGNAL(projectChanged(ProjectExplorer::Project*)),
|
|
|
|
|
label, SLOT(setProject(ProjectExplorer::Project*)));
|
|
|
|
|
hbox->addWidget(changeProject);
|
2009-09-17 13:59:10 +02:00
|
|
|
|
2009-11-25 16:01:46 +01:00
|
|
|
// no projects label:
|
2009-10-07 15:46:07 +02:00
|
|
|
m_noprojectLabel = new QLabel(this);
|
|
|
|
|
m_noprojectLabel->setText(tr("No project loaded."));
|
|
|
|
|
{
|
|
|
|
|
QFont f = m_noprojectLabel->font();
|
|
|
|
|
f.setPointSizeF(f.pointSizeF() * 1.4);
|
|
|
|
|
f.setBold(true);
|
|
|
|
|
m_noprojectLabel->setFont(f);
|
|
|
|
|
}
|
|
|
|
|
m_noprojectLabel->setMargin(10);
|
|
|
|
|
m_noprojectLabel->setAlignment(Qt::AlignTop);
|
2009-11-25 16:01:46 +01:00
|
|
|
viewLayout->addWidget(m_noprojectLabel);
|
2009-10-07 15:46:07 +02:00
|
|
|
|
2009-11-25 16:01:46 +01:00
|
|
|
// show either panels or no projects label:
|
2009-10-07 15:46:07 +02:00
|
|
|
bool noProjects = session->projects().isEmpty();
|
|
|
|
|
m_panelsWidget->setVisible(!noProjects);
|
|
|
|
|
m_noprojectLabel->setVisible(noProjects);
|
|
|
|
|
|
2009-11-25 16:01:46 +01:00
|
|
|
// connects:
|
2009-09-29 18:06:13 +02:00
|
|
|
connect(changeProject, SIGNAL(projectChanged(ProjectExplorer::Project*)),
|
2009-09-17 13:59:10 +02:00
|
|
|
this, SLOT(showProperties(ProjectExplorer::Project*)));
|
|
|
|
|
|
2009-10-07 15:46:07 +02:00
|
|
|
connect(session, SIGNAL(sessionLoaded()), this, SLOT(restoreStatus()));
|
|
|
|
|
connect(session, SIGNAL(aboutToSaveSession()), this, SLOT(saveStatus()));
|
|
|
|
|
|
|
|
|
|
connect(session, SIGNAL(projectAdded(ProjectExplorer::Project*)),
|
|
|
|
|
this, SLOT(projectAdded()));
|
|
|
|
|
connect(session, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
|
|
|
|
|
this, SLOT(projectRemoved()));
|
2009-11-25 15:18:51 +01:00
|
|
|
|
|
|
|
|
// Update properties to empty project for now:
|
|
|
|
|
showProperties(0);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectWindow::~ProjectWindow()
|
|
|
|
|
{
|
2009-11-04 18:50:37 +01:00
|
|
|
qDeleteAll(m_panels);
|
|
|
|
|
m_panels.clear();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-10-07 15:46:07 +02:00
|
|
|
void ProjectWindow::projectAdded()
|
|
|
|
|
{
|
|
|
|
|
m_panelsWidget->setVisible(true);
|
|
|
|
|
m_noprojectLabel->setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProjectWindow::projectRemoved()
|
|
|
|
|
{
|
|
|
|
|
if (ProjectExplorerPlugin::instance()->session()->projects().isEmpty()) {
|
|
|
|
|
m_panelsWidget->setVisible(false);
|
|
|
|
|
m_noprojectLabel->setVisible(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
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
|
|
|
{
|
2009-11-25 15:18:51 +01:00
|
|
|
// Remove all existing panels:
|
2009-07-16 15:33:19 +02:00
|
|
|
m_panelsWidget->clear();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-11-25 15:18:51 +01:00
|
|
|
// delete custom panels:
|
2009-11-04 18:50:37 +01:00
|
|
|
qDeleteAll(m_panels);
|
|
|
|
|
m_panels.clear();
|
|
|
|
|
|
2009-11-25 15:57:09 +01:00
|
|
|
// Set up our default panels:
|
2009-11-25 16:01:46 +01:00
|
|
|
m_panelsWidget->addWidget(tr("Active Build and Run Configurations"), m_activeConfigurationWidget, QIcon());
|
2009-09-17 13:59:10 +02:00
|
|
|
m_panelsWidget->addWidget(m_spacerBetween);
|
2009-09-29 18:06:13 +02:00
|
|
|
m_panelsWidget->addWidget(m_projectChooser);
|
2009-09-17 13:59:10 +02:00
|
|
|
|
2009-11-25 15:18:51 +01:00
|
|
|
// Set up custom panels again:
|
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)) {
|
2009-11-25 15:57:09 +01:00
|
|
|
IPropertiesPanel *panel = panelFactory->createPanel(project);
|
2009-11-25 16:01:46 +01:00
|
|
|
m_panelsWidget->addWidget(panel->name(), panel->widget(), panel->icon());
|
2009-11-04 18:50:37 +01:00
|
|
|
m_panels.push_back(panel);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|