Commit 65137e1f authored by Laurent Montel's avatar Laurent Montel 😁

Modernize code

parent 5d51a75d
Pipeline #33748 passed with stage
in 13 minutes and 32 seconds
......@@ -68,7 +68,7 @@ public:
mWithRevocations = value;
}
bool withRevocations () {
Q_REQUIRED_RESULT bool withRevocations () {
return mWithRevocations;
}
......
......@@ -60,7 +60,7 @@ public:
private:
QMap<GpgME::Protocol, QString> fileNames;
uint jobsPending;
uint jobsPending = 0;
QMap<QObject *, QString> outFileForSender;
QPointer<ExportJob> cmsJob;
QPointer<ExportJob> pgpJob;
......@@ -79,8 +79,7 @@ const ExportCertificateCommand::Private *ExportCertificateCommand::d_func() cons
#define q q_func()
ExportCertificateCommand::Private::Private(ExportCertificateCommand *qq, KeyListController *c)
: Command::Private(qq, c),
jobsPending(0)
: Command::Private(qq, c)
{
}
......
......@@ -49,7 +49,7 @@ private:
QString errorExitMessage(const QStringList &) const override;
private:
QWidget *mParent;
QWidget *const mParent;
QProcess mPkProc;
};
......
......@@ -39,7 +39,7 @@ public:
explicit Private(ImportCrlCommand *qq, KeyListController *c);
~Private();
QString errorString() const
Q_REQUIRED_RESULT QString errorString() const
{
return stringFromGpgOutput(errorBuffer);
}
......
......@@ -87,17 +87,13 @@ public:
std::vector<std::shared_ptr<const DecryptVerifyResult> > m_results;
std::vector<std::shared_ptr<Task> > m_runnableTasks, m_completedTasks;
std::shared_ptr<Task> m_runningTask;
bool m_errorDetected;
DecryptVerifyOperation m_operation;
DecryptVerifyFilesDialog *m_dialog;
QTemporaryDir *m_workDir;
bool m_errorDetected = false;
DecryptVerifyOperation m_operation = DecryptVerify;
DecryptVerifyFilesDialog *m_dialog = nullptr;
QTemporaryDir *m_workDir = nullptr;
};
AutoDecryptVerifyFilesController::Private::Private(AutoDecryptVerifyFilesController *qq) : q(qq),
m_errorDetected(false),
m_operation(DecryptVerify),
m_dialog(nullptr),
m_workDir(nullptr)
AutoDecryptVerifyFilesController::Private::Private(AutoDecryptVerifyFilesController *qq) : q(qq)
{
qRegisterMetaType<VerificationResult>();
}
......
......@@ -21,15 +21,13 @@ class Controller::Private
Controller *const q;
public:
explicit Private(Controller *qq)
: q(qq),
lastError(0),
lastErrorString()
: q(qq)
{
}
private:
int lastError;
int lastError = 0;
QString lastErrorString;
};
......
......@@ -84,16 +84,12 @@ CertificateLineEdit::CertificateLineEdit(AbstractKeyListModel *model,
: QLineEdit(parent),
mFilterModel(new KeyListSortFilterProxyModel(this)),
mFilter(std::shared_ptr<KeyFilter>(filter)),
mEditStarted(false),
mEditFinished(false),
mLineAction(new QAction(this))
{
setPlaceholderText(i18n("Please enter a name or email address..."));
setClearButtonEnabled(true);
addAction(mLineAction, QLineEdit::LeadingPosition);
QFontMetrics fm(font());
auto *completer = new QCompleter(this);
auto *completeFilterModel = new ProxyModel(completer);
completeFilterModel->setKeyFilter(mFilter);
......
......@@ -82,15 +82,15 @@ private Q_SLOTS:
void checkLocate();
private:
KeyListSortFilterProxyModel *mFilterModel;
KeyListSortFilterProxyModel *const mFilterModel;
QLabel *mStatusLabel,
*mStatusIcon;
GpgME::Key mKey;
GpgME::Protocol mCurrentProto;
std::shared_ptr<KeyFilter> mFilter;
bool mEditStarted,
mEditFinished;
QAction *mLineAction;
bool mEditStarted = false;
bool mEditFinished = false;
QAction *const mLineAction;
};
}
#endif
......@@ -77,11 +77,11 @@ public:
}
QString initialText() const
Q_REQUIRED_RESULT QString initialText() const
{
return m_initialText;
}
QIcon initialIcon() const
Q_REQUIRED_RESULT QIcon initialIcon() const
{
return m_initialIcon;
}
......
......@@ -39,7 +39,7 @@ using namespace Kleo::Crypto;
using namespace Kleo::Crypto::Gui;
DecryptVerifyFilesDialog::DecryptVerifyFilesDialog(const std::shared_ptr<TaskCollection> &coll, QWidget *parent)
: QDialog(parent), m_tasks(coll), m_saveButton(QDialogButtonBox::NoButton), m_buttonBox(new QDialogButtonBox)
: QDialog(parent), m_tasks(coll), m_buttonBox(new QDialogButtonBox)
{
readConfig();
auto vLay = new QVBoxLayout(this);
......
......@@ -65,8 +65,8 @@ private:
int m_lastErrorItemIndex;
ResultListWidget *m_resultList;
FileNameRequester *m_outputLocationFNR;
QDialogButtonBox::StandardButton m_saveButton;
QDialogButtonBox *m_buttonBox;
QDialogButtonBox::StandardButton m_saveButton = QDialogButtonBox::NoButton;
QDialogButtonBox *const m_buttonBox;
};
} // namespace Gui
......
......@@ -21,8 +21,7 @@ using namespace Kleo::Crypto::Gui;
class EncryptEMailWizard::Private
{
public:
Private() : m_quickMode(false) {}
bool m_quickMode;
bool m_quickMode = false;
};
EncryptEMailWizard::EncryptEMailWizard(QWidget *parent, Qt::WindowFlags flags) : SignEncryptWizard(parent, flags), d(new Private)
......
......@@ -59,7 +59,8 @@ ResolveRecipientsPage::ListWidget::~ListWidget()
void ResolveRecipientsPage::ListWidget::onSelectionChange()
{
Q_FOREACH (const QString &i, widgets.keys()) {
const auto widgetskeys = widgets.keys();
for (const QString &i : widgetskeys) {
Q_ASSERT(items.contains(i));
widgets[i]->setSelected(items[i]->isSelected());
}
......
......@@ -85,7 +85,7 @@ class ResultItemWidget::Private
{
ResultItemWidget *const q;
public:
explicit Private(const std::shared_ptr<const Task::Result> &result, ResultItemWidget *qq) : q(qq), m_result(result), m_detailsLabel(nullptr), m_actionsLabel(nullptr), m_closeButton(nullptr), m_importCanceled(false)
explicit Private(const std::shared_ptr<const Task::Result> &result, ResultItemWidget *qq) : q(qq), m_result(result)
{
Q_ASSERT(m_result);
}
......@@ -99,10 +99,10 @@ public:
void oneImportFinished();
const std::shared_ptr<const Task::Result> m_result;
QLabel *m_detailsLabel;
QLabel *m_actionsLabel;
QPushButton *m_closeButton;
bool m_importCanceled;
QLabel *m_detailsLabel = nullptr;
QLabel *m_actionsLabel = nullptr;
QPushButton *m_closeButton = nullptr;
bool m_importCanceled = false;
};
void ResultItemWidget::Private::oneImportFinished()
......
......@@ -49,23 +49,17 @@ public:
void resizeIfStandalone();
std::vector< std::shared_ptr<TaskCollection> > m_collections;
bool m_standaloneMode;
int m_lastErrorItemIndex;
ScrollArea *m_scrollArea;
QPushButton *m_closeButton;
QVBoxLayout *m_layout;
QLabel *m_progressLabel;
bool m_standaloneMode = false;
int m_lastErrorItemIndex = 0;
ScrollArea *m_scrollArea = nullptr;
QPushButton *m_closeButton = nullptr;
QVBoxLayout *m_layout = nullptr;
QLabel *m_progressLabel = nullptr;
};
ResultListWidget::Private::Private(ResultListWidget *qq)
: q(qq),
m_collections(),
m_standaloneMode(false),
m_lastErrorItemIndex(0),
m_scrollArea(nullptr),
m_closeButton(nullptr),
m_layout(nullptr),
m_progressLabel(nullptr)
m_collections()
{
m_layout = new QVBoxLayout(q);
m_layout->setContentsMargins(0, 0, 0, 0);
......
......@@ -47,12 +47,12 @@ public:
QProgressBar *m_progressBar;
QHash<QString, QLabel *> m_progressLabelByTag;
QVBoxLayout *m_progressLabelLayout;
int m_lastErrorItemIndex;
int m_lastErrorItemIndex = 0;
ResultListWidget *m_resultList;
QCheckBox *m_keepOpenCB;
};
ResultPage::Private::Private(ResultPage *qq) : q(qq), m_lastErrorItemIndex(0)
ResultPage::Private::Private(ResultPage *qq) : q(qq)
{
QBoxLayout *const layout = new QVBoxLayout(q);
QWidget *const labels = new QWidget;
......
......@@ -46,7 +46,8 @@ private:
};
}
SignerResolveValidator::SignerResolveValidator(SignerResolvePage *page) : SignerResolvePage::Validator(), m_page(page), complete(true)
SignerResolveValidator::SignerResolveValidator(SignerResolvePage *page)
: SignerResolvePage::Validator(), m_page(page), complete(true)
{
Q_ASSERT(m_page);
}
......
......@@ -370,8 +370,6 @@ private:
SignEncryptFilesWizard::SignEncryptFilesWizard(QWidget *parent, Qt::WindowFlags f)
: QWizard(parent, f)
, mSigningUserMutable(true)
, mEncryptionUserMutable(true)
{
readConfig();
......
......@@ -93,11 +93,11 @@ private Q_SLOTS:
void slotCurrentIdChanged(int);
private:
SigEncPage *mSigEncPage;
ResultPage *mResultPage;
QAbstractButton *mLabel;
bool mSigningUserMutable,
mEncryptionUserMutable;
SigEncPage *mSigEncPage = nullptr;
ResultPage *mResultPage = nullptr;
QAbstractButton *mLabel = nullptr;
bool mSigningUserMutable = true;
bool mEncryptionUserMutable = true;
};
}
......
......@@ -102,21 +102,21 @@ Q_SIGNALS:
void keysChanged();
private:
KeySelectionCombo *mSigSelect,
*mSelfSelect;
KeySelectionCombo *mSigSelect = nullptr;
KeySelectionCombo *mSelfSelect = nullptr;
QVector<CertificateLineEdit *> mRecpWidgets;
QVector<UnknownRecipientWidget *> mUnknownWidgets;
QVector<GpgME::Key> mAddedKeys;
QGridLayout *mRecpLayout;
QGridLayout *mRecpLayout = nullptr;
QString mOp;
AbstractKeyListModel *mModel;
QCheckBox *mSymmetric,
*mSigChk,
*mEncOtherChk,
*mEncSelfChk;
int mRecpRowCount;
AbstractKeyListModel *mModel = nullptr;
QCheckBox *mSymmetric = nullptr;
QCheckBox *mSigChk = nullptr;
QCheckBox *mEncOtherChk = nullptr;
QCheckBox *mEncSelfChk = nullptr;
int mRecpRowCount = 2;
GpgME::Protocol mCurrentProto;
bool mIsExclusive;
const bool mIsExclusive;
};
} // namespace Kleo
#endif // CRYPTO_GUI_SIGNENCRYPTWIDGET_H
......@@ -49,10 +49,10 @@ public:
void setCommitPage(Page page);
Gui::ResolveRecipientsPage *recipientResolvePage; // clashes with enum of same name
SignerResolvePage *signerResolvePage;
Gui::ObjectsPage *objectsPage; // clashes with enum of same name
Gui::ResultPage *resultPage; // clashes with enum of same name
Gui::ResolveRecipientsPage *const recipientResolvePage; // clashes with enum of same name
SignerResolvePage *const signerResolvePage;
Gui::ObjectsPage *const objectsPage; // clashes with enum of same name
Gui::ResultPage *const resultPage; // clashes with enum of same name
};
SignEncryptWizard::Private::Private(SignEncryptWizard *qq)
......
......@@ -80,7 +80,8 @@ ReadOnlyProtocolSelectionWidget::ReadOnlyProtocolSelectionWidget(QWidget *p, Qt:
{
QVBoxLayout *const layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
Q_FOREACH (const Protocol i, supportedProtocols()) { //krazy:exclude=foreach
const auto supportedProtocolsLst = supportedProtocols();
for (const Protocol i: supportedProtocolsLst) {
QLabel *const l = new QLabel;
l->setText(formatLabel(i, Key()));
layout->addWidget(l);
......
......@@ -35,12 +35,12 @@ public:
void setAllowedProtocols(const QVector<GpgME::Protocol> &allowedProtocols);
void setSelectedCertificates(const QMap<GpgME::Protocol, GpgME::Key> &certificates);
QMap<GpgME::Protocol, GpgME::Key> selectedCertificates() const;
Q_REQUIRED_RESULT QMap<GpgME::Protocol, GpgME::Key> selectedCertificates() const;
bool rememberAsDefault() const;
Q_REQUIRED_RESULT bool rememberAsDefault() const;
private:
SigningCertificateSelectionWidget *widget;
SigningCertificateSelectionWidget *const widget;
};
}
......
......@@ -50,23 +50,23 @@ private:
std::vector<int> pageOrder;
std::set<int> hiddenPages;
std::map<int, WizardPage *> idToPage;
int currentId;
QStackedWidget *stack;
QPushButton *nextButton;
QPushButton *backButton;
QPushButton *cancelButton;
int currentId = -1;
QStackedWidget *const stack;
QPushButton *nextButton = nullptr;
QPushButton *backButton = nullptr;
QPushButton *cancelButton = nullptr;
KGuiItem finishItem;
KGuiItem nextItem;
QFrame *titleFrame;
QLabel *titleLabel;
QLabel *subTitleLabel;
QFrame *explanationFrame;
QLabel *explanationLabel;
QTimer *nextPageTimer;
QFrame *titleFrame = nullptr;
QLabel *titleLabel = nullptr;
QLabel *subTitleLabel = nullptr;
QFrame *explanationFrame = nullptr;
QLabel *explanationLabel = nullptr;
QTimer *nextPageTimer = nullptr;
};
Wizard::Private::Private(Wizard *qq)
: q(qq), currentId(-1), stack(new QStackedWidget)
: q(qq), stack(new QStackedWidget)
{
nextPageTimer = new QTimer(q);
nextPageTimer->setInterval(0);
......
......@@ -24,8 +24,8 @@ public:
~Private();
private:
bool commitPage;
bool autoAdvance;
bool commitPage = false;
bool autoAdvance = false;
QString title;
QString subTitle;
QString explanation;
......@@ -33,7 +33,7 @@ private:
};
WizardPage::Private::Private(WizardPage *qq)
: q(qq), commitPage(false), autoAdvance(false)
: q(qq)
{
}
......
......@@ -64,8 +64,8 @@ public:
return AuditLog();
}
private:
int m_code;
QString m_details;
const int m_code;
const QString m_details;
};
}
......
......@@ -31,8 +31,7 @@ class AddEmailDialog::Private
{
public:
Private(AddEmailDialog *qq):
q(qq),
mAdvancedSelected(false)
q(qq)
{
auto mainLay = new QVBoxLayout(q);
......@@ -72,9 +71,9 @@ public:
}
AddEmailDialog *const q;
QPushButton *mOkButton;
QLineEdit *mEmailEdit;
bool mAdvancedSelected;
QPushButton *mOkButton = nullptr;
QLineEdit *mEmailEdit = nullptr;
bool mAdvancedSelected = false;
};
AddEmailDialog::AddEmailDialog(QWidget *parent):
......
......@@ -37,7 +37,7 @@ struct Line {
QString attr;
QString label;
QString regex;
QLineEdit *edit;
QLineEdit *edit = nullptr;
};
}
......
......@@ -34,9 +34,7 @@ static const char option_prefix[] = "prefix";
class EchoCommand::Private
{
public:
Private() : operationsInFlight(0), buffer() {}
int operationsInFlight;
int operationsInFlight = 0;
QByteArray buffer;
};
......
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