2015-03-10 10:22:38 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2015-03-10 10:22:38 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2015-03-10 10:22:38 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2015-03-10 10:22:38 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "cmakebuildsettingswidget.h"
|
2016-01-27 10:22:07 +01:00
|
|
|
|
|
|
|
|
#include "configmodel.h"
|
2016-10-10 09:49:46 +10:00
|
|
|
#include "configmodelitemdelegate.h"
|
2017-01-18 16:56:00 +01:00
|
|
|
#include "cmakekitinformation.h"
|
2015-03-10 10:22:38 +01:00
|
|
|
#include "cmakeproject.h"
|
|
|
|
|
#include "cmakebuildconfiguration.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
2016-01-27 10:22:07 +01:00
|
|
|
#include <coreplugin/find/itemviewfind.h>
|
2017-01-18 16:56:00 +01:00
|
|
|
#include <projectexplorer/kitmanager.h>
|
2017-09-14 15:18:50 +02:00
|
|
|
#include <projectexplorer/project.h>
|
2015-03-10 10:22:38 +01:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
|
|
2017-09-14 15:18:50 +02:00
|
|
|
#include <utils/asconst.h>
|
2017-10-17 16:11:17 +02:00
|
|
|
#include <utils/categorysortfiltermodel.h>
|
2016-01-06 15:41:09 +01:00
|
|
|
#include <utils/detailswidget.h>
|
2017-05-14 23:18:31 +02:00
|
|
|
#include <utils/fancylineedit.h>
|
2016-01-27 10:22:07 +01:00
|
|
|
#include <utils/headerviewstretcher.h>
|
|
|
|
|
#include <utils/itemviews.h>
|
2017-10-17 16:10:41 +02:00
|
|
|
#include <utils/pathchooser.h>
|
|
|
|
|
#include <utils/progressindicator.h>
|
2016-08-03 17:55:54 +02:00
|
|
|
#include <utils/utilsicons.h>
|
2016-01-06 15:41:09 +01:00
|
|
|
|
2016-01-27 10:22:07 +01:00
|
|
|
#include <QBoxLayout>
|
|
|
|
|
#include <QCheckBox>
|
2017-09-14 15:18:50 +02:00
|
|
|
#include <QComboBox>
|
2016-01-27 10:22:07 +01:00
|
|
|
#include <QFrame>
|
|
|
|
|
#include <QGridLayout>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QSortFilterProxyModel>
|
|
|
|
|
#include <QSpacerItem>
|
2017-09-14 15:18:50 +02:00
|
|
|
#include <QStyledItemDelegate>
|
2016-05-15 15:57:17 +02:00
|
|
|
#include <QMenu>
|
2015-03-10 10:22:38 +01:00
|
|
|
|
|
|
|
|
namespace CMakeProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2017-09-27 12:28:11 +02:00
|
|
|
static QModelIndex mapToSource(const QAbstractItemView *view, const QModelIndex &idx)
|
|
|
|
|
{
|
|
|
|
|
if (!idx.isValid())
|
|
|
|
|
return idx;
|
|
|
|
|
|
|
|
|
|
QAbstractItemModel *model = view->model();
|
|
|
|
|
QModelIndex result = idx;
|
|
|
|
|
while (QSortFilterProxyModel *proxy = qobject_cast<QSortFilterProxyModel *>(model)) {
|
|
|
|
|
result = proxy->mapToSource(result);
|
|
|
|
|
model = proxy->sourceModel();
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-27 10:22:07 +01:00
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// CMakeBuildSettingsWidget:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
2016-01-07 15:22:53 +01:00
|
|
|
CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc) :
|
2016-01-27 10:22:07 +01:00
|
|
|
m_buildConfiguration(bc),
|
|
|
|
|
m_configModel(new ConfigModel(this)),
|
2017-10-17 16:11:17 +02:00
|
|
|
m_configFilterModel(new Utils::CategorySortFilterModel),
|
|
|
|
|
m_configTextFilterModel(new Utils::CategorySortFilterModel)
|
2015-03-10 10:22:38 +01:00
|
|
|
{
|
2016-01-27 10:22:07 +01:00
|
|
|
QTC_CHECK(bc);
|
|
|
|
|
|
|
|
|
|
setDisplayName(tr("CMake"));
|
|
|
|
|
|
2016-01-07 15:22:53 +01:00
|
|
|
auto vbox = new QVBoxLayout(this);
|
2016-01-06 15:41:09 +01:00
|
|
|
vbox->setMargin(0);
|
2016-01-07 15:22:53 +01:00
|
|
|
auto container = new Utils::DetailsWidget;
|
2016-01-06 15:41:09 +01:00
|
|
|
container->setState(Utils::DetailsWidget::NoSummary);
|
|
|
|
|
vbox->addWidget(container);
|
|
|
|
|
|
2016-01-07 15:22:53 +01:00
|
|
|
auto details = new QWidget(container);
|
2016-01-06 15:41:09 +01:00
|
|
|
container->setWidget(details);
|
|
|
|
|
|
2016-01-27 10:22:07 +01:00
|
|
|
auto mainLayout = new QGridLayout(details);
|
|
|
|
|
mainLayout->setMargin(0);
|
|
|
|
|
mainLayout->setColumnStretch(1, 10);
|
2015-03-10 10:22:38 +01:00
|
|
|
|
2017-09-27 12:28:11 +02:00
|
|
|
auto project = static_cast<CMakeProject *>(bc->project());
|
2016-01-27 10:22:07 +01:00
|
|
|
|
2016-01-20 12:19:16 +01:00
|
|
|
auto buildDirChooser = new Utils::PathChooser;
|
|
|
|
|
buildDirChooser->setBaseFileName(project->projectDirectory());
|
|
|
|
|
buildDirChooser->setFileName(bc->buildDirectory());
|
|
|
|
|
connect(buildDirChooser, &Utils::PathChooser::rawPathChanged, this,
|
2016-02-24 18:00:24 +01:00
|
|
|
[this](const QString &path) {
|
2016-01-27 10:22:07 +01:00
|
|
|
m_configModel->flush(); // clear out config cache...
|
2016-02-24 18:00:24 +01:00
|
|
|
m_buildConfiguration->setBuildDirectory(Utils::FileName::fromString(path));
|
2016-01-20 12:19:16 +01:00
|
|
|
});
|
2015-03-10 10:22:38 +01:00
|
|
|
|
2016-01-27 10:22:07 +01:00
|
|
|
int row = 0;
|
|
|
|
|
mainLayout->addWidget(new QLabel(tr("Build directory:")), row, 0);
|
|
|
|
|
mainLayout->addWidget(buildDirChooser->lineEdit(), row, 1);
|
|
|
|
|
mainLayout->addWidget(buildDirChooser->buttonAtIndex(0), row, 2);
|
2015-03-10 10:22:38 +01:00
|
|
|
|
2016-01-27 10:22:07 +01:00
|
|
|
++row;
|
2016-02-11 16:33:15 +01:00
|
|
|
mainLayout->addItem(new QSpacerItem(20, 10), row, 0);
|
|
|
|
|
|
|
|
|
|
++row;
|
|
|
|
|
m_errorLabel = new QLabel;
|
2017-01-02 12:37:49 +01:00
|
|
|
m_errorLabel->setPixmap(Utils::Icons::CRITICAL.pixmap());
|
2016-02-11 16:33:15 +01:00
|
|
|
m_errorLabel->setVisible(false);
|
|
|
|
|
m_errorMessageLabel = new QLabel;
|
|
|
|
|
m_errorMessageLabel->setVisible(false);
|
|
|
|
|
auto boxLayout = new QHBoxLayout;
|
|
|
|
|
boxLayout->addWidget(m_errorLabel);
|
|
|
|
|
boxLayout->addWidget(m_errorMessageLabel);
|
|
|
|
|
mainLayout->addLayout(boxLayout, row, 0, 1, 3, Qt::AlignHCenter);
|
|
|
|
|
|
2016-05-12 17:23:03 +02:00
|
|
|
++row;
|
|
|
|
|
m_warningLabel = new QLabel;
|
2016-08-03 17:55:54 +02:00
|
|
|
m_warningLabel->setPixmap(Utils::Icons::WARNING.pixmap());
|
2016-05-12 17:23:03 +02:00
|
|
|
m_warningLabel->setVisible(false);
|
|
|
|
|
m_warningMessageLabel = new QLabel;
|
|
|
|
|
m_warningMessageLabel->setVisible(false);
|
|
|
|
|
auto boxLayout2 = new QHBoxLayout;
|
|
|
|
|
boxLayout2->addWidget(m_warningLabel);
|
|
|
|
|
boxLayout2->addWidget(m_warningMessageLabel);
|
|
|
|
|
mainLayout->addLayout(boxLayout2, row, 0, 1, 3, Qt::AlignHCenter);
|
|
|
|
|
|
2016-02-11 16:33:15 +01:00
|
|
|
++row;
|
|
|
|
|
mainLayout->addItem(new QSpacerItem(20, 10), row, 0);
|
2016-01-27 10:22:07 +01:00
|
|
|
|
2017-05-14 23:18:31 +02:00
|
|
|
++row;
|
|
|
|
|
m_filterEdit = new Utils::FancyLineEdit;
|
|
|
|
|
m_filterEdit->setPlaceholderText(tr("Filter"));
|
|
|
|
|
m_filterEdit->setFiltering(true);
|
|
|
|
|
mainLayout->addWidget(m_filterEdit, row, 0, 1, 2);
|
|
|
|
|
|
2016-01-27 10:22:07 +01:00
|
|
|
++row;
|
|
|
|
|
auto tree = new Utils::TreeView;
|
|
|
|
|
connect(tree, &Utils::TreeView::activated,
|
|
|
|
|
tree, [tree](const QModelIndex &idx) { tree->edit(idx); });
|
|
|
|
|
m_configView = tree;
|
2017-09-05 13:55:08 +02:00
|
|
|
|
2017-09-14 13:16:10 +02:00
|
|
|
m_configView->viewport()->installEventFilter(this);
|
|
|
|
|
|
2016-01-27 10:22:07 +01:00
|
|
|
m_configFilterModel->setSourceModel(m_configModel);
|
2017-09-05 13:55:08 +02:00
|
|
|
m_configFilterModel->setFilterKeyColumn(0);
|
|
|
|
|
m_configFilterModel->setFilterRole(ConfigModel::ItemIsAdvancedRole);
|
|
|
|
|
m_configFilterModel->setFilterFixedString("0");
|
|
|
|
|
|
2017-05-14 23:18:31 +02:00
|
|
|
m_configTextFilterModel->setSourceModel(m_configFilterModel);
|
2017-09-13 13:20:25 +02:00
|
|
|
m_configTextFilterModel->setSortRole(Qt::DisplayRole);
|
2017-05-14 23:18:31 +02:00
|
|
|
m_configTextFilterModel->setFilterKeyColumn(-1);
|
|
|
|
|
m_configTextFilterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
2017-09-05 13:55:08 +02:00
|
|
|
|
2017-05-14 23:18:31 +02:00
|
|
|
m_configView->setModel(m_configTextFilterModel);
|
2016-01-27 10:22:07 +01:00
|
|
|
m_configView->setMinimumHeight(300);
|
|
|
|
|
m_configView->setUniformRowHeights(true);
|
2017-09-13 13:20:25 +02:00
|
|
|
m_configView->setSortingEnabled(true);
|
|
|
|
|
m_configView->sortByColumn(0, Qt::AscendingOrder);
|
2016-02-24 18:00:24 +01:00
|
|
|
auto stretcher = new Utils::HeaderViewStretcher(m_configView->header(), 1);
|
2016-01-27 10:22:07 +01:00
|
|
|
m_configView->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
|
|
|
m_configView->setSelectionBehavior(QAbstractItemView::SelectItems);
|
|
|
|
|
m_configView->setFrameShape(QFrame::NoFrame);
|
2017-09-14 15:18:50 +02:00
|
|
|
m_configView->setItemDelegate(new ConfigModelItemDelegate(m_buildConfiguration->project()->projectDirectory(),
|
|
|
|
|
m_configView));
|
2016-01-27 10:22:07 +01:00
|
|
|
QFrame *findWrapper = Core::ItemViewFind::createSearchableWrapper(m_configView, Core::ItemViewFind::LightColored);
|
|
|
|
|
findWrapper->setFrameStyle(QFrame::StyledPanel);
|
|
|
|
|
|
2017-07-25 13:51:36 +02:00
|
|
|
m_progressIndicator = new Utils::ProgressIndicator(Utils::ProgressIndicatorSize::Large, findWrapper);
|
2016-01-27 10:22:07 +01:00
|
|
|
m_progressIndicator->attachToWidget(findWrapper);
|
|
|
|
|
m_progressIndicator->raise();
|
|
|
|
|
m_progressIndicator->hide();
|
|
|
|
|
m_showProgressTimer.setSingleShot(true);
|
|
|
|
|
m_showProgressTimer.setInterval(50); // don't show progress for < 50ms tasks
|
|
|
|
|
connect(&m_showProgressTimer, &QTimer::timeout, [this]() { m_progressIndicator->show(); });
|
|
|
|
|
|
|
|
|
|
mainLayout->addWidget(findWrapper, row, 0, 1, 2);
|
|
|
|
|
|
|
|
|
|
auto buttonLayout = new QVBoxLayout;
|
2016-05-15 15:57:17 +02:00
|
|
|
m_addButton = new QPushButton(tr("&Add"));
|
2017-09-27 12:28:11 +02:00
|
|
|
m_addButton->setToolTip(tr("Add a new configuration value."));
|
2016-05-15 15:57:17 +02:00
|
|
|
buttonLayout->addWidget(m_addButton);
|
|
|
|
|
{
|
|
|
|
|
m_addButtonMenu = new QMenu;
|
|
|
|
|
m_addButtonMenu->addAction(tr("&Boolean"))->setData(
|
|
|
|
|
QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::BOOLEAN)));
|
|
|
|
|
m_addButtonMenu->addAction(tr("&String"))->setData(
|
|
|
|
|
QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::STRING)));
|
|
|
|
|
m_addButtonMenu->addAction(tr("&Directory"))->setData(
|
|
|
|
|
QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::DIRECTORY)));
|
|
|
|
|
m_addButtonMenu->addAction(tr("&File"))->setData(
|
|
|
|
|
QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::FILE)));
|
|
|
|
|
m_addButton->setMenu(m_addButtonMenu);
|
|
|
|
|
}
|
2016-01-27 10:22:07 +01:00
|
|
|
m_editButton = new QPushButton(tr("&Edit"));
|
2017-09-27 12:28:11 +02:00
|
|
|
m_editButton->setToolTip(tr("Edit the current CMake configuration value."));
|
2016-01-27 10:22:07 +01:00
|
|
|
buttonLayout->addWidget(m_editButton);
|
2017-09-27 12:28:11 +02:00
|
|
|
m_unsetButton = new QPushButton(tr("&Unset"));
|
|
|
|
|
m_unsetButton->setToolTip(tr("Unset a value in the CMake configuration."));
|
|
|
|
|
buttonLayout->addWidget(m_unsetButton);
|
2016-01-27 10:22:07 +01:00
|
|
|
m_resetButton = new QPushButton(tr("&Reset"));
|
2017-09-27 12:28:11 +02:00
|
|
|
m_resetButton->setToolTip(tr("Reset all unapplied changes."));
|
2016-01-27 10:22:07 +01:00
|
|
|
m_resetButton->setEnabled(false);
|
|
|
|
|
buttonLayout->addWidget(m_resetButton);
|
|
|
|
|
buttonLayout->addItem(new QSpacerItem(10, 10, QSizePolicy::Fixed, QSizePolicy::Fixed));
|
|
|
|
|
m_showAdvancedCheckBox = new QCheckBox(tr("Advanced"));
|
|
|
|
|
buttonLayout->addWidget(m_showAdvancedCheckBox);
|
|
|
|
|
buttonLayout->addItem(new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
|
|
|
|
|
|
|
|
|
mainLayout->addLayout(buttonLayout, row, 2);
|
|
|
|
|
|
2017-09-13 12:23:21 +02:00
|
|
|
connect(m_configView->selectionModel(), &QItemSelectionModel::currentChanged,
|
|
|
|
|
this, &CMakeBuildSettingsWidget::updateSelection);
|
|
|
|
|
|
2016-01-27 10:22:07 +01:00
|
|
|
++row;
|
|
|
|
|
m_reconfigureButton = new QPushButton(tr("Apply Configuration Changes"));
|
|
|
|
|
m_reconfigureButton->setEnabled(false);
|
|
|
|
|
mainLayout->addWidget(m_reconfigureButton, row, 0, 1, 3);
|
|
|
|
|
|
|
|
|
|
updateAdvancedCheckBox();
|
2016-02-11 16:33:15 +01:00
|
|
|
setError(bc->error());
|
2016-05-12 17:23:03 +02:00
|
|
|
setWarning(bc->warning());
|
2016-01-27 10:22:07 +01:00
|
|
|
|
2017-07-13 10:51:15 +02:00
|
|
|
connect(project, &ProjectExplorer::Project::parsingStarted, this, [this]() {
|
2016-01-27 10:22:07 +01:00
|
|
|
updateButtonState();
|
|
|
|
|
m_showProgressTimer.start();
|
|
|
|
|
});
|
2016-02-24 18:00:24 +01:00
|
|
|
|
|
|
|
|
if (m_buildConfiguration->isParsing())
|
|
|
|
|
m_showProgressTimer.start();
|
2017-09-14 15:18:50 +02:00
|
|
|
else {
|
2017-09-28 11:32:39 +02:00
|
|
|
m_configModel->setConfiguration(m_buildConfiguration->configurationFromCMake());
|
2017-09-14 15:18:50 +02:00
|
|
|
m_configView->expandAll();
|
|
|
|
|
}
|
2016-02-24 18:00:24 +01:00
|
|
|
|
2017-09-28 11:32:39 +02:00
|
|
|
connect(project, &ProjectExplorer::Project::parsingFinished,
|
2016-02-24 18:00:24 +01:00
|
|
|
this, [this, buildDirChooser, stretcher]() {
|
2017-09-28 11:32:39 +02:00
|
|
|
m_configModel->setConfiguration(m_buildConfiguration->configurationFromCMake());
|
2017-09-14 15:18:50 +02:00
|
|
|
m_configView->expandAll();
|
2016-02-24 18:00:24 +01:00
|
|
|
stretcher->stretch();
|
2017-09-14 15:18:50 +02:00
|
|
|
updateButtonState();
|
2016-02-24 18:00:24 +01:00
|
|
|
buildDirChooser->triggerChanged(); // refresh valid state...
|
2016-01-27 10:22:07 +01:00
|
|
|
m_showProgressTimer.stop();
|
|
|
|
|
m_progressIndicator->hide();
|
|
|
|
|
});
|
2016-12-02 17:25:27 +01:00
|
|
|
connect(m_buildConfiguration, &CMakeBuildConfiguration::errorOccured,
|
|
|
|
|
this, [this]() {
|
|
|
|
|
m_showProgressTimer.stop();
|
|
|
|
|
m_progressIndicator->hide();
|
|
|
|
|
});
|
2017-09-14 15:18:50 +02:00
|
|
|
connect(m_configTextFilterModel, &QAbstractItemModel::modelReset, this, [this, stretcher]() {
|
|
|
|
|
m_configView->expandAll();
|
|
|
|
|
stretcher->stretch();
|
|
|
|
|
});
|
2016-01-27 10:22:07 +01:00
|
|
|
|
|
|
|
|
connect(m_configModel, &QAbstractItemModel::dataChanged,
|
|
|
|
|
this, &CMakeBuildSettingsWidget::updateButtonState);
|
|
|
|
|
connect(m_configModel, &QAbstractItemModel::modelReset,
|
|
|
|
|
this, &CMakeBuildSettingsWidget::updateButtonState);
|
|
|
|
|
|
|
|
|
|
connect(m_showAdvancedCheckBox, &QCheckBox::stateChanged,
|
|
|
|
|
this, &CMakeBuildSettingsWidget::updateAdvancedCheckBox);
|
|
|
|
|
|
2017-05-14 23:18:31 +02:00
|
|
|
connect(m_filterEdit, &QLineEdit::textChanged,
|
|
|
|
|
m_configTextFilterModel, &QSortFilterProxyModel::setFilterFixedString);
|
|
|
|
|
|
2016-01-27 10:22:07 +01:00
|
|
|
connect(m_resetButton, &QPushButton::clicked, m_configModel, &ConfigModel::resetAllChanges);
|
2016-02-24 18:00:24 +01:00
|
|
|
connect(m_reconfigureButton, &QPushButton::clicked, this, [this]() {
|
2017-09-29 23:34:52 +02:00
|
|
|
m_buildConfiguration->setConfigurationForCMake(m_configModel->configurationForCMake());
|
2016-01-27 10:22:07 +01:00
|
|
|
});
|
2017-09-27 12:28:11 +02:00
|
|
|
connect(m_unsetButton, &QPushButton::clicked, this, [this]() {
|
|
|
|
|
m_configModel->toggleUnsetFlag(mapToSource(m_configView, m_configView->currentIndex()));
|
|
|
|
|
});
|
2016-01-27 10:22:07 +01:00
|
|
|
connect(m_editButton, &QPushButton::clicked, this, [this]() {
|
|
|
|
|
QModelIndex idx = m_configView->currentIndex();
|
|
|
|
|
if (idx.column() != 1)
|
|
|
|
|
idx = idx.sibling(idx.row(), 1);
|
|
|
|
|
m_configView->setCurrentIndex(idx);
|
|
|
|
|
m_configView->edit(idx);
|
|
|
|
|
});
|
2016-05-15 15:57:17 +02:00
|
|
|
connect(m_addButtonMenu, &QMenu::triggered, this, [this](QAction *action) {
|
|
|
|
|
ConfigModel::DataItem::Type type =
|
|
|
|
|
static_cast<ConfigModel::DataItem::Type>(action->data().value<int>());
|
|
|
|
|
QString value = tr("<UNSET>");
|
|
|
|
|
if (type == ConfigModel::DataItem::BOOLEAN)
|
|
|
|
|
value = QString::fromLatin1("OFF");
|
|
|
|
|
|
|
|
|
|
m_configModel->appendConfiguration(tr("<UNSET>"), value, type);
|
|
|
|
|
QModelIndex idx;
|
|
|
|
|
idx = m_configView->model()->index(
|
|
|
|
|
m_configView->model()->rowCount(idx) - 1, 0);
|
|
|
|
|
m_configView->setCurrentIndex(idx);
|
|
|
|
|
m_configView->edit(idx);
|
|
|
|
|
});
|
2016-02-11 16:33:15 +01:00
|
|
|
|
|
|
|
|
connect(bc, &CMakeBuildConfiguration::errorOccured, this, &CMakeBuildSettingsWidget::setError);
|
2016-05-12 17:23:03 +02:00
|
|
|
connect(bc, &CMakeBuildConfiguration::warningOccured, this, &CMakeBuildSettingsWidget::setWarning);
|
2017-01-18 16:56:00 +01:00
|
|
|
|
|
|
|
|
updateFromKit();
|
|
|
|
|
connect(m_buildConfiguration->target(), &ProjectExplorer::Target::kitChanged,
|
|
|
|
|
this, &CMakeBuildSettingsWidget::updateFromKit);
|
2017-04-07 11:03:53 +02:00
|
|
|
connect(m_buildConfiguration, &CMakeBuildConfiguration::enabledChanged,
|
2017-09-29 23:34:52 +02:00
|
|
|
this, [this]() {
|
|
|
|
|
setError(m_buildConfiguration->disabledReason());
|
|
|
|
|
setConfigurationForCMake();
|
|
|
|
|
});
|
|
|
|
|
connect(m_buildConfiguration, &CMakeBuildConfiguration::configurationForCMakeChanged,
|
|
|
|
|
this, [this]() { setConfigurationForCMake(); });
|
2017-09-27 12:28:11 +02:00
|
|
|
|
|
|
|
|
updateSelection(QModelIndex(), QModelIndex());
|
2016-02-11 16:33:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeBuildSettingsWidget::setError(const QString &message)
|
|
|
|
|
{
|
2016-05-12 17:23:03 +02:00
|
|
|
bool showError = !message.isEmpty();
|
|
|
|
|
m_errorLabel->setVisible(showError);
|
2016-02-11 16:33:15 +01:00
|
|
|
m_errorLabel->setToolTip(message);
|
2016-05-12 17:23:03 +02:00
|
|
|
m_errorMessageLabel->setVisible(showError);
|
2016-02-11 16:33:15 +01:00
|
|
|
m_errorMessageLabel->setText(message);
|
|
|
|
|
m_errorMessageLabel->setToolTip(message);
|
|
|
|
|
|
2017-01-26 10:45:59 +01:00
|
|
|
m_editButton->setEnabled(!showError);
|
2017-09-27 12:28:11 +02:00
|
|
|
m_unsetButton->setEnabled(!showError);
|
2017-01-26 10:45:59 +01:00
|
|
|
m_resetButton->setEnabled(!showError);
|
|
|
|
|
m_showAdvancedCheckBox->setEnabled(!showError);
|
2017-05-14 23:18:31 +02:00
|
|
|
m_filterEdit->setEnabled(!showError);
|
2016-05-12 17:23:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeBuildSettingsWidget::setWarning(const QString &message)
|
|
|
|
|
{
|
|
|
|
|
bool showWarning = !message.isEmpty();
|
|
|
|
|
m_warningLabel->setVisible(showWarning);
|
|
|
|
|
m_warningLabel->setToolTip(message);
|
|
|
|
|
m_warningMessageLabel->setVisible(showWarning);
|
|
|
|
|
m_warningMessageLabel->setText(message);
|
|
|
|
|
m_warningMessageLabel->setToolTip(message);
|
2016-01-27 10:22:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeBuildSettingsWidget::updateButtonState()
|
|
|
|
|
{
|
2016-02-24 18:00:24 +01:00
|
|
|
const bool isParsing = m_buildConfiguration->isParsing();
|
2016-01-27 10:22:07 +01:00
|
|
|
const bool hasChanges = m_configModel->hasChanges();
|
|
|
|
|
m_resetButton->setEnabled(hasChanges && !isParsing);
|
|
|
|
|
m_reconfigureButton->setEnabled((hasChanges || m_configModel->hasCMakeChanges()) && !isParsing);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeBuildSettingsWidget::updateAdvancedCheckBox()
|
|
|
|
|
{
|
2017-09-14 15:18:50 +02:00
|
|
|
if (m_showAdvancedCheckBox->isChecked()) {
|
|
|
|
|
m_configFilterModel->setSourceModel(nullptr);
|
2017-09-05 13:55:08 +02:00
|
|
|
m_configTextFilterModel->setSourceModel(m_configModel);
|
2017-09-14 15:18:50 +02:00
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
m_configTextFilterModel->setSourceModel(nullptr);
|
|
|
|
|
m_configFilterModel->setSourceModel(m_configModel);
|
2017-09-05 13:55:08 +02:00
|
|
|
m_configTextFilterModel->setSourceModel(m_configFilterModel);
|
2017-09-14 15:18:50 +02:00
|
|
|
}
|
2015-03-10 10:22:38 +01:00
|
|
|
}
|
|
|
|
|
|
2017-01-18 16:56:00 +01:00
|
|
|
void CMakeBuildSettingsWidget::updateFromKit()
|
|
|
|
|
{
|
|
|
|
|
const ProjectExplorer::Kit *k = m_buildConfiguration->target()->kit();
|
|
|
|
|
const CMakeConfig config = CMakeConfigurationKitInformation::configuration(k);
|
|
|
|
|
|
|
|
|
|
QHash<QString, QString> configHash;
|
|
|
|
|
for (const CMakeConfigItem &i : config)
|
|
|
|
|
configHash.insert(QString::fromUtf8(i.key), i.expandedValue(k));
|
|
|
|
|
|
2017-09-29 23:34:52 +02:00
|
|
|
m_configModel->setConfigurationFromKit(configHash);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeBuildSettingsWidget::setConfigurationForCMake()
|
|
|
|
|
{
|
|
|
|
|
QHash<QString, QString> config;
|
|
|
|
|
const CMakeConfig configList = m_buildConfiguration->configurationForCMake();
|
|
|
|
|
for (const CMakeConfigItem &i : configList) {
|
|
|
|
|
config.insert(QString::fromUtf8(i.key),
|
|
|
|
|
CMakeConfigItem::expandedValueOf(m_buildConfiguration->target()->kit(),
|
|
|
|
|
i.key, configList));
|
|
|
|
|
}
|
|
|
|
|
m_configModel->setConfigurationForCMake(config);
|
2017-01-18 16:56:00 +01:00
|
|
|
}
|
|
|
|
|
|
2017-09-13 12:23:21 +02:00
|
|
|
void CMakeBuildSettingsWidget::updateSelection(const QModelIndex ¤t, const QModelIndex &previous)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(previous);
|
2017-09-27 12:28:11 +02:00
|
|
|
|
|
|
|
|
m_editButton->setEnabled(current.isValid() && current.flags().testFlag(Qt::ItemIsEditable));
|
|
|
|
|
m_unsetButton->setEnabled(current.isValid() && current.flags().testFlag(Qt::ItemIsSelectable));
|
2017-09-13 12:23:21 +02:00
|
|
|
}
|
|
|
|
|
|
2017-09-14 15:36:18 +02:00
|
|
|
QAction *CMakeBuildSettingsWidget::createForceAction(int type, const QModelIndex &idx)
|
|
|
|
|
{
|
|
|
|
|
ConfigModel::DataItem::Type t = static_cast<ConfigModel::DataItem::Type>(type);
|
|
|
|
|
QString typeString;
|
|
|
|
|
switch (type) {
|
|
|
|
|
case ConfigModel::DataItem::BOOLEAN:
|
|
|
|
|
typeString = tr("bool", "display string for cmake type BOOLEAN");
|
|
|
|
|
break;
|
|
|
|
|
case ConfigModel::DataItem::FILE:
|
|
|
|
|
typeString = tr("file", "display string for cmake type FILE");
|
|
|
|
|
break;
|
|
|
|
|
case ConfigModel::DataItem::DIRECTORY:
|
|
|
|
|
typeString = tr("directory", "display string for cmake type DIRECTORY");
|
|
|
|
|
break;
|
|
|
|
|
case ConfigModel::DataItem::STRING:
|
|
|
|
|
typeString = tr("string", "display string for cmake type STRING");
|
|
|
|
|
break;
|
|
|
|
|
case ConfigModel::DataItem::UNKNOWN:
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
2017-09-20 06:52:37 +02:00
|
|
|
QAction *forceAction = new QAction(tr("Force to %1").arg(typeString), nullptr);
|
2017-09-14 15:36:18 +02:00
|
|
|
forceAction->setEnabled(m_configModel->canForceTo(idx, t));
|
|
|
|
|
connect(forceAction, &QAction::triggered,
|
|
|
|
|
this, [this, idx, t]() { m_configModel->forceTo(idx, t); });
|
|
|
|
|
return forceAction;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-14 13:16:10 +02:00
|
|
|
bool CMakeBuildSettingsWidget::eventFilter(QObject *target, QEvent *event)
|
|
|
|
|
{
|
|
|
|
|
// handle context menu events:
|
|
|
|
|
if (target != m_configView->viewport() || event->type() != QEvent::ContextMenu)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
auto e = static_cast<QContextMenuEvent *>(event);
|
|
|
|
|
const QModelIndex idx = mapToSource(m_configView, m_configView->indexAt(e->pos()));
|
|
|
|
|
if (!idx.isValid())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
QMenu *menu = new QMenu(this);
|
|
|
|
|
connect(menu, &QMenu::triggered, menu, &QMenu::deleteLater);
|
|
|
|
|
|
2017-09-14 15:36:18 +02:00
|
|
|
QAction *action = nullptr;
|
|
|
|
|
if ((action = createForceAction(ConfigModel::DataItem::BOOLEAN, idx)))
|
|
|
|
|
menu->addAction(action);
|
|
|
|
|
if ((action = createForceAction(ConfigModel::DataItem::FILE, idx)))
|
|
|
|
|
menu->addAction(action);
|
|
|
|
|
if ((action = createForceAction(ConfigModel::DataItem::DIRECTORY, idx)))
|
|
|
|
|
menu->addAction(action);
|
|
|
|
|
if ((action = createForceAction(ConfigModel::DataItem::STRING, idx)))
|
|
|
|
|
menu->addAction(action);
|
2017-09-14 13:16:10 +02:00
|
|
|
|
|
|
|
|
menu->move(e->globalPos());
|
|
|
|
|
menu->show();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-10 10:22:38 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace CMakeProjectManager
|