Commit f8141321 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Modernize code (using auto)

parent 70639649
Pipeline #39365 passed with stage
in 8 minutes and 9 seconds
......@@ -236,7 +236,7 @@ int LdapOperation::LdapOperationPrivate::bind(const QByteArray &creds, SASL_Call
if (server.auth() == LdapServer::SASL) {
#if !defined(HAVE_WINLDAP_H)
sasl_conn_t *saslconn = (sasl_conn_t *)mConnection->saslHandle();
auto *saslconn = (sasl_conn_t *)mConnection->saslHandle();
sasl_interact_t *client_interact = nullptr;
const char *out = nullptr;
uint outlen;
......@@ -579,7 +579,7 @@ static void addModOp(LDAPMod ***pmods, int mod_type, const QString &attr, const
static void addControlOp(LDAPControl ***pctrls, const QString &oid, const QByteArray &value, bool critical)
{
LDAPControl **ctrls;
LDAPControl *ctrl = (LDAPControl *)malloc(sizeof(LDAPControl));
auto *ctrl = (LDAPControl *)malloc(sizeof(LDAPControl));
ctrls = *pctrls;
......
......@@ -62,7 +62,7 @@ AddHostDialog::AddHostDialog(KLDAP::LdapServer *server, QWidget *parent)
, d(new KLDAP::AddHostDialogPrivate(this))
{
setWindowTitle(i18nc("@title:window", "Add Host"));
QVBoxLayout *mainLayout = new QVBoxLayout(this);
auto *mainLayout = new QVBoxLayout(this);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
d->mOkButton = buttonBox->button(QDialogButtonBox::Ok);
d->mOkButton->setDefault(true);
......@@ -76,7 +76,7 @@ AddHostDialog::AddHostDialog(KLDAP::LdapServer *server, QWidget *parent)
QWidget *page = new QWidget(this);
mainLayout->addWidget(page);
mainLayout->addWidget(buttonBox);
QHBoxLayout *layout = new QHBoxLayout(page);
auto *layout = new QHBoxLayout(page);
layout->setContentsMargins(0, 0, 0, 0);
d->mCfg = new KLDAP::LdapConfigWidget(
......
......@@ -162,7 +162,7 @@ void LdapClientSearch::Private::readConfig()
mNoLDAPLookup = true;
} else {
for (int j = 0; j < numHosts; ++j) {
LdapClient *ldapClient = new LdapClient(j, q);
auto *ldapClient = new LdapClient(j, q);
KLDAP::LdapServer server;
mClientSearchConfig->readConfig(server, config, j, true);
if (!server.host().isEmpty()) {
......
......@@ -96,7 +96,7 @@ void LdapConfigureWidget::slotSelectionChanged(QListWidgetItem *item)
void LdapConfigureWidget::slotItemClicked(QListWidgetItem *item)
{
LDAPItem *ldapItem = dynamic_cast<LDAPItem *>(item);
auto *ldapItem = dynamic_cast<LDAPItem *>(item);
if (!ldapItem) {
return;
}
......@@ -121,7 +121,7 @@ void LdapConfigureWidget::slotAddHost()
void LdapConfigureWidget::slotEditHost()
{
LDAPItem *item = dynamic_cast<LDAPItem *>(mHostListView->currentItem());
auto *item = dynamic_cast<LDAPItem *>(mHostListView->currentItem());
if (!item) {
return;
}
......@@ -143,7 +143,7 @@ void LdapConfigureWidget::slotRemoveHost()
if (!item) {
return;
}
LDAPItem *ldapItem = dynamic_cast<LDAPItem *>(item);
auto *ldapItem = dynamic_cast<LDAPItem *>(item);
if (KMessageBox::No == KMessageBox::questionYesNo(this, i18n("Do you want to remove setting for host \"%1\"?", ldapItem->server().host()), i18n("Remove Host"))) {
return;
}
......@@ -179,7 +179,7 @@ void LdapConfigureWidget::slotMoveUp()
return;
}
LDAPItem *above = static_cast<LDAPItem *>(mHostListView->item(mHostListView->row(item) - 1));
auto *above = static_cast<LDAPItem *>(mHostListView->item(mHostListView->row(item) - 1));
if (!above) {
return;
}
......@@ -204,7 +204,7 @@ void LdapConfigureWidget::slotMoveDown()
return;
}
LDAPItem *below = static_cast<LDAPItem *>(mHostListView->item(mHostListView->row(item) + 1));
auto *below = static_cast<LDAPItem *>(mHostListView->item(mHostListView->row(item) + 1));
if (!below) {
return;
}
......@@ -227,7 +227,7 @@ void LdapConfigureWidget::load()
for (int i = 0; i < count; ++i) {
KLDAP::LdapServer server;
mClientSearchConfig->readConfig(server, group, i, true);
LDAPItem *item = new LDAPItem(mHostListView, server, true);
auto *item = new LDAPItem(mHostListView, server, true);
item->setCheckState(Qt::Checked);
}
......@@ -252,7 +252,7 @@ void LdapConfigureWidget::save()
int selected = 0;
int unselected = 0;
for (int i = 0; i < mHostListView->count(); ++i) {
LDAPItem *item = dynamic_cast<LDAPItem *>(mHostListView->item(i));
auto *item = dynamic_cast<LDAPItem *>(mHostListView->item(i));
if (!item) {
continue;
}
......@@ -276,13 +276,13 @@ void LdapConfigureWidget::save()
void LdapConfigureWidget::initGUI()
{
QVBoxLayout *layout = new QVBoxLayout(this);
auto *layout = new QVBoxLayout(this);
layout->setObjectName(QStringLiteral("layout"));
layout->setContentsMargins(0, 0, 0, 0);
QGroupBox *groupBox = new QGroupBox(i18n("LDAP Servers"));
layout->addWidget(groupBox);
QVBoxLayout *mainLayout = new QVBoxLayout;
auto *mainLayout = new QVBoxLayout;
mainLayout->setObjectName(QStringLiteral("mainlayout"));
groupBox->setLayout(mainLayout);
......@@ -293,7 +293,7 @@ void LdapConfigureWidget::initGUI()
QWidget *hBox = new QWidget(this);
mainLayout->addWidget(hBox);
QHBoxLayout *hBoxHBoxLayout = new QHBoxLayout(hBox);
auto *hBoxHBoxLayout = new QHBoxLayout(hBox);
hBoxHBoxLayout->setContentsMargins(0, 0, 0, 0);
hBoxHBoxLayout->setSpacing(6);
// Contents of the hbox: listview and up/down buttons on the right (vbox)
......@@ -302,7 +302,7 @@ void LdapConfigureWidget::initGUI()
mHostListView->setSortingEnabled(false);
QWidget *upDownBox = new QWidget(hBox);
QVBoxLayout *upDownBoxVBoxLayout = new QVBoxLayout(upDownBox);
auto *upDownBoxVBoxLayout = new QVBoxLayout(upDownBox);
upDownBoxVBoxLayout->setContentsMargins(0, 0, 0, 0);
hBoxHBoxLayout->addWidget(upDownBox);
upDownBoxVBoxLayout->setSpacing(6);
......@@ -320,7 +320,7 @@ void LdapConfigureWidget::initGUI()
upDownBoxVBoxLayout->addWidget(spacer);
upDownBoxVBoxLayout->setStretchFactor(spacer, 100);
QDialogButtonBox *buttons = new QDialogButtonBox(this);
auto *buttons = new QDialogButtonBox(this);
QPushButton *add = buttons->addButton(i18n("&Add Host..."),
QDialogButtonBox::ActionRole);
connect(add, &QPushButton::clicked, this, &LdapConfigureWidget::slotAddHost);
......
......@@ -249,7 +249,7 @@ void LdapConfigWidget::Private::initWidget()
if (mFeatures & W_SECBOX) {
QGroupBox *btgroup = new QGroupBox(i18n("Security"), mParent);
QHBoxLayout *hbox = new QHBoxLayout;
auto *hbox = new QHBoxLayout;
btgroup->setLayout(hbox);
mSecNo = new QRadioButton(i18nc("@option:radio set no security", "No"), btgroup);
mSecNo->setObjectName(QStringLiteral("kcfg_ldapnosec"));
......@@ -279,9 +279,9 @@ void LdapConfigWidget::Private::initWidget()
if (mFeatures & W_AUTHBOX) {
QGroupBox *authbox
= new QGroupBox(i18n("Authentication"), mParent);
QVBoxLayout *vbox = new QVBoxLayout;
auto *vbox = new QVBoxLayout;
authbox->setLayout(vbox);
QHBoxLayout *hbox = new QHBoxLayout;
auto *hbox = new QHBoxLayout;
vbox->addLayout(hbox);
mAnonymous
......
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