Commit 8b2cb605 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Modernize code + use QStringLiteral multi arg etc.

parent 6f278659
Pipeline #74653 passed with stage
in 11 minutes and 27 seconds
......@@ -47,7 +47,7 @@ public:
}
auto layout = new QVBoxLayout(mParent);
layout->setContentsMargins(0, 0, 0, 0);
layout->setContentsMargins({});
layout->setSpacing(0);
layout->addWidget(mEditorWidget);
}
......
......@@ -54,7 +54,7 @@ public:
mainLayout->addWidget(buttonBox);
auto layout = new QGridLayout(mainWidget);
layout->setContentsMargins(0, 0, 0, 0);
layout->setContentsMargins({});
if (editorWidget) {
mEditor = new AkonadiContactEditor(mode == ContactEditorDialog::CreateMode ? AkonadiContactEditor::CreateMode : AkonadiContactEditor::EditMode,
......
......@@ -91,7 +91,7 @@ ContactGroupEditorDialog::ContactGroupEditorDialog(Mode mode, QWidget *parent)
auto mainWidget = new QWidget(this);
auto layout = new QGridLayout(mainWidget);
layout->setContentsMargins(0, 0, 0, 0);
layout->setContentsMargins({});
d->mEditor = new Akonadi::ContactGroupEditor(mode == CreateMode ? Akonadi::ContactGroupEditor::CreateMode : Akonadi::ContactGroupEditor::EditMode, this);
......
......@@ -142,7 +142,7 @@ ContactGroupViewer::ContactGroupViewer(QWidget *parent)
, d(new Private(this))
{
auto layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setContentsMargins({});
connect(d->mBrowser, &TextBrowser::anchorClicked, this, [this](const QUrl &url) {
d->slotMailClicked(url);
......
......@@ -221,7 +221,7 @@ ContactViewer::ContactViewer(QWidget *parent)
, d(new Private(this))
{
auto layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setContentsMargins({});
d->mBrowser = new TextBrowser;
......
......@@ -67,7 +67,7 @@ EmailAddressRequester::EmailAddressRequester(QWidget *parent)
{
auto layout = new QHBoxLayout(this);
layout->setSpacing(4);
layout->setContentsMargins(0, 0, 0, 0);
layout->setContentsMargins({});
d->mLineEdit = new KLineEdit(this);
d->mLineEdit->setClearButtonEnabled(true);
......
......@@ -114,14 +114,14 @@ void EmailAddressSelectionWidget::Private::init()
// setup ui
auto layout = new QVBoxLayout(q);
layout->setContentsMargins(0, 0, 0, 0);
layout->setContentsMargins({});
mDescriptionLabel = new QLabel;
mDescriptionLabel->hide();
layout->addWidget(mDescriptionLabel);
auto searchLayout = new QHBoxLayout;
searchLayout->setContentsMargins(0, 0, 0, 0);
searchLayout->setContentsMargins({});
layout->addLayout(searchLayout);
mView = new Akonadi::EntityTreeView;
......
......@@ -69,7 +69,7 @@ QString ContactGrantleeWrapper::addressBookName() const
int ContactGrantleeWrapper::age() const
{
QDate now = QDate::currentDate();
const QDate now = QDate::currentDate();
int age = now.year() - birthday().date().year();
if (birthday().date() > now.addYears(-age)) {
age--;
......
......@@ -115,7 +115,7 @@ public:
}
}
ContactGroupExpandJob *mParent = nullptr;
ContactGroupExpandJob *const mParent;
KContacts::ContactGroup mGroup;
QString mName;
KContacts::Addressee::List mContacts;
......
......@@ -80,7 +80,7 @@ public:
}
OpenEmailAddressJob *const q;
QString mCompleteAddress;
const QString mCompleteAddress;
QString mEmail;
QString mName;
QWidget *const mParentWidget;
......
......@@ -21,7 +21,7 @@ CategoriesEditWidget::CategoriesEditWidget(QWidget *parent, const QList<QVariant
, mTagWidget(new Akonadi::TagWidget(this))
{
auto layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setContentsMargins({});
layout->addWidget(mTagWidget);
}
......
......@@ -18,7 +18,7 @@ RecipientsPickerWidget::RecipientsPickerWidget(bool onlyShowEmailWithAddress, QA
: QWidget(parent)
{
auto layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setContentsMargins({});
mView =
new Akonadi::EmailAddressSelectionWidget(onlyShowEmailWithAddress, model ? model : Akonadi::RecipientsEditorManager::self()->model()->model(), this);
......
......@@ -40,7 +40,7 @@ StandardContactFormatter::~StandardContactFormatter()
static int contactAge(const QDate &date)
{
QDate now = QDate::currentDate();
const QDate now = QDate::currentDate();
int age = now.year() - date.year();
if (date > now.addYears(-age)) {
age--;
......@@ -93,8 +93,8 @@ QString StandardContactFormatter::toHtml(HtmlForm form) const
const int years = contactAge(date);
if (date.isValid()) {
dynamicPart += rowFmtStr1.arg(KContacts::Addressee::birthdayLabel())
.arg(QLocale().toString(date) + QLatin1String("&nbsp;&nbsp;") + i18np("(One year old)", "(%1 years old)", years));
dynamicPart += rowFmtStr1.arg(KContacts::Addressee::birthdayLabel(),
QLocale().toString(date) + QLatin1String("&nbsp;&nbsp;") + i18np("(One year old)", "(%1 years old)", years));
}
// Phone Numbers
......@@ -122,7 +122,7 @@ QString StandardContactFormatter::toHtml(HtmlForm form) const
const QString fullEmail = QString::fromLatin1(QUrl::toPercentEncoding(rawContact.fullEmail(email)));
dynamicPart += rowFmtStr1.arg(type).arg(QStringLiteral("<a href=\"mailto:%1\">%2</a>").arg(fullEmail, email));
dynamicPart += rowFmtStr1.arg(type, QStringLiteral("<a href=\"mailto:%1\">%2</a>").arg(fullEmail, email));
}
// Homepage
......@@ -139,7 +139,7 @@ QString StandardContactFormatter::toHtml(HtmlForm form) const
// Blog Feed
const QString blog = rawContact.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("BlogFeed"));
if (!blog.isEmpty()) {
dynamicPart += rowFmtStr1.arg(i18n("Blog Feed")).arg(KStringHandler::tagUrls(blog.toHtmlEscaped()));
dynamicPart += rowFmtStr1.arg(i18n("Blog Feed"), KStringHandler::tagUrls(blog.toHtmlEscaped()));
}
// Addresses
......@@ -167,7 +167,7 @@ QString StandardContactFormatter::toHtml(HtmlForm form) const
// Note
QString notes;
if (!rawContact.note().isEmpty()) {
notes = rowFmtStr1.arg(i18n("Notes")).arg(rawContact.note().toHtmlEscaped().replace(QLatin1Char('\n'), QLatin1String("<br>")));
notes = rowFmtStr1.arg(i18n("Notes"), rawContact.note().toHtmlEscaped().replace(QLatin1Char('\n'), QLatin1String("<br>")));
}
// Custom Data
......@@ -278,25 +278,23 @@ QString StandardContactFormatter::toHtml(HtmlForm form) const
role = rawContact.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("X-Profession"));
}
QString strAddr = QStringLiteral(
"<div align=\"center\">"
"<table cellpadding=\"3\" cellspacing=\"1\">"
"<tr>"
"<td align=\"right\" valign=\"top\" width=\"30%\" rowspan=\"3\">"
"<img src=\"%1\" width=\"100\" vspace=\"1\"/>" // image
"</td>"
"<td colspan=\"2\" align=\"left\" width=\"70%\"><font size=\"+2\"><b>%2</b></font></td>" // name
"</tr>"
"<tr>"
"<td colspan=\"2\" align=\"left\" width=\"70%\">%3</td>" // role
"</tr>"
"<tr>"
"<td colspan=\"2\" align=\"left\" width=\"70%\">%4</td>" // organization
"</tr>")
.arg(QStringLiteral("contact_photo"))
.arg(rawContact.realName().toHtmlEscaped())
.arg(role.toHtmlEscaped())
.arg(rawContact.organization().toHtmlEscaped());
QString strAddr =
QStringLiteral(
"<div align=\"center\">"
"<table cellpadding=\"3\" cellspacing=\"1\">"
"<tr>"
"<td align=\"right\" valign=\"top\" width=\"30%\" rowspan=\"3\">"
"<img src=\"%1\" width=\"100\" vspace=\"1\"/>" // image
"</td>"
"<td colspan=\"2\" align=\"left\" width=\"70%\"><font size=\"+2\"><b>%2</b></font></td>" // name
"</tr>"
"<tr>"
"<td colspan=\"2\" align=\"left\" width=\"70%\">%3</td>" // role
"</tr>"
"<tr>"
"<td colspan=\"2\" align=\"left\" width=\"70%\">%4</td>" // organization
"</tr>")
.arg(QStringLiteral("contact_photo"), rawContact.realName().toHtmlEscaped(), role.toHtmlEscaped(), rawContact.organization().toHtmlEscaped());
strAddr.append(dynamicPart);
strAddr.append(notes);
......@@ -331,9 +329,9 @@ QString StandardContactFormatter::toHtml(HtmlForm form) const
"%3" // contact part
"</body>"
"</html>")
.arg(KColorScheme(QPalette::Active, KColorScheme::View).foreground().color().name())
.arg(KColorScheme(QPalette::Active, KColorScheme::View).background().color().name())
.arg(strAddr);
.arg(KColorScheme(QPalette::Active, KColorScheme::View).foreground().color().name(),
KColorScheme(QPalette::Active, KColorScheme::View).background().color().name(),
strAddr);
return document;
}
......
......@@ -113,7 +113,7 @@ AddressLocationWidget::AddressLocationWidget(QWidget *parent)
auto addButtonWidget = new QWidget(this);
auto addButtonWidgetLayout = new QHBoxLayout(addButtonWidget);
addButtonWidgetLayout->setContentsMargins(0, 0, 0, 0);
addButtonWidgetLayout->setContentsMargins({});
mAddAddress = new QPushButton(i18n("Add Address"), this);
mAddAddress->setObjectName(QStringLiteral("addbuttonaddress"));
connect(mAddAddress, &QPushButton::clicked, this, &AddressLocationWidget::slotAddAddress);
......@@ -123,7 +123,7 @@ AddressLocationWidget::AddressLocationWidget(QWidget *parent)
auto modifyButtonWidget = new QWidget(this);
auto modifyButtonWidgetLayout = new QHBoxLayout(modifyButtonWidget);
modifyButtonWidgetLayout->setContentsMargins(0, 0, 0, 0);
modifyButtonWidgetLayout->setContentsMargins({});
mButtonStack->addWidget(modifyButtonWidget);
mRemoveAddress = new QPushButton(i18n("Remove Address"), this);
......
......@@ -33,7 +33,7 @@ AddressTypeDialog::AddressTypeDialog(KContacts::Address::Type type, QWidget *par
mainLayout->addWidget(page);
mainLayout->addWidget(buttonBox);
auto layout = new QVBoxLayout(page);
layout->setContentsMargins(0, 0, 0, 0);
layout->setContentsMargins({});
auto box = new QGroupBox(i18nc("street/postal", "Address Types"), page);
mainLayout->addWidget(box);
......
......@@ -21,7 +21,7 @@ FreeBusyEditWidget::FreeBusyEditWidget(QWidget *parent)
: QWidget(parent)
{
auto layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setContentsMargins({});
mURL = new KUrlRequester(this);
mURL->lineEdit()->setTrapReturnKey(true);
......
......@@ -74,7 +74,7 @@ public:
void ContactEditorWidget::Private::initGui()
{
auto layout = new QVBoxLayout(mParent);
layout->setContentsMargins(0, 0, 0, 0);
layout->setContentsMargins({});
mTabWidget = new QTabWidget(mParent);
layout->addWidget(mTabWidget);
......
......@@ -19,7 +19,7 @@ CustomFieldsWidget::CustomFieldsWidget(QWidget *parent)
: QWidget(parent)
{
auto topLayout = new QVBoxLayout(this);
topLayout->setContentsMargins(0, 0, 0, 0);
topLayout->setContentsMargins({});
mCustomFieldEditorWidget = new ContactEditor::CustomFieldEditorWidget(this);
mCustomFieldEditorWidget->setObjectName(QStringLiteral("customfieldeditorwidget"));
topLayout->addWidget(mCustomFieldEditorWidget);
......
......@@ -19,7 +19,7 @@ BlogfeedWidget::BlogfeedWidget(QWidget *parent)
: QWidget(parent)
{
auto topLayout = new QVBoxLayout(this);
topLayout->setContentsMargins(0, 0, 0, 0);
topLayout->setContentsMargins({});
topLayout->setObjectName(QStringLiteral("mainlayout"));
auto blogFeedLabel = new QLabel(i18n("Blog Feed"), this);
blogFeedLabel->setObjectName(QStringLiteral("blogFeedLabel"));
......
......@@ -14,7 +14,7 @@ CategoriesEditWidget::CategoriesEditWidget(QWidget *parent)
: ContactEditor::CategoriesEditAbstractWidget(parent)
{
auto layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setContentsMargins({});
}
CategoriesEditWidget::~CategoriesEditWidget()
......
Supports Markdown
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