2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-01-13 11:41:45 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-01-13 11:41:45 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-01-13 11:41:45 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
2011-01-13 11:41:45 +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.
|
2011-01-13 11:41:45 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-01-13 11:41:45 +01:00
|
|
|
|
|
|
|
|
#include "environmentwidget.h"
|
|
|
|
|
|
2014-08-01 16:16:11 +02:00
|
|
|
#include <coreplugin/find/itemviewfind.h>
|
|
|
|
|
|
2011-01-13 11:41:45 +01:00
|
|
|
#include <utils/detailswidget.h>
|
|
|
|
|
#include <utils/environment.h>
|
|
|
|
|
#include <utils/environmentmodel.h>
|
2016-06-16 14:23:22 +02:00
|
|
|
#include <utils/environmentdialog.h>
|
2013-03-27 11:01:02 +01:00
|
|
|
#include <utils/headerviewstretcher.h>
|
2016-02-01 13:00:46 +01:00
|
|
|
#include <utils/itemviews.h>
|
2015-08-04 16:15:13 +02:00
|
|
|
#include <utils/tooltip/tooltip.h>
|
2011-01-13 11:41:45 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QString>
|
|
|
|
|
#include <QPushButton>
|
2014-06-03 16:53:39 +02:00
|
|
|
#include <QTreeView>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QVBoxLayout>
|
2014-09-18 15:08:12 +02:00
|
|
|
#include <QKeyEvent>
|
2015-08-04 16:15:13 +02:00
|
|
|
#include <QStyledItemDelegate>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QDebug>
|
2011-01-13 11:41:45 +01:00
|
|
|
|
|
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
|
2015-08-04 16:15:13 +02:00
|
|
|
class EnvironmentValidator : public QValidator
|
|
|
|
|
{
|
2015-10-28 12:59:34 +03:00
|
|
|
Q_OBJECT
|
2015-08-04 16:15:13 +02:00
|
|
|
public:
|
2016-04-13 15:52:14 +02:00
|
|
|
EnvironmentValidator(QWidget *parent, Utils::EnvironmentModel *model, QTreeView *view,
|
|
|
|
|
const QModelIndex &index) :
|
|
|
|
|
QValidator(parent), m_model(model), m_view(view), m_index(index)
|
2015-08-04 16:15:13 +02:00
|
|
|
{
|
|
|
|
|
m_hideTipTimer.setInterval(2000);
|
|
|
|
|
m_hideTipTimer.setSingleShot(true);
|
|
|
|
|
connect(&m_hideTipTimer, &QTimer::timeout,
|
|
|
|
|
this, [](){Utils::ToolTip::hide();});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QValidator::State validate(QString &in, int &pos) const override
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(pos)
|
|
|
|
|
QModelIndex idx = m_model->variableToIndex(in);
|
|
|
|
|
if (idx.isValid() && idx != m_index)
|
|
|
|
|
return QValidator::Intermediate;
|
|
|
|
|
Utils::ToolTip::hide();
|
|
|
|
|
m_hideTipTimer.stop();
|
|
|
|
|
return QValidator::Acceptable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void fixup(QString &input) const override
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(input)
|
|
|
|
|
|
|
|
|
|
QPoint pos = m_view->mapToGlobal(m_view->visualRect(m_index).topLeft());
|
|
|
|
|
pos -= Utils::ToolTip::offsetFromPosition();
|
|
|
|
|
Utils::ToolTip::show(pos, tr("Variable already exists."));
|
|
|
|
|
m_hideTipTimer.start();
|
|
|
|
|
// do nothing
|
|
|
|
|
}
|
|
|
|
|
private:
|
|
|
|
|
Utils::EnvironmentModel *m_model;
|
|
|
|
|
QTreeView *m_view;
|
|
|
|
|
QModelIndex m_index;
|
|
|
|
|
mutable QTimer m_hideTipTimer;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class EnvironmentDelegate : public QStyledItemDelegate
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
EnvironmentDelegate(Utils::EnvironmentModel *model,
|
|
|
|
|
QTreeView *view)
|
|
|
|
|
: QStyledItemDelegate(view), m_model(model), m_view(view)
|
|
|
|
|
{}
|
|
|
|
|
|
2018-07-12 22:17:17 +02:00
|
|
|
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
|
2015-08-04 16:15:13 +02:00
|
|
|
{
|
|
|
|
|
QWidget *w = QStyledItemDelegate::createEditor(parent, option, index);
|
|
|
|
|
if (index.column() != 0)
|
|
|
|
|
return w;
|
|
|
|
|
|
2016-04-13 15:52:14 +02:00
|
|
|
if (auto edit = qobject_cast<QLineEdit *>(w))
|
2015-08-04 16:15:13 +02:00
|
|
|
edit->setValidator(new EnvironmentValidator(edit, m_model, m_view, index));
|
|
|
|
|
return w;
|
|
|
|
|
}
|
|
|
|
|
private:
|
|
|
|
|
Utils::EnvironmentModel *m_model;
|
|
|
|
|
QTreeView *m_view;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 11:41:45 +01:00
|
|
|
////
|
|
|
|
|
// EnvironmentWidget::EnvironmentWidget
|
|
|
|
|
////
|
|
|
|
|
|
|
|
|
|
class EnvironmentWidgetPrivate
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Utils::EnvironmentModel *m_model;
|
|
|
|
|
|
|
|
|
|
QString m_baseEnvironmentText;
|
|
|
|
|
Utils::DetailsWidget *m_detailsContainer;
|
2014-06-03 16:53:39 +02:00
|
|
|
QTreeView *m_environmentView;
|
2011-01-13 11:41:45 +01:00
|
|
|
QPushButton *m_editButton;
|
|
|
|
|
QPushButton *m_addButton;
|
|
|
|
|
QPushButton *m_resetButton;
|
|
|
|
|
QPushButton *m_unsetButton;
|
2011-12-06 16:45:07 +01:00
|
|
|
QPushButton *m_batchEditButton;
|
2011-01-13 11:41:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
EnvironmentWidget::EnvironmentWidget(QWidget *parent, QWidget *additionalDetailsWidget)
|
|
|
|
|
: QWidget(parent), d(new EnvironmentWidgetPrivate)
|
|
|
|
|
{
|
|
|
|
|
d->m_model = new Utils::EnvironmentModel();
|
2016-01-29 16:38:37 +02:00
|
|
|
connect(d->m_model, &Utils::EnvironmentModel::userChangesChanged,
|
|
|
|
|
this, &EnvironmentWidget::userChangesChanged);
|
|
|
|
|
connect(d->m_model, &QAbstractItemModel::modelReset,
|
|
|
|
|
this, &EnvironmentWidget::invalidateCurrentIndex);
|
2011-01-13 11:41:45 +01:00
|
|
|
|
2016-01-29 16:38:37 +02:00
|
|
|
connect(d->m_model, &Utils::EnvironmentModel::focusIndex,
|
|
|
|
|
this, &EnvironmentWidget::focusIndex);
|
2011-01-13 11:41:45 +01:00
|
|
|
|
2016-04-13 15:52:14 +02:00
|
|
|
auto vbox = new QVBoxLayout(this);
|
2011-01-13 11:41:45 +01:00
|
|
|
vbox->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
|
|
|
|
|
d->m_detailsContainer = new Utils::DetailsWidget(this);
|
|
|
|
|
|
2016-04-13 15:52:14 +02:00
|
|
|
auto details = new QWidget(d->m_detailsContainer);
|
2011-01-13 11:41:45 +01:00
|
|
|
d->m_detailsContainer->setWidget(details);
|
|
|
|
|
details->setVisible(false);
|
|
|
|
|
|
2016-04-13 15:52:14 +02:00
|
|
|
auto vbox2 = new QVBoxLayout(details);
|
2011-01-13 11:41:45 +01:00
|
|
|
vbox2->setMargin(0);
|
|
|
|
|
|
|
|
|
|
if (additionalDetailsWidget)
|
|
|
|
|
vbox2->addWidget(additionalDetailsWidget);
|
|
|
|
|
|
2016-04-13 15:52:14 +02:00
|
|
|
auto horizontalLayout = new QHBoxLayout();
|
2011-01-13 11:41:45 +01:00
|
|
|
horizontalLayout->setMargin(0);
|
2016-02-01 13:00:46 +01:00
|
|
|
auto tree = new Utils::TreeView(this);
|
|
|
|
|
connect(tree, &QAbstractItemView::activated,
|
|
|
|
|
tree, [tree](const QModelIndex &idx) { tree->edit(idx); });
|
|
|
|
|
d->m_environmentView = tree;
|
2011-01-13 11:41:45 +01:00
|
|
|
d->m_environmentView->setModel(d->m_model);
|
2015-08-04 16:15:13 +02:00
|
|
|
d->m_environmentView->setItemDelegate(new EnvironmentDelegate(d->m_model, d->m_environmentView));
|
2011-01-13 11:41:45 +01:00
|
|
|
d->m_environmentView->setMinimumHeight(400);
|
2014-06-03 16:53:39 +02:00
|
|
|
d->m_environmentView->setRootIsDecorated(false);
|
|
|
|
|
d->m_environmentView->setUniformRowHeights(true);
|
|
|
|
|
new Utils::HeaderViewStretcher(d->m_environmentView->header(), 1);
|
2011-01-13 11:41:45 +01:00
|
|
|
d->m_environmentView->setSelectionMode(QAbstractItemView::SingleSelection);
|
2014-06-03 16:53:39 +02:00
|
|
|
d->m_environmentView->setSelectionBehavior(QAbstractItemView::SelectItems);
|
2014-08-01 16:16:11 +02:00
|
|
|
d->m_environmentView->setFrameShape(QFrame::NoFrame);
|
2014-08-11 17:31:27 +02:00
|
|
|
QFrame *findWrapper = Core::ItemViewFind::createSearchableWrapper(d->m_environmentView, Core::ItemViewFind::LightColored);
|
2014-08-01 16:16:11 +02:00
|
|
|
findWrapper->setFrameStyle(QFrame::StyledPanel);
|
|
|
|
|
horizontalLayout->addWidget(findWrapper);
|
2011-01-13 11:41:45 +01:00
|
|
|
|
2016-04-13 15:52:14 +02:00
|
|
|
auto buttonLayout = new QVBoxLayout();
|
2011-01-13 11:41:45 +01:00
|
|
|
|
|
|
|
|
d->m_editButton = new QPushButton(this);
|
2017-05-22 14:26:07 +02:00
|
|
|
d->m_editButton->setText(tr("Ed&it"));
|
2011-01-13 11:41:45 +01:00
|
|
|
buttonLayout->addWidget(d->m_editButton);
|
|
|
|
|
|
|
|
|
|
d->m_addButton = new QPushButton(this);
|
|
|
|
|
d->m_addButton->setText(tr("&Add"));
|
|
|
|
|
buttonLayout->addWidget(d->m_addButton);
|
|
|
|
|
|
|
|
|
|
d->m_resetButton = new QPushButton(this);
|
|
|
|
|
d->m_resetButton->setEnabled(false);
|
|
|
|
|
d->m_resetButton->setText(tr("&Reset"));
|
|
|
|
|
buttonLayout->addWidget(d->m_resetButton);
|
|
|
|
|
|
|
|
|
|
d->m_unsetButton = new QPushButton(this);
|
|
|
|
|
d->m_unsetButton->setEnabled(false);
|
|
|
|
|
d->m_unsetButton->setText(tr("&Unset"));
|
|
|
|
|
buttonLayout->addWidget(d->m_unsetButton);
|
|
|
|
|
|
2011-12-06 16:45:07 +01:00
|
|
|
d->m_batchEditButton = new QPushButton(this);
|
|
|
|
|
d->m_batchEditButton->setText(tr("&Batch Edit..."));
|
|
|
|
|
buttonLayout->addWidget(d->m_batchEditButton);
|
|
|
|
|
|
2014-11-28 17:07:56 +01:00
|
|
|
buttonLayout->addStretch();
|
|
|
|
|
|
2011-01-13 11:41:45 +01:00
|
|
|
horizontalLayout->addLayout(buttonLayout);
|
|
|
|
|
vbox2->addLayout(horizontalLayout);
|
|
|
|
|
|
|
|
|
|
vbox->addWidget(d->m_detailsContainer);
|
|
|
|
|
|
2016-01-29 16:38:37 +02:00
|
|
|
connect(d->m_model, &QAbstractItemModel::dataChanged,
|
|
|
|
|
this, &EnvironmentWidget::updateButtons);
|
|
|
|
|
|
|
|
|
|
connect(d->m_editButton, &QAbstractButton::clicked,
|
|
|
|
|
this, &EnvironmentWidget::editEnvironmentButtonClicked);
|
|
|
|
|
connect(d->m_addButton, &QAbstractButton::clicked,
|
|
|
|
|
this, &EnvironmentWidget::addEnvironmentButtonClicked);
|
|
|
|
|
connect(d->m_resetButton, &QAbstractButton::clicked,
|
|
|
|
|
this, &EnvironmentWidget::removeEnvironmentButtonClicked);
|
|
|
|
|
connect(d->m_unsetButton, &QAbstractButton::clicked,
|
|
|
|
|
this, &EnvironmentWidget::unsetEnvironmentButtonClicked);
|
|
|
|
|
connect(d->m_batchEditButton, &QAbstractButton::clicked,
|
|
|
|
|
this, &EnvironmentWidget::batchEditEnvironmentButtonClicked);
|
|
|
|
|
connect(d->m_environmentView->selectionModel(), &QItemSelectionModel::currentChanged,
|
|
|
|
|
this, &EnvironmentWidget::environmentCurrentIndexChanged);
|
|
|
|
|
|
|
|
|
|
connect(d->m_detailsContainer, &Utils::DetailsWidget::linkActivated,
|
|
|
|
|
this, &EnvironmentWidget::linkActivated);
|
|
|
|
|
|
|
|
|
|
connect(d->m_model, &Utils::EnvironmentModel::userChangesChanged,
|
|
|
|
|
this, &EnvironmentWidget::updateSummaryText);
|
2011-01-13 11:41:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EnvironmentWidget::~EnvironmentWidget()
|
|
|
|
|
{
|
|
|
|
|
delete d->m_model;
|
2016-04-13 15:52:14 +02:00
|
|
|
d->m_model = nullptr;
|
2011-09-16 15:00:41 +02:00
|
|
|
delete d;
|
2011-01-13 11:41:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EnvironmentWidget::focusIndex(const QModelIndex &index)
|
|
|
|
|
{
|
|
|
|
|
d->m_environmentView->setCurrentIndex(index);
|
|
|
|
|
d->m_environmentView->setFocus();
|
2018-02-05 10:44:21 +01:00
|
|
|
// When the current item changes as a result of the call above,
|
|
|
|
|
// QAbstractItemView::currentChanged() is called. That calls scrollTo(current),
|
|
|
|
|
// using the default EnsureVisible scroll hint, whereas we want PositionAtTop,
|
|
|
|
|
// because it ensures that the user doesn't have to scroll down when they've
|
|
|
|
|
// added a new environment variable and want to edit its value; they'll be able
|
|
|
|
|
// to see its value as they're typing it.
|
|
|
|
|
// This only helps to a certain degree - variables whose names start with letters
|
|
|
|
|
// later in the alphabet cause them fall within the "end" of the view's range,
|
|
|
|
|
// making it impossible to position them at the top of the view.
|
|
|
|
|
d->m_environmentView->scrollTo(index, QAbstractItemView::PositionAtTop);
|
2011-01-13 11:41:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EnvironmentWidget::setBaseEnvironment(const Utils::Environment &env)
|
|
|
|
|
{
|
|
|
|
|
d->m_model->setBaseEnvironment(env);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EnvironmentWidget::setBaseEnvironmentText(const QString &text)
|
|
|
|
|
{
|
|
|
|
|
d->m_baseEnvironmentText = text;
|
|
|
|
|
updateSummaryText();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<Utils::EnvironmentItem> EnvironmentWidget::userChanges() const
|
|
|
|
|
{
|
|
|
|
|
return d->m_model->userChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EnvironmentWidget::setUserChanges(const QList<Utils::EnvironmentItem> &list)
|
|
|
|
|
{
|
|
|
|
|
d->m_model->setUserChanges(list);
|
|
|
|
|
updateSummaryText();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EnvironmentWidget::updateSummaryText()
|
|
|
|
|
{
|
2011-03-01 19:47:11 +01:00
|
|
|
QList<Utils::EnvironmentItem> list = d->m_model->userChanges();
|
2011-12-06 16:45:07 +01:00
|
|
|
Utils::EnvironmentItem::sort(&list);
|
2011-03-01 19:47:11 +01:00
|
|
|
|
2011-01-13 11:41:45 +01:00
|
|
|
QString text;
|
|
|
|
|
foreach (const Utils::EnvironmentItem &item, list) {
|
|
|
|
|
if (item.name != Utils::EnvironmentModel::tr("<VARIABLE>")) {
|
2012-01-09 16:30:33 +01:00
|
|
|
text.append(QLatin1String("<br>"));
|
2017-06-23 16:54:45 +02:00
|
|
|
if (item.operation == Utils::EnvironmentItem::Unset)
|
2014-08-28 17:33:47 +02:00
|
|
|
text.append(tr("Unset <a href=\"%1\"><b>%1</b></a>").arg(item.name.toHtmlEscaped()));
|
2011-01-13 11:41:45 +01:00
|
|
|
else
|
2014-08-28 17:33:47 +02:00
|
|
|
text.append(tr("Set <a href=\"%1\"><b>%1</b></a> to <b>%2</b>").arg(item.name.toHtmlEscaped(), item.value.toHtmlEscaped()));
|
2011-01-13 11:41:45 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-22 17:01:34 +01:00
|
|
|
if (text.isEmpty()) {
|
|
|
|
|
//: %1 is "System Environment" or some such.
|
|
|
|
|
text.prepend(tr("Use <b>%1</b>").arg(d->m_baseEnvironmentText));
|
|
|
|
|
} else {
|
|
|
|
|
//: Yup, word puzzle. The Set/Unset phrases above are appended to this.
|
|
|
|
|
//: %1 is "System Environment" or some such.
|
|
|
|
|
text.prepend(tr("Use <b>%1</b> and").arg(d->m_baseEnvironmentText));
|
|
|
|
|
}
|
2011-01-13 11:41:45 +01:00
|
|
|
|
|
|
|
|
d->m_detailsContainer->setSummaryText(text);
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-28 17:57:17 +02:00
|
|
|
void EnvironmentWidget::linkActivated(const QString &link)
|
|
|
|
|
{
|
|
|
|
|
d->m_detailsContainer->setState(Utils::DetailsWidget::Expanded);
|
|
|
|
|
QModelIndex idx = d->m_model->variableToIndex(link);
|
|
|
|
|
focusIndex(idx);
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-13 11:41:45 +01:00
|
|
|
void EnvironmentWidget::updateButtons()
|
|
|
|
|
{
|
|
|
|
|
environmentCurrentIndexChanged(d->m_environmentView->currentIndex());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EnvironmentWidget::editEnvironmentButtonClicked()
|
|
|
|
|
{
|
|
|
|
|
d->m_environmentView->edit(d->m_environmentView->currentIndex());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EnvironmentWidget::addEnvironmentButtonClicked()
|
|
|
|
|
{
|
|
|
|
|
QModelIndex index = d->m_model->addVariable();
|
|
|
|
|
d->m_environmentView->setCurrentIndex(index);
|
|
|
|
|
d->m_environmentView->edit(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EnvironmentWidget::removeEnvironmentButtonClicked()
|
|
|
|
|
{
|
|
|
|
|
const QString &name = d->m_model->indexToVariable(d->m_environmentView->currentIndex());
|
|
|
|
|
d->m_model->resetVariable(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// unset in Merged Environment Mode means, unset if it comes from the base environment
|
|
|
|
|
// or remove when it is just a change we added
|
|
|
|
|
void EnvironmentWidget::unsetEnvironmentButtonClicked()
|
|
|
|
|
{
|
|
|
|
|
const QString &name = d->m_model->indexToVariable(d->m_environmentView->currentIndex());
|
|
|
|
|
if (!d->m_model->canReset(name))
|
|
|
|
|
d->m_model->resetVariable(name);
|
|
|
|
|
else
|
|
|
|
|
d->m_model->unsetVariable(name);
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-06 16:45:07 +01:00
|
|
|
void EnvironmentWidget::batchEditEnvironmentButtonClicked()
|
|
|
|
|
{
|
|
|
|
|
const QList<Utils::EnvironmentItem> changes = d->m_model->userChanges();
|
|
|
|
|
|
|
|
|
|
bool ok;
|
2016-06-16 14:23:22 +02:00
|
|
|
const QList<Utils::EnvironmentItem> newChanges = Utils::EnvironmentDialog::getEnvironmentItems(&ok, this, changes);
|
|
|
|
|
if (!ok)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
d->m_model->setUserChanges(newChanges);
|
2011-12-06 16:45:07 +01:00
|
|
|
}
|
|
|
|
|
|
2011-01-13 11:41:45 +01:00
|
|
|
void EnvironmentWidget::environmentCurrentIndexChanged(const QModelIndex ¤t)
|
|
|
|
|
{
|
|
|
|
|
if (current.isValid()) {
|
|
|
|
|
d->m_editButton->setEnabled(true);
|
|
|
|
|
const QString &name = d->m_model->indexToVariable(current);
|
|
|
|
|
bool modified = d->m_model->canReset(name) && d->m_model->changes(name);
|
|
|
|
|
bool unset = d->m_model->canUnset(name);
|
|
|
|
|
d->m_resetButton->setEnabled(modified || unset);
|
|
|
|
|
d->m_unsetButton->setEnabled(!unset);
|
|
|
|
|
} else {
|
|
|
|
|
d->m_editButton->setEnabled(false);
|
|
|
|
|
d->m_resetButton->setEnabled(false);
|
|
|
|
|
d->m_unsetButton->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EnvironmentWidget::invalidateCurrentIndex()
|
|
|
|
|
{
|
|
|
|
|
environmentCurrentIndexChanged(QModelIndex());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace ProjectExplorer
|
2015-10-28 12:59:34 +03:00
|
|
|
|
|
|
|
|
#include "environmentwidget.moc"
|