1
0
Fork 0
forked from blue/squawk

cleanup some warnings suppression

This commit is contained in:
Blue 2023-08-15 12:28:25 -03:00
parent 5fbb03fc46
commit 23ec80ccba
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
26 changed files with 630 additions and 924 deletions

View file

@ -19,6 +19,7 @@
#include "phones.h"
#include "shared/icons.h"
#include "shared/defines.h"
#include <QCoreApplication>
Models::Phones::Phones(bool p_edit, QObject* parent):
@ -27,10 +28,14 @@ Models::Phones::Phones(bool p_edit, QObject* parent):
deque() {}
int Models::Phones::columnCount(const QModelIndex& parent) const {
return 4;}
SHARED_UNUSED(parent);
return 4;
}
int Models::Phones::rowCount(const QModelIndex& parent) const {
return deque.size();}
SHARED_UNUSED(parent);
return deque.size();
}
void Models::Phones::revertPreferred(quint32 row) {
setData(createIndex(row, 3), !isPreferred(row));
@ -77,9 +82,9 @@ QVariant Models::Phones::data(const QModelIndex& index, int role) const {
case Qt::DisplayRole:
return QVariant();
case Qt::DecorationRole:
if (deque[index.row()].prefered) {
if (deque[index.row()].prefered)
return Shared::icon("favorite", false);
}
return QVariant();
default:
return QVariant();
@ -101,9 +106,9 @@ QModelIndex Models::Phones::addNewEmptyLine() {
Qt::ItemFlags Models::Phones::flags(const QModelIndex& index) const {
Qt::ItemFlags f = QAbstractTableModel::flags(index);
if (edit && index.column() != 3) {
if (edit && index.column() != 3)
f = Qt::ItemIsEditable | f;
}
return f;
}
@ -139,25 +144,22 @@ bool Models::Phones::dropPrefered() {
}
void Models::Phones::getPhones(std::deque<Shared::VCard::Phone>& phones) const {
for (const Shared::VCard::Phone& my : deque) {
for (const Shared::VCard::Phone& my : deque)
phones.emplace_back(my);
}
}
bool Models::Phones::isPreferred(quint32 row) const {
if (row < deque.size()) {
if (row < deque.size())
return deque[row].prefered;
} else {
else
return false;
}
}
void Models::Phones::removeLines(quint32 index, quint32 count) {
if (index < deque.size()) {
quint32 maxCount = deque.size() - index;
if (count > maxCount) {
if (count > maxCount)
count = maxCount;
}
if (count > 0) {
beginRemoveRows(QModelIndex(), index, index + count - 1);
@ -178,17 +180,17 @@ bool Models::Phones::setData(const QModelIndex& index, const QVariant& value, in
return true;
case 1: {
quint8 newRole = value.toUInt();
if (newRole > Shared::VCard::Phone::work) {
if (newRole > Shared::VCard::Phone::work)
return false;
}
item.role = static_cast<Shared::VCard::Phone::Role>(newRole);
return true;
}
case 2: {
quint8 newType = value.toUInt();
if (newType > Shared::VCard::Phone::other) {
if (newType > Shared::VCard::Phone::other)
return false;
}
item.type = static_cast<Shared::VCard::Phone::Type>(newType);
return true;
}
@ -209,15 +211,15 @@ bool Models::Phones::setData(const QModelIndex& index, const QVariant& value, in
}
void Models::Phones::setPhones(const std::deque<Shared::VCard::Phone>& phones) {
if (deque.size() > 0) {
if (deque.size() > 0)
removeLines(0, deque.size());
}
if (phones.size() > 0) {
beginInsertRows(QModelIndex(), 0, phones.size() - 1);
for (const Shared::VCard::Phone& comming : phones) {
for (const Shared::VCard::Phone& comming : phones)
deque.emplace_back(comming);
}
endInsertRows();
}
}