2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2012-04-24 15:49:09 +02:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2012-04-24 15:49:09 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-04-24 15:49:09 +02: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
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2012-04-24 15:49:09 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, 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.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2012-04-24 15:49:09 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
#include "debuggerkitconfigwidget.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2013-10-25 13:47:08 +02:00
|
|
|
#include "debuggeritemmanager.h"
|
|
|
|
|
#include "debuggeritemmodel.h"
|
2013-10-28 14:05:12 +01:00
|
|
|
#include "debuggerkitinformation.h"
|
2013-10-25 13:47:08 +02:00
|
|
|
|
2013-02-20 14:15:42 +01:00
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/abi.h>
|
2013-08-14 18:30:40 +02:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
|
|
|
|
#include <projectexplorer/toolchain.h>
|
|
|
|
|
#include <projectexplorer/toolchainmanager.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2013-02-08 14:09:04 +01:00
|
|
|
#include <utils/elidinglabel.h>
|
2013-08-14 18:30:40 +02:00
|
|
|
#include <utils/environment.h>
|
|
|
|
|
#include <utils/pathchooser.h>
|
|
|
|
|
#include <utils/persistentsettings.h>
|
|
|
|
|
#include <utils/qtcassert.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
#include <utils/winutils.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-08-14 18:30:40 +02:00
|
|
|
#include <QApplication>
|
2012-09-05 14:56:08 +02:00
|
|
|
#include <QComboBox>
|
2013-08-14 18:30:40 +02:00
|
|
|
#include <QDirIterator>
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QFormLayout>
|
|
|
|
|
#include <QHeaderView>
|
|
|
|
|
#include <QLineEdit>
|
2012-09-11 14:03:08 +02:00
|
|
|
#include <QPushButton>
|
2013-08-14 18:30:40 +02:00
|
|
|
#include <QStandardItem>
|
|
|
|
|
#include <QStandardItemModel>
|
|
|
|
|
#include <QTreeView>
|
|
|
|
|
#include <QUuid>
|
|
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace Utils;
|
|
|
|
|
using namespace Debugger::Internal;
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
namespace Debugger {
|
2013-10-09 12:42:00 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class DebuggerItemConfigWidget;
|
|
|
|
|
|
2013-08-14 18:30:40 +02:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
// DebuggerKitConfigWidget
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
2013-09-09 17:10:41 +02:00
|
|
|
DebuggerKitConfigWidget::DebuggerKitConfigWidget(Kit *workingCopy, const KitInformation *ki)
|
|
|
|
|
: KitConfigWidget(workingCopy, ki)
|
2013-08-14 18:30:40 +02:00
|
|
|
{
|
|
|
|
|
m_comboBox = new QComboBox;
|
|
|
|
|
m_comboBox->setEnabled(true);
|
|
|
|
|
m_comboBox->setToolTip(toolTip());
|
|
|
|
|
m_comboBox->addItem(tr("None"), QString());
|
2013-10-09 12:42:00 +02:00
|
|
|
foreach (const DebuggerItem &item, DebuggerItemManager::debuggers())
|
2013-09-25 11:38:26 +02:00
|
|
|
m_comboBox->addItem(item.displayName(), item.id());
|
2013-08-14 18:30:40 +02:00
|
|
|
|
|
|
|
|
refresh();
|
|
|
|
|
connect(m_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(currentDebuggerChanged(int)));
|
|
|
|
|
|
|
|
|
|
m_manageButton = new QPushButton(tr("Manage..."));
|
|
|
|
|
m_manageButton->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
connect(m_manageButton, SIGNAL(clicked()), this, SLOT(manageDebuggers()));
|
|
|
|
|
|
2013-10-28 14:05:12 +01:00
|
|
|
QObject *manager = DebuggerItemManager::instance();
|
|
|
|
|
connect(manager, SIGNAL(debuggerAdded(QVariant)),
|
|
|
|
|
this, SLOT(onDebuggerAdded(QVariant)));
|
|
|
|
|
connect(manager, SIGNAL(debuggerUpdated(QVariant)),
|
|
|
|
|
this, SLOT(onDebuggerUpdated(QVariant)));
|
|
|
|
|
connect(manager, SIGNAL(debuggerRemoved(QVariant)),
|
2013-09-03 12:31:28 +02:00
|
|
|
this, SLOT(onDebuggerRemoved(QVariant)));
|
2013-08-14 18:30:40 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-13 16:30:17 +02:00
|
|
|
DebuggerKitConfigWidget::~DebuggerKitConfigWidget()
|
|
|
|
|
{
|
|
|
|
|
delete m_comboBox;
|
|
|
|
|
delete m_manageButton;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-14 18:30:40 +02:00
|
|
|
QString DebuggerKitConfigWidget::toolTip() const
|
2012-09-07 16:30:18 +02:00
|
|
|
{
|
2013-08-14 18:30:40 +02:00
|
|
|
return tr("The debugger to use for this kit.");
|
2012-09-07 16:30:18 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QString DebuggerKitConfigWidget::displayName() const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-08-28 11:33:49 +02:00
|
|
|
return tr("Debugger:");
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
void DebuggerKitConfigWidget::makeReadOnly()
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-08-14 18:30:40 +02:00
|
|
|
m_manageButton->setEnabled(false);
|
|
|
|
|
m_comboBox->setEnabled(false);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-10-10 15:34:35 +02:00
|
|
|
void DebuggerKitConfigWidget::refresh()
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-10-09 12:42:00 +02:00
|
|
|
const DebuggerItem *item = DebuggerKitInformation::debugger(m_kit);
|
2013-09-25 11:38:26 +02:00
|
|
|
updateComboBox(item ? item->id() : QVariant());
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-14 18:30:40 +02:00
|
|
|
QWidget *DebuggerKitConfigWidget::buttonWidget() const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-08-14 18:30:40 +02:00
|
|
|
return m_manageButton;
|
2012-09-11 14:03:08 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-14 18:30:40 +02:00
|
|
|
QWidget *DebuggerKitConfigWidget::mainWidget() const
|
2012-09-11 14:03:08 +02:00
|
|
|
{
|
2013-08-14 18:30:40 +02:00
|
|
|
return m_comboBox;
|
2012-09-05 14:56:08 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-14 18:30:40 +02:00
|
|
|
void DebuggerKitConfigWidget::manageDebuggers()
|
|
|
|
|
{
|
|
|
|
|
Core::ICore::showOptionsDialog(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY,
|
|
|
|
|
ProjectExplorer::Constants::DEBUGGER_SETTINGS_PAGE_ID);
|
|
|
|
|
}
|
2012-09-11 14:03:08 +02:00
|
|
|
|
2013-08-14 18:30:40 +02:00
|
|
|
void DebuggerKitConfigWidget::currentDebuggerChanged(int)
|
2012-09-11 14:03:08 +02:00
|
|
|
{
|
2013-10-17 12:48:16 +02:00
|
|
|
int currentIndex = m_comboBox->currentIndex();
|
|
|
|
|
QVariant id = m_comboBox->itemData(currentIndex);
|
|
|
|
|
m_kit->setValue(DebuggerKitInformation::id(), id);
|
2013-08-14 18:30:40 +02:00
|
|
|
}
|
2012-09-11 14:03:08 +02:00
|
|
|
|
2013-10-28 14:05:12 +01:00
|
|
|
void DebuggerKitConfigWidget::onDebuggerAdded(const QVariant &id)
|
2013-08-14 18:30:40 +02:00
|
|
|
{
|
2013-10-28 14:05:12 +01:00
|
|
|
const DebuggerItem *item = DebuggerItemManager::findById(id);
|
|
|
|
|
QTC_ASSERT(item, return);
|
|
|
|
|
m_comboBox->addItem(item->displayName(), id);
|
2013-08-14 18:30:40 +02:00
|
|
|
}
|
2012-09-11 14:03:08 +02:00
|
|
|
|
2013-10-28 14:05:12 +01:00
|
|
|
void DebuggerKitConfigWidget::onDebuggerUpdated(const QVariant &id)
|
2013-08-14 18:30:40 +02:00
|
|
|
{
|
2013-10-28 14:05:12 +01:00
|
|
|
const DebuggerItem *item = DebuggerItemManager::findById(id);
|
|
|
|
|
QTC_ASSERT(item, return);
|
2013-09-03 12:31:28 +02:00
|
|
|
const int pos = indexOf(id);
|
2013-08-14 18:30:40 +02:00
|
|
|
if (pos < 0)
|
|
|
|
|
return;
|
2013-10-28 14:05:12 +01:00
|
|
|
m_comboBox->setItemText(pos, item->displayName());
|
2013-08-14 18:30:40 +02:00
|
|
|
}
|
2012-09-11 14:03:08 +02:00
|
|
|
|
2013-09-03 12:31:28 +02:00
|
|
|
void DebuggerKitConfigWidget::onDebuggerRemoved(const QVariant &id)
|
2013-08-14 18:30:40 +02:00
|
|
|
{
|
2013-09-03 12:31:28 +02:00
|
|
|
if (const int pos = indexOf(id)) {
|
|
|
|
|
m_comboBox->removeItem(pos);
|
2013-11-26 13:31:01 +01:00
|
|
|
refresh();
|
2013-09-03 12:31:28 +02:00
|
|
|
}
|
2013-08-14 18:30:40 +02:00
|
|
|
}
|
2012-09-11 14:03:08 +02:00
|
|
|
|
2013-09-03 12:31:28 +02:00
|
|
|
int DebuggerKitConfigWidget::indexOf(const QVariant &id)
|
2013-08-14 18:30:40 +02:00
|
|
|
{
|
2013-09-03 12:31:28 +02:00
|
|
|
QTC_ASSERT(id.isValid(), return -1);
|
2013-08-14 18:30:40 +02:00
|
|
|
for (int i = 0; i < m_comboBox->count(); ++i) {
|
|
|
|
|
if (id == m_comboBox->itemData(i))
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
2012-09-11 14:03:08 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-14 18:30:40 +02:00
|
|
|
QVariant DebuggerKitConfigWidget::currentId() const
|
2012-09-05 14:56:08 +02:00
|
|
|
{
|
2013-08-14 18:30:40 +02:00
|
|
|
return m_comboBox->itemData(m_comboBox->currentIndex());
|
2012-09-05 14:56:08 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-14 18:30:40 +02:00
|
|
|
void DebuggerKitConfigWidget::updateComboBox(const QVariant &id)
|
2012-09-05 14:56:08 +02:00
|
|
|
{
|
2013-08-14 18:30:40 +02:00
|
|
|
for (int i = 0; i < m_comboBox->count(); ++i) {
|
|
|
|
|
if (id == m_comboBox->itemData(i)) {
|
2012-09-05 14:56:08 +02:00
|
|
|
m_comboBox->setCurrentIndex(i);
|
2013-08-14 18:30:40 +02:00
|
|
|
return;
|
2012-09-05 14:56:08 +02:00
|
|
|
}
|
|
|
|
|
}
|
2013-08-14 18:30:40 +02:00
|
|
|
m_comboBox->setCurrentIndex(0);
|
2012-09-05 14:56:08 +02:00
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|