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

Modernize code

parent f87b256d
Pipeline #60418 passed with stage
in 14 minutes and 31 seconds
......@@ -256,7 +256,7 @@ void CertifyCertificateCommand::Private::slotDialogRejected()
void CertifyCertificateCommand::Private::slotResult(const Error &err)
{
if (!err && !err.isCanceled() && dialog && dialog->exportableCertificationSelected() && dialog->sendToServer()) {
ExportOpenPGPCertsToServerCommand *const cmd = new ExportOpenPGPCertsToServerCommand(key());
auto const cmd = new ExportOpenPGPCertsToServerCommand(key());
cmd->start();
} else if (!err) {
information(i18n("Certification successful."),
......
......@@ -39,7 +39,7 @@ private:
return;
}
CertificateDetailsDialog *dlg = new CertificateDetailsDialog;
auto dlg = new CertificateDetailsDialog;
applyWindowID(dlg);
dlg->setAttribute(Qt::WA_DeleteOnClose);
connect(dlg, &QDialog::finished, q_func(), [this] (int) {
......
......@@ -311,12 +311,12 @@ void LookupCertificatesCommand::Private::slotImportRequested(const std::vector<K
setWaitForMoreJobs(true);
if (!pgp.empty())
startImport(OpenPGP, pgp,
i18nc("@title %1:\"OpenPGP\" or \"CMS\"",
i18nc(R"(@title %1:"OpenPGP" or "CMS")",
"%1 Certificate Server",
Formatting::displayName(OpenPGP)));
if (!cms.empty())
startImport(CMS, cms,
i18nc("@title %1:\"OpenPGP\" or \"CMS\"",
i18nc(R"(@title %1:"OpenPGP" or "CMS")",
"%1 Certificate Server",
Formatting::displayName(CMS)));
setWaitForMoreJobs(false);
......
......@@ -132,7 +132,7 @@ void RevokeCertificationCommand::Private::slotResult(const Error &err)
information(i18n("Revocation successful."),
i18n("Revocation Succeeded"));
if (dialog && dialog->sendToServer()) {
ExportOpenPGPCertsToServerCommand *const cmd = new ExportOpenPGPCertsToServerCommand(certificationTarget);
auto const cmd = new ExportOpenPGPCertsToServerCommand(certificationTarget);
cmd->start();
}
}
......
......@@ -48,7 +48,7 @@ private:
return;
}
SetInitialPinDialog *dlg = new SetInitialPinDialog;
auto dlg = new SetInitialPinDialog;
applyWindowID(dlg);
dlg->setAttribute(Qt::WA_DeleteOnClose);
dlg->setWindowTitle(i18nc("@title:window", "Set Initial Pin"));
......
......@@ -21,7 +21,7 @@ using namespace Kleo::Config;
AppearanceConfigurationPage::AppearanceConfigurationPage(QWidget *parent, const QVariantList &args)
: KCModule(parent, args)
{
QVBoxLayout *lay = new QVBoxLayout(this);
auto lay = new QVBoxLayout(this);
mWidget = new AppearanceConfigWidget(this);
lay->addWidget(mWidget);
......@@ -50,7 +50,7 @@ extern "C"
{
Q_DECL_EXPORT KCModule *create_kleopatra_config_appear(QWidget *parent = nullptr, const QVariantList &args = QVariantList())
{
AppearanceConfigurationPage *page =
auto page =
new AppearanceConfigurationPage(parent, args);
page->setObjectName(QStringLiteral("kleopatra_config_appear"));
return page;
......
......@@ -301,7 +301,7 @@ public:
l->setContentsMargins(0, 0, 0, 0);
}
QWidget *w = new QWidget;
auto w = new QWidget;
dnOrderWidget = Kleo::DNAttributeMapper::instance()->configWidget(w);
dnOrderWidget->setObjectName(QStringLiteral("dnOrderWidget"));
(new QVBoxLayout(w))->addWidget(dnOrderWidget);
......
......@@ -21,7 +21,7 @@ using namespace Kleo::Config;
CryptoOperationsConfigurationPage::CryptoOperationsConfigurationPage(QWidget *parent, const QVariantList &args)
: KCModule(parent, args)
{
QVBoxLayout *lay = new QVBoxLayout(this);
auto lay = new QVBoxLayout(this);
lay->setContentsMargins(0, 0, 0, 0);
mWidget = new CryptoOperationsConfigWidget(this);
lay->addWidget(mWidget);
......@@ -49,7 +49,7 @@ extern "C"
{
Q_DECL_EXPORT KCModule *create_kleopatra_config_cryptooperations(QWidget *parent = nullptr, const QVariantList &args = QVariantList())
{
CryptoOperationsConfigurationPage *page =
auto page =
new CryptoOperationsConfigurationPage(parent, args);
page->setObjectName(QStringLiteral("kleopatra_config_cryptooperations"));
return page;
......
......@@ -218,11 +218,11 @@ void CryptoOperationsConfigWidget::setupProfileGui(QBoxLayout *layout)
void CryptoOperationsConfigWidget::setupGui()
{
QVBoxLayout *baseLay = new QVBoxLayout(this);
auto baseLay = new QVBoxLayout(this);
baseLay->setContentsMargins(0, 0, 0, 0);
QGroupBox *mailGrp = new QGroupBox(i18n("EMail Operations"));
QVBoxLayout *mailGrpLayout = new QVBoxLayout;
auto mailGrp = new QGroupBox(i18n("EMail Operations"));
auto mailGrpLayout = new QVBoxLayout;
mQuickSignCB = new QCheckBox(i18n("Don't confirm signing certificate if there is only one valid certificate for the identity"));
mQuickEncryptCB = new QCheckBox(i18n("Don't confirm encryption certificates if there is exactly one valid certificate for each recipient"));
mailGrpLayout->addWidget(mQuickSignCB);
......@@ -230,9 +230,9 @@ void CryptoOperationsConfigWidget::setupGui()
mailGrp->setLayout(mailGrpLayout);
baseLay->addWidget(mailGrp);
QGroupBox *fileGrp = new QGroupBox(i18n("File Operations"));
QVBoxLayout *fileGrpLay = new QVBoxLayout;
mPGPFileExtCB = new QCheckBox(i18n("Create OpenPGP encrypted files with \".pgp\" file extensions instead of \".gpg\""));
auto fileGrp = new QGroupBox(i18n("File Operations"));
auto fileGrpLay = new QVBoxLayout;
mPGPFileExtCB = new QCheckBox(i18n(R"(Create OpenPGP encrypted files with ".pgp" file extensions instead of ".gpg")"));
mASCIIArmorCB = new QCheckBox(i18n("Create signed or encrypted files as text files."));
mASCIIArmorCB->setToolTip(i18nc("@info", "Set this option to encode encrypted or signed files as base64 encoded text. "
"So that they can be opened with an editor or sent in a mail body. "
......@@ -246,13 +246,13 @@ void CryptoOperationsConfigWidget::setupGui()
fileGrpLay->addWidget(mASCIIArmorCB);
fileGrpLay->addWidget(mTmpDirCB);
QGridLayout *comboLay = new QGridLayout;
QLabel *chkLabel = new QLabel(i18n("Checksum program to use when creating checksum files:"));
auto comboLay = new QGridLayout;
auto chkLabel = new QLabel(i18n("Checksum program to use when creating checksum files:"));
comboLay->addWidget(chkLabel, 0, 0);
mChecksumDefinitionCB = new QComboBox;
comboLay->addWidget(mChecksumDefinitionCB, 0, 1);
QLabel *archLabel = new QLabel(i18n("Archive command to use when archiving files:"));
auto archLabel = new QLabel(i18n("Archive command to use when archiving files:"));
comboLay->addWidget(archLabel, 1, 0);
mArchiveDefinitionCB = new QComboBox;
comboLay->addWidget(mArchiveDefinitionCB, 1, 1);
......@@ -372,7 +372,7 @@ void CryptoOperationsConfigWidget::save()
const int idx = mChecksumDefinitionCB->currentIndex();
if (idx >= 0) {
const std::shared_ptr<ChecksumDefinition> cd = qvariant_cast< std::shared_ptr<ChecksumDefinition> >(mChecksumDefinitionCB->itemData(idx));
const auto cd = qvariant_cast< std::shared_ptr<ChecksumDefinition> >(mChecksumDefinitionCB->itemData(idx));
ChecksumDefinition::setDefaultChecksumDefinition(cd);
}
......
......@@ -135,7 +135,7 @@ DirectoryServicesConfigurationPage::DirectoryServicesConfigurationPage(QWidget *
: KCModule(parent, args)
{
mConfig = QGpgME::cryptoConfig();
QGridLayout *glay = new QGridLayout(this);
auto glay = new QGridLayout(this);
glay->setContentsMargins(0, 0, 0, 0);
int row = 0;
......@@ -148,7 +148,7 @@ DirectoryServicesConfigurationPage::DirectoryServicesConfigurationPage(QWidget *
// LDAP timeout
++row;
QLabel *label = new QLabel(i18n("LDAP &timeout (minutes:seconds):"), this);
auto label = new QLabel(i18n("LDAP &timeout (minutes:seconds):"), this);
mTimeout = new QTimeEdit(this);
mTimeout->setDisplayFormat(QStringLiteral("mm:ss"));
connect(mTimeout, SIGNAL(timeChanged(QTime)), this, SLOT(changed()));
......@@ -204,9 +204,9 @@ void DirectoryServicesConfigurationPage::load()
mWidget->setX509ReadOnly(mX509ServicesEntry && mX509ServicesEntry->isReadOnly());
{
auto *const newEntry = configEntry(s_pgpservice_componentName, s_pgpservice_entryName,
auto const newEntry = configEntry(s_pgpservice_componentName, s_pgpservice_entryName,
CryptoConfigEntry::ArgType_String, SingleValue, DoNotShowError);
auto *const legacyEntry = configEntry(s_pgpservice_legacy_componentName, s_pgpservice_legacy_entryName,
auto const legacyEntry = configEntry(s_pgpservice_legacy_componentName, s_pgpservice_legacy_entryName,
CryptoConfigEntry::ArgType_String, SingleValue, DoNotShowError);
mOpenPGPServiceEntry = newEntry ? newEntry : legacyEntry;
......@@ -297,7 +297,7 @@ void updateIntegerConfigEntry(QGpgME::CryptoConfigEntry *configEntry, int value)
configEntry->setIntValue(value);
}
} else {
const unsigned int newValue = static_cast<unsigned>(value);
const auto newValue = static_cast<unsigned>(value);
if (configEntry->uintValue() != newValue) {
configEntry->setUIntValue(newValue);
}
......@@ -383,7 +383,7 @@ extern "C"
{
Q_DECL_EXPORT KCModule *create_kleopatra_config_dirserv(QWidget *parent = nullptr, const QVariantList &args = QVariantList())
{
DirectoryServicesConfigurationPage *page =
auto page =
new DirectoryServicesConfigurationPage(parent, args);
page->setObjectName(QStringLiteral("kleopatra_config_dirserv"));
return page;
......
......@@ -21,7 +21,7 @@ using namespace Kleo::Config;
GnuPGSystemConfigurationPage::GnuPGSystemConfigurationPage(QWidget *parent, const QVariantList &args)
: KCModule(parent, args)
{
QVBoxLayout *lay = new QVBoxLayout(this);
auto lay = new QVBoxLayout(this);
lay->setContentsMargins(0, 0, 0, 0);
QGpgME::CryptoConfig *const config = QGpgME::cryptoConfig();
......@@ -68,7 +68,7 @@ void GnuPGSystemConfigurationPage::defaults()
extern "C" Q_DECL_EXPORT KCModule *create_kleopatra_config_gnupgsystem(QWidget *parent, const QVariantList &args)
{
GnuPGSystemConfigurationPage *page =
auto page =
new GnuPGSystemConfigurationPage(parent, args);
page->setObjectName(QStringLiteral("kleopatra_config_gnupgsystem"));
return page;
......
......@@ -46,7 +46,7 @@ GroupsConfigPage::GroupsConfigPage(QWidget *parent)
: QWidget(parent)
, d(new Private(this))
{
QVBoxLayout *layout = new QVBoxLayout(this);
auto layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
d->widget = new Kleo::GroupsConfigWidget(this);
......
......@@ -18,7 +18,7 @@ using namespace Kleo::Config;
SMimeValidationConfigurationPage::SMimeValidationConfigurationPage(QWidget *parent, const QVariantList &args)
: KCModule(parent, args)
{
QVBoxLayout *lay = new QVBoxLayout(this);
auto lay = new QVBoxLayout(this);
lay->setContentsMargins(0, 0, 0, 0);
mWidget = new SMimeValidationConfigurationWidget(this);
......@@ -46,7 +46,7 @@ void SMimeValidationConfigurationPage::defaults()
extern "C" Q_DECL_EXPORT KCModule *create_kleopatra_config_smimevalidation(QWidget *parent, const QVariantList &args)
{
SMimeValidationConfigurationPage *page =
auto page =
new SMimeValidationConfigurationPage(parent, args);
page->setObjectName(QStringLiteral("kleopatra_config_smimevalidation"));
return page;
......
......@@ -211,7 +211,7 @@ private:
progressDialog->close();
}
#endif // QT_NO_PROGRESSDIALOG
ResultDialog *const dlg = new ResultDialog(created, errors);
auto const dlg = new ResultDialog(created, errors);
dlg->setAttribute(Qt::WA_DeleteOnClose);
q->bringToForeground(dlg);
if (!errors.empty())
......@@ -560,7 +560,7 @@ static std::vector<Dir> find_dirs_by_input_files(const QStringList &files, const
std::vector<Dir> dirs;
dirs.reserve(dirs2files.size());
for (std::map<QDir, QStringList, less_dir>::const_iterator it = dirs2files.begin(), end = dirs2files.end(); it != end; ++it) {
for (auto it = dirs2files.begin(), end = dirs2files.end(); it != end; ++it) {
const QStringList inputFiles = remove_checksum_files(it->second, patterns);
if (inputFiles.empty()) {
......
......@@ -198,7 +198,7 @@ namespace
template <typename C>
void collectGarbage(C &c)
{
typename C::iterator it = c.begin();
auto it = c.begin();
while (it != c.end() /*sic!*/)
if (it->second) {
++it;
......@@ -220,7 +220,7 @@ DecryptVerifyEMailWizard *DecryptVerifyEMailController::Private::findOrCreateWiz
if (id != 0) {
const std::map<unsigned int, QPointer<DecryptVerifyEMailWizard> >::const_iterator it
const auto it
= s_wizards.find(id);
if (it != s_wizards.end()) {
......@@ -230,7 +230,7 @@ DecryptVerifyEMailWizard *DecryptVerifyEMailController::Private::findOrCreateWiz
}
DecryptVerifyEMailWizard *w = new DecryptVerifyEMailWizard;
auto w = new DecryptVerifyEMailWizard;
w->setWindowTitle(i18nc("@title:window", "Decrypt/Verify E-Mail"));
w->setAttribute(Qt::WA_DeleteOnClose);
......
......@@ -260,7 +260,7 @@ std::shared_ptr<ArchiveDefinition> DecryptVerifyFilesController::pick_archive_de
}
for (;;) {
const std::vector<std::shared_ptr<ArchiveDefinition> >::const_iterator it
const auto it
= std::find_if(ads.begin(), ads.end(), FindExtension(extension, proto));
if (it != ads.end()) {
return *it;
......
......@@ -186,7 +186,7 @@ std::unique_ptr<QGpgME::EncryptJob> EncryptEMailTask::Private::createJob(GpgME::
void EncryptEMailTask::Private::slotResult(const EncryptionResult &result)
{
const QGpgME::Job *const job = qobject_cast<const QGpgME::Job *>(q->sender());
const auto *const job = qobject_cast<const QGpgME::Job *>(q->sender());
if (result.error().code()) {
output->cancel();
} else {
......
......@@ -140,7 +140,7 @@ CertificateLineEdit::CertificateLineEdit(AbstractKeyListModel *model,
connect(mCompleter, QOverload<const QModelIndex &>::of(&QCompleter::activated),
this, [this] (const QModelIndex &index) {
Key key = mCompleter->completionModel()->data(index, KeyList::KeyRole).value<Key>();
KeyGroup group = mCompleter->completionModel()->data(index, KeyList::GroupRole).value<KeyGroup>();
auto group = mCompleter->completionModel()->data(index, KeyList::GroupRole).value<KeyGroup>();
if (!key.isNull()) {
setKey(key);
} else if (!group.isNull()) {
......
......@@ -139,7 +139,7 @@ void DecryptVerifyFilesDialog::started(const std::shared_ptr<Task> &task)
if (tag.isEmpty()) {
label->setText(i18nc("number, operation description", "Operation %1: %2", m_tasks->numberOfCompletedTasks() + 1, task->label()));
} else {
label->setText(i18nc("tag( \"OpenPGP\" or \"CMS\"), operation description", "%1: %2", tag, task->label()));
label->setText(i18nc(R"(tag( "OpenPGP" or "CMS"), operation description)", "%1: %2", tag, task->label()));
}
if (m_saveButton != QDialogButtonBox::NoButton) {
m_buttonBox->button(m_saveButton)->setEnabled(false);
......
......@@ -243,7 +243,7 @@ void OperationsWidget::ensureIndexAvailable(unsigned int idx)
if (i) {
blay.insertWidget(blay.count() - 1, new HLine(m_ui.scrollArea.widget()));
}
DecryptVerifyOperationWidget *w = new DecryptVerifyOperationWidget(m_ui.scrollArea.widget());
auto w = new DecryptVerifyOperationWidget(m_ui.scrollArea.widget());
blay.insertWidget(blay.count() - 1, w);
w->show();
m_widgets.push_back(w);
......
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