Fix treemodelcompleter example
All nodes in the view were at the top level due to a spurious trimmed() call. The condition in the indentation calculation was flipped, leading to a segfault. Also, the input data does not contain tabs. Remove the condition that checks for tabs altogether. This amends commit 3fede6cb547b783377e833c9b269d4cecfe47e61. Fixes: QTBUG-97727 Pick-to: 6.2 5.15 Change-Id: Ic5068ead755c4dae5f0607724ac7704cce03227c Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
This commit is contained in:
parent
dece6f5840
commit
9beae46b59
@ -206,7 +206,7 @@ QAbstractItemModel *MainWindow::modelFromFile(const QString &fileName)
|
|||||||
|
|
||||||
QRegularExpression re("^\\s+");
|
QRegularExpression re("^\\s+");
|
||||||
while (!file.atEnd()) {
|
while (!file.atEnd()) {
|
||||||
const QString line = QString::fromUtf8(file.readLine()).trimmed();
|
const QString line = QString::fromUtf8(file.readLine());
|
||||||
const QString trimmedLine = line.trimmed();
|
const QString trimmedLine = line.trimmed();
|
||||||
if (trimmedLine.isEmpty())
|
if (trimmedLine.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
@ -218,7 +218,7 @@ QAbstractItemModel *MainWindow::modelFromFile(const QString &fileName)
|
|||||||
level = 0;
|
level = 0;
|
||||||
} else {
|
} else {
|
||||||
const int capLen = match.capturedLength();
|
const int capLen = match.capturedLength();
|
||||||
level = line.startsWith(QLatin1Char('\t')) ? capLen / 4 : capLen;
|
level = capLen / 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (level + 1 >= parents.size())
|
if (level + 1 >= parents.size())
|
||||||
@ -267,4 +267,3 @@ void MainWindow::updateContentsLabel(const QString &sep)
|
|||||||
{
|
{
|
||||||
contentsLabel->setText(tr("Type path from model above with items at each level separated by a '%1'").arg(sep));
|
contentsLabel->setText(tr("Type path from model above with items at each level separated by a '%1'").arg(sep));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user