forked from qt-creator/qt-creator
TreeModel: Introduce a TreeItem::indexInParent() convenience function
To shorten user code and hide the ugly const_cast. Change-Id: I798bd105932004ea17cb95b243fc38ccfcda0a2c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -278,7 +278,7 @@ QVariant FrameItem::data(int column, int role) const
|
||||
case ErrorListModel::ErrorRole:
|
||||
return QVariant::fromValue(getErrorItem()->error());
|
||||
case Qt::DisplayRole: {
|
||||
const int row = parent()->children().indexOf(const_cast<FrameItem *>(this)) + 1;
|
||||
const int row = indexInParent() + 1;
|
||||
const int padding = static_cast<int>(std::log10(parent()->childCount()))
|
||||
- static_cast<int>(std::log10(row));
|
||||
return QString::fromLatin1("%1%2: %3")
|
||||
|
||||
Reference in New Issue
Block a user