Add break; statements in the generated switch code for model::data()

Summary:
Compiler complains about generated code with
warning: this statement may fall through
and is slightly right, as the code might fall through if a role is used
which is not catched for a column.

Reviewers: vandenoever

Reviewed By: vandenoever

Differential Revision: https://phabricator.kde.org/D15541
master
Friedrich W. H. Kossebau 2018-09-15 21:43:06 +02:00
parent 0192124c70
commit 1ce86bd5d5
5 changed files with 18 additions and 1 deletions

View File

@ -228,12 +228,14 @@ QVariant FibonacciList::data(const QModelIndex &index, int role) const
case Qt::UserRole + 1:
return QVariant::fromValue(row(index.row()));
}
break;
case 1:
switch (role) {
case Qt::DisplayRole:
case Qt::UserRole + 0:
return QVariant::fromValue(fibonacciNumber(index.row()));
}
break;
}
return QVariant();
}
@ -471,30 +473,35 @@ QVariant FileSystemTree::data(const QModelIndex &index, int role) const
case Qt::UserRole + 5:
return QVariant::fromValue(fileType(index));
}
break;
case 1:
switch (role) {
case Qt::DisplayRole:
case Qt::UserRole + 4:
return fileSize(index);
}
break;
case 2:
switch (role) {
case Qt::DisplayRole:
case Qt::UserRole + 2:
return cleanNullQVariant(QVariant::fromValue(filePath(index)));
}
break;
case 3:
switch (role) {
case Qt::DisplayRole:
case Qt::UserRole + 3:
return QVariant::fromValue(filePermissions(index));
}
break;
case 4:
switch (role) {
case Qt::DisplayRole:
case Qt::UserRole + 5:
return QVariant::fromValue(fileType(index));
}
break;
}
return QVariant();
}
@ -743,18 +750,21 @@ QVariant Processes::data(const QModelIndex &index, int role) const
case Qt::UserRole + 6:
return QVariant::fromValue(uid(index));
}
break;
case 1:
switch (role) {
case Qt::DisplayRole:
case Qt::UserRole + 2:
return QVariant::fromValue(cpuUsage(index));
}
break;
case 2:
switch (role) {
case Qt::DisplayRole:
case Qt::UserRole + 3:
return QVariant::fromValue(memory(index));
}
break;
}
return QVariant();
}
@ -965,6 +975,7 @@ QVariant TimeSeries::data(const QModelIndex &index, int role) const
case Qt::UserRole + 2:
return QVariant::fromValue(time(index.row()));
}
break;
case 1:
switch (role) {
case Qt::DisplayRole:
@ -972,6 +983,7 @@ QVariant TimeSeries::data(const QModelIndex &index, int role) const
case Qt::UserRole + 1:
return QVariant::fromValue(sin(index.row()));
}
break;
case 2:
switch (role) {
case Qt::DisplayRole:
@ -979,6 +991,7 @@ QVariant TimeSeries::data(const QModelIndex &index, int role) const
case Qt::UserRole + 0:
return QVariant::fromValue(cos(index.row()));
}
break;
}
return QVariant();
}

View File

@ -483,7 +483,7 @@ Qt::ItemFlags %1::flags(const QModelIndex &i) const
cpp << QString(" return QVariant::fromValue(%1(index%2));\n").arg(ip.name, ii);
}
}
cpp << " }\n";
cpp << " }\n break;\n";
}
cpp << " }\n return QVariant();\n}\n\n";
cpp << "int " << o.name << "::role(const char* name) const {\n";

View File

@ -151,6 +151,7 @@ QVariant NoRole::data(const QModelIndex &index, int role) const
case Qt::UserRole + 1:
return QVariant::fromValue(userName(index.row()));
}
break;
}
return QVariant();
}
@ -327,6 +328,7 @@ QVariant Persons::data(const QModelIndex &index, int role) const
case Qt::UserRole + 0:
return QVariant::fromValue(userName(index.row()));
}
break;
}
return QVariant();
}

View File

@ -482,6 +482,7 @@ QVariant List::data(const QModelIndex &index, int role) const
case Qt::UserRole + 15:
return QVariant::fromValue(u8(index.row()));
}
break;
}
return QVariant();
}

View File

@ -179,6 +179,7 @@ QVariant Persons::data(const QModelIndex &index, int role) const
case Qt::UserRole + 0:
return QVariant::fromValue(userName(index));
}
break;
}
return QVariant();
}