diff --git a/demo/src/Bindings.cpp b/demo/src/Bindings.cpp index 562ff65..6ff92fd 100644 --- a/demo/src/Bindings.cpp +++ b/demo/src/Bindings.cpp @@ -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(); } diff --git a/src/cpp.cpp b/src/cpp.cpp index 34f660d..3e09321 100644 --- a/src/cpp.cpp +++ b/src/cpp.cpp @@ -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"; diff --git a/tests/test_list_rust.cpp b/tests/test_list_rust.cpp index 758e5fd..96ce2ff 100644 --- a/tests/test_list_rust.cpp +++ b/tests/test_list_rust.cpp @@ -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(); } diff --git a/tests/test_list_types_rust.cpp b/tests/test_list_types_rust.cpp index d202492..5c53df4 100644 --- a/tests/test_list_types_rust.cpp +++ b/tests/test_list_types_rust.cpp @@ -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(); } diff --git a/tests/test_tree_rust.cpp b/tests/test_tree_rust.cpp index 4d747a5..375aa2d 100644 --- a/tests/test_tree_rust.cpp +++ b/tests/test_tree_rust.cpp @@ -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(); }