Skip to content

Commit 4c8e2a3

Browse files
committed
Simplify code
1 parent 8be2c54 commit 4c8e2a3

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/DbStructureModel.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,18 @@ QVariant DbStructureModel::data(const QModelIndex& index, int role) const
3737
QTreeWidgetItem* item = static_cast<QTreeWidgetItem*>(index.internalPointer());
3838

3939
// Depending on the role either return the text or the icon
40-
if(role == Qt::DisplayRole)
40+
switch(role)
41+
{
42+
case Qt::DisplayRole:
4143
return Settings::getSettingsValue("db", "hideschemalinebreaks").toBool() ? item->text(index.column()).replace("\n", " ").simplified() : item->text(index.column());
42-
else if(role == Qt::EditRole)
44+
case Qt::EditRole:
45+
case Qt::ToolTipRole: // Don't modify the text when it's supposed to be shown in a tooltip
4346
return item->text(index.column());
44-
else if(role == Qt::ToolTipRole)
45-
return item->text(index.column()); // Don't modify the text when it's supposed to be shown in a tooltip
46-
else if(role == Qt::DecorationRole)
47+
case Qt::DecorationRole:
4748
return item->icon(index.column());
48-
else
49+
default:
4950
return QVariant();
51+
}
5052
}
5153

5254
Qt::ItemFlags DbStructureModel::flags(const QModelIndex &index) const

0 commit comments

Comments
 (0)