Commit 74474f5b authored by Edric Milaret's avatar Edric Milaret

code cleanup

Using clang static analyser and cppcheck

Change-Id: Iff54cab58fb8d05a55f9fe32edffc3af8bcee7bd
parent f8048cfd
......@@ -36,7 +36,7 @@ namespace Ui {
class NotCurrentProxyModel : public QSortFilterProxyModel
{
public:
NotCurrentProxyModel(QAbstractItemModel* parent) : QSortFilterProxyModel(parent)
explicit NotCurrentProxyModel(QAbstractItemModel* parent) : QSortFilterProxyModel(parent)
{
setSourceModel(parent);
}
......
......@@ -331,21 +331,17 @@ CallWidget::findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec
Q_UNUSED(vec)
auto a_count = AccountModel::instance().rowCount();
auto found = false;
for (int i = 0; i < a_count; ++i) {
auto idx = AccountModel::instance().index(i, 0);
auto protocol = idx.data(static_cast<int>(Account::Role::Proto));
if ((Account::Protocol)protocol.toUInt() == Account::Protocol::RING) {
if (static_cast<Account::Protocol>(protocol.toUInt()) == Account::Protocol::RING) {
auto username = idx.data(static_cast<int>(Account::Role::Username));
ui->ringIdLabel->setText(username.toString());
found = true;
setupQRCode();
return;
}
}
if (not found) {
ui->ringIdLabel->setText(tr("NO RING ACCOUNT FOUND"));
}
ui->ringIdLabel->setText(tr("NO RING ACCOUNT FOUND"));
}
void CallWidget::setupQRCode()
......@@ -369,10 +365,10 @@ void CallWidget::setupQRCode()
painter.setPen(QPen(Qt::black, 0.1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
painter.setBrush(Qt::black);
painter.fillRect(QRect(0, 0, qrwidth, qrwidth), Qt::white);
unsigned char *row, *p;
unsigned char* p;
p = rcode->data;
for(int y = 0; y < rcode->width; y++) {
row = (p + (y * rcode->width));
unsigned char* row = (p + (y * rcode->width));
for(int x = 0; x < rcode->width; x++) {
if(*(row + x) & 0x1) {
painter.drawRect(margin + x, margin + y, 1, 1);
......@@ -389,28 +385,23 @@ void
CallWidget::findRingAccount()
{
auto a_count = AccountModel::instance().rowCount();
auto found = false;
for (int i = 0; i < a_count; ++i) {
auto idx = AccountModel::instance().index(i, 0);
auto protocol = idx.data(static_cast<int>(Account::Role::Proto));
if ((Account::Protocol)protocol.toUInt() == Account::Protocol::RING) {
if (static_cast<Account::Protocol>(protocol.toUInt()) == Account::Protocol::RING) {
auto account = AccountModel::instance().getAccountByModelIndex(idx);
if (account->displayName().isEmpty())
account->displayName() = account->alias();
auto username = account->username();
ui->ringIdLabel->setText(username);
setupQRCode();
found = true;
return;
}
}
if (!found) {
ui->ringIdLabel->setText(tr("NO RING ACCOUNT FOUND"));
auto wizardDialog = new WizardDialog();
wizardDialog->exec();
delete wizardDialog;
}
ui->ringIdLabel->setText(tr("NO RING ACCOUNT FOUND"));
auto wizardDialog = new WizardDialog();
wizardDialog->exec();
delete wizardDialog;
}
void
......@@ -482,12 +473,11 @@ CallWidget::on_contactView_doubleClicked(const QModelIndex& index)
if (not index.isValid())
return;
ContactMethod* uri = nullptr;
auto var = index.child(0,0).data(
static_cast<int>(Person::Role::Object));
if (var.isValid()) {
Person* person = var.value<Person*>();
ContactMethod* uri = nullptr;
if (person->phoneNumbers().size() == 1) {
uri = person->phoneNumbers().at(0);
} else if (person->phoneNumbers().size() > 1) {
......
......@@ -39,7 +39,7 @@ ContactDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, opt.widget);
QRect rect = opt.rect;
QPalette::ColorGroup cg = opt.state & QStyle::State_Enabled ?
QPalette::ColorGroup cg = (opt.state & QStyle::State_Enabled) ?
QPalette::Normal : QPalette::Disabled;
if (cg == QPalette::Normal && !(opt.state & QStyle::State_Active))
cg = QPalette::Inactive;
......
......@@ -31,7 +31,7 @@ class ContactPicker;
class OnlyPersonProxyModel : public QSortFilterProxyModel
{
public:
OnlyPersonProxyModel(QAbstractItemModel* parent) : QSortFilterProxyModel(parent)
explicit OnlyPersonProxyModel(QAbstractItemModel* parent) : QSortFilterProxyModel(parent)
{
setSourceModel(parent);
}
......
......@@ -43,7 +43,7 @@ HistoryDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, opt.widget);
auto rect = opt.rect;
QPalette::ColorGroup cg = opt.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled;
QPalette::ColorGroup cg = (opt.state & QStyle::State_Enabled) ? QPalette::Normal : QPalette::Disabled;
if (cg == QPalette::Normal && !(opt.state & QStyle::State_Active))
cg = QPalette::Inactive;
painter->setPen(opt.palette.color(cg, QPalette::Text));
......
......@@ -67,10 +67,6 @@ ImDelegate::paint(QPainter* painter,
auto msg = index.data(Qt::DisplayRole).toString();
opt.text.clear();
QStyle* style = opt.widget ? opt.widget->style() : QApplication::style();
QPalette::ColorGroup cg = opt.state & QStyle::State_Enabled
? QPalette::Normal : QPalette::Disabled;
if (cg == QPalette::Normal && !(opt.state & QStyle::State_Active))
cg = QPalette::Inactive;
auto dir = index.data(static_cast<int>(Media::TextRecording::Role::Direction))
.value<Media::Media::Direction>() == Media::Media::Direction::IN
......
......@@ -32,7 +32,7 @@ class NavWidget : public QWidget
Q_OBJECT
public:
NavWidget(QWidget* parent = 0);
explicit NavWidget(QWidget* parent = 0);
~NavWidget();
signals:
......
......@@ -251,7 +251,7 @@ WindowsContactBackend::getPersonFromContactFile(const QDir& contactDir,
QFile contactFile(contactFilePath);
if (contactFile.open(QIODevice::ReadOnly)) {
QXmlStreamReader reader;
Person *p = new Person(this);
Person* p = new Person(this);
QVector<ContactMethod*> contactMethod;
reader.setDevice(&contactFile);
while (!reader.atEnd()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment