Commit ab899983 authored by Tobias Hunger's avatar Tobias Hunger Committed by hjk

Debugger: Move classes into their own files

Change-Id: I89853ffb4192b0da1f34d471e250d4ec32daa3da
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 3a24b2d3
......@@ -44,6 +44,7 @@
#include <projectexplorer/devicesupport/devicemanager.h>
#include <projectexplorer/toolchainmanager.h>
#include <projectexplorer/session.h>
#include <debugger/debuggeritemmanager.h>
#include <debugger/debuggerkitinformation.h>
#include <qtsupport/baseqtversion.h>
#include <qtsupport/qtkitinformation.h>
......
......@@ -24,9 +24,13 @@ HEADERS += \
debuggercore.h \
debuggerconstants.h \
debuggerinternalconstants.h \
debuggeritem.h \
debuggeritemmanager.h \
debuggeritemmodel.h \
debuggerdialogs.h \
debuggerengine.h \
debuggermainwindow.h \
debuggeroptionspage.h \
debuggerplugin.h \
debuggerprotocol.h \
debuggerrunconfigurationaspect.h \
......@@ -80,12 +84,16 @@ SOURCES += \
debuggeractions.cpp \
debuggerdialogs.cpp \
debuggerengine.cpp \
debuggeritem.cpp \
debuggeritemmanager.cpp \
debuggeritemmodel.cpp \
debuggermainwindow.cpp \
debuggerplugin.cpp \
debuggerprotocol.cpp \
debuggerrunconfigurationaspect.cpp \
debuggerrunner.cpp \
debuggerstreamops.cpp \
debuggeroptionspage.cpp \
debuggerkitconfigwidget.cpp \
debuggerkitinformation.cpp \
disassembleragent.cpp \
......
......@@ -40,9 +40,13 @@ QtcPlugin {
"debuggerdialogs.cpp", "debuggerdialogs.h",
"debuggerengine.cpp", "debuggerengine.h",
"debuggerinternalconstants.h",
"debuggeritem.cpp", "debuggeritem.h",
"debuggeritemmanager.cpp", "debuggeritemmanager.h",
"debuggeritemmodel.cpp", "debuggeritemmodel.h",
"debuggerkitconfigwidget.cpp", "debuggerkitconfigwidget.h",
"debuggerkitinformation.cpp", "debuggerkitinformation.h",
"debuggermainwindow.cpp", "debuggermainwindow.h",
"debuggeroptionspage.cpp", "debuggeroptionspage.h",
"debuggerplugin.cpp", "debuggerplugin.h",
"debuggerprotocol.cpp", "debuggerprotocol.h",
"debuggerruncontrolfactory.h",
......
This diff is collapsed.
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** 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
** 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.
**
** GNU Lesser General Public License Usage
** 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
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef DEBUGGER_DEBUGGERITEM_H
#define DEBUGGER_DEBUGGERITEM_H
#include "debugger_global.h"
#include "debuggerconstants.h"
#include <projectexplorer/abi.h>
#include <utils/fileutils.h>
#include <QList>
#include <QVariant>
namespace Debugger {
// -----------------------------------------------------------------------
// DebuggerItem
// -----------------------------------------------------------------------
class DEBUGGER_EXPORT DebuggerItem
{
public:
DebuggerItem();
DebuggerItem(const QVariantMap &data);
bool canClone() const { return true; }
bool isValid() const;
QString engineTypeName() const;
QVariantMap toMap() const;
void reinitializeFromFile();
QVariant id() const { return m_id; }
QString displayName() const { return m_displayName; }
void setDisplayName(const QString &displayName);
DebuggerEngineType engineType() const { return m_engineType; }
void setEngineType(const DebuggerEngineType &engineType);
Utils::FileName command() const { return m_command; }
void setCommand(const Utils::FileName &command);
bool isAutoDetected() const { return m_isAutoDetected; }
void setAutoDetected(bool isAutoDetected);
QList<ProjectExplorer::Abi> abis() const { return m_abis; }
void setAbis(const QList<ProjectExplorer::Abi> &abis);
void setAbi(const ProjectExplorer::Abi &abi);
enum MatchLevel { DoesNotMatch, MatchesSomewhat, MatchesPerfectly };
MatchLevel matchTarget(const ProjectExplorer::Abi &targetAbi) const;
QStringList abiNames() const;
private:
QVariant m_id;
QString m_displayName;
DebuggerEngineType m_engineType;
Utils::FileName m_command;
bool m_isAutoDetected;
QList<ProjectExplorer::Abi> m_abis;
};
} // namespace Debugger
#endif // DEBUGGER_DEBUGGERITEM_H
This diff is collapsed.
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** 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
** 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.
**
** GNU Lesser General Public License Usage
** 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
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef DEBUGGER_DEBUGGERITEMMANAGER_H
#define DEBUGGER_DEBUGGERITEMMANAGER_H
#include "debugger_global.h"
#include "debuggeritem.h"
#include "debuggeritemmodel.h"
#include <QList>
#include <QObject>
#include <QString>
namespace Utils { class PersistentSettingsWriter; }
namespace Debugger {
// -----------------------------------------------------------------------
// DebuggerItemManager
// -----------------------------------------------------------------------
class DEBUGGER_EXPORT DebuggerItemManager : public QObject
{
Q_OBJECT
public:
static QObject *instance();
~DebuggerItemManager();
static QList<DebuggerItem> debuggers();
static Debugger::Internal::DebuggerItemModel *model();
static QVariant registerDebugger(const DebuggerItem &item);
static void deregisterDebugger(const DebuggerItem &item);
static const DebuggerItem *findByCommand(const Utils::FileName &command);
static const DebuggerItem *findById(const QVariant &id);
static void restoreDebuggers();
static QString uniqueDisplayName(const QString &base);
static void setItemData(const QVariant &id, const QString& displayName, const Utils::FileName &fileName);
static void removeDebugger(const QVariant &id);
static QVariant addDebugger(const DebuggerItem &item);
public slots:
void saveDebuggers();
private:
explicit DebuggerItemManager(QObject *parent = 0);
static void autoDetectGdbOrLldbDebuggers();
static void autoDetectCdbDebuggers();
static void readLegacyDebuggers();
static Utils::PersistentSettingsWriter *m_writer;
static QList<DebuggerItem> m_debuggers;
static Debugger::Internal::DebuggerItemModel *m_model;
friend class Internal::DebuggerItemModel;
friend class DebuggerPlugin; // Enable constrcutor for DebuggerPlugin
};
} // namespace Debugger
#endif // DEBUGGER_DEBUGGERITEMMANAGER_H
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** 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
** 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.
**
** GNU Lesser General Public License Usage
** 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
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "debuggeritemmodel.h"
#include "debuggeritem.h"
#include "debuggeritemmanager.h"
#include <utils/qtcassert.h>
namespace Debugger {
namespace Internal {
static QList<QStandardItem *> describeItem(const DebuggerItem &item)
{
QList<QStandardItem *> row;
row.append(new QStandardItem(item.displayName()));
row.append(new QStandardItem(item.command().toUserOutput()));
row.append(new QStandardItem(item.engineTypeName()));
row.at(0)->setData(item.id());
row.at(0)->setEditable(false);
row.at(1)->setEditable(false);
row.at(2)->setEditable(false);
row.at(0)->setSelectable(true);
row.at(1)->setSelectable(true);
row.at(2)->setSelectable(true);
return row;
}
static QList<QStandardItem *> createRow(const QString &display)
{
QList<QStandardItem *> row;
row.append(new QStandardItem(display));
row.append(new QStandardItem());
row.append(new QStandardItem());
row.at(0)->setEditable(false);
row.at(1)->setEditable(false);
row.at(2)->setEditable(false);
row.at(0)->setSelectable(false);
row.at(1)->setSelectable(false);
row.at(2)->setSelectable(false);
return row;
}
// --------------------------------------------------------------------------
// DebuggerItemModel
// --------------------------------------------------------------------------
DebuggerItemModel::DebuggerItemModel(QObject *parent)
: QStandardItemModel(parent)
{
setColumnCount(3);
QList<QStandardItem *> row = createRow(tr("Auto-detected"));
m_autoRoot = row.at(0);
appendRow(row);
row = createRow(tr("Manual"));
m_manualRoot = row.at(0);
appendRow(row);
}
QVariant DebuggerItemModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
switch (section) {
case 0:
return tr("Name");
case 1:
return tr("Path");
case 2:
return tr("Type");
}
}
return QVariant();
}
QStandardItem *DebuggerItemModel::currentStandardItem() const
{
return findStandardItemById(m_currentDebugger);
}
QStandardItem *DebuggerItemModel::findStandardItemById(const QVariant &id) const
{
for (int i = 0, n = m_autoRoot->rowCount(); i != n; ++i) {
QStandardItem *sitem = m_autoRoot->child(i);
if (sitem->data() == id)
return sitem;
}
for (int i = 0, n = m_manualRoot->rowCount(); i != n; ++i) {
QStandardItem *sitem = m_manualRoot->child(i);
if (sitem->data() == id)
return sitem;
}
return 0;
}
QModelIndex DebuggerItemModel::currentIndex() const
{
QStandardItem *current = currentStandardItem();
return current ? current->index() : QModelIndex();
}
QModelIndex DebuggerItemModel::lastIndex() const
{
int n = m_manualRoot->rowCount();
QStandardItem *current = m_manualRoot->child(n - 1);
return current ? current->index() : QModelIndex();
}
void DebuggerItemModel::markCurrentDirty()
{
QStandardItem *sitem = currentStandardItem();
QTC_ASSERT(sitem, return);
QFont font = sitem->font();
font.setBold(true);
sitem->setFont(font);
}
void DebuggerItemModel::addDebugger(const DebuggerItem &item)
{
QTC_ASSERT(item.id().isValid(), return);
QList<QStandardItem *> row = describeItem(item);
(item.isAutoDetected() ? m_autoRoot : m_manualRoot)->appendRow(row);
emit debuggerAdded(item.id(), item.displayName());
}
void DebuggerItemModel::removeDebugger(const QVariant &id)
{
QStandardItem *sitem = findStandardItemById(id);
QTC_ASSERT(sitem, return);
QStandardItem *parent = sitem->parent();
QTC_ASSERT(parent, return);
// This will trigger a change of m_currentDebugger via changing the
// view selection.
parent->removeRow(sitem->row());
emit debuggerRemoved(id);
}
void DebuggerItemModel::updateDebugger(const QVariant &id)
{
QList<DebuggerItem> debuggers = DebuggerItemManager::debuggers();
for (int i = 0, n = debuggers.size(); i != n; ++i) {
DebuggerItem &item = debuggers[i];
if (item.id() == id) {
QStandardItem *sitem = findStandardItemById(id);
QTC_ASSERT(sitem, return);
QStandardItem *parent = sitem->parent();
QTC_ASSERT(parent, return);
int row = sitem->row();
QFont font = sitem->font();
font.setBold(false);
parent->child(row, 0)->setData(item.displayName(), Qt::DisplayRole);
parent->child(row, 0)->setFont(font);
parent->child(row, 1)->setData(item.command().toUserOutput(), Qt::DisplayRole);
parent->child(row, 1)->setFont(font);
parent->child(row, 2)->setData(item.engineTypeName(), Qt::DisplayRole);
parent->child(row, 2)->setFont(font);
emit debuggerUpdated(id, item.displayName());
return;
}
}
}
void DebuggerItemModel::setCurrentIndex(const QModelIndex &index)
{
QStandardItem *sit = itemFromIndex(index);
m_currentDebugger = sit ? sit->data() : QVariant();
}
} // namespace Internal
} // namespace Debugger
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** 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
** 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.
**
** GNU Lesser General Public License Usage
** 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
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef DEBUGGER_DEBUGGERITEMMODEL_H
#define DEBUGGER_DEBUGGERITEMMODEL_H
#include "debuggeritem.h"
#include <QStandardItemModel>
#include <QVariant>
namespace Debugger {
namespace Internal {
// -----------------------------------------------------------------------
// DebuggerItemModel
//------------------------------------------------------------------------
class DebuggerItemModel : public QStandardItemModel
{
Q_OBJECT
public:
DebuggerItemModel(QObject *parent);
QModelIndex currentIndex() const;
QModelIndex lastIndex() const;
void setCurrentIndex(const QModelIndex &index);
QVariant currentDebugger() const { return m_currentDebugger; }
void addDebugger(const DebuggerItem &item);
void removeDebugger(const QVariant &id);
void updateDebugger(const QVariant &id);
public slots:
void markCurrentDirty();
signals:
void debuggerAdded(const QVariant &id, const QString &display);
void debuggerUpdated(const QVariant &id, const QString &display);
void debuggerRemoved(const QVariant &id);
private:
// <debug>
// friend class Debugger::DebuggerKitInformation;
// friend class DebuggerKitConfigWidget;
// friend class DebuggerItemConfigWidget;
// friend class DebuggerOptionsPage;
// </debug>
QStandardItem *currentStandardItem() const;
QStandardItem *findStandardItemById(const QVariant &id) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
QVariant m_currentDebugger;
QStandardItem *m_autoRoot;
QStandardItem *m_manualRoot;
QStringList removed;
};
} // namespace Internal
} // namespace Debugger
#endif // DEBUGGER_DEBUGGERITEMMODEL_H
......@@ -52,52 +52,6 @@ QT_END_NAMESPACE
namespace Debugger {
namespace Internal {
class DebuggerItemConfigWidget;
class DebuggerKitConfigWidget;
// -----------------------------------------------------------------------
// DebuggerItemModel
//------------------------------------------------------------------------
class DebuggerItemModel : public QStandardItemModel
{
Q_OBJECT
public:
DebuggerItemModel(QObject *parent);
QModelIndex currentIndex() const;
QModelIndex lastIndex() const;
void setCurrentIndex(const QModelIndex &index);
QVariant currentDebugger() const { return m_currentDebugger; }
void addDebugger(const DebuggerItem &item);
void removeDebugger(const QVariant &id);
void updateDebugger(const QVariant &id);
public slots:
void markCurrentDirty();
signals:
void debuggerAdded(const QVariant &id, const QString &display);
void debuggerUpdated(const QVariant &id, const QString &display);
void debuggerRemoved(const QVariant &id);
private:
friend class Debugger::DebuggerKitInformation;
friend class DebuggerKitConfigWidget;
friend class DebuggerItemConfigWidget;
friend class DebuggerOptionsPage;
QStandardItem *currentStandardItem() const;
QStandardItem *findStandardItemById(const QVariant &id) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
QVariant m_currentDebugger;
QStandardItem *m_autoRoot;
QStandardItem *m_manualRoot;
QStringList removed;
};
// -----------------------------------------------------------------------
// DebuggerKitConfigWidget
// -----------------------------------------------------------------------
......@@ -135,44 +89,7 @@ private:
QPushButton *m_manageButton;
};
// --------------------------------------------------------------------------
// DebuggerOptionsPage
// --------------------------------------------------------------------------
class DebuggerOptionsPage : public Core::IOptionsPage
{
Q_OBJECT
public:
DebuggerOptionsPage();
QWidget *createPage(QWidget *parent);
void apply();
void finish();
bool matches(const QString &) const;
private slots:
void debuggerSelectionChanged();
void debuggerModelChanged();
void updateState();
void cloneDebugger();
void addDebugger();
void removeDebugger();
private:
QWidget *m_configWidget;
QString m_searchKeywords;
DebuggerItemModel *m_model;
DebuggerItemConfigWidget *m_itemConfigWidget;
QTreeView *m_debuggerView;
Utils::DetailsWidget *m_container;
QPushButton *m_addButton;
QPushButton *m_cloneButton;