forked from qt-creator/qt-creator
Debugger: Use an enum for column numbers in stack view
Easier to read. Change-Id: I85abf6e8c881b4d521f7791625cff37bbd2fffdc Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -84,7 +84,7 @@ int StackHandler::rowCount(const QModelIndex &parent) const
|
|||||||
|
|
||||||
int StackHandler::columnCount(const QModelIndex &parent) const
|
int StackHandler::columnCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
return parent.isValid() ? 0 : 5;
|
return parent.isValid() ? 0 : StackColumnCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant StackHandler::data(const QModelIndex &index, int role) const
|
QVariant StackHandler::data(const QModelIndex &index, int role) const
|
||||||
@@ -93,11 +93,11 @@ QVariant StackHandler::data(const QModelIndex &index, int role) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
if (index.row() == m_stackFrames.size()) {
|
if (index.row() == m_stackFrames.size()) {
|
||||||
if (role == Qt::DisplayRole && index.column() == 0)
|
if (role == Qt::DisplayRole && index.column() == StackLevelColumn)
|
||||||
return tr("...");
|
return tr("...");
|
||||||
if (role == Qt::DisplayRole && index.column() == 1)
|
if (role == Qt::DisplayRole && index.column() == StackFunctionNameColumn)
|
||||||
return tr("<More>");
|
return tr("<More>");
|
||||||
if (role == Qt::DecorationRole && index.column() == 0)
|
if (role == Qt::DecorationRole && index.column() == StackLevelColumn)
|
||||||
return m_emptyIcon;
|
return m_emptyIcon;
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@@ -106,15 +106,15 @@ QVariant StackHandler::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
case 0: // Stack frame level
|
case StackLevelColumn:
|
||||||
return QString::number(frame.level);
|
return QString::number(frame.level);
|
||||||
case 1: // Function name
|
case StackFunctionNameColumn:
|
||||||
return simplifyType(frame.function);
|
return simplifyType(frame.function);
|
||||||
case 2: // File name
|
case StackFileNameColumn:
|
||||||
return frame.file.isEmpty() ? frame.from : QFileInfo(frame.file).fileName();
|
return frame.file.isEmpty() ? frame.from : QFileInfo(frame.file).fileName();
|
||||||
case 3: // Line number
|
case StackLineNumberColumn:
|
||||||
return frame.line > 0 ? QVariant(frame.line) : QVariant();
|
return frame.line > 0 ? QVariant(frame.line) : QVariant();
|
||||||
case 4: // Address
|
case StackAddressColumn:
|
||||||
if (frame.address)
|
if (frame.address)
|
||||||
return QString::fromLatin1("0x%1").arg(frame.address, 0, 16);
|
return QString::fromLatin1("0x%1").arg(frame.address, 0, 16);
|
||||||
return QString();
|
return QString();
|
||||||
@@ -122,7 +122,7 @@ QVariant StackHandler::data(const QModelIndex &index, int role) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role == Qt::DecorationRole && index.column() == 0) {
|
if (role == Qt::DecorationRole && index.column() == StackLevelColumn) {
|
||||||
// Return icon that indicates whether this is the active stack frame
|
// Return icon that indicates whether this is the active stack frame
|
||||||
return (m_contentsValid && index.row() == m_currentIndex)
|
return (m_contentsValid && index.row() == m_currentIndex)
|
||||||
? m_positionIcon : m_emptyIcon;
|
? m_positionIcon : m_emptyIcon;
|
||||||
|
|||||||
@@ -38,6 +38,16 @@
|
|||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
enum StackColumns
|
||||||
|
{
|
||||||
|
StackLevelColumn,
|
||||||
|
StackFunctionNameColumn,
|
||||||
|
StackFileNameColumn,
|
||||||
|
StackLineNumberColumn,
|
||||||
|
StackAddressColumn,
|
||||||
|
StackColumnCount = StackAddressColumn,
|
||||||
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// StackCookie
|
// StackCookie
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ StackTreeView::StackTreeView()
|
|||||||
|
|
||||||
void StackTreeView::showAddressColumn(bool on)
|
void StackTreeView::showAddressColumn(bool on)
|
||||||
{
|
{
|
||||||
setColumnHidden(4, !on);
|
setColumnHidden(StackAddressColumn, !on);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StackTreeView::rowActivated(const QModelIndex &index)
|
void StackTreeView::rowActivated(const QModelIndex &index)
|
||||||
@@ -82,8 +82,8 @@ void StackTreeView::rowActivated(const QModelIndex &index)
|
|||||||
void StackTreeView::setModel(QAbstractItemModel *model)
|
void StackTreeView::setModel(QAbstractItemModel *model)
|
||||||
{
|
{
|
||||||
BaseTreeView::setModel(model);
|
BaseTreeView::setModel(model);
|
||||||
resizeColumnToContents(0);
|
resizeColumnToContents(StackLevelColumn);
|
||||||
resizeColumnToContents(3);
|
resizeColumnToContents(StackLineNumberColumn);
|
||||||
showAddressColumn(action(UseAddressInStackView)->isChecked());
|
showAddressColumn(action(UseAddressInStackView)->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user