Implementation, tests and first use of rangechecked_cast
This commit is contained in:
parent
c5f6da48ce
commit
f875f0f012
8 changed files with 61 additions and 5 deletions
|
|
@ -1,5 +1,5 @@
|
|||
#include "BackupFormatModel.h"
|
||||
|
||||
#include "rangechecked_cast.h"
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
|
|
@ -61,7 +61,7 @@ BackupFormatModel::BackupFormatModel(QObject *parent)
|
|||
|
||||
int BackupFormatModel::rowCount(const QModelIndex &) const
|
||||
{
|
||||
int size = g_BackupFormats.size();
|
||||
int size = rangechecked_cast<int>(g_BackupFormats.size());
|
||||
return size;
|
||||
}
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ QVariant BackupFormatModel::data(const QModelIndex &index, int role) const
|
|||
const int col = index.column();
|
||||
|
||||
if (role == Qt::DisplayRole) {
|
||||
const auto &item = g_BackupFormats.at(row);
|
||||
const auto &item = g_BackupFormats.at(rangechecked_cast<size_t>(row));
|
||||
switch (col) {
|
||||
case ColumnShort:
|
||||
result = item.shortFlag;
|
||||
|
|
@ -93,7 +93,7 @@ QVariant BackupFormatModel::data(const QModelIndex &index, int role) const
|
|||
}
|
||||
}
|
||||
else if (role == Qt::ToolTipRole) {
|
||||
const auto &item = g_BackupFormats.at(row);
|
||||
const auto &item = g_BackupFormats.at(rangechecked_cast<size_t>(row));
|
||||
result = item.description;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue