2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
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
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-05-06 15:05:37 +02:00
|
|
|
** Nokia at info@qt.nokia.com.
|
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 "buildstepspage.h"
|
2010-07-16 14:00:41 +02:00
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
#include "buildconfiguration.h"
|
2010-07-16 14:00:41 +02:00
|
|
|
#include "buildsteplist.h"
|
2010-05-07 12:26:01 +02:00
|
|
|
#include "detailsbutton.h"
|
2010-07-16 14:00:41 +02:00
|
|
|
#include "projectexplorerconstants.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-12 15:06:43 +01:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2010-04-13 15:04:21 +02:00
|
|
|
#include <coreplugin/icore.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2008-12-09 15:25:01 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2010-11-02 16:14:00 +01:00
|
|
|
#include <utils/detailswidget.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-11-30 16:44:22 +01:00
|
|
|
#include <QtCore/QSignalMapper>
|
|
|
|
|
|
2009-08-06 15:31:32 +02:00
|
|
|
#include <QtGui/QLabel>
|
|
|
|
|
#include <QtGui/QPushButton>
|
2009-09-29 11:39:55 +02:00
|
|
|
#include <QtGui/QMenu>
|
2009-09-30 10:42:20 +02:00
|
|
|
#include <QtGui/QVBoxLayout>
|
|
|
|
|
#include <QtGui/QHBoxLayout>
|
2009-10-01 14:24:44 +02:00
|
|
|
#include <QtGui/QToolButton>
|
2010-04-13 15:04:21 +02:00
|
|
|
#include <QtGui/QMessageBox>
|
|
|
|
|
#include <QtGui/QMainWindow>
|
2009-08-06 15:31:32 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace ProjectExplorer::Internal;
|
|
|
|
|
|
2011-05-16 18:06:27 +02:00
|
|
|
BuildStepsWidgetData::BuildStepsWidgetData(BuildStep *s) :
|
|
|
|
|
step(s), widget(0), detailsWidget(0), upButton(0), downButton(0), removeButton(0)
|
|
|
|
|
{
|
|
|
|
|
widget = s->createConfigWidget();
|
|
|
|
|
Q_ASSERT(widget);
|
|
|
|
|
|
|
|
|
|
detailsWidget = new Utils::DetailsWidget;
|
|
|
|
|
detailsWidget->setWidget(widget);
|
|
|
|
|
|
|
|
|
|
Utils::FadingPanel *toolWidget = new Utils::FadingPanel(detailsWidget);
|
|
|
|
|
#ifdef Q_WS_MAC
|
|
|
|
|
QSize buttonSize(20, 20);
|
|
|
|
|
#else
|
|
|
|
|
QSize buttonSize(20, 26);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
upButton = new QToolButton(toolWidget);
|
|
|
|
|
upButton->setAutoRaise(true);
|
|
|
|
|
upButton->setToolTip(BuildStepListWidget::tr("Move Up"));
|
|
|
|
|
upButton->setFixedSize(buttonSize);
|
|
|
|
|
upButton->setIcon(QIcon(QLatin1String(":/core/images/darkarrowup.png")));
|
|
|
|
|
|
|
|
|
|
downButton = new QToolButton(toolWidget);
|
|
|
|
|
downButton->setAutoRaise(true);
|
|
|
|
|
downButton->setToolTip(BuildStepListWidget::tr("Move Down"));
|
|
|
|
|
downButton->setFixedSize(buttonSize);
|
|
|
|
|
downButton->setIcon(QIcon(QLatin1String(":/core/images/darkarrowdown.png")));
|
|
|
|
|
|
|
|
|
|
removeButton = new QToolButton(toolWidget);
|
|
|
|
|
removeButton->setAutoRaise(true);
|
|
|
|
|
removeButton->setToolTip(BuildStepListWidget::tr("Remove Item"));
|
|
|
|
|
removeButton->setFixedSize(buttonSize);
|
|
|
|
|
removeButton->setIcon(QIcon(QLatin1String(":/core/images/darkclose.png")));
|
|
|
|
|
|
|
|
|
|
toolWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
|
|
|
|
QHBoxLayout *hbox = new QHBoxLayout();
|
|
|
|
|
toolWidget->setLayout(hbox);
|
|
|
|
|
hbox->setMargin(4);
|
|
|
|
|
hbox->setSpacing(0);
|
|
|
|
|
hbox->addWidget(upButton);
|
|
|
|
|
hbox->addWidget(downButton);
|
|
|
|
|
hbox->addWidget(removeButton);
|
|
|
|
|
|
|
|
|
|
detailsWidget->setToolWidget(toolWidget);
|
|
|
|
|
|
|
|
|
|
detailsWidget->setContentsMargins(0, 0, 0, 1);
|
|
|
|
|
|
|
|
|
|
detailsWidget->setSummaryText(widget->summaryText());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildStepsWidgetData::~BuildStepsWidgetData()
|
|
|
|
|
{
|
|
|
|
|
delete detailsWidget; // other widgets are children of that!
|
|
|
|
|
// We do not own the step
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
BuildStepListWidget::BuildStepListWidget(QWidget *parent) :
|
|
|
|
|
NamedWidget(parent),
|
|
|
|
|
m_buildStepList(0),
|
2010-05-21 14:29:11 +02:00
|
|
|
m_addButton(0)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-05-21 14:29:11 +02:00
|
|
|
setStyleSheet("background: red");
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
BuildStepListWidget::~BuildStepListWidget()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2011-05-16 18:06:27 +02:00
|
|
|
qDeleteAll(m_buildStepsData);
|
|
|
|
|
m_buildStepsData.clear();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
void BuildStepListWidget::updateSummary()
|
2009-08-06 15:31:32 +02:00
|
|
|
{
|
|
|
|
|
BuildStepConfigWidget *widget = qobject_cast<BuildStepConfigWidget *>(sender());
|
2009-10-27 14:16:28 +01:00
|
|
|
if (widget) {
|
2011-05-16 18:06:27 +02:00
|
|
|
foreach (const BuildStepsWidgetData *s, m_buildStepsData) {
|
|
|
|
|
if (s->widget == widget) {
|
|
|
|
|
s->detailsWidget->setSummaryText(widget->summaryText());
|
2009-10-27 14:16:28 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
void BuildStepListWidget::init(BuildStepList *bsl)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
Q_ASSERT(bsl);
|
2011-05-16 18:06:27 +02:00
|
|
|
if (bsl == m_buildStepList)
|
|
|
|
|
return;
|
2009-11-30 16:44:22 +01:00
|
|
|
|
|
|
|
|
setupUi();
|
|
|
|
|
|
2011-05-16 18:03:56 +02:00
|
|
|
if (m_buildStepList) {
|
|
|
|
|
disconnect(m_buildStepList, SIGNAL(stepInserted(int)), this, SLOT(addBuildStep(int)));
|
|
|
|
|
disconnect(m_buildStepList, SIGNAL(stepRemoved(int)), this, SLOT(removeBuildStep(int)));
|
|
|
|
|
disconnect(m_buildStepList, SIGNAL(stepMoved(int,int)), this, SLOT(stepMoved(int,int)));
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-11 13:12:26 +02:00
|
|
|
connect(bsl, SIGNAL(stepInserted(int)), this, SLOT(addBuildStep(int)));
|
|
|
|
|
connect(bsl, SIGNAL(stepRemoved(int)), this, SLOT(removeBuildStep(int)));
|
|
|
|
|
connect(bsl, SIGNAL(stepMoved(int,int)), this, SLOT(stepMoved(int,int)));
|
|
|
|
|
|
2011-05-16 18:06:27 +02:00
|
|
|
qDeleteAll(m_buildStepsData);
|
|
|
|
|
m_buildStepsData.clear();
|
2009-10-27 14:16:28 +01:00
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
m_buildStepList = bsl;
|
|
|
|
|
//: %1 is the name returned by BuildStepList::displayName
|
|
|
|
|
setDisplayName(tr("%1 Steps").arg(m_buildStepList->displayName()));
|
2009-10-27 14:16:28 +01:00
|
|
|
|
2011-05-16 18:06:27 +02:00
|
|
|
for (int i = 0; i < bsl->count(); ++i) {
|
|
|
|
|
addBuildStep(i);
|
|
|
|
|
m_buildStepsData.at(i)->detailsWidget->setState(Utils::DetailsWidget::Collapsed);
|
|
|
|
|
}
|
2009-10-27 14:16:28 +01:00
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
m_noStepsLabel->setVisible(bsl->isEmpty());
|
|
|
|
|
m_noStepsLabel->setText(tr("No %1 Steps").arg(m_buildStepList->displayName()));
|
|
|
|
|
|
|
|
|
|
m_addButton->setText(tr("Add %1 Step").arg(m_buildStepList->displayName()));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
updateBuildStepButtonsState();
|
2010-05-07 12:26:01 +02:00
|
|
|
|
|
|
|
|
static QLatin1String buttonStyle(
|
|
|
|
|
"QToolButton{ border-width: 2;}"
|
|
|
|
|
"QToolButton:hover{border-image: url(:/welcome/images/btn_26_hover.png) 4;}"
|
|
|
|
|
"QToolButton:pressed{ border-image: url(:/welcome/images/btn_26_pressed.png) 4;}");
|
|
|
|
|
setStyleSheet(buttonStyle);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
void BuildStepListWidget::updateAddBuildStepMenu()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
QMap<QString, QPair<QString, IBuildStepFactory *> > map;
|
|
|
|
|
//Build up a list of possible steps and save map the display names to the (internal) name and factories.
|
|
|
|
|
QList<IBuildStepFactory *> factories = ExtensionSystem::PluginManager::instance()->getObjects<IBuildStepFactory>();
|
2009-11-30 16:44:22 +01:00
|
|
|
foreach (IBuildStepFactory *factory, factories) {
|
2010-07-16 14:00:41 +02:00
|
|
|
QStringList ids = factory->availableCreationIds(m_buildStepList);
|
2010-01-07 18:17:24 +01:00
|
|
|
foreach (const QString &id, ids) {
|
|
|
|
|
map.insert(factory->displayNameForId(id), QPair<QString, IBuildStepFactory *>(id, factory));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ask the user which one to add
|
2009-08-06 15:31:32 +02:00
|
|
|
QMenu *menu = m_addButton->menu();
|
2008-12-02 12:01:29 +01:00
|
|
|
m_addBuildStepHash.clear();
|
|
|
|
|
menu->clear();
|
2008-12-09 11:07:24 +01:00
|
|
|
if (!map.isEmpty()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
QMap<QString, QPair<QString, IBuildStepFactory *> >::const_iterator it, end;
|
|
|
|
|
end = map.constEnd();
|
2008-12-09 11:07:24 +01:00
|
|
|
for (it = map.constBegin(); it != end; ++it) {
|
2008-12-02 12:01:29 +01:00
|
|
|
QAction *action = menu->addAction(it.key());
|
|
|
|
|
connect(action, SIGNAL(triggered()),
|
2011-05-11 13:12:26 +02:00
|
|
|
this, SLOT(triggerAddBuildStep()));
|
2008-12-02 12:01:29 +01:00
|
|
|
m_addBuildStepHash.insert(action, it.value());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
void BuildStepListWidget::addBuildStepWidget(int pos, BuildStep *step)
|
2009-08-06 15:31:32 +02:00
|
|
|
{
|
|
|
|
|
// create everything
|
2011-05-16 18:06:27 +02:00
|
|
|
BuildStepsWidgetData *s = new BuildStepsWidgetData(step);
|
|
|
|
|
m_buildStepsData.insert(pos, s);
|
2010-05-07 12:26:01 +02:00
|
|
|
|
2011-05-16 18:06:27 +02:00
|
|
|
m_vbox->insertWidget(pos, s->detailsWidget);
|
2010-05-07 12:26:01 +02:00
|
|
|
|
2011-05-16 18:06:27 +02:00
|
|
|
connect(s->widget, SIGNAL(updateSummary()),
|
2009-08-06 15:31:32 +02:00
|
|
|
this, SLOT(updateSummary()));
|
|
|
|
|
|
2011-05-16 18:06:27 +02:00
|
|
|
connect(s->upButton, SIGNAL(clicked()),
|
2009-11-30 16:44:22 +01:00
|
|
|
m_upMapper, SLOT(map()));
|
2011-05-16 18:06:27 +02:00
|
|
|
connect(s->downButton, SIGNAL(clicked()),
|
2009-11-30 16:44:22 +01:00
|
|
|
m_downMapper, SLOT(map()));
|
2011-05-16 18:06:27 +02:00
|
|
|
connect(s->removeButton, SIGNAL(clicked()),
|
2009-11-30 16:44:22 +01:00
|
|
|
m_removeMapper, SLOT(map()));
|
2009-08-06 15:31:32 +02:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-05-11 13:12:26 +02:00
|
|
|
void BuildStepListWidget::triggerAddBuildStep()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2008-12-09 11:07:24 +01:00
|
|
|
if (QAction *action = qobject_cast<QAction *>(sender())) {
|
2008-12-02 12:01:29 +01:00
|
|
|
QPair<QString, IBuildStepFactory *> pair = m_addBuildStepHash.value(action);
|
2010-07-16 14:00:41 +02:00
|
|
|
BuildStep *newStep = pair.second->create(m_buildStepList, pair.first);
|
|
|
|
|
int pos = m_buildStepList->count();
|
|
|
|
|
m_buildStepList->insertStep(pos, newStep);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2011-05-11 13:12:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BuildStepListWidget::addBuildStep(int pos)
|
|
|
|
|
{
|
|
|
|
|
BuildStep *newStep = m_buildStepList->at(pos);
|
|
|
|
|
addBuildStepWidget(pos, newStep);
|
2011-05-16 18:06:27 +02:00
|
|
|
BuildStepsWidgetData *s = m_buildStepsData.at(pos);
|
|
|
|
|
s->detailsWidget->setState(Utils::DetailsWidget::Expanded);
|
2009-11-30 16:44:22 +01:00
|
|
|
|
2009-12-07 15:23:32 +01:00
|
|
|
m_noStepsLabel->setVisible(false);
|
2009-08-11 18:09:52 +02:00
|
|
|
updateBuildStepButtonsState();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-05-11 13:12:26 +02:00
|
|
|
void BuildStepListWidget::triggerStepMoveUp(int pos)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
m_buildStepList->moveStepUp(pos);
|
2011-05-11 13:12:26 +02:00
|
|
|
}
|
2009-11-30 16:44:22 +01:00
|
|
|
|
2011-05-11 13:12:26 +02:00
|
|
|
void BuildStepListWidget::stepMoved(int from, int to)
|
|
|
|
|
{
|
2011-05-16 18:06:27 +02:00
|
|
|
m_vbox->insertWidget(to, m_buildStepsData.at(from)->detailsWidget);
|
2009-11-30 16:44:22 +01:00
|
|
|
|
2011-05-16 18:06:27 +02:00
|
|
|
Internal::BuildStepsWidgetData *data = m_buildStepsData.at(from);
|
|
|
|
|
m_buildStepsData.removeAt(from);
|
|
|
|
|
m_buildStepsData.insert(to, data);
|
2009-08-06 15:31:32 +02:00
|
|
|
|
2009-08-11 18:09:52 +02:00
|
|
|
updateBuildStepButtonsState();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-05-11 13:12:26 +02:00
|
|
|
void BuildStepListWidget::triggerStepMoveDown(int pos)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2011-05-11 13:12:26 +02:00
|
|
|
triggerStepMoveUp(pos + 1);
|
2009-11-30 16:44:22 +01:00
|
|
|
}
|
2009-08-06 15:31:32 +02:00
|
|
|
|
2011-05-11 13:12:26 +02:00
|
|
|
void BuildStepListWidget::triggerRemoveBuildStep(int pos)
|
2009-11-30 16:44:22 +01:00
|
|
|
{
|
2011-05-11 13:12:26 +02:00
|
|
|
if (!m_buildStepList->removeStep(pos)) {
|
2010-04-13 15:04:21 +02:00
|
|
|
QMessageBox::warning(Core::ICore::instance()->mainWindow(),
|
|
|
|
|
tr("Removing Step failed"),
|
2010-09-10 10:51:43 +02:00
|
|
|
tr("Cannot remove build step while building"),
|
2010-04-13 15:04:21 +02:00
|
|
|
QMessageBox::Ok, QMessageBox::Ok);
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-05-11 13:12:26 +02:00
|
|
|
void BuildStepListWidget::removeBuildStep(int pos)
|
|
|
|
|
{
|
2011-05-16 18:06:27 +02:00
|
|
|
delete m_buildStepsData.takeAt(pos);
|
2011-05-11 13:12:26 +02:00
|
|
|
|
|
|
|
|
updateBuildStepButtonsState();
|
|
|
|
|
|
|
|
|
|
bool hasSteps = m_buildStepList->isEmpty();
|
|
|
|
|
m_noStepsLabel->setVisible(hasSteps);
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
void BuildStepListWidget::setupUi()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-11-30 16:44:22 +01:00
|
|
|
if (0 != m_addButton)
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
2009-08-06 15:31:32 +02:00
|
|
|
|
2009-11-30 16:44:22 +01:00
|
|
|
m_upMapper = new QSignalMapper(this);
|
|
|
|
|
connect(m_upMapper, SIGNAL(mapped(int)),
|
2011-05-11 13:12:26 +02:00
|
|
|
this, SLOT(triggerStepMoveUp(int)));
|
2009-11-30 16:44:22 +01:00
|
|
|
m_downMapper = new QSignalMapper(this);
|
|
|
|
|
connect(m_downMapper, SIGNAL(mapped(int)),
|
2011-05-11 13:12:26 +02:00
|
|
|
this, SLOT(triggerStepMoveDown(int)));
|
2009-11-30 16:44:22 +01:00
|
|
|
m_removeMapper = new QSignalMapper(this);
|
|
|
|
|
connect(m_removeMapper, SIGNAL(mapped(int)),
|
2011-05-11 13:12:26 +02:00
|
|
|
this, SLOT(triggerRemoveBuildStep(int)));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-11-30 16:44:22 +01:00
|
|
|
m_vbox = new QVBoxLayout(this);
|
|
|
|
|
m_vbox->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
m_vbox->setSpacing(0);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-11-30 16:44:22 +01:00
|
|
|
m_noStepsLabel = new QLabel(tr("No Build Steps"), this);
|
2010-05-21 14:29:11 +02:00
|
|
|
m_noStepsLabel->setContentsMargins(0, 0, 0, 0);
|
2009-11-30 16:44:22 +01:00
|
|
|
m_vbox->addWidget(m_noStepsLabel);
|
2009-08-06 15:31:32 +02:00
|
|
|
|
2009-11-30 16:44:22 +01:00
|
|
|
QHBoxLayout *hboxLayout = new QHBoxLayout();
|
2010-05-21 14:29:11 +02:00
|
|
|
hboxLayout->setContentsMargins(0, 4, 0, 0);
|
2009-11-30 16:44:22 +01:00
|
|
|
m_addButton = new QPushButton(this);
|
|
|
|
|
m_addButton->setMenu(new QMenu(this));
|
|
|
|
|
hboxLayout->addWidget(m_addButton);
|
|
|
|
|
|
|
|
|
|
hboxLayout->addStretch(10);
|
|
|
|
|
|
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
|
m_addButton->setAttribute(Qt::WA_MacSmallSize);
|
|
|
|
|
#endif
|
2009-08-06 15:31:32 +02:00
|
|
|
|
2009-11-30 16:44:22 +01:00
|
|
|
m_vbox->addLayout(hboxLayout);
|
|
|
|
|
|
|
|
|
|
connect(m_addButton->menu(), SIGNAL(aboutToShow()),
|
|
|
|
|
this, SLOT(updateAddBuildStepMenu()));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
void BuildStepListWidget::updateBuildStepButtonsState()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2011-05-16 18:06:27 +02:00
|
|
|
if (m_buildStepsData.count() != m_buildStepList->count())
|
|
|
|
|
return;
|
|
|
|
|
for (int i = 0; i < m_buildStepsData.count(); ++i) {
|
|
|
|
|
BuildStepsWidgetData *s = m_buildStepsData.at(i);
|
|
|
|
|
s->removeButton->setEnabled(!m_buildStepList->at(i)->immutable());
|
|
|
|
|
m_removeMapper->setMapping(s->removeButton, i);
|
2010-05-07 12:26:01 +02:00
|
|
|
|
2011-05-16 18:06:27 +02:00
|
|
|
s->upButton->setEnabled((i > 0)
|
2010-07-16 14:00:41 +02:00
|
|
|
&& !(m_buildStepList->at(i)->immutable()
|
|
|
|
|
&& m_buildStepList->at(i - 1)));
|
2011-05-16 18:06:27 +02:00
|
|
|
m_upMapper->setMapping(s->upButton, i);
|
|
|
|
|
s->downButton->setEnabled((i + 1 < m_buildStepList->count())
|
2010-07-16 14:00:41 +02:00
|
|
|
&& !(m_buildStepList->at(i)->immutable()
|
|
|
|
|
&& m_buildStepList->at(i + 1)->immutable()));
|
2011-05-16 18:06:27 +02:00
|
|
|
m_downMapper->setMapping(s->downButton, i);
|
2010-05-07 12:26:01 +02:00
|
|
|
|
|
|
|
|
// Only show buttons when needed
|
2011-05-16 18:06:27 +02:00
|
|
|
s->downButton->setVisible(m_buildStepList->count() != 1);
|
|
|
|
|
s->upButton->setVisible(m_buildStepList->count() != 1);
|
2009-07-27 16:37:06 +02:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2010-07-16 14:00:41 +02:00
|
|
|
|
|
|
|
|
BuildStepsPage::BuildStepsPage(Target *target, const QString &id) :
|
|
|
|
|
BuildConfigWidget(),
|
|
|
|
|
m_id(id),
|
|
|
|
|
m_widget(new BuildStepListWidget(this))
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(target);
|
|
|
|
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
|
|
|
|
layout->setMargin(0);
|
|
|
|
|
layout->setSpacing(0);
|
|
|
|
|
layout->addWidget(m_widget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildStepsPage::~BuildStepsPage()
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
QString BuildStepsPage::displayName() const
|
|
|
|
|
{
|
|
|
|
|
if (m_id == QLatin1String(Constants::BUILDSTEPS_BUILD))
|
|
|
|
|
return tr("Build Steps");
|
|
|
|
|
if (m_id == QLatin1String(Constants::BUILDSTEPS_CLEAN))
|
|
|
|
|
return tr("Clean Steps");
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BuildStepsPage::init(BuildConfiguration *bc)
|
|
|
|
|
{
|
|
|
|
|
m_widget->init(bc->stepList(m_id));
|
|
|
|
|
}
|