Commit f8d9b028 authored by Laurent Montel's avatar Laurent Montel 😁

GIT_SILENT: coding style

parent 5bd8469a
Pipeline #34235 failed with stage
in 5 minutes and 47 seconds
......@@ -25,8 +25,8 @@
#include <QRegularExpression>
ContactInfoProxyModel::ContactInfoProxyModel(QObject *parent)
: QIdentityProxyModel(parent),
mMonitor(new Akonadi::Monitor(this))
: QIdentityProxyModel(parent)
, mMonitor(new Akonadi::Monitor(this))
{
mMonitor->setTypeMonitored(Akonadi::Monitor::Items);
mMonitor->itemFetchScope().fetchFullPayload(true);
......@@ -68,8 +68,7 @@ QVariant ContactInfoProxyModel::data(const QModelIndex &index, int role) const
return i18n("Loading contacts details ...");
}
if (!mPendingGroups.contains(groupContacts.id())) {
QMap<const char*, QVariant> properties{
QMap<const char *, QVariant> properties{
{"groupPersistentModelIndex", QVariant::fromValue(index)},
{"groupId", QVariant::fromValue(groupContacts.id())},
};
......@@ -162,7 +161,7 @@ QString ContactInfoProxyModel::getDescription(const KContacts::Addressee &contac
const QList<KContacts::PhoneNumber> phoneList = contact.phoneNumbers().toList();
QList<KContacts::PhoneNumber>::const_reverse_iterator itPhone = std::find_if(phoneList.rbegin(),
phoneList.rend(),
[&phoneList](const KContacts::PhoneNumber &phone) {
[&phoneList](const KContacts::PhoneNumber &phone) {
return phone.isPreferred() || phoneList.at(0) == phone;
});
if (itPhone != phoneList.rend()) {
......@@ -182,14 +181,13 @@ QString ContactInfoProxyModel::getDescription(const QModelIndex &index, const KC
for (int idx = 0; idx < groupContacts.dataCount(); idx++) {
QString dataSeparator;
if (!groupContacts.data(idx).name().isEmpty() &&
!groupContacts.data(idx).email().isEmpty()) {
if (!groupContacts.data(idx).name().isEmpty()
&& !groupContacts.data(idx).email().isEmpty()) {
dataSeparator = QStringLiteral("-");
}
contactDescription = i18n("%1 %2 %3", groupContacts.data(idx).name(), dataSeparator, groupContacts.data(idx).email());
groupDescription << contactDescription.trimmed();
contactDescription.clear();
}
for (int idx = 0; idx < groupContacts.contactReferenceCount(); ++idx) {
const KContacts::ContactGroup::ContactReference contactRef = groupContacts.contactReference(idx);
......@@ -214,9 +212,8 @@ QString ContactInfoProxyModel::getDescription(const QModelIndex &index, const KC
void ContactInfoProxyModel::updateCache(const QModelIndex &index, const KContacts::ContactGroup &groupContacts) const
{
mGroupsCache[index].erase(std::remove_if(mGroupsCache[index].begin(), mGroupsCache[index].end(),
[&groupContacts](const ContactCacheData &cacheContact) -> bool {
for (int idx = 0; idx < groupContacts.contactReferenceCount(); ++idx)
{
[&groupContacts](const ContactCacheData &cacheContact) -> bool {
for (int idx = 0; idx < groupContacts.contactReferenceCount(); ++idx) {
const KContacts::ContactGroup::ContactReference &reference = groupContacts.contactReference(idx);
if (cacheContact == reference) {
......@@ -233,8 +230,8 @@ bool ContactInfoProxyModel::groupFetchDone(const QModelIndex &index, const KCont
QStringList contactCacheIds;
auto sortFunc = [](const QString &lhs, const QString &rhs) -> bool {
return lhs.toLongLong() < rhs.toLongLong();
};
return lhs.toLongLong() < rhs.toLongLong();
};
for (int idx = 0; idx < groupContacts.contactReferenceCount(); ++idx) {
const KContacts::ContactGroup::ContactReference &reference = groupContacts.contactReference(idx);
......@@ -252,26 +249,27 @@ bool ContactInfoProxyModel::groupFetchDone(const QModelIndex &index, const KCont
return std::equal(contactRefIds.begin(), contactRefIds.end(), contactCacheIds.begin(), contactCacheIds.end());
}
ContactInfoProxyModel::ContactCacheData::ListIterator ContactInfoProxyModel::findCacheItem(const QModelIndex &index,
const ContactInfoProxyModel::ContactCacheData &cacheContact)
ContactInfoProxyModel::ContactCacheData::ListIterator ContactInfoProxyModel::findCacheItem(const QModelIndex &index, const ContactInfoProxyModel::ContactCacheData &cacheContact)
{
ContactCacheData::ListIterator it = std::find_if(mGroupsCache[index].begin(), mGroupsCache[index].end(),
[&cacheContact](const ContactCacheData &contact) -> bool
{ return contact == cacheContact; });
[&cacheContact](const ContactCacheData &contact) -> bool
{
return contact == cacheContact;
});
return it;
}
ContactInfoProxyModel::ContactCacheData::ConstListIterator ContactInfoProxyModel::findCacheItem(const QModelIndex &index,
const ContactInfoProxyModel::ContactCacheData &cacheContact) const
ContactInfoProxyModel::ContactCacheData::ConstListIterator ContactInfoProxyModel::findCacheItem(const QModelIndex &index, const ContactInfoProxyModel::ContactCacheData &cacheContact) const
{
ContactCacheData::ConstListIterator it = std::find_if(mGroupsCache[index].cbegin(), mGroupsCache[index].cend(),
[&cacheContact](const ContactCacheData &contact) -> bool
{ return contact == cacheContact; });
[&cacheContact](const ContactCacheData &contact) -> bool
{
return contact == cacheContact;
});
return it;
}
void ContactInfoProxyModel::fetchItems(const Akonadi::Item::List &items, const QMap<const char*, QVariant> &properties) const
void ContactInfoProxyModel::fetchItems(const Akonadi::Item::List &items, const QMap<const char *, QVariant> &properties) const
{
Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(items);
job->fetchScope().fetchFullPayload();
......@@ -294,7 +292,7 @@ void ContactInfoProxyModel::slotFetchJobFinished(KJob *job)
const QPersistentModelIndex index = job->property("groupPersistentModelIndex").value<QPersistentModelIndex>();
const QString groupId = job->property("groupId").value<QString>();
const QList<QJsonObject> groupRefIdsList = job->property("groupRefIdsList").value<QList<QJsonObject>>();
const QList<QJsonObject> groupRefIdsList = job->property("groupRefIdsList").value<QList<QJsonObject> >();
for (const QJsonObject &refId : groupRefIdsList) {
ContactCacheData cacheContact;
......@@ -303,8 +301,8 @@ void ContactInfoProxyModel::slotFetchJobFinished(KJob *job)
for (const Akonadi::Item &item : fetchJob->items()) {
if (item.isValid()) {
if ((!item.gid().isEmpty() && refId[QStringLiteral("gid")].toString() == item.gid()) ||
QString::number(item.id()) == refId[QStringLiteral("uid")].toString()) {
if ((!item.gid().isEmpty() && refId[QStringLiteral("gid")].toString() == item.gid())
|| QString::number(item.id()) == refId[QStringLiteral("uid")].toString()) {
if (item.hasPayload<KContacts::Addressee>()) {
mMonitor->setItemMonitored(item);
const KContacts::Addressee contact = item.payload<KContacts::Addressee>();
......
......@@ -15,14 +15,12 @@
#include <QIdentityProxyModel>
#include <QPersistentModelIndex>
namespace Akonadi
{
namespace Akonadi {
class Item;
class Monitor;
}
namespace KContacts
{
namespace KContacts {
class Addressee;
class ContactGroup;
}
......@@ -49,10 +47,13 @@ private:
ContactCacheData(const ContactCacheData &) = default;
ContactCacheData(const KContacts::ContactGroup::ContactReference &other)
: uid(other.uid()), gid(other.gid()) {
: uid(other.uid())
, gid(other.gid())
{
}
ContactCacheData(const Akonadi::Item &other) {
ContactCacheData(const Akonadi::Item &other)
{
uid = QString::number(other.id());
gid = other.gid();
}
......@@ -78,7 +79,7 @@ private:
Q_REQUIRED_RESULT bool groupFetchDone(const QModelIndex &index, const KContacts::ContactGroup &groupContacts) const;
Q_REQUIRED_RESULT ContactCacheData::ListIterator findCacheItem(const QModelIndex &index, const ContactCacheData &cacheContact);
Q_REQUIRED_RESULT ContactCacheData::ConstListIterator findCacheItem(const QModelIndex &index, const ContactCacheData &cacheContact) const;
void fetchItems(const Akonadi::Item::List &items, const QMap<const char*, QVariant> &properties) const;
void fetchItems(const Akonadi::Item::List &items, const QMap<const char *, QVariant> &properties) const;
void slotFetchJobFinished(KJob *job);
void slotItemChanged(const Akonadi::Item &item, const QSet<QByteArray> &partIdentifiers);
void slotItemRemoved(const Akonadi::Item &item);
......@@ -87,7 +88,7 @@ private:
using Cache = QMap<QPersistentModelIndex, ContactCacheData::List>;
mutable Cache mGroupsCache;
mutable QStringList mPendingGroups;
const QVector<int>mKrole {PictureRole, InitialsRole, DescriptionRole};
const QVector<int> mKrole {PictureRole, InitialsRole, DescriptionRole};
Akonadi::Monitor *const mMonitor;
};
......
......@@ -12,7 +12,6 @@
#include <KContacts/Addressee>
#include "kaddressbook_importexport_export.h"
namespace KAddressBookImportExport {
/** Contact fields for import/export. */
class KADDRESSBOOK_IMPORTEXPORT_EXPORT ContactFields
{
......
......@@ -13,7 +13,6 @@
#include "kaddressbook_importexport_export.h"
namespace KAddressBookImportExport {
/** Import/export contact list. */
class KADDRESSBOOK_IMPORTEXPORT_EXPORT ContactList
{
......
......@@ -12,7 +12,6 @@
class QCheckBox;
namespace KAddressBookImportExport {
/** Addressbool export selection widget. */
class KADDRESSBOOK_IMPORTEXPORT_EXPORT ExportSelectionWidget : public QWidget
{
......
......@@ -16,9 +16,7 @@
class QProgressDialog;
class KJob;
namespace KAddressBookImportExport
{
namespace KAddressBookImportExport {
class KADDRESSBOOK_IMPORTEXPORT_EXPORT ImportExportEngine : public QObject
{
Q_OBJECT
......@@ -44,7 +42,6 @@ private:
int mNumberElementToImport = -1;
int mImportDone = 0;
};
}
#endif // IMPORTEXPORTENGINE_H
......@@ -12,9 +12,8 @@
#include "kaddressbook_importexport_export.h"
namespace KAddressBookImportExport {
/** Import/export plugin. */
class KADDRESSBOOK_IMPORTEXPORT_EXPORT Plugin: public PimCommon::AbstractGenericPlugin
class KADDRESSBOOK_IMPORTEXPORT_EXPORT Plugin : public PimCommon::AbstractGenericPlugin
{
Q_OBJECT
public:
......
......@@ -15,9 +15,8 @@
class QItemSelectionModel;
namespace KAddressBookImportExport {
/** Import/export plugin interface. */
class KADDRESSBOOK_IMPORTEXPORT_EXPORT PluginInterface: public PimCommon::AbstractGenericPluginInterface
class KADDRESSBOOK_IMPORTEXPORT_EXPORT PluginInterface : public PimCommon::AbstractGenericPluginInterface
{
Q_OBJECT
public:
......
......@@ -27,7 +27,6 @@
#include "importexport/plugininterface.h"
#include "importexport/contactselectiondialog.h"
#include <Akonadi/Contact/GrantleeContactFormatter>
#include <Akonadi/Contact/GrantleeContactGroupFormatter>
#include <GrantleeTheme/GrantleeThemeManager>
......@@ -246,7 +245,7 @@ MainWidget::MainWidget(KXMLGUIClient *guiClient, QWidget *parent)
mContactsFilterModel = new Akonadi::ContactsFilterProxyModel(this);
mContactsFilterModel->setSourceModel(mCategoryFilterModel);
ContactInfoProxyModel *contactInfoProxyModel = new ContactInfoProxyModel(this);
contactInfoProxyModel->setSourceModel(mContactsFilterModel);
......
......@@ -18,15 +18,13 @@
#include <QImage>
StyleContactListDelegate::StyleContactListDelegate(QObject *parent)
: QStyledItemDelegate(parent),
mKImageSize(50, 50)
: QStyledItemDelegate(parent)
, mKImageSize(50, 50)
{
}
void StyleContactListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
Q_ASSERT(index.isValid());
if (Akonadi::ContactsTreeModel::Column::FullName == index.column()) {
......@@ -36,7 +34,6 @@ void StyleContactListDelegate::paint(QPainter *painter, const QStyleOptionViewIt
QRectF pictureRect = QRectF(optionRect.topLeft(), mKImageSize);
if (mKImageSize.width() > optionRect.size().width()) {
const qreal width = option.rect.size().width();
const qreal height = option.rect.size().height();
const QMargins fitMargins(0, (qMax(width, height) - qMin(width, height)) / qreal(2),
......@@ -51,7 +48,6 @@ void StyleContactListDelegate::paint(QPainter *painter, const QStyleOptionViewIt
QMargins textMargin;
switch (static_cast<int>(option.widget->layoutDirection())) {
case Qt::LayoutDirection::LeftToRight:
{
textMargin.setLeft(mKMargin);
nameTextRect.setLeft(pictureRect.bottomRight().x());
......@@ -59,10 +55,8 @@ void StyleContactListDelegate::paint(QPainter *painter, const QStyleOptionViewIt
descriptionTextRect.setLeft(pictureRect.bottomRight().x());
descriptionTextRect = descriptionTextRect.marginsRemoved(textMargin);
}
break;
case Qt::LayoutDirection::RightToLeft:
{
pictureRect.moveRight(optionRect.bottomRight().x());
textMargin.setRight(mKMargin);
......@@ -71,7 +65,6 @@ void StyleContactListDelegate::paint(QPainter *painter, const QStyleOptionViewIt
descriptionTextRect.setRight(pictureRect.bottomLeft().x());
descriptionTextRect = descriptionTextRect.marginsRemoved(textMargin);
}
break;
}
......@@ -85,10 +78,9 @@ void StyleContactListDelegate::paint(QPainter *painter, const QStyleOptionViewIt
painter->setFont(QFont(option.font.family(), 12, QFont::Bold, true));
if (index.data(ContactInfoProxyModel::Roles::PictureRole).value<QImage>().isNull()) {
const QString initials = index.data(ContactInfoProxyModel::Roles::InitialsRole).value<QString>();
painter->drawText(pictureRect, Qt::AlignCenter, painter->fontMetrics().elidedText(initials,
Qt::ElideRight, pictureRect.width() - qreal(10)));
Qt::ElideRight, pictureRect.width() - qreal(10)));
} else {
const qreal dpr = qApp->devicePixelRatio();
QImage image(index.data(ContactInfoProxyModel::Roles::PictureRole).value<QImage>());
......@@ -109,7 +101,6 @@ void StyleContactListDelegate::paint(QPainter *painter, const QStyleOptionViewIt
painter->drawText(descriptionTextRect, Qt::AlignLeft | Qt::AlignVCenter,
painter->fontMetrics().elidedText(description, Qt::ElideRight, descriptionTextRect.width()));
return;
}
QStyledItemDelegate::paint(painter, option, index);
}
......@@ -121,4 +112,3 @@ QSize StyleContactListDelegate::sizeHint(const QStyleOptionViewItem &option, con
return size;
}
......@@ -16,10 +16,8 @@ class StyleContactListDelegate : public QStyledItemDelegate
Q_OBJECT
public:
explicit StyleContactListDelegate(QObject *parent = nullptr);
void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const override;
QSize sizeHint(const QStyleOptionViewItem &option,
const QModelIndex &index) const override;
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
private:
const QSize mKImageSize;
const qreal mKMargin = 5.0;
......
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