Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
Akonadi Contacts
Commits
869ccf43
Commit
869ccf43
authored
Jan 23, 2017
by
Laurent Montel
Browse files
Port for(...:...)
parent
94bd3ea4
Changes
15
Hide whitespace changes
Inline
Side-by-side
src/contactgroupviewer.cpp
View file @
869ccf43
...
...
@@ -24,6 +24,7 @@
#include
"job/contactgroupexpandjob.h"
#include
"standardcontactgroupformatter.h"
#include
"textbrowser_p.h"
#include
"helper_p.h"
#include
<collectionfetchjob.h>
#include
<entitydisplayattribute.h>
...
...
@@ -72,7 +73,7 @@ public:
KContacts
::
ContactGroup
group
;
group
.
setName
(
mCurrentGroupName
);
for
each
(
const
KContacts
::
Addressee
&
contact
,
mCurrentContacts
)
{
for
(
const
KContacts
::
Addressee
&
contact
:
qAsConst
(
mCurrentContacts
)
)
{
group
.
append
(
KContacts
::
ContactGroup
::
Data
(
contact
.
realName
(),
contact
.
preferredEmail
()));
}
...
...
src/contactviewer.cpp
View file @
869ccf43
...
...
@@ -26,6 +26,7 @@
#include
"customfieldmanager_p.h"
#include
"standardcontactformatter.h"
#include
"textbrowser_p.h"
#include
"helper_p.h"
#include
"editor/im/improtocols.h"
#include
<KIOCore/kio/transferjob.h>
#include
<collection.h>
...
...
@@ -170,11 +171,11 @@ public:
QVector
<
QVariantMap
>
customFieldDescriptions
;
const
CustomField
::
List
globalCustomFields
=
CustomFieldManager
::
globalCustomFieldDescriptions
();
customFieldDescriptions
.
reserve
(
localCustomFieldDescriptions
.
count
()
+
globalCustomFields
.
count
());
for
each
(
const
QVariant
&
entry
,
localCustomFieldDescriptions
)
{
for
(
const
QVariant
&
entry
:
qAsConst
(
localCustomFieldDescriptions
)
)
{
customFieldDescriptions
<<
entry
.
toMap
();
}
for
each
(
const
CustomField
&
field
,
globalCustomFields
)
{
for
(
const
CustomField
&
field
:
qAsConst
(
globalCustomFields
)
)
{
QVariantMap
description
;
description
.
insert
(
QStringLiteral
(
"key"
),
field
.
key
());
description
.
insert
(
QStringLiteral
(
"title"
),
field
.
title
());
...
...
src/customfieldmanager.cpp
View file @
869ccf43
...
...
@@ -32,7 +32,7 @@ void CustomFieldManager::setGlobalCustomFieldDescriptions(const CustomField::Lis
KConfigGroup
group
(
&
config
,
QStringLiteral
(
"GlobalCustomFields"
));
group
.
deleteGroup
();
for
each
(
const
CustomField
&
field
,
customFields
)
{
for
(
const
CustomField
&
field
:
customFields
)
{
const
QString
key
=
field
.
key
();
const
QString
value
=
CustomField
::
typeToString
(
field
.
type
())
+
QLatin1Char
(
':'
)
+
field
.
title
();
...
...
@@ -49,7 +49,7 @@ CustomField::List CustomFieldManager::globalCustomFieldDescriptions()
const
QStringList
keys
=
group
.
keyList
();
customFields
.
reserve
(
keys
.
count
());
for
each
(
const
QString
&
key
,
keys
)
{
for
(
const
QString
&
key
:
keys
)
{
CustomField
field
;
field
.
setKey
(
key
);
field
.
setScope
(
CustomField
::
GlobalScope
);
...
...
src/editor/addresseditor/addresslocationwidget.cpp
View file @
869ccf43
...
...
@@ -182,7 +182,7 @@ void AddressLocationWidget::fillCountryCombo()
QStringList
countries
;
const
QList
<
QLocale
>
localeList
=
QLocale
::
matchingLocales
(
QLocale
::
AnyLanguage
,
QLocale
::
AnyScript
,
QLocale
::
AnyCountry
);
countries
.
reserve
(
localeList
.
count
());
for
each
(
const
QLocale
&
locale
,
localeList
)
{
for
(
const
QLocale
&
locale
:
localeList
)
{
const
QString
localeStr
=
QLocale
::
countryToString
(
locale
.
country
());
if
(
countries
.
contains
(
localeStr
))
{
continue
;
...
...
src/editor/contacteditorwidget.cpp
View file @
869ccf43
...
...
@@ -25,6 +25,7 @@
#include
"personaleditor/personaleditorwidget.h"
#include
"contacteditorpageplugin.h"
#include
"contactmetadata_p.h"
#include
"helper_p.h"
#include
<kconfig.h>
#include
<kconfiggroup.h>
...
...
@@ -169,7 +170,7 @@ void ContactEditorWidget::Private::loadCustomPages()
mCustomPages
.
append
(
plugin
);
}
for
each
(
Akonadi
::
ContactEditorPagePlugin
*
plugin
,
mCustomPages
)
{
for
(
Akonadi
::
ContactEditorPagePlugin
*
plugin
:
qAsConst
(
mCustomPages
)
)
{
mTabWidget
->
addTab
(
plugin
,
plugin
->
title
());
}
}
...
...
@@ -227,7 +228,7 @@ void ContactEditorWidget::loadContact(const KContacts::Addressee &contact, const
d
->
mCustomFieldsWidget
->
loadContact
(
contact
);
// custom pages
for
each
(
Akonadi
::
ContactEditorPagePlugin
*
plugin
,
d
->
mCustomPages
)
{
for
(
Akonadi
::
ContactEditorPagePlugin
*
plugin
:
qAsConst
(
d
->
mCustomPages
)
)
{
plugin
->
loadContact
(
contact
);
}
}
...
...
@@ -255,7 +256,7 @@ void ContactEditorWidget::storeContact(KContacts::Addressee &contact, Akonadi::C
metaData
.
setDisplayNameMode
(
d
->
mGeneralInfoWidget
->
displayType
());
// custom pages
for
each
(
Akonadi
::
ContactEditorPagePlugin
*
plugin
,
d
->
mCustomPages
)
{
for
(
Akonadi
::
ContactEditorPagePlugin
*
plugin
:
qAsConst
(
d
->
mCustomPages
)
)
{
plugin
->
storeContact
(
contact
);
}
}
...
...
@@ -279,7 +280,7 @@ void ContactEditorWidget::setReadOnly(bool readOnly)
d
->
mCustomFieldsWidget
->
setReadOnly
(
readOnly
);
// custom pages
for
each
(
Akonadi
::
ContactEditorPagePlugin
*
plugin
,
d
->
mCustomPages
)
{
for
(
Akonadi
::
ContactEditorPagePlugin
*
plugin
:
qAsConst
(
d
->
mCustomPages
)
)
{
plugin
->
setReadOnly
(
readOnly
);
}
}
...
...
src/editor/customfieldeditor/customfieldslistwidget.cpp
View file @
869ccf43
...
...
@@ -22,6 +22,7 @@
#include
"customfieldslistwidget.h"
#include
"../utils/utils.h"
#include
"helper_p.h"
#include
"customfieldmanager_p.h"
#include
"customfieldslistdelegate.h"
#include
<QSortFilterProxyModel>
...
...
@@ -64,7 +65,7 @@ void CustomFieldsListWidget::loadContact(const KContacts::Addressee &contact)
CustomField
::
List
globalCustomFields
=
CustomFieldManager
::
globalCustomFieldDescriptions
();
const
QStringList
customs
=
contact
.
customs
();
for
each
(
const
QString
&
custom
,
customs
)
{
for
(
const
QString
&
custom
:
customs
)
{
QString
app
,
name
,
value
;
Akonadi
::
Utils
::
splitCustomField
(
custom
,
app
,
name
,
value
);
...
...
@@ -163,11 +164,11 @@ void CustomFieldsListWidget::storeContact(KContacts::Addressee &contact) const
// Now remove all fields that were available in loadContact (these are stored in mLocalCustomFields)
// but are not part of customFields now, which means they have been removed or renamed by the user
// in the editor dialog.
for
each
(
const
CustomField
&
oldCustomField
,
mLocalCustomFields
)
{
for
(
const
CustomField
&
oldCustomField
:
qAsConst
(
mLocalCustomFields
)
)
{
if
(
oldCustomField
.
scope
()
!=
CustomField
::
ExternalScope
)
{
bool
fieldStillExists
=
false
;
for
each
(
const
CustomField
&
newCustomField
,
customFields
)
{
for
(
const
CustomField
&
newCustomField
:
qAsConst
(
customFields
)
)
{
if
(
newCustomField
.
scope
()
!=
CustomField
::
ExternalScope
)
{
if
(
newCustomField
.
key
()
==
oldCustomField
.
key
())
{
fieldStillExists
=
true
;
...
...
@@ -184,7 +185,7 @@ void CustomFieldsListWidget::storeContact(KContacts::Addressee &contact) const
// And store the global custom fields descriptions as well
CustomField
::
List
globalCustomFields
;
for
each
(
const
CustomField
&
customField
,
customFields
)
{
for
(
const
CustomField
&
customField
:
qAsConst
(
customFields
)
)
{
if
(
customField
.
scope
()
==
CustomField
::
GlobalScope
)
{
globalCustomFields
<<
customField
;
}
...
...
src/editor/generalinfoeditor/categorieseditwidget.cpp
View file @
869ccf43
...
...
@@ -52,7 +52,7 @@ void CategoriesEditWidget::loadContact(const KContacts::Addressee &contact)
const
QStringList
categories
=
contact
.
categories
();
tags
.
reserve
(
categories
.
count
());
for
each
(
const
QString
&
category
,
categories
)
{
for
(
const
QString
&
category
:
categories
)
{
tags
.
append
(
Akonadi
::
Tag
::
fromUrl
(
QUrl
(
category
)));
}
...
...
@@ -65,7 +65,7 @@ void CategoriesEditWidget::storeContact(KContacts::Addressee &contact) const
const
Akonadi
::
Tag
::
List
tags
=
mTagWidget
->
selection
();
categories
.
reserve
(
tags
.
count
());
for
each
(
const
Akonadi
::
Tag
&
tag
,
tags
)
{
for
(
const
Akonadi
::
Tag
&
tag
:
tags
)
{
categories
.
append
(
tag
.
url
().
url
());
}
...
...
src/editor/generalinfoeditor/displaynameeditwidget.cpp
View file @
869ccf43
...
...
@@ -20,6 +20,7 @@
*/
#include
"displaynameeditwidget.h"
#include
"helper_p.h"
#include
<QtCore/QEvent>
#include
<QAbstractItemView>
...
...
@@ -68,7 +69,7 @@ public:
QFont
font
=
view
->
font
();
font
.
setStyle
(
QFont
::
StyleItalic
);
QFontMetrics
metrics
(
font
);
for
each
(
const
QString
&
description
,
mDescriptions
)
{
for
(
const
QString
&
description
:
qAsConst
(
mDescriptions
)
)
{
mMaxDescriptionWidth
=
qMax
(
mMaxDescriptionWidth
,
metrics
.
width
(
description
));
}
...
...
src/editor/generalinfoeditor/messaging/messagingwidget.cpp
View file @
869ccf43
...
...
@@ -52,7 +52,7 @@ MessagingWidget::MessagingWidget(QWidget *parent)
layout
->
addWidget
(
mProtocolCombo
);
const
QStringList
protocols
=
IMProtocols
::
self
()
->
protocols
();
for
each
(
const
QString
&
protocol
,
protocols
)
{
for
(
const
QString
&
protocol
:
protocols
)
{
mProtocolCombo
->
addItem
(
QIcon
::
fromTheme
(
IMProtocols
::
self
()
->
icon
(
protocol
)),
IMProtocols
::
self
()
->
name
(
protocol
),
protocol
);
...
...
src/editor/generalinfoeditor/messaging/messagingwidgetlister.cpp
View file @
869ccf43
...
...
@@ -25,6 +25,7 @@
#include
"../../im/imaddress.h"
#include
"../../im/improtocols.h"
#include
"../../utils/utils.h"
#include
"helper_p.h"
#include
<KContacts/Addressee>
using
namespace
Akonadi
;
...
...
@@ -47,7 +48,7 @@ void MessagingWidgetLister::loadContact(const KContacts::Addressee &contact)
IMAddress
::
List
imaddresses
;
const
QStringList
customs
=
contact
.
customs
();
for
each
(
const
QString
&
custom
,
customs
)
{
for
(
const
QString
&
custom
:
customs
)
{
QString
app
,
name
,
value
;
Akonadi
::
Utils
::
splitCustomField
(
custom
,
app
,
name
,
value
);
...
...
@@ -56,7 +57,7 @@ void MessagingWidgetLister::loadContact(const KContacts::Addressee &contact)
const
QString
protocol
=
app
;
const
QStringList
names
=
value
.
split
(
QChar
(
0xE000
),
QString
::
SkipEmptyParts
);
for
each
(
const
QString
&
name
,
names
)
{
for
(
const
QString
&
name
:
names
)
{
//TODO preferred support ?
imaddresses
<<
IMAddress
(
protocol
,
name
,
false
);
}
...
...
@@ -90,12 +91,13 @@ void MessagingWidgetLister::storeContact(KContacts::Addressee &contact) const
QMap
<
QString
,
QStringList
>
protocolMap
;
// fill map with all known protocols
foreach
(
const
QString
&
protocol
,
IMProtocols
::
self
()
->
protocols
())
{
const
QStringList
lstProtocols
=
IMProtocols
::
self
()
->
protocols
();
for
(
const
QString
&
protocol
:
lstProtocols
)
{
protocolMap
.
insert
(
protocol
,
QStringList
());
}
// add the configured addresses
for
each
(
const
IMAddress
&
address
,
imaddresses
)
{
for
(
const
IMAddress
&
address
:
qAsConst
(
imaddresses
)
)
{
protocolMap
[
address
.
protocol
()].
append
(
address
.
name
());
}
...
...
src/editor/widgets/kwidgetlister.cpp
View file @
869ccf43
...
...
@@ -31,7 +31,7 @@
*/
#include
"kwidgetlister_p.h"
#include
"helper_p.h"
#include
<QHBoxLayout>
#include
<QPushButton>
...
...
@@ -116,7 +116,7 @@ void KWidgetLister::slotClear()
setNumberOfShownWidgetsTo
(
d
->
mMinWidgets
);
// clear remaining widgets
for
each
(
QWidget
*
widget
,
d
->
mWidgetList
)
{
for
(
QWidget
*
widget
:
qAsConst
(
d
->
mWidgetList
)
)
{
clearWidget
(
widget
);
}
...
...
src/emailaddressselectionwidget.cpp
View file @
869ccf43
...
...
@@ -206,7 +206,7 @@ EmailAddressSelection::List EmailAddressSelectionWidget::selectedAddresses() con
}
const
QModelIndexList
selectedRows
=
d
->
mView
->
selectionModel
()
->
selectedRows
(
0
);
for
each
(
const
QModelIndex
&
index
,
selectedRows
)
{
for
(
const
QModelIndex
&
index
:
selectedRows
)
{
EmailAddressSelection
selection
;
selection
.
d
->
mName
=
index
.
data
(
EmailAddressSelectionProxyModel
::
NameRole
).
toString
();
selection
.
d
->
mEmailAddress
=
index
.
data
(
EmailAddressSelectionProxyModel
::
EmailAddressRole
).
toString
();
...
...
src/helper_p.h
0 → 100644
View file @
869ccf43
/*
Copyright (c) 2017 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef _HELPER_H
#define _HELPER_H
#include
<qglobal.h>
#if QT_VERSION < QT_VERSION_CHECK(5,7,0)
namespace
QtPrivate
{
template
<
typename
T
>
struct
QAddConst
{
typedef
const
T
Type
;
};
}
// this adds const to non-const objects (like std::as_const)
template
<
typename
T
>
Q_DECL_CONSTEXPR
typename
QtPrivate
::
QAddConst
<
T
>::
Type
&
qAsConst
(
T
&
t
)
Q_DECL_NOTHROW
{
return
t
;
}
// prevent rvalue arguments:
template
<
typename
T
>
void
qAsConst
(
const
T
&&
)
Q_DECL_EQ_DELETE
;
#endif
#endif
src/job/contactgroupsearchjob.cpp
View file @
869ccf43
...
...
@@ -92,8 +92,8 @@ void ContactGroupSearchJob::setLimit(int limit)
KContacts
::
ContactGroup
::
List
ContactGroupSearchJob
::
contactGroups
()
const
{
KContacts
::
ContactGroup
::
List
contactGroups
;
for
each
(
const
Item
&
item
,
i
tems
()
)
{
const
Akonadi
::
Item
::
List
lstItems
=
items
();
for
(
const
Item
&
item
:
lstI
tems
)
{
if
(
item
.
hasPayload
<
KContacts
::
ContactGroup
>
())
{
contactGroups
.
append
(
item
.
payload
<
KContacts
::
ContactGroup
>
());
}
...
...
src/job/contactsearchjob.cpp
View file @
869ccf43
...
...
@@ -96,7 +96,8 @@ KContacts::Addressee::List ContactSearchJob::contacts() const
{
KContacts
::
Addressee
::
List
contacts
;
foreach
(
const
Item
&
item
,
items
())
{
const
Akonadi
::
Item
::
List
lstItems
=
items
();
for
(
const
Item
&
item
:
lstItems
)
{
if
(
item
.
hasPayload
<
KContacts
::
Addressee
>
())
{
contacts
.
append
(
item
.
payload
<
KContacts
::
Addressee
>
());
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment