Commit 8bc72824 authored by Laurent Montel's avatar Laurent Montel 😁

Fix indent

parent 9538eff9
......@@ -25,10 +25,10 @@
#include <KLocalizedString>
AboutData::AboutData()
: KAboutData( "kaddressbook", 0, ki18n( "KAddressBook" ),
KDEPIM_VERSION, ki18n( "The KDE Address Book Application" ),
KAboutData::License_GPL_V2,
ki18n( "Copyright © 2007–2014 KAddressBook authors" ) )
: KAboutData( "kaddressbook", 0, ki18n( "KAddressBook" ),
KDEPIM_VERSION, ki18n( "The KDE Address Book Application" ),
KAboutData::License_GPL_V2,
ki18n( "Copyright © 2007–2014 KAddressBook authors" ) )
{
addAuthor( ki18n( "Laurent Montel" ), ki18n( "Current maintainer" ), "montel@kde.org" );
addAuthor( ki18n( "Tobias Koenig" ), ki18n( "Previous maintainer" ), "tokoe@kde.org" );
......
......@@ -27,7 +27,7 @@
class KADDRESSBOOK_EXPORT AboutData : public KAboutData
{
public:
public:
/**
* Creates a new about data object.
*/
......
This diff is collapsed.
......@@ -25,68 +25,68 @@
class ContactFields
{
public:
public:
/**
* Describes the standard fields that are available for every contact
*/
enum Field {
Undefined = 0,
FormattedName,
Prefix,
GivenName,
AdditionalName,
FamilyName,
Suffix,
NickName,
Birthday,
Anniversary,
HomeAddressStreet,
HomeAddressPostOfficeBox,
HomeAddressLocality,
HomeAddressRegion,
HomeAddressPostalCode,
HomeAddressCountry,
HomeAddressLabel,
BusinessAddressStreet,
BusinessAddressPostOfficeBox,
BusinessAddressLocality,
BusinessAddressRegion,
BusinessAddressPostalCode,
BusinessAddressCountry,
BusinessAddressLabel,
HomePhone,
BusinessPhone,
MobilePhone,
HomeFax,
BusinessFax,
CarPhone,
Isdn,
Pager,
PreferredEmail,
Email2,
Email3,
Email4,
Mailer,
Title,
Role,
Organization,
Note,
Homepage,
BlogFeed,
Profession,
Office,
Manager,
Assistant,
Spouse
Undefined = 0,
FormattedName,
Prefix,
GivenName,
AdditionalName,
FamilyName,
Suffix,
NickName,
Birthday,
Anniversary,
HomeAddressStreet,
HomeAddressPostOfficeBox,
HomeAddressLocality,
HomeAddressRegion,
HomeAddressPostalCode,
HomeAddressCountry,
HomeAddressLabel,
BusinessAddressStreet,
BusinessAddressPostOfficeBox,
BusinessAddressLocality,
BusinessAddressRegion,
BusinessAddressPostalCode,
BusinessAddressCountry,
BusinessAddressLabel,
HomePhone,
BusinessPhone,
MobilePhone,
HomeFax,
BusinessFax,
CarPhone,
Isdn,
Pager,
PreferredEmail,
Email2,
Email3,
Email4,
Mailer,
Title,
Role,
Organization,
Note,
Homepage,
BlogFeed,
Profession,
Office,
Manager,
Assistant,
Spouse
};
/**
......
......@@ -24,29 +24,29 @@
ContactSelectionDialog::ContactSelectionDialog( QItemSelectionModel *selectionModel,
QWidget *parent )
: KDialog( parent )
: KDialog( parent )
{
setCaption( i18n( "Select Contacts" ) );
setButtons( Ok | Cancel );
setCaption( i18n( "Select Contacts" ) );
setButtons( Ok | Cancel );
mSelectionWidget = new ContactSelectionWidget( selectionModel, this );
setMainWidget( mSelectionWidget );
mSelectionWidget = new ContactSelectionWidget( selectionModel, this );
setMainWidget( mSelectionWidget );
setInitialSize( QSize( 450, 220 ) );
setInitialSize( QSize( 450, 220 ) );
}
void ContactSelectionDialog::setMessageText( const QString &message )
{
mSelectionWidget->setMessageText( message );
mSelectionWidget->setMessageText( message );
}
void ContactSelectionDialog::setDefaultAddressBook( const Akonadi::Collection &addressBook )
{
mSelectionWidget->setDefaultAddressBook( addressBook );
mSelectionWidget->setDefaultAddressBook( addressBook );
}
KABC::Addressee::List ContactSelectionDialog::selectedContacts() const
{
return mSelectionWidget->selectedContacts();
return mSelectionWidget->selectedContacts();
}
......@@ -29,7 +29,7 @@ class QItemSelectionModel;
namespace Akonadi
{
class Collection;
class Collection;
}
/**
......@@ -39,9 +39,9 @@ namespace Akonadi
*/
class ContactSelectionDialog : public KDialog
{
Q_OBJECT
Q_OBJECT
public:
public:
/**
* Creates a new contact selection dialog.
*
......@@ -65,7 +65,7 @@ class ContactSelectionDialog : public KDialog
*/
KABC::Addressee::List selectedContacts() const;
private:
private:
ContactSelectionWidget *mSelectionWidget;
};
......
......@@ -39,176 +39,176 @@
ContactSelectionWidget::ContactSelectionWidget( QItemSelectionModel *selectionModel,
QWidget *parent )
: QWidget( parent ), mSelectionModel( selectionModel )
: QWidget( parent ), mSelectionModel( selectionModel )
{
initGui();
mSelectedContactsButton->setEnabled( mSelectionModel->hasSelection() );
mAddressBookSelection->setEnabled( false );
mAddressBookSelectionRecursive->setEnabled( false );
connect( mAddressBookContactsButton, SIGNAL(toggled(bool)),
mAddressBookSelection, SLOT(setEnabled(bool)) );
connect( mAddressBookContactsButton, SIGNAL(toggled(bool)),
mAddressBookSelectionRecursive, SLOT(setEnabled(bool)) );
// apply default configuration
if ( mSelectionModel->hasSelection() ) {
mSelectedContactsButton->setChecked( true );
} else {
mAllContactsButton->setChecked( true );
}
initGui();
mSelectedContactsButton->setEnabled( mSelectionModel->hasSelection() );
mAddressBookSelection->setEnabled( false );
mAddressBookSelectionRecursive->setEnabled( false );
connect( mAddressBookContactsButton, SIGNAL(toggled(bool)),
mAddressBookSelection, SLOT(setEnabled(bool)) );
connect( mAddressBookContactsButton, SIGNAL(toggled(bool)),
mAddressBookSelectionRecursive, SLOT(setEnabled(bool)) );
// apply default configuration
if ( mSelectionModel->hasSelection() ) {
mSelectedContactsButton->setChecked( true );
} else {
mAllContactsButton->setChecked( true );
}
}
void ContactSelectionWidget::setMessageText( const QString &message )
{
mMessageLabel->setText( message );
mMessageLabel->setText( message );
}
void ContactSelectionWidget::setDefaultAddressBook( const Akonadi::Collection &addressBook )
{
mAddressBookSelection->setDefaultCollection( addressBook );
mAddressBookSelection->setDefaultCollection( addressBook );
}
KABC::Addressee::List ContactSelectionWidget::selectedContacts() const
{
if ( mAllContactsButton->isChecked() ) {
return collectAllContacts();
} else if ( mSelectedContactsButton->isChecked() ) {
return collectSelectedContacts();
} else if ( mAddressBookContactsButton->isChecked() ) {
return collectAddressBookContacts();
}
return KABC::Addressee::List();
if ( mAllContactsButton->isChecked() ) {
return collectAllContacts();
} else if ( mSelectedContactsButton->isChecked() ) {
return collectSelectedContacts();
} else if ( mAddressBookContactsButton->isChecked() ) {
return collectAddressBookContacts();
}
return KABC::Addressee::List();
}
Akonadi::Item::List ContactSelectionWidget::selectedContactsItem() const
{
if ( mAllContactsButton->isChecked() ) {
return collectAllContactsItem();
} else if ( mSelectedContactsButton->isChecked() ) {
return collectSelectedContactsItem();
} else if ( mAddressBookContactsButton->isChecked() ) {
return collectAddressBookContactsItem();
}
return Akonadi::Item::List();
if ( mAllContactsButton->isChecked() ) {
return collectAllContactsItem();
} else if ( mSelectedContactsButton->isChecked() ) {
return collectSelectedContactsItem();
} else if ( mAddressBookContactsButton->isChecked() ) {
return collectAddressBookContactsItem();
}
return Akonadi::Item::List();
}
void ContactSelectionWidget::initGui()
{
QVBoxLayout *layout = new QVBoxLayout( this );
mMessageLabel = new QLabel;
layout->addWidget( mMessageLabel );
QButtonGroup *group = new QButtonGroup( this );
QGroupBox *groupBox = new QGroupBox;
QGridLayout *boxLayout = new QGridLayout;
groupBox->setLayout( boxLayout );
mAllContactsButton = new QRadioButton( i18nc( "@option:radio", "All contacts" ) );
mAllContactsButton->setToolTip(
i18nc( "@info:tooltip", "All contacts from all your address books" ) );
mAllContactsButton->setWhatsThis(
i18nc( "@info:whatsthis",
"Choose this option you want to select all your contacts from "
"all your address books." ) );
mSelectedContactsButton = new QRadioButton( i18nc( "@option:radio","Selected contacts" ) );
mSelectedContactsButton->setToolTip(
i18nc( "@info:tooltip", "Only the contacts currently selected" ) );
mSelectedContactsButton->setWhatsThis(
i18nc( "@info:whatsthis",
"Choose this option if you want only the contacts you have already "
"selected in the graphical interface." ) );
mAddressBookContactsButton = new QRadioButton( i18nc( "@option:radio", "All contacts from:" ) );
mAddressBookContactsButton->setToolTip(
i18nc( "@info:tooltip", "All contacts from a chosen address book" ) );
mAddressBookContactsButton->setWhatsThis(
i18nc( "@info:whatsthis",
"Choose this option if you want to select all the contacts from only one "
"of your address books. Once this option is clicked you will be provided "
"a drop down box listing all those address books and permitted to select "
"the one you want." ) );
mAddressBookSelection = new Akonadi::CollectionComboBox;
mAddressBookSelection->setMimeTypeFilter( QStringList() << KABC::Addressee::mimeType() );
mAddressBookSelection->setAccessRightsFilter( Akonadi::Collection::ReadOnly );
mAddressBookSelection->setExcludeVirtualCollections( true );
mAddressBookSelectionRecursive = new QCheckBox( i18nc( "@option:check", "Include Subfolders" ) );
mAddressBookSelectionRecursive->setToolTip(
i18nc( "@info:tooltip", "Select all subfolders including the top-level folder" ) );
mAddressBookSelectionRecursive->setWhatsThis(
i18nc( "@info:whatsthis",
"Check this box if you want to select all contacts from this folder, "
"including all subfolders. If you only want the contacts from the "
"top-level folder then leave this box unchecked." ) );
group->addButton( mAllContactsButton );
group->addButton( mSelectedContactsButton );
group->addButton( mAddressBookContactsButton );
boxLayout->addWidget( mAllContactsButton, 0, 0, 1, 2 );
boxLayout->addWidget( mSelectedContactsButton, 1, 0, 1, 2 );
boxLayout->addWidget( mAddressBookContactsButton, 2, 0, Qt::AlignTop );
QVBoxLayout *addressBookLayout = new QVBoxLayout;
addressBookLayout->setMargin( 0 );
addressBookLayout->addWidget( mAddressBookSelection );
addressBookLayout->addWidget( mAddressBookSelectionRecursive );
boxLayout->addLayout( addressBookLayout, 2, 1 );
layout->addWidget( groupBox );
layout->addStretch( 1 );
QVBoxLayout *layout = new QVBoxLayout( this );
mMessageLabel = new QLabel;
layout->addWidget( mMessageLabel );
QButtonGroup *group = new QButtonGroup( this );
QGroupBox *groupBox = new QGroupBox;
QGridLayout *boxLayout = new QGridLayout;
groupBox->setLayout( boxLayout );
mAllContactsButton = new QRadioButton( i18nc( "@option:radio", "All contacts" ) );
mAllContactsButton->setToolTip(
i18nc( "@info:tooltip", "All contacts from all your address books" ) );
mAllContactsButton->setWhatsThis(
i18nc( "@info:whatsthis",
"Choose this option you want to select all your contacts from "
"all your address books." ) );
mSelectedContactsButton = new QRadioButton( i18nc( "@option:radio","Selected contacts" ) );
mSelectedContactsButton->setToolTip(
i18nc( "@info:tooltip", "Only the contacts currently selected" ) );
mSelectedContactsButton->setWhatsThis(
i18nc( "@info:whatsthis",
"Choose this option if you want only the contacts you have already "
"selected in the graphical interface." ) );
mAddressBookContactsButton = new QRadioButton( i18nc( "@option:radio", "All contacts from:" ) );
mAddressBookContactsButton->setToolTip(
i18nc( "@info:tooltip", "All contacts from a chosen address book" ) );
mAddressBookContactsButton->setWhatsThis(
i18nc( "@info:whatsthis",
"Choose this option if you want to select all the contacts from only one "
"of your address books. Once this option is clicked you will be provided "
"a drop down box listing all those address books and permitted to select "
"the one you want." ) );
mAddressBookSelection = new Akonadi::CollectionComboBox;
mAddressBookSelection->setMimeTypeFilter( QStringList() << KABC::Addressee::mimeType() );
mAddressBookSelection->setAccessRightsFilter( Akonadi::Collection::ReadOnly );
mAddressBookSelection->setExcludeVirtualCollections( true );
mAddressBookSelectionRecursive = new QCheckBox( i18nc( "@option:check", "Include Subfolders" ) );
mAddressBookSelectionRecursive->setToolTip(
i18nc( "@info:tooltip", "Select all subfolders including the top-level folder" ) );
mAddressBookSelectionRecursive->setWhatsThis(
i18nc( "@info:whatsthis",
"Check this box if you want to select all contacts from this folder, "
"including all subfolders. If you only want the contacts from the "
"top-level folder then leave this box unchecked." ) );
group->addButton( mAllContactsButton );
group->addButton( mSelectedContactsButton );
group->addButton( mAddressBookContactsButton );
boxLayout->addWidget( mAllContactsButton, 0, 0, 1, 2 );
boxLayout->addWidget( mSelectedContactsButton, 1, 0, 1, 2 );
boxLayout->addWidget( mAddressBookContactsButton, 2, 0, Qt::AlignTop );
QVBoxLayout *addressBookLayout = new QVBoxLayout;
addressBookLayout->setMargin( 0 );
addressBookLayout->addWidget( mAddressBookSelection );
addressBookLayout->addWidget( mAddressBookSelectionRecursive );
boxLayout->addLayout( addressBookLayout, 2, 1 );
layout->addWidget( groupBox );
layout->addStretch( 1 );
}
KABC::Addressee::List ContactSelectionWidget::collectAllContacts() const
{
Akonadi::RecursiveItemFetchJob *job =
new Akonadi::RecursiveItemFetchJob( Akonadi::Collection::root(),
QStringList() << KABC::Addressee::mimeType() );
job->fetchScope().fetchFullPayload();
Akonadi::RecursiveItemFetchJob *job =
new Akonadi::RecursiveItemFetchJob( Akonadi::Collection::root(),
QStringList() << KABC::Addressee::mimeType() );
job->fetchScope().fetchFullPayload();
KABC::Addressee::List contacts;
if ( !job->exec() ) {
return contacts;
}
KABC::Addressee::List contacts;
if ( !job->exec() ) {
return contacts;
}
foreach ( const Akonadi::Item &item, job->items() ) {
if ( item.isValid() && item.hasPayload<KABC::Addressee>() ) {
contacts.append( item.payload<KABC::Addressee>() );
foreach ( const Akonadi::Item &item, job->items() ) {
if ( item.isValid() && item.hasPayload<KABC::Addressee>() ) {
contacts.append( item.payload<KABC::Addressee>() );
}
}
}
return contacts;
return contacts;
}
Akonadi::Item::List ContactSelectionWidget::collectAllContactsItem() const
{
Akonadi::RecursiveItemFetchJob *job =
new Akonadi::RecursiveItemFetchJob( Akonadi::Collection::root(),
QStringList() << KABC::Addressee::mimeType() );
job->fetchScope().fetchFullPayload();
Akonadi::RecursiveItemFetchJob *job =
new Akonadi::RecursiveItemFetchJob( Akonadi::Collection::root(),
QStringList() << KABC::Addressee::mimeType() );
job->fetchScope().fetchFullPayload();
Akonadi::Item::List lst;
if ( !job->exec() ) {
return lst;
}
Akonadi::Item::List lst;
if ( !job->exec() ) {
return lst;
}
foreach ( const Akonadi::Item &item, job->items() ) {
if ( item.isValid() && item.hasPayload<KABC::Addressee>() ) {
lst.append( item );
foreach ( const Akonadi::Item &item, job->items() ) {
if ( item.isValid() && item.hasPayload<KABC::Addressee>() ) {
lst.append( item );
}
}
}
return lst;
return lst;
}
Akonadi::Item::List ContactSelectionWidget::collectSelectedContactsItem() const
......@@ -220,104 +220,104 @@ Akonadi::Item::List ContactSelectionWidget::collectSelectedContactsItem() const
KABC::Addressee::List ContactSelectionWidget::collectSelectedContacts() const
{
KABC::Addressee::List contacts;
const QModelIndexList indexes = mSelectionModel->selectedRows( 0 );
for ( int i = 0; i < indexes.count(); ++i ) {
const QModelIndex index = indexes.at( i );
if ( index.isValid() ) {
const Akonadi::Item item =
index.data( Akonadi::EntityTreeModel::ItemRole ).value<Akonadi::Item>();
if ( item.isValid() && item.hasPayload<KABC::Addressee>() ) {
contacts.append( item.payload<KABC::Addressee>() );
}
KABC::Addressee::List contacts;
const QModelIndexList indexes = mSelectionModel->selectedRows( 0 );
for ( int i = 0; i < indexes.count(); ++i ) {
const QModelIndex index = indexes.at( i );
if ( index.isValid() ) {
const Akonadi::Item item =
index.data( Akonadi::EntityTreeModel::ItemRole ).value<Akonadi::Item>();
if ( item.isValid() && item.hasPayload<KABC::Addressee>() ) {
contacts.append( item.payload<KABC::Addressee>() );
}
}
}
}
return contacts;
return contacts;
}
KABC::Addressee::List ContactSelectionWidget::collectAddressBookContacts() const
{
KABC::Addressee::List contacts;
const Akonadi::Collection collection = mAddressBookSelection->currentCollection();
if ( !collection.isValid() ) {
return contacts;
}
if ( mAddressBookSelectionRecursive->isChecked() ) {
Akonadi::RecursiveItemFetchJob *job =
new Akonadi::RecursiveItemFetchJob( collection,
QStringList() << KABC::Addressee::mimeType() );
job->fetchScope().fetchFullPayload();
KABC::Addressee::List contacts;
if ( !job->exec() ) {
return contacts;
const Akonadi::Collection collection = mAddressBookSelection->currentCollection();
if ( !collection.isValid() ) {
return contacts;
}
foreach ( const Akonadi::Item &item, job->items() ) {