Skip to content

Commit

Permalink
Fix clang-tidy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Fanda Vacek committed Mar 6, 2024
1 parent 76601ce commit 16ca9af
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 25 deletions.
8 changes: 4 additions & 4 deletions shvspy/src/dlgaddeditmount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void DlgAddEditMount::accept()
void DlgAddEditMount::checkExistingMountId(std::function<void(bool, bool)> callback)
{
int rqid = m_rpcConnection->nextRequestId();
shv::iotqt::rpc::RpcResponseCallBack *cb = new shv::iotqt::rpc::RpcResponseCallBack(m_rpcConnection, rqid, this);
auto *cb = new shv::iotqt::rpc::RpcResponseCallBack(m_rpcConnection, rqid, this);

cb->start(this, [this, callback](const shv::chainpack::RpcResponse &response) {
if (response.isSuccess()) {
Expand Down Expand Up @@ -103,7 +103,7 @@ void DlgAddEditMount::callSetMountSettings()
setStatusText(tr("Error: device id is empty."));
return;
}
else if (ui->leMountPoint->text().trimmed().isEmpty()){
if (ui->leMountPoint->text().trimmed().isEmpty()) {
setStatusText(tr("Error: mount point is empty."));
return;
}
Expand All @@ -112,7 +112,7 @@ void DlgAddEditMount::callSetMountSettings()
return;

int rqid = m_rpcConnection->nextRequestId();
shv::iotqt::rpc::RpcResponseCallBack *cb = new shv::iotqt::rpc::RpcResponseCallBack(m_rpcConnection, rqid, this);
auto *cb = new shv::iotqt::rpc::RpcResponseCallBack(m_rpcConnection, rqid, this);

cb->start(this, [this](const shv::chainpack::RpcResponse &response) {
if (response.isValid()){
Expand Down Expand Up @@ -142,7 +142,7 @@ void DlgAddEditMount::callGetMountSettings()
}

int rqid = m_rpcConnection->nextRequestId();
shv::iotqt::rpc::RpcResponseCallBack *cb = new shv::iotqt::rpc::RpcResponseCallBack(m_rpcConnection, rqid, this);
auto *cb = new shv::iotqt::rpc::RpcResponseCallBack(m_rpcConnection, rqid, this);

cb->start(this, [this](const shv::chainpack::RpcResponse &response) {
if (response.isValid()){
Expand Down
12 changes: 6 additions & 6 deletions shvspy/src/dlgaddeditrole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void DlgAddEditRole::accept()
QMessageBox::critical(this, tr("Invalid data"), tr("Role name is empty."));
return;
}
else if (!m_accessModel.isRulesValid()){
if (!m_accessModel.isRulesValid()){
QMessageBox::critical(this, tr("Invalid data"), tr("Access rules are invalid."));
return;
}
Expand Down Expand Up @@ -98,7 +98,7 @@ void DlgAddEditRole::accept()
void DlgAddEditRole::checkExistingRole(std::function<void(bool, bool)> callback)
{
int rqid = m_rpcConnection->nextRequestId();
shv::iotqt::rpc::RpcResponseCallBack *cb = new shv::iotqt::rpc::RpcResponseCallBack(m_rpcConnection, rqid, this);
auto *cb = new shv::iotqt::rpc::RpcResponseCallBack(m_rpcConnection, rqid, this);

cb->start(this, [this, callback](const shv::chainpack::RpcResponse &response) {
if (response.isSuccess()) {
Expand Down Expand Up @@ -133,7 +133,7 @@ void DlgAddEditRole::callSetRoleSettings()
return;

int rqid = m_rpcConnection->nextRequestId();
shv::iotqt::rpc::RpcResponseCallBack *cb = new shv::iotqt::rpc::RpcResponseCallBack(m_rpcConnection, rqid, this);
auto *cb = new shv::iotqt::rpc::RpcResponseCallBack(m_rpcConnection, rqid, this);

cb->start(this, [this](const shv::chainpack::RpcResponse &response) {
if (response.isValid()){
Expand Down Expand Up @@ -168,7 +168,7 @@ void DlgAddEditRole::callGetRoleSettings()
}

int rqid = m_rpcConnection->nextRequestId();
shv::iotqt::rpc::RpcResponseCallBack *cb = new shv::iotqt::rpc::RpcResponseCallBack(m_rpcConnection, rqid, this);
auto *cb = new shv::iotqt::rpc::RpcResponseCallBack(m_rpcConnection, rqid, this);

cb->start(this, [this](const shv::chainpack::RpcResponse &response) {
if (response.isValid()){
Expand Down Expand Up @@ -206,7 +206,7 @@ void DlgAddEditRole::callGetAccessRulesForRole()
setStatusText(tr("Getting access rules ..."));

int rqid = m_rpcConnection->nextRequestId();
shv::iotqt::rpc::RpcResponseCallBack *cb = new shv::iotqt::rpc::RpcResponseCallBack(m_rpcConnection, rqid, this);
auto *cb = new shv::iotqt::rpc::RpcResponseCallBack(m_rpcConnection, rqid, this);

cb->start(this, [this](const shv::chainpack::RpcResponse &response) {
if(response.isValid()){
Expand Down Expand Up @@ -237,7 +237,7 @@ void DlgAddEditRole::callSetAccessRulesForRole()
setStatusText(tr("Updating access rules ..."));

int rqid = m_rpcConnection->nextRequestId();
shv::iotqt::rpc::RpcResponseCallBack *cb = new shv::iotqt::rpc::RpcResponseCallBack(m_rpcConnection, rqid, this);
auto *cb = new shv::iotqt::rpc::RpcResponseCallBack(m_rpcConnection, rqid, this);

cb->start(this, [this](const shv::chainpack::RpcResponse &response) {
if(response.isValid()){
Expand Down
2 changes: 1 addition & 1 deletion shvspy/src/dlgcallshvmethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void DlgCallShvMethod::callShvMethod()
return;
}
int rq_id = m_connection->nextRequestId();
shv::iotqt::rpc::RpcResponseCallBack *cb = new shv::iotqt::rpc::RpcResponseCallBack(m_connection, rq_id, this);
auto *cb = new shv::iotqt::rpc::RpcResponseCallBack(m_connection, rq_id, this);
cb->start(this, [this](const cp::RpcResponse &resp) {
if(resp.isValid()) {
if(resp.isError())
Expand Down
23 changes: 10 additions & 13 deletions shvspy/src/rolestreemodel/rolestreemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void RolesTreeModel::load(shv::iotqt::rpc::ClientConnection *rpc_connection, con
return;

int rqid = rpc_connection->nextRequestId();
shv::iotqt::rpc::RpcResponseCallBack *cb = new shv::iotqt::rpc::RpcResponseCallBack(rpc_connection, rqid, this);
auto *cb = new shv::iotqt::rpc::RpcResponseCallBack(rpc_connection, rqid, this);

cb->start(this, [this, rpc_connection, acl_etc_roles_node_path](const shv::chainpack::RpcResponse &response) {
if(response.isValid()){
Expand Down Expand Up @@ -77,7 +77,7 @@ void RolesTreeModel::loadRoles(shv::iotqt::rpc::ClientConnection *rpc_connection
int rqid = rpc_connection->nextRequestId();
std::string role_name = not_loaded_roles.takeFirst();

shv::iotqt::rpc::RpcResponseCallBack *cb = new shv::iotqt::rpc::RpcResponseCallBack(rpc_connection, rqid, this);
auto *cb = new shv::iotqt::rpc::RpcResponseCallBack(rpc_connection, rqid, this);
std::string role_path = acl_etc_roles_node_path + "/" + role_name;

cb->start(this, [this, rpc_connection, acl_etc_roles_node_path, role_path, role_name, not_loaded_roles](const shv::chainpack::RpcResponse &response) {
Expand All @@ -104,8 +104,7 @@ void RolesTreeModel::loadRoles(shv::iotqt::rpc::ClientConnection *rpc_connection

void RolesTreeModel::setSelectedRoles(const std::vector<std::string> &roles)
{
for (size_t r = 0; r < roles.size(); r++){
std::string role = roles.at(r);
for (const auto &role : roles) {
QStandardItem *root_item = invisibleRootItem();

for(int i = 0; i < root_item->rowCount(); i++) {
Expand Down Expand Up @@ -148,7 +147,7 @@ void RolesTreeModel::generateTree()

for (const QString &role_name: m_shvRoles.keys()){
QList<QStandardItem *> row;
QStandardItem *it = new QStandardItem(role_name);
auto *it = new QStandardItem(role_name);
it->setData(role_name, NameRole);
it->setCheckable(true);
it->setFlags(it->flags() & ~Qt::ItemIsEditable);
Expand All @@ -158,8 +157,8 @@ void RolesTreeModel::generateTree()
std::vector<std::string> sub_roles = m_shvRoles.value(role_name);
QSet<QString> created_roles{role_name};

for (size_t i = 0; i < sub_roles.size(); i++){
generateSubTree(it, QString::fromStdString(sub_roles.at(i)), created_roles);
for (const auto &subrole : sub_roles) {
generateSubTree(it, QString::fromStdString(subrole), created_roles);
}
}
}
Expand All @@ -172,20 +171,18 @@ void RolesTreeModel::generateSubTree(QStandardItem *parent_item, const QString &
}

QList<QStandardItem *> row;
QStandardItem *it = new QStandardItem(role);
auto *it = new QStandardItem(role);
it->setData(role, NameRole);
it->setFlags(it->flags() & ~Qt::ItemIsEditable);
row << it;
parent_item->appendRow(row);

std::vector<std::string> subRoles = m_shvRoles.value(role);
std::vector<std::string> sub_roles = m_shvRoles.value(role);

for (size_t j = 0; j < subRoles.size(); j++){
QString sub_role = QString::fromStdString(subRoles.at(j));
for (const auto &sub_role : sub_roles) {
QSet<QString> cr = created_roles;
cr += role;

generateSubTree(it, sub_role, cr);
generateSubTree(it, QString::fromStdString(sub_role), cr);
}
}

Expand Down

0 comments on commit 16ca9af

Please sign in to comment.