forked from qt-creator/qt-creator
ProjectExplorer: Remove now unused interpreter aspect
Change-Id: I1715ba1cadb1662dd9d598ff9f7ffd2126325683 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -788,122 +788,6 @@ Interpreter::Interpreter(const QString &_id,
|
|||||||
, autoDetected(_autoDetected)
|
, autoDetected(_autoDetected)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/*!
|
|
||||||
\class ProjectExplorer::InterpreterAspect
|
|
||||||
\inmodule QtCreator
|
|
||||||
|
|
||||||
\brief The InterpreterAspect class lets a user specify an interpreter
|
|
||||||
to use with files or projects using an interpreted language.
|
|
||||||
*/
|
|
||||||
|
|
||||||
InterpreterAspect::InterpreterAspect(AspectContainer *container)
|
|
||||||
: BaseAspect(container)
|
|
||||||
{
|
|
||||||
addDataExtractor(this, &InterpreterAspect::currentInterpreter, &Data::interpreter);
|
|
||||||
}
|
|
||||||
|
|
||||||
Interpreter InterpreterAspect::currentInterpreter() const
|
|
||||||
{
|
|
||||||
return Utils::findOrDefault(m_interpreters, Utils::equal(&Interpreter::id, m_currentId));
|
|
||||||
}
|
|
||||||
|
|
||||||
void InterpreterAspect::updateInterpreters(const QList<Interpreter> &interpreters)
|
|
||||||
{
|
|
||||||
if (m_interpreters == interpreters)
|
|
||||||
return;
|
|
||||||
m_interpreters = interpreters;
|
|
||||||
if (m_comboBox)
|
|
||||||
updateComboBox();
|
|
||||||
}
|
|
||||||
|
|
||||||
void InterpreterAspect::setDefaultInterpreter(const Interpreter &interpreter)
|
|
||||||
{
|
|
||||||
if (m_defaultId == interpreter.id)
|
|
||||||
return;
|
|
||||||
m_defaultId = interpreter.id;
|
|
||||||
if (m_currentId.isEmpty())
|
|
||||||
setCurrentInterpreter(interpreter);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InterpreterAspect::setCurrentInterpreter(const Interpreter &interpreter)
|
|
||||||
{
|
|
||||||
if (m_comboBox) {
|
|
||||||
const int index = m_interpreters.indexOf(interpreter);
|
|
||||||
if (index < 0 || index >= m_comboBox->count())
|
|
||||||
return;
|
|
||||||
m_comboBox->setCurrentIndex(index);
|
|
||||||
} else {
|
|
||||||
setCurrentInterpreterId(interpreter.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void InterpreterAspect::fromMap(const Store &map)
|
|
||||||
{
|
|
||||||
setCurrentInterpreterId(map.value(settingsKey(), m_defaultId).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void InterpreterAspect::toMap(Store &map) const
|
|
||||||
{
|
|
||||||
if (m_currentId != m_defaultId)
|
|
||||||
saveToMap(map, m_currentId, QString(), settingsKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
void InterpreterAspect::addToLayout(LayoutItem &builder)
|
|
||||||
{
|
|
||||||
if (QTC_GUARD(m_comboBox.isNull()))
|
|
||||||
m_comboBox = new QComboBox;
|
|
||||||
|
|
||||||
updateComboBox();
|
|
||||||
connect(m_comboBox, &QComboBox::currentIndexChanged,
|
|
||||||
this, &InterpreterAspect::updateCurrentInterpreter);
|
|
||||||
|
|
||||||
auto manageButton = new QPushButton(Tr::tr("Manage..."));
|
|
||||||
connect(manageButton, &QPushButton::clicked, this, [this] {
|
|
||||||
Core::ICore::showOptionsDialog(m_settingsDialogId);
|
|
||||||
});
|
|
||||||
|
|
||||||
builder.addItems({Tr::tr("Interpreter:"), m_comboBox.data(), manageButton});
|
|
||||||
}
|
|
||||||
|
|
||||||
void InterpreterAspect::setCurrentInterpreterId(const QString &id)
|
|
||||||
{
|
|
||||||
if (id == m_currentId)
|
|
||||||
return;
|
|
||||||
m_currentId = id;
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
void InterpreterAspect::updateCurrentInterpreter()
|
|
||||||
{
|
|
||||||
const int index = m_comboBox->currentIndex();
|
|
||||||
if (index < 0)
|
|
||||||
return;
|
|
||||||
QTC_ASSERT(index < m_interpreters.size(), return);
|
|
||||||
m_comboBox->setToolTip(m_interpreters[index].command.toUserOutput());
|
|
||||||
setCurrentInterpreterId(m_interpreters[index].id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InterpreterAspect::updateComboBox()
|
|
||||||
{
|
|
||||||
int currentIndex = -1;
|
|
||||||
int defaultIndex = -1;
|
|
||||||
m_comboBox->clear();
|
|
||||||
for (const Interpreter &interpreter : std::as_const(m_interpreters)) {
|
|
||||||
int index = m_comboBox->count();
|
|
||||||
m_comboBox->addItem(interpreter.name);
|
|
||||||
m_comboBox->setItemData(index, interpreter.command.toUserOutput(), Qt::ToolTipRole);
|
|
||||||
if (interpreter.id == m_currentId)
|
|
||||||
currentIndex = index;
|
|
||||||
if (interpreter.id == m_defaultId)
|
|
||||||
defaultIndex = index;
|
|
||||||
}
|
|
||||||
if (currentIndex >= 0)
|
|
||||||
m_comboBox->setCurrentIndex(currentIndex);
|
|
||||||
else if (defaultIndex >= 0)
|
|
||||||
m_comboBox->setCurrentIndex(defaultIndex);
|
|
||||||
updateCurrentInterpreter();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class ProjectExplorer::X11ForwardingAspect
|
\class ProjectExplorer::X11ForwardingAspect
|
||||||
\inmodule QtCreator
|
\inmodule QtCreator
|
||||||
|
@@ -227,36 +227,6 @@ public:
|
|||||||
QString detectionSource;
|
QString detectionSource;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT InterpreterAspect : public Utils::BaseAspect
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
InterpreterAspect(Utils::AspectContainer *container = nullptr);
|
|
||||||
|
|
||||||
Interpreter currentInterpreter() const;
|
|
||||||
void updateInterpreters(const QList<Interpreter> &interpreters);
|
|
||||||
void setDefaultInterpreter(const Interpreter &interpreter);
|
|
||||||
void setCurrentInterpreter(const Interpreter &interpreter);
|
|
||||||
void setSettingsDialogId(Utils::Id id) { m_settingsDialogId = id; }
|
|
||||||
|
|
||||||
void fromMap(const Utils::Store &) override;
|
|
||||||
void toMap(Utils::Store &) const override;
|
|
||||||
void addToLayout(Layouting::LayoutItem &parent) override;
|
|
||||||
|
|
||||||
struct Data : Utils::BaseAspect::Data { Interpreter interpreter; };
|
|
||||||
|
|
||||||
private:
|
|
||||||
void setCurrentInterpreterId(const QString &id);
|
|
||||||
void updateCurrentInterpreter();
|
|
||||||
void updateComboBox();
|
|
||||||
QList<Interpreter> m_interpreters;
|
|
||||||
QPointer<QComboBox> m_comboBox;
|
|
||||||
QString m_defaultId;
|
|
||||||
QString m_currentId;
|
|
||||||
Utils::Id m_settingsDialogId;
|
|
||||||
};
|
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT MainScriptAspect : public Utils::FilePathAspect
|
class PROJECTEXPLORER_EXPORT MainScriptAspect : public Utils::FilePathAspect
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Reference in New Issue
Block a user