Commit 60afc7ff authored by hjk's avatar hjk Committed by hjk

debugger: slightly saner behaviour for the threads combobox

Change-Id: I20400b037f00a5dbaf11cbbfb184a5bf526883cc
Reviewed-on: http://codereview.qt.nokia.com/4095Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 4b3890ee
......@@ -114,7 +114,7 @@ public:
int ignoreCount(BreakpointModelId id) const;
void setIgnoreCount(BreakpointModelId, const int &count);
int threadSpec(BreakpointModelId id) const;
void setThreadSpec(BreakpointModelId, const int&spec);
void setThreadSpec(BreakpointModelId, const int &spec);
QString fileName(BreakpointModelId id) const;
void setFileName(BreakpointModelId, const QString &fileName);
QString functionName(BreakpointModelId id) const;
......
......@@ -105,7 +105,8 @@ public:
virtual bool initialize(const QStringList &arguments, QString *errorMessage) = 0;
virtual QWidget *mainWindow() const = 0;
virtual bool isDockVisible(const QString &objectName) const = 0;
virtual QString debuggerForAbi(const ProjectExplorer::Abi &abi, DebuggerEngineType et = NoEngineType) const = 0;
virtual QString debuggerForAbi(const ProjectExplorer::Abi &abi,
DebuggerEngineType et = NoEngineType) const = 0;
virtual void showModuleSymbols(const QString &moduleName,
const QVector<Symbol> &symbols) = 0;
virtual void openMemoryEditor() = 0;
......@@ -115,6 +116,7 @@ public:
virtual Utils::SavedAction *action(int code) const = 0;
virtual bool boolSetting(int code) const = 0;
virtual QString stringSetting(int code) const = 0;
virtual void setThreads(const QStringList &list, int index) = 0;
virtual DebuggerToolTipManager *toolTipManager() const = 0;
virtual QSharedPointer<GlobalDebuggerOptions> globalDebuggerOptions() const = 0;
......
......@@ -580,6 +580,16 @@ public:
DebuggerEngine *currentEngine() const { return m_currentEngine; }
DebuggerEngine *dummyEngine();
void setThreads(const QStringList &list, int index)
{
const bool state = m_threadBox->blockSignals(true);
m_threadBox->clear();
foreach (const QString &item, list)
m_threadBox->addItem(item);
m_threadBox->setCurrentIndex(index);
m_threadBox->blockSignals(state);
}
public slots:
void writeSettings()
{
......@@ -1869,8 +1879,8 @@ void DebuggerPluginPrivate::connectEngine(DebuggerEngine *engine)
m_sourceFilesWindow->setModel(engine->sourceFilesModel());
m_stackWindow->setModel(engine->stackModel());
m_threadsWindow->setModel(engine->threadsModel());
m_threadBox->setModel(engine->threadsModel());
m_threadBox->setModelColumn(ThreadData::NameColumn);
//m_threadBox->setModel(engine->threadsModel());
//m_threadBox->setModelColumn(ThreadData::ComboNameColumn);
m_watchersWindow->setModel(engine->watchersModel());
engine->watchHandler()->rebuildModel();
}
......@@ -3120,6 +3130,7 @@ void DebuggerPluginPrivate::extensionsInitialized()
hbox->addWidget(new QLabel(tr("Threads:")));
m_threadBox = new QComboBox;
m_threadBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
connect(m_threadBox, SIGNAL(activated(int)), SLOT(selectThread(int)));
hbox->addWidget(m_threadBox);
......
......@@ -60,7 +60,9 @@ struct ThreadData
LineColumn,
StateColumn,
NameColumn,
TargetIdColumn,
CoreColumn,
ComboNameColumn,
ColumnCount = CoreColumn
};
......
......@@ -34,6 +34,7 @@
#include "gdb/gdbmi.h"
#include "debuggerconstants.h"
#include "debuggercore.h"
#include <QtCore/QDebug>
#include <QtCore/QTextStream>
......@@ -124,7 +125,7 @@ QVariant ThreadsHandler::data(const QModelIndex &index, int role) const
if (!index.isValid())
return QVariant();
const int row = index.row();
if (row >= m_threads.size())
if (row >= m_threads.size())
return QVariant();
const ThreadData &thread = m_threads.at(row);
......@@ -148,14 +149,14 @@ QVariant ThreadsHandler::data(const QModelIndex &index, int role) const
return thread.core;
case ThreadData::StateColumn:
return thread.state;
case ThreadData::NameColumn: {
QString s;
if (!thread.name.isEmpty())
s += ' ' + thread.name;
if (!thread.targetId.isEmpty())
s += ' ' + thread.targetId;
return s;
}
case ThreadData::TargetIdColumn:
if (thread.targetId.startsWith(QLatin1String("Thread ")))
return thread.targetId.mid(7);
return thread.targetId;
case ThreadData::NameColumn:
return thread.name;
case ThreadData::ComboNameColumn:
return QString("#%1 %2").arg(thread.id).arg(thread.name);
}
case Qt::ToolTipRole:
return threadToolTip(thread);
......@@ -177,7 +178,7 @@ QVariant ThreadsHandler::headerData
return QVariant();
switch (section) {
case ThreadData::IdColumn:
return tr("Thread ID");
return QString(QLatin1String(" ") + tr("Id"));
case ThreadData::FunctionColumn:
return tr("Function");
case ThreadData::FileColumn:
......@@ -190,6 +191,8 @@ QVariant ThreadsHandler::headerData
return tr("Core");
case ThreadData::StateColumn:
return tr("State");
case ThreadData::TargetIdColumn:
return tr("Target Id");
case ThreadData::NameColumn:
return tr("Name");
}
......@@ -219,19 +222,20 @@ void ThreadsHandler::setCurrentThread(int index)
m_currentIndex = index;
// Emit changed for new frame
// Emit changed for new frame.
i = ThreadsHandler::index(m_currentIndex, 0);
emit dataChanged(i, i);
updateThreadBox();
}
void ThreadsHandler::setCurrentThreadId(int id)
{
const int index = indexOf(id);
if (index != -1) {
if (index != -1)
setCurrentThread(index);
} else {
else
qWarning("ThreadsHandler::setCurrentThreadId: No such thread %d.", id);
}
}
int ThreadsHandler::indexOf(quint64 threadId) const
......@@ -251,6 +255,15 @@ void ThreadsHandler::setThreads(const Threads &threads)
m_resetLocationScheduled = false;
m_contentsValid = true;
reset();
updateThreadBox();
}
void ThreadsHandler::updateThreadBox()
{
QStringList list;
foreach (const ThreadData &thread, m_threads)
list.append(QString("#%1 %2").arg(thread.id).arg(thread.name));
debuggerCore()->setThreads(list, m_currentIndex);
}
Threads ThreadsHandler::threads() const
......
......@@ -38,15 +38,17 @@
#include "threaddata.h"
namespace Debugger {
namespace Internal {
class GdbMi;
////////////////////////////////////////////////////////////////////////
//
// ThreadsHandler
//
////////////////////////////////////////////////////////////////////////
namespace Debugger {
namespace Internal {
class GdbMi;
class ThreadsHandler : public QAbstractTableModel
{
Q_OBJECT
......@@ -80,6 +82,7 @@ private:
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
void updateThreadBox();
Threads m_threads;
int m_currentIndex;
......
......@@ -79,9 +79,11 @@ void ThreadsWindow::rowActivated(const QModelIndex &index)
void ThreadsWindow::setModel(QAbstractItemModel *model)
{
QTreeView::setModel(model);
resizeColumnToContents(0); // Id
resizeColumnToContents(4); // Line
resizeColumnToContents(6); // Name
resizeColumnToContents(ThreadData::IdColumn);
resizeColumnToContents(ThreadData::LineColumn);
resizeColumnToContents(ThreadData::NameColumn);
resizeColumnToContents(ThreadData::StateColumn);
resizeColumnToContents(ThreadData::TargetIdColumn);
if (header()) {
bool adjust = debuggerCore()->boolSetting(AlwaysAdjustThreadsColumnWidths);
setAlwaysResizeColumnsToContents(adjust);
......@@ -109,7 +111,7 @@ void ThreadsWindow::contextMenuEvent(QContextMenuEvent *ev)
void ThreadsWindow::resizeColumnsToContents()
{
const int columnCount = model()->columnCount();
for (int c = 0 ; c < columnCount; c++)
for (int c = 0 ; c != columnCount; ++c)
resizeColumnToContents(c);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment