forked from qt-creator/qt-creator
CMake: Mark changes to CMake configuration that contradicts a kit
Mark changes in the project that override configuration settings from the kit. Task-number: QTCREATORBUG-17244 Change-Id: I3452116ad5f4626ffcd85dfcc86715b6946d6572 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -27,11 +27,13 @@
|
||||
|
||||
#include "configmodel.h"
|
||||
#include "configmodelitemdelegate.h"
|
||||
#include "cmakekitinformation.h"
|
||||
#include "cmakeproject.h"
|
||||
#include "cmakebuildconfiguration.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/find/itemviewfind.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
@@ -252,6 +254,10 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc)
|
||||
|
||||
connect(bc, &CMakeBuildConfiguration::errorOccured, this, &CMakeBuildSettingsWidget::setError);
|
||||
connect(bc, &CMakeBuildConfiguration::warningOccured, this, &CMakeBuildSettingsWidget::setWarning);
|
||||
|
||||
updateFromKit();
|
||||
connect(m_buildConfiguration->target(), &ProjectExplorer::Target::kitChanged,
|
||||
this, &CMakeBuildSettingsWidget::updateFromKit);
|
||||
}
|
||||
|
||||
void CMakeBuildSettingsWidget::setError(const QString &message)
|
||||
@@ -294,5 +300,17 @@ void CMakeBuildSettingsWidget::updateAdvancedCheckBox()
|
||||
m_configFilterModel->setFilterRole(m_showAdvancedCheckBox->isChecked() ? Qt::EditRole : Qt::DisplayRole);
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
m_configModel->setKitConfiguration(configHash);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CMakeProjectManager
|
||||
|
||||
@@ -60,6 +60,7 @@ public:
|
||||
private:
|
||||
void updateButtonState();
|
||||
void updateAdvancedCheckBox();
|
||||
void updateFromKit();
|
||||
|
||||
CMakeBuildConfiguration *m_buildConfiguration;
|
||||
QTreeView *m_configView;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/theme/theme.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QFont>
|
||||
@@ -113,7 +114,9 @@ QVariant ConfigModel::data(const QModelIndex &index, int role) const
|
||||
return QVariant();
|
||||
}
|
||||
case 1: {
|
||||
const QString value = item.isUserChanged ? item.newValue : item.value;
|
||||
const QString value = item.currentValue();
|
||||
const QString kitValue = m_kitConfiguartion.value(item.key);
|
||||
|
||||
switch (role) {
|
||||
case Qt::CheckStateRole:
|
||||
return (item.type == DataItem::BOOLEAN)
|
||||
@@ -128,8 +131,19 @@ QVariant ConfigModel::data(const QModelIndex &index, int role) const
|
||||
font.setItalic(item.isCMakeChanged);
|
||||
return font;
|
||||
}
|
||||
case Qt::ToolTipRole:
|
||||
return item.toolTip();
|
||||
case Qt::ForegroundRole:
|
||||
return Utils::creatorTheme()->color((!kitValue.isNull() && kitValue != value)
|
||||
? Utils::Theme::TextColorHighlight : Utils::Theme::TextColorNormal);
|
||||
case Qt::ToolTipRole: {
|
||||
QString tooltip = item.toolTip();
|
||||
const QString kitValue = m_kitConfiguartion.value(item.key);
|
||||
if (!kitValue.isNull()) {
|
||||
if (!tooltip.isEmpty())
|
||||
tooltip.append("<br>");
|
||||
tooltip.append(tr("Kit value: %1").arg(kitValue));
|
||||
}
|
||||
return tooltip;
|
||||
}
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@@ -273,6 +287,11 @@ void ConfigModel::setConfiguration(const QList<ConfigModel::DataItem> &config)
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void ConfigModel::setKitConfiguration(const QHash<QString, QString> &kitConfig)
|
||||
{
|
||||
m_kitConfiguartion = kitConfig;
|
||||
}
|
||||
|
||||
void ConfigModel::flush()
|
||||
{
|
||||
beginResetModel();
|
||||
@@ -338,10 +357,18 @@ ConfigModel::InternalDataItem::InternalDataItem(const ConfigModel::DataItem &ite
|
||||
QString ConfigModel::InternalDataItem::toolTip() const
|
||||
{
|
||||
QStringList tooltip(description);
|
||||
if (!value.isEmpty() && !newValue.isEmpty() && value != newValue)
|
||||
tooltip << QCoreApplication::translate("CMakeProjectManager", "Current CMake: %1").arg(value);
|
||||
if (inCMakeCache) {
|
||||
if (value != newValue)
|
||||
tooltip << QCoreApplication::translate("CMakeProjectManager", "Current CMake: %1").arg(value);
|
||||
} else {
|
||||
tooltip << QCoreApplication::translate("CMakeProjectManager", "Not in CMakeCache.txt").arg(value);
|
||||
}
|
||||
return tooltip.join("<br>");
|
||||
}
|
||||
|
||||
} // namespace CMakeProjectManager
|
||||
QString ConfigModel::InternalDataItem::currentValue() const
|
||||
{
|
||||
return isUserChanged ? newValue : value;
|
||||
}
|
||||
|
||||
} // namespace CMakeProjectManager
|
||||
|
||||
@@ -68,6 +68,7 @@ public:
|
||||
const QString &description = QString(),
|
||||
const QStringList &values = QStringList());
|
||||
void setConfiguration(const QList<DataItem> &config);
|
||||
void setKitConfiguration(const QHash<QString, QString> &kitConfig);
|
||||
void flush();
|
||||
void resetAllChanges();
|
||||
|
||||
@@ -84,6 +85,7 @@ private:
|
||||
InternalDataItem(const InternalDataItem &item) = default;
|
||||
|
||||
QString toolTip() const;
|
||||
QString currentValue() const;
|
||||
|
||||
bool isUserChanged = false;
|
||||
bool isUserNew = false;
|
||||
@@ -94,6 +96,7 @@ private:
|
||||
InternalDataItem &itemAtRow(int row);
|
||||
const InternalDataItem &itemAtRow(int row) const;
|
||||
QList<InternalDataItem> m_configuration;
|
||||
QHash<QString, QString> m_kitConfiguartion;
|
||||
};
|
||||
|
||||
} // namespace CMakeProjectManager
|
||||
|
||||
Reference in New Issue
Block a user