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

Modernize code

parent c28bcda1
Pipeline #39278 passed with stage
in 10 minutes and 33 seconds
......@@ -64,7 +64,7 @@ void CategorySelectWidgetPrivate::init()
{
Q_Q(CategorySelectWidget);
QHBoxLayout *hbox = new QHBoxLayout(q);
auto *hbox = new QHBoxLayout(q);
hbox->setSpacing(0);
hbox->setContentsMargins(0, 0, 0, 0);
......@@ -75,7 +75,7 @@ void CategorySelectWidgetPrivate::init()
this, &CategorySelectWidgetPrivate::slotCheckedItemsChanged);
hbox->addWidget(checkCombo);
Monitor *monitor = new Monitor(this);
auto *monitor = new Monitor(this);
monitor->setTypeMonitored(Monitor::Tags);
tagModel = new Akonadi::TagModel(monitor, this);
......@@ -91,7 +91,7 @@ void CategorySelectWidgetPrivate::init()
updateTimer->setInterval(200);
connect(updateTimer, &QTimer::timeout, this, &CategorySelectWidgetPrivate::slotCheckedItemsTimer);
QToolButton *but = new QToolButton(q);
auto *but = new QToolButton(q);
but->setAutoRaise(true);
but->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo")));
but->setToolTip(i18nc("@action:button", "Reset category filter"));
......@@ -123,7 +123,7 @@ void CategorySelectWidgetPrivate::init()
QStandardItemModel *CategorySelectWidgetPrivate::itemModel() const
{
QStandardItemModel *m = qobject_cast<QStandardItemModel *>(checkCombo->model());
auto *m = qobject_cast<QStandardItemModel *>(checkCombo->model());
Q_ASSERT(m != nullptr);
return m;
}
......@@ -167,7 +167,7 @@ void CategorySelectWidgetPrivate::slotTagsInserted(const QModelIndex &parent, in
//
// FIXME: not tested (no way to create hierarchical tags at present)
if (parent != QModelIndex()) {
const Tag::Id parentId = tagModel->data(idx, TagModel::IdRole).value<Tag::Id>();
const auto parentId = tagModel->data(idx, TagModel::IdRole).value<Tag::Id>();
QModelIndexList matchList = itemModel()->match(itemModel()->index(0, 0), FILTER_ROLE,
parentId, 1,
Qt::MatchExactly | Qt::MatchRecursive);
......
......@@ -21,7 +21,7 @@ K_PLUGIN_FACTORY(KCMKaddressbookPluginsConfigFactory, registerPlugin<KCMKaddress
KCMKaddressbookPluginsConfig::KCMKaddressbookPluginsConfig(QWidget *parent, const QVariantList &args)
: KCModule(parent, args)
{
QHBoxLayout *lay = new QHBoxLayout(this);
auto *lay = new QHBoxLayout(this);
lay->setContentsMargins(0, 0, 0, 0);
KAboutData *about = new KAboutData(QStringLiteral("kcmakrpluginsconfig"),
......
......@@ -22,7 +22,7 @@ K_PLUGIN_FACTORY(KCMKaddressbookUserFeedBackConfigFactory, registerPlugin<KCMKad
KCMKaddressbookUserFeedBackConfig::KCMKaddressbookUserFeedBackConfig(QWidget *parent, const QVariantList &args)
: KCModule(parent, args)
{
QHBoxLayout *lay = new QHBoxLayout(this);
auto *lay = new QHBoxLayout(this);
lay->setContentsMargins(0, 0, 0, 0);
KAboutData *about = new KAboutData(QStringLiteral("kcmaddressbookuserfeedbackconfig"),
......
......@@ -269,7 +269,7 @@ ContactInfoProxyModel::ContactCacheData::ConstListIterator ContactInfoProxyModel
void ContactInfoProxyModel::fetchItems(const Akonadi::Item::List &items, const QMap<const char *, QVariant> &properties) const
{
Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(items);
auto *job = new Akonadi::ItemFetchJob(items);
job->fetchScope().fetchFullPayload();
job->fetchScope().setIgnoreRetrievalErrors(true);
......@@ -286,7 +286,7 @@ void ContactInfoProxyModel::slotFetchJobFinished(KJob *job)
qCWarning(KADDRESSBOOK_LOG) << " error during fetching items" << job->errorString();
return;
}
Akonadi::ItemFetchJob *fetchJob = qobject_cast<Akonadi::ItemFetchJob *>(job);
auto *fetchJob = qobject_cast<Akonadi::ItemFetchJob *>(job);
const QPersistentModelIndex index = job->property("groupPersistentModelIndex").value<QPersistentModelIndex>();
const QString groupId = job->property("groupId").value<QString>();
......
......@@ -16,7 +16,7 @@
ContactSwitcher::ContactSwitcher(QWidget *parent)
: QWidget(parent)
{
QHBoxLayout *layout = new QHBoxLayout(this);
auto *layout = new QHBoxLayout(this);
mPreviousButton = new QPushButton(i18nc("@action:button Previous contact", "Previous"));
mPreviousButton->setToolTip(
......
......@@ -19,7 +19,7 @@ ContactSelectionDialog::ContactSelectionDialog(QItemSelectionModel *selectionMod
: QDialog(parent)
{
setWindowTitle(i18nc("@title:window", "Select Contacts"));
QVBoxLayout *mainLayout = new QVBoxLayout(this);
auto *mainLayout = new QVBoxLayout(this);
mSelectionWidget = new ContactSelectionWidget(selectionModel, this);
if (allowToSelectTypeToExport) {
......
......@@ -98,18 +98,18 @@ void ContactSelectionWidget::setAddGroupContact(bool addGroupContact)
void ContactSelectionWidget::initGui()
{
QVBoxLayout *layout = new QVBoxLayout(this);
auto *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
mMessageLabel = new QLabel;
layout->addWidget(mMessageLabel);
mMessageLabel->hide();
QButtonGroup *group = new QButtonGroup(this);
auto *group = new QButtonGroup(this);
QGroupBox *groupBox = new QGroupBox;
auto *groupBox = new QGroupBox;
QGridLayout *boxLayout = new QGridLayout;
auto *boxLayout = new QGridLayout;
groupBox->setLayout(boxLayout);
mAllContactsButton = new QRadioButton(i18nc("@option:radio", "All contacts"));
......@@ -159,7 +159,7 @@ void ContactSelectionWidget::initGui()
boxLayout->addWidget(mSelectedContactsButton, 1, 0, 1, 2);
boxLayout->addWidget(mAddressBookContactsButton, 2, 0, Qt::AlignTop);
QVBoxLayout *addressBookLayout = new QVBoxLayout;
auto *addressBookLayout = new QVBoxLayout;
addressBookLayout->setContentsMargins(0, 0, 0, 0);
addressBookLayout->addWidget(mAddressBookSelection);
addressBookLayout->addWidget(mAddressBookSelectionRecursive);
......@@ -276,7 +276,7 @@ Akonadi::Item::List ContactSelectionWidget::collectAddressBookItems() const
items = job->items();
} else {
Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(collection);
auto *job = new Akonadi::ItemFetchJob(collection);
job->fetchScope().fetchFullPayload();
if (!job->exec()) {
......@@ -314,7 +314,7 @@ ContactList ContactSelectionWidget::collectAddressBookContacts() const
}
}
} else {
Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(collection);
auto *job = new Akonadi::ItemFetchJob(collection);
job->fetchScope().fetchFullPayload();
if (!job->exec()) {
......
......@@ -19,12 +19,12 @@ using namespace KAddressBookImportExport;
ExportSelectionWidget::ExportSelectionWidget(QWidget *parent)
: QWidget(parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
auto *mainLayout = new QVBoxLayout(this);
mainLayout->setContentsMargins(0, 0, 0, 0);
QGroupBox *gbox = new QGroupBox(
i18nc("@title:group", "Fields to be exported"), this);
mainLayout->addWidget(gbox);
QGridLayout *layout = new QGridLayout;
auto *layout = new QGridLayout;
gbox->setLayout(layout);
gbox->setFlat(true);
......@@ -77,7 +77,7 @@ ExportSelectionWidget::ExportSelectionWidget(QWidget *parent)
i18nc("@title:group", "Export options"), this);
gbox->setFlat(true);
mainLayout->addWidget(gbox);
QHBoxLayout *gbLayout = new QHBoxLayout;
auto *gbLayout = new QHBoxLayout;
gbox->setLayout(gbLayout);
mDisplayNameBox = new QCheckBox(i18nc("@option:check", "Display name as full name"), this);
......
......@@ -91,7 +91,7 @@ void ImportExportEngine::importContacts()
item.setPayload<KContacts::Addressee>(mContactsList.addressList().at(i));
item.setMimeType(KContacts::Addressee::mimeType());
Akonadi::ItemCreateJob *job = new Akonadi::ItemCreateJob(item, collection);
auto *job = new Akonadi::ItemCreateJob(item, collection);
connect(job, &Akonadi::ItemCreateJob::result, this, &ImportExportEngine::slotImportJobDone);
}
const int numberGroup(mContactsList.contactGroupList().count());
......
......@@ -33,7 +33,7 @@ KAddressBookPart::KAddressBookPart(QWidget *parentWidget, QObject *parent, const
QWidget *canvas = new QWidget(parentWidget);
canvas->setFocusPolicy(Qt::ClickFocus);
setWidget(canvas);
QVBoxLayout *topLayout = new QVBoxLayout(canvas);
auto *topLayout = new QVBoxLayout(canvas);
mMainWidget = new MainWidget(this, canvas);
initAction();
......
......@@ -69,7 +69,7 @@ int main(int argc, char **argv)
#ifdef WITH_KUSERFEEDBACK
if (cmdArgs->isSet(QStringLiteral("feedback"))) {
KAddressBookUserFeedbackProvider *userFeedBack = new KAddressBookUserFeedbackProvider(nullptr);
auto *userFeedBack = new KAddressBookUserFeedbackProvider(nullptr);
QTextStream(stdout) << userFeedBack->describeDataSources() << '\n';
delete userFeedBack;
return 0;
......
......@@ -209,7 +209,7 @@ MainWidget::MainWidget(KXMLGUIClient *guiClient, QWidget *parent)
mCollectionTree->setHeaderGroup(Akonadi::EntityTreeModel::CollectionTreeHeaders);
mCollectionSelectionModel = new QItemSelectionModel(mCollectionTree);
StructuralCollectionsNotCheckableProxy *checkableProxyModel
auto *checkableProxyModel
= new StructuralCollectionsNotCheckableProxy(this);
checkableProxyModel->setSelectionModel(mCollectionSelectionModel);
checkableProxyModel->setSourceModel(mCollectionTree);
......@@ -225,7 +225,7 @@ MainWidget::MainWidget(KXMLGUIClient *guiClient, QWidget *parent)
connect(mCollectionView, qOverload<const Akonadi::Collection &>(&Akonadi::EntityTreeView::currentChanged),
this, &MainWidget::slotCurrentCollectionChanged);
KSelectionProxyModel *selectionProxyModel
auto *selectionProxyModel
= new KSelectionProxyModel(mCollectionSelectionModel, this);
selectionProxyModel->setSourceModel(GlobalContactModel::instance()->model());
selectionProxyModel->setFilterBehavior(KSelectionProxyModel::ChildrenOfExactSelection);
......@@ -246,7 +246,7 @@ MainWidget::MainWidget(KXMLGUIClient *guiClient, QWidget *parent)
mContactsFilterModel = new Akonadi::ContactsFilterProxyModel(this);
mContactsFilterModel->setSourceModel(mCategoryFilterModel);
ContactInfoProxyModel *contactInfoProxyModel = new ContactInfoProxyModel(this);
auto *contactInfoProxyModel = new ContactInfoProxyModel(this);
contactInfoProxyModel->setSourceModel(mContactsFilterModel);
connect(mQuickSearchWidget, &QuickSearchWidget::filterStringChanged,
......@@ -335,7 +335,7 @@ void MainWidget::initializeImportExportPlugin(KActionCollection *collection)
QList<QAction *> exportActions;
for (KAddressBookImportExport::Plugin *plugin : listPlugins) {
if (plugin->isEnabled()) {
KAddressBookImportExport::PluginInterface *interface
auto *interface
= static_cast<KAddressBookImportExport::PluginInterface *>(plugin->createInterface(this));
interface->setItemSelectionModel(mItemView->selectionModel());
interface->setParentWidget(this);
......@@ -447,7 +447,7 @@ void MainWidget::restoreState()
{
// collection view
{
Akonadi::ETMViewStateSaver *saver = new Akonadi::ETMViewStateSaver;
auto *saver = new Akonadi::ETMViewStateSaver;
saver->setView(mCollectionView);
const KConfigGroup group(Settings::self()->config(), "CollectionViewState");
......@@ -456,7 +456,7 @@ void MainWidget::restoreState()
// collection view
{
Akonadi::ETMViewStateSaver *saver = new Akonadi::ETMViewStateSaver;
auto *saver = new Akonadi::ETMViewStateSaver;
saver->setSelectionModel(mCollectionSelectionModel);
const KConfigGroup group(Settings::self()->config(), "CollectionViewCheckState");
......@@ -465,7 +465,7 @@ void MainWidget::restoreState()
// item view
{
Akonadi::ETMViewStateSaver *saver = new Akonadi::ETMViewStateSaver;
auto *saver = new Akonadi::ETMViewStateSaver;
saver->setView(mItemView);
saver->setSelectionModel(mItemView->selectionModel());
......@@ -517,7 +517,7 @@ void MainWidget::saveState()
void MainWidget::setupGui()
{
// the horizontal main layout
QHBoxLayout *layout = new QHBoxLayout(this);
auto *layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
// Splitter 1 contains the two main parts of the GUI:
......@@ -558,7 +558,7 @@ void MainWidget::setupGui()
mMainWidgetSplitter2->setChildrenCollapsible(false);
mMainWidgetSplitter1->setChildrenCollapsible(false);
QVBoxLayout *detailsPaneLayout = new QVBoxLayout(mDetailsPane);
auto *detailsPaneLayout = new QVBoxLayout(mDetailsPane);
detailsPaneLayout->setContentsMargins(0, 0, 0, 0);
// the details view stack
......@@ -590,7 +590,7 @@ void MainWidget::setupGui()
mCategorySelectWidget = new CategorySelectWidget;
// setup the default actions
Akonadi::ContactDefaultActions *actions = new Akonadi::ContactDefaultActions(this);
auto *actions = new Akonadi::ContactDefaultActions(this);
actions->connectToView(mContactDetails);
actions->connectToView(mContactGroupDetails);
mFormatter = new KAddressBookGrantlee::GrantleeContactFormatter;
......@@ -634,7 +634,7 @@ void MainWidget::setupActions(KActionCollection *collection)
collection->addAction(QStringLiteral("theme_menu"), themeMenu);
initGrantleeThemeName();
QActionGroup *group = new QActionGroup(this);
auto *group = new QActionGroup(this);
mGrantleeThemeManager->setThemeMenu(themeMenu);
mGrantleeThemeManager->setActionGroup(group);
......@@ -645,12 +645,12 @@ void MainWidget::setupActions(KActionCollection *collection)
KStandardAction::printPreview(this, &MainWidget::printPreview, collection);
QWidgetAction *quicksearch = new QWidgetAction(this);
auto *quicksearch = new QWidgetAction(this);
quicksearch->setText(i18n("Quick search"));
quicksearch->setDefaultWidget(mQuickSearchWidget);
collection->addAction(QStringLiteral("quick_search"), quicksearch);
QWidgetAction *categoryFilter = new QWidgetAction(this);
auto *categoryFilter = new QWidgetAction(this);
categoryFilter->setText(i18n("Category filter"));
categoryFilter->setDefaultWidget(mCategorySelectWidget);
collection->addAction(QStringLiteral("category_filter"), categoryFilter);
......@@ -661,7 +661,7 @@ void MainWidget::setupActions(KActionCollection *collection)
action->setWhatsThis(i18n("Select all contacts in the current address book view."));
connect(action, &QAction::triggered, mItemView, &Akonadi::EntityTreeView::selectAll);
KToggleAction *qrtoggleAction = collection->add<KToggleAction>(QStringLiteral("options_show_qrcodes"));
auto *qrtoggleAction = collection->add<KToggleAction>(QStringLiteral("options_show_qrcodes"));
qrtoggleAction->setText(i18n("Show QR Codes"));
qrtoggleAction->setWhatsThis(i18n("Show QR Codes in the contact."));
connect(qrtoggleAction, &KToggleAction::toggled, this, &MainWidget::setQRCodeShow);
......@@ -862,7 +862,7 @@ Akonadi::Collection MainWidget::currentAddressBook() const
QAbstractItemModel *MainWidget::allContactsModel()
{
if (!mAllContactsModel) {
KDescendantsProxyModel *descendantsModel = new KDescendantsProxyModel(this);
auto *descendantsModel = new KDescendantsProxyModel(this);
descendantsModel->setSourceModel(GlobalContactModel::instance()->model());
mAllContactsModel = new Akonadi::EntityMimeTypeFilterModel(this);
......@@ -975,9 +975,9 @@ void MainWidget::slotGrantleeThemesUpdated()
Akonadi::EntityTreeModel *MainWidget::entityTreeModel() const
{
QAbstractProxyModel *proxy = qobject_cast<QAbstractProxyModel *>(mCollectionView->model());
auto *proxy = qobject_cast<QAbstractProxyModel *>(mCollectionView->model());
while (proxy) {
Akonadi::EntityTreeModel *etm = qobject_cast<Akonadi::EntityTreeModel *>(proxy->sourceModel());
auto *etm = qobject_cast<Akonadi::EntityTreeModel *>(proxy->sourceModel());
if (etm) {
return etm;
}
......@@ -1055,7 +1055,7 @@ void MainWidget::slotServerSideSubscription()
{
Akonadi::Collection collection = currentAddressBook();
if (collection.isValid()) {
PimCommon::ManageServerSideSubscriptionJob *job = new PimCommon::ManageServerSideSubscriptionJob(this);
auto *job = new PimCommon::ManageServerSideSubscriptionJob(this);
job->setCurrentCollection(collection);
job->setParentWidget(this);
job->start();
......
......@@ -47,7 +47,7 @@ MainWindow::MainWindow()
mHideMenuBarAction->setChecked(Settings::self()->showMenuBar());
slotToggleMenubar(true);
#ifdef WITH_KUSERFEEDBACK
KUserFeedback::NotificationPopup *userFeedBackNotificationPopup = new KUserFeedback::NotificationPopup(this);
auto *userFeedBackNotificationPopup = new KUserFeedback::NotificationPopup(this);
userFeedBackNotificationPopup->setFeedbackProvider(UserFeedBackManager::self()->userFeedbackProvider());
#endif
}
......
......@@ -48,7 +48,7 @@ void ManageShowCollectionProperties::showCollectionProperties()
dlg->raise();
return;
}
Akonadi::CollectionAttributesSynchronizationJob *sync
auto *sync
= new Akonadi::CollectionAttributesSynchronizationJob(col);
sync->setProperty("collectionId", id);
connect(sync, &KJob::result,
......@@ -59,7 +59,7 @@ void ManageShowCollectionProperties::showCollectionProperties()
void ManageShowCollectionProperties::slotCollectionPropertiesContinued(KJob *job)
{
if (job) {
Akonadi::CollectionAttributesSynchronizationJob *sync
auto *sync
= qobject_cast<Akonadi::CollectionAttributesSynchronizationJob *>(job);
Q_ASSERT(sync);
if (sync->property("collectionId") != mMainWidget->currentAddressBook().id()) {
......@@ -79,7 +79,7 @@ void ManageShowCollectionProperties::slotCollectionPropertiesFinished(KJob *job)
return;
}
Akonadi::CollectionFetchJob *fetch = qobject_cast<Akonadi::CollectionFetchJob *>(job);
auto *fetch = qobject_cast<Akonadi::CollectionFetchJob *>(job);
Q_ASSERT(fetch);
if (fetch->collections().isEmpty()) {
qCWarning(KADDRESSBOOK_LOG) << "no collection";
......
......@@ -190,7 +190,7 @@ bool ModelColumnManager::eventFilter(QObject *watched, QEvent *event)
void ModelColumnManager::adaptHeaderView()
{
QHeaderView *view = qobject_cast<QHeaderView *>(mWidget);
auto *view = qobject_cast<QHeaderView *>(mWidget);
if (view) {
view->resizeSections(QHeaderView::Stretch);
......
......@@ -34,7 +34,7 @@ void KAddressBookPluginInterface::initializeInterfaceRequires(PimCommon::Abstrac
qCCritical(KADDRESSBOOK_LOG) << "Main windows pointer not defined";
return;
}
PimCommon::GenericPluginInterface *interface = static_cast<PimCommon::GenericPluginInterface *>(abstractInterface);
auto *interface = static_cast<PimCommon::GenericPluginInterface *>(abstractInterface);
PimCommon::GenericPluginInterface::RequireTypes requires = interface->requires();
if (requires & PimCommon::GenericPluginInterface::CurrentItems) {
interface->setCurrentItems(mMainWidget->collectSelectedAllContactsItem());
......
......@@ -169,11 +169,11 @@ QString contactsToHtml(const KContacts::Addressee::List &contacts, const ColorSe
content += QLatin1String(" <tr>\n");
content += QLatin1String(" <td style=\"color: ") + settings.headerTextColor
+QLatin1String(";\" bgcolor=\"") + settings.headerBackgroundColor
+QLatin1String("\" style=\"padding-left: 20px\">")
+QLatin1String(R"(" style="padding-left: 20px">)")
+name + QLatin1String("</td>\n");
content += QLatin1String(" <td style=\"color: ") + settings.headerTextColor
+QLatin1String(";\" align=\"right\" bgcolor=\"") + settings.headerBackgroundColor
+QLatin1String("\" style=\"padding-right: 20px\">")
+QLatin1String(R"(;" align="right" bgcolor=")") + settings.headerBackgroundColor
+QLatin1String(R"(" style="padding-right: 20px">)")
+birthday + QLatin1String("</td>\n");
content += QLatin1String(" </tr>\n");
......
......@@ -21,7 +21,7 @@ PrintProgress::PrintProgress(QWidget *parent)
{
setWindowTitle(i18nc("@title:window", "Printing: Progress"));
QGridLayout *topLayout = new QGridLayout(this);
auto *topLayout = new QGridLayout(this);
mLogBrowser = new QTextBrowser(this);
topLayout->addWidget(mLogBrowser, 0, 0);
......
......@@ -68,7 +68,7 @@ void PrintStyle::addPage(QWidget *page, const QString &title)
mPageList.append(page);
mPageTitles.append(title);
KPageWidgetItem *item = new KPageWidgetItem(page, title);
auto *item = new KPageWidgetItem(page, title);
mPageItems.insert(page, item);
mWizard->addPage(item);
mWizard->setAppropriate(item, false);
......
......@@ -111,7 +111,7 @@ void StylePage::initGUI()
{
setWindowTitle(i18nc("@title:window", "Choose Printing Style"));
QGridLayout *topLayout = new QGridLayout(this);
auto *topLayout = new QGridLayout(this);
QLabel *label
= new QLabel(
......@@ -122,7 +122,7 @@ void StylePage::initGUI()
topLayout->addWidget(label, 0, 0, 1, 2);
QGroupBox *group = new QGroupBox(i18nc("@title:group", "Sorting"), this);
QGridLayout *sortLayout = new QGridLayout();
auto *sortLayout = new QGridLayout();
group->setLayout(sortLayout);
sortLayout->setAlignment(Qt::AlignTop);
......@@ -155,7 +155,7 @@ void StylePage::initGUI()
topLayout->addWidget(group, 1, 0);
group = new QGroupBox(i18nc("@title:group", "Print Style"), this);
QVBoxLayout *styleLayout = new QVBoxLayout();
auto *styleLayout = new QVBoxLayout();
group->setLayout(styleLayout);
mStyleCombo = new QComboBox(group);
......
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