mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
fixed warning + added more checks to SignalVectorModel
This commit is contained in:
parent
2a8c5e654f
commit
2f39f4246c
1 changed files with 23 additions and 5 deletions
|
@ -102,19 +102,26 @@ public:
|
|||
|
||||
int rowCount(const QModelIndex &parent) const override
|
||||
{
|
||||
(void)parent;
|
||||
|
||||
return this->rows_.size();
|
||||
}
|
||||
|
||||
int columnCount(const QModelIndex &parent) const override
|
||||
{
|
||||
(void)parent;
|
||||
|
||||
return this->columnCount_;
|
||||
}
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override
|
||||
{
|
||||
int row = index.row(), column = index.column();
|
||||
assert(row >= 0 && row < this->rows_.size() && column >= 0 &&
|
||||
column < this->columnCount_);
|
||||
if (row < 0 || column < 0 || row >= this->rows_.size() ||
|
||||
column >= this->columnCount_)
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
return rows_[row].items[column]->data(role);
|
||||
}
|
||||
|
@ -123,8 +130,11 @@ public:
|
|||
int role) override
|
||||
{
|
||||
int row = index.row(), column = index.column();
|
||||
assert(row >= 0 && row < this->rows_.size() && column >= 0 &&
|
||||
column < this->columnCount_);
|
||||
if (row < 0 || column < 0 || row >= this->rows_.size() ||
|
||||
column >= this->columnCount_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Row &rowItem = this->rows_[row];
|
||||
|
||||
|
@ -186,7 +196,9 @@ public:
|
|||
{
|
||||
int row = index.row(), column = index.column();
|
||||
|
||||
if (row < 0 || column < 0) {
|
||||
if (row < 0 || column < 0 || row >= this->rows_.size() ||
|
||||
column >= this->columnCount_)
|
||||
{
|
||||
return Qt::NoItemFlags;
|
||||
}
|
||||
|
||||
|
@ -212,6 +224,8 @@ public:
|
|||
|
||||
bool removeRows(int row, int count, const QModelIndex &parent) override
|
||||
{
|
||||
(void)parent;
|
||||
|
||||
if (count != 1)
|
||||
{
|
||||
return false;
|
||||
|
@ -242,18 +256,22 @@ protected:
|
|||
std::vector<QStandardItem *> &row,
|
||||
int proposedIndex)
|
||||
{
|
||||
(void)item, (void)row;
|
||||
|
||||
return proposedIndex;
|
||||
}
|
||||
|
||||
virtual void afterRemoved(const TVectorItem &item,
|
||||
std::vector<QStandardItem *> &row, int index)
|
||||
{
|
||||
(void)item, (void)row, (void)index;
|
||||
}
|
||||
|
||||
virtual void customRowSetData(const std::vector<QStandardItem *> &row,
|
||||
int column, const QVariant &value, int role,
|
||||
int rowIndex)
|
||||
{
|
||||
(void)row, (void)column, (void)value, (void)role, (void)rowIndex;
|
||||
}
|
||||
|
||||
void insertCustomRow(std::vector<QStandardItem *> row, int index)
|
||||
|
|
Loading…
Reference in a new issue