Commit c3650bf2 authored by hjk's avatar hjk
Browse files

Debugger: Use an enum for column numbers in stack view



Easier to read.

Change-Id: I85abf6e8c881b4d521f7791625cff37bbd2fffdc
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 242b3f41
......@@ -84,7 +84,7 @@ int StackHandler::rowCount(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
......@@ -93,11 +93,11 @@ QVariant StackHandler::data(const QModelIndex &index, int role) const
return QVariant();
if (index.row() == m_stackFrames.size()) {
if (role == Qt::DisplayRole && index.column() == 0)
if (role == Qt::DisplayRole && index.column() == StackLevelColumn)
return tr("...");
if (role == Qt::DisplayRole && index.column() == 1)
if (role == Qt::DisplayRole && index.column() == StackFunctionNameColumn)
return tr("<More>");
if (role == Qt::DecorationRole && index.column() == 0)
if (role == Qt::DecorationRole && index.column() == StackLevelColumn)
return m_emptyIcon;
return QVariant();
}
......@@ -106,15 +106,15 @@ QVariant StackHandler::data(const QModelIndex &index, int role) const
if (role == Qt::DisplayRole) {
switch (index.column()) {
case 0: // Stack frame level
case StackLevelColumn:
return QString::number(frame.level);
case 1: // Function name
case StackFunctionNameColumn:
return simplifyType(frame.function);
case 2: // File name
case StackFileNameColumn:
return frame.file.isEmpty() ? frame.from : QFileInfo(frame.file).fileName();
case 3: // Line number
case StackLineNumberColumn:
return frame.line > 0 ? QVariant(frame.line) : QVariant();
case 4: // Address
case StackAddressColumn:
if (frame.address)
return QString::fromLatin1("0x%1").arg(frame.address, 0, 16);
return QString();
......@@ -122,7 +122,7 @@ QVariant StackHandler::data(const QModelIndex &index, int role) const
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 (m_contentsValid && index.row() == m_currentIndex)
? m_positionIcon : m_emptyIcon;
......
......@@ -38,6 +38,16 @@
namespace Debugger {
namespace Internal {
enum StackColumns
{
StackLevelColumn,
StackFunctionNameColumn,
StackFileNameColumn,
StackLineNumberColumn,
StackAddressColumn,
StackColumnCount = StackAddressColumn,
};
////////////////////////////////////////////////////////////////////////
//
// StackCookie
......
......@@ -71,7 +71,7 @@ StackTreeView::StackTreeView()
void StackTreeView::showAddressColumn(bool on)
{
setColumnHidden(4, !on);
setColumnHidden(StackAddressColumn, !on);
}
void StackTreeView::rowActivated(const QModelIndex &index)
......@@ -82,8 +82,8 @@ void StackTreeView::rowActivated(const QModelIndex &index)
void StackTreeView::setModel(QAbstractItemModel *model)
{
BaseTreeView::setModel(model);
resizeColumnToContents(0);
resizeColumnToContents(3);
resizeColumnToContents(StackLevelColumn);
resizeColumnToContents(StackLineNumberColumn);
showAddressColumn(action(UseAddressInStackView)->isChecked());
}
......
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