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 "emails.h"
#include "shared/icons.h"
#include "shared/defines.h"
#include <QCoreApplication>
Models::EMails::EMails(bool p_edit, QObject* parent):
@ -27,10 +28,15 @@ Models::EMails::EMails(bool p_edit, QObject* parent):
deque() {}
int Models::EMails::columnCount(const QModelIndex& parent) const {
return 3;}
SHARED_UNUSED(parent);
return 3;
}
int Models::EMails::rowCount(const QModelIndex& parent) const {
return deque.size();}
SHARED_UNUSED(parent);
return deque.size();
}
void Models::EMails::revertPreferred(quint32 row) {
setData(createIndex(row, 2), !isPreferred(row));}
@ -83,9 +89,9 @@ QVariant Models::EMails::data(const QModelIndex& index, int role) const {
Qt::ItemFlags Models::EMails::flags(const QModelIndex& index) const {
Qt::ItemFlags f = QAbstractTableModel::flags(index);
if (edit && index.column() != 2) {
if (edit && index.column() != 2)
f = Qt::ItemIsEditable | f;
}
return f;
}
@ -114,9 +120,9 @@ bool Models::EMails::setData(const QModelIndex& index, const QVariant& value, in
return true;
case 1: {
quint8 newRole = value.toUInt();
if (newRole > Shared::VCard::Email::work) {
if (newRole > Shared::VCard::Email::work)
return false;
}
item.role = static_cast<Shared::VCard::Email::Role>(newRole);
return true;
}
@ -160,19 +166,17 @@ QModelIndex Models::EMails::addNewEmptyLine() {
}
bool Models::EMails::isPreferred(quint32 row) const {
if (row < deque.size()) {
if (row < deque.size())
return deque[row].prefered;
} else {
else
return false;
}
}
void Models::EMails::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);
@ -185,21 +189,19 @@ void Models::EMails::removeLines(quint32 index, quint32 count) {
}
void Models::EMails::getEmails(std::deque<Shared::VCard::Email>& emails) const {
for (const Shared::VCard::Email& my : deque) {
for (const Shared::VCard::Email& my : deque)
emails.emplace_back(my);
}
}
void Models::EMails::setEmails(const std::deque<Shared::VCard::Email>& emails) {
if (deque.size() > 0) {
if (deque.size() > 0)
removeLines(0, deque.size());
}
if (emails.size() > 0) {
beginInsertRows(QModelIndex(), 0, emails.size() - 1);
for (const Shared::VCard::Email& comming : emails) {
for (const Shared::VCard::Email& comming : emails)
deque.emplace_back(comming);
}
endInsertRows();
}
}

View file

@ -16,6 +16,8 @@
#include "keys.h"
#include "shared/defines.h"
const QHash<int, QByteArray> Models::Keys::roles = {
{Label, "label"},
{FingerPrint, "fingerPrint"},
@ -28,13 +30,11 @@ Models::Keys::Keys(QObject* parent):
modified() {}
Models::Keys::~Keys() {
for (Shared::KeyInfo* key : keys) {
for (Shared::KeyInfo* key : keys)
delete key;
}
for (std::pair<const int, Shared::KeyInfo*>& pair: modified) {
for (std::pair<const int, Shared::KeyInfo*>& pair: modified)
delete pair.second;
}
}
std::deque<Shared::KeyInfo> Models::Keys::modifiedKeys() const {
@ -92,15 +92,15 @@ QVariant Models::Keys::data(const QModelIndex& index, int role) const {
}
int Models::Keys::rowCount(const QModelIndex& parent) const {
SHARED_UNUSED(parent);
return keys.size();
}
QHash<int, QByteArray> Models::Keys::roleNames() const {return roles;}
QModelIndex Models::Keys::index(int row, int column, const QModelIndex& parent) const {
if (!hasIndex(row, column, parent)) {
if (!hasIndex(row, column, parent))
return QModelIndex();
}
return createIndex(row, column, keys[row]);
}

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();
}
}