Commit 16ec1da9 authored by Laurent Montel's avatar Laurent Montel 😁

Allow to show just "vcard" page (not custom page) need by kmail

parent ec35e6f3
......@@ -47,14 +47,14 @@ using namespace Akonadi;
class ContactEditor::Private
{
public:
Private( ContactEditor::Mode mode, AbstractContactEditorWidget *editorWidget, ContactEditor *parent )
Private( ContactEditor::Mode mode, ContactEditor::DisplayMode displayMode, AbstractContactEditorWidget *editorWidget, ContactEditor *parent )
: mParent( parent ), mMode( mode ), mMonitor( 0 ), mReadOnly( false )
{
if ( editorWidget ) {
mEditorWidget = editorWidget;
#ifndef DISABLE_EDITOR_WIDGETS
} else {
mEditorWidget = new ContactEditorWidget();
mEditorWidget = new ContactEditorWidget(displayMode == FullMode ? ContactEditorWidget::FullMode : ContactEditorWidget::VCardMode, 0);
#endif
}
......@@ -201,15 +201,21 @@ void ContactEditor::Private::setupMonitor()
ContactEditor::ContactEditor( Mode mode, QWidget *parent )
: QWidget( parent ), d( new Private( mode, 0, this ) )
: QWidget( parent ), d( new Private( mode, FullMode, 0, this ) )
{
}
ContactEditor::ContactEditor( Mode mode, AbstractContactEditorWidget *editorWidget, QWidget *parent )
: QWidget( parent ), d( new Private( mode, editorWidget, this ) )
: QWidget( parent ), d( new Private( mode, FullMode, editorWidget, this ) )
{
}
ContactEditor::ContactEditor( Mode mode, DisplayMode displayMode, QWidget *parent )
: QWidget( parent ), d( new Private( mode, displayMode, 0, this ) )
{
}
ContactEditor::~ContactEditor()
{
delete d;
......
......@@ -93,6 +93,11 @@ class AKONADI_CONTACT_EXPORT ContactEditor : public QWidget
EditMode ///< Edits an existing contact
};
enum DisplayMode {
FullMode, //Show all pages
VCardMode //Show just pages with elements stored in vcard.
};
/**
* Creates a new contact editor with the standard editor widget.
*
......@@ -110,6 +115,18 @@ class AKONADI_CONTACT_EXPORT ContactEditor : public QWidget
*/
ContactEditor( Mode mode, AbstractContactEditorWidget *editorWidget, QWidget *parent = 0 );
/**
* Creates a new contact editor dialog with a custom editor widget.
*
* @param mode The mode of the dialog.
* @param editorWidget The contact editor widget that shall be used for editing.
* @param parent The parent widget of the dialog.
* @since 4.10
*/
ContactEditor( Mode mode, DisplayMode displayMode, QWidget *parent = 0 );
/**
* Destroys the contact editor.
*/
......
......@@ -38,7 +38,7 @@ using namespace Akonadi;
class ContactEditorDialog::Private
{
public:
Private( ContactEditorDialog::Mode mode, AbstractContactEditorWidget *editorWidget,
Private( ContactEditorDialog::Mode mode, ContactEditorDialog::DisplayMode displaymode, AbstractContactEditorWidget *editorWidget,
ContactEditorDialog *parent )
: q( parent ), mAddressBookBox( 0 ), mMode( mode )
{
......@@ -54,7 +54,7 @@ class ContactEditorDialog::Private
if ( editorWidget ) {
mEditor = new ContactEditor( mode == ContactEditorDialog::CreateMode ? ContactEditor::CreateMode : ContactEditor::EditMode, editorWidget, q );
} else {
mEditor = new ContactEditor( mode == ContactEditorDialog::CreateMode ? ContactEditor::CreateMode : ContactEditor::EditMode, q );
mEditor = new ContactEditor( mode == ContactEditorDialog::CreateMode ? ContactEditor::CreateMode : ContactEditor::EditMode, displaymode == ContactEditorDialog::FullMode ? ContactEditor::FullMode : ContactEditor::VCardMode, q );
}
if ( mode == ContactEditorDialog::CreateMode ) {
......@@ -103,12 +103,17 @@ class ContactEditorDialog::Private
};
ContactEditorDialog::ContactEditorDialog( Mode mode, QWidget *parent )
: KDialog( parent ), d( new Private( mode, 0, this ) )
: KDialog( parent ), d( new Private( mode, FullMode, 0, this ) )
{
}
ContactEditorDialog::ContactEditorDialog( Mode mode, AbstractContactEditorWidget *editorWidget, QWidget *parent )
: KDialog( parent ), d( new Private( mode, editorWidget, this ) )
: KDialog( parent ), d( new Private( mode, FullMode, editorWidget, this ) )
{
}
ContactEditorDialog::ContactEditorDialog( Mode mode, DisplayMode displayMode, QWidget *parent )
: KDialog( parent ), d( new Private( mode, displayMode, 0, this ) )
{
}
......
......@@ -87,6 +87,11 @@ class AKONADI_CONTACT_EXPORT ContactEditorDialog : public KDialog
EditMode ///< Edits an existing contact
};
enum DisplayMode {
FullMode, //Show all pages
VCardMode //Show just pages with elements stored in vcard.
};
/**
* Creates a new contact editor dialog with the standard editor widget.
*
......@@ -104,6 +109,16 @@ class AKONADI_CONTACT_EXPORT ContactEditorDialog : public KDialog
*/
ContactEditorDialog( Mode mode, AbstractContactEditorWidget *editorWidget, QWidget *parent = 0 );
/**
* Creates a new contact editor dialog with a custom editor widget.
*
* @param mode The mode of the dialog.
* @param editorWidget The contact editor widget that shall be used for editing.
* @param parent The parent widget of the dialog.
* @since 4.10
*/
ContactEditorDialog( Mode mode, DisplayMode displayMode, QWidget *parent = 0 );
/**
* Destroys the contact editor dialog.
*/
......
......@@ -58,8 +58,8 @@
class ContactEditorWidget::Private
{
public:
Private( ContactEditorWidget *parent )
: mParent( parent )
Private( ContactEditorWidget::DisplayMode displayMode, ContactEditorWidget *parent )
: mDisplayMode(displayMode), mParent( parent ), mCustomFieldsWidget(0)
{
}
......@@ -76,6 +76,7 @@ class ContactEditorWidget::Private
QString loadCustom( const KABC::Addressee &contact, const QString &key ) const;
void storeCustom( KABC::Addressee &contact, const QString &key, const QString &value ) const;
ContactEditorWidget::DisplayMode mDisplayMode;
ContactEditorWidget *mParent;
KTabWidget *mTabWidget;
......@@ -150,9 +151,10 @@ void ContactEditorWidget::Private::initGui()
initGuiBusinessTab();
initGuiPersonalTab();
initGuiNotesTab();
initGuiCustomFieldsTab();
loadCustomPages();
if(mDisplayMode == FullMode) {
initGuiCustomFieldsTab();
loadCustomPages();
}
}
void ContactEditorWidget::Private::initGuiContactTab()
......@@ -519,7 +521,18 @@ void ContactEditorWidget::Private::storeCustom( KABC::Addressee &contact, const
}
ContactEditorWidget::ContactEditorWidget( QWidget* )
: d( new Private( this ) )
: d( new Private( FullMode, this ) )
{
d->initGui();
connect( d->mNameWidget, SIGNAL(nameChanged(KABC::Addressee)),
d->mDisplayNameWidget, SLOT(changeName(KABC::Addressee)) );
connect( d->mOrganizationWidget, SIGNAL(textChanged(QString)),
d->mDisplayNameWidget, SLOT(changeOrganization(QString)) );
}
ContactEditorWidget::ContactEditorWidget( ContactEditorWidget::DisplayMode displayMode, QWidget * )
: d( new Private( displayMode, this ) )
{
d->initGui();
......@@ -602,13 +615,15 @@ void ContactEditorWidget::loadContact( const KABC::Addressee &contact, const Ako
d->mDisplayNameWidget->setDisplayType( (DisplayNameEditWidget::DisplayType)metaData.displayNameMode() );
// custom fields group
d->mCustomFieldsWidget->setLocalCustomFieldDescriptions( metaData.customFieldDescriptions() );
d->mCustomFieldsWidget->loadContact( contact );
if(d->mDisplayMode == FullMode) {
// custom fields group
d->mCustomFieldsWidget->setLocalCustomFieldDescriptions( metaData.customFieldDescriptions() );
d->mCustomFieldsWidget->loadContact( contact );
// custom pages
foreach ( Akonadi::ContactEditorPagePlugin *plugin, d->mCustomPages ) {
plugin->loadContact( contact );
// custom pages
foreach ( Akonadi::ContactEditorPagePlugin *plugin, d->mCustomPages ) {
plugin->loadContact( contact );
}
}
}
......@@ -686,15 +701,17 @@ void ContactEditorWidget::storeContact( KABC::Addressee &contact, Akonadi::Conta
// family group
d->storeCustom( contact, QLatin1String( "X-SpousesName" ), d->mPartnerWidget->text().trimmed() );
// custom fields group
d->mCustomFieldsWidget->storeContact( contact );
metaData.setCustomFieldDescriptions( d->mCustomFieldsWidget->localCustomFieldDescriptions() );
if(d->mDisplayMode == FullMode) {
// custom fields group
d->mCustomFieldsWidget->storeContact( contact );
metaData.setCustomFieldDescriptions( d->mCustomFieldsWidget->localCustomFieldDescriptions() );
metaData.setDisplayNameMode( d->mDisplayNameWidget->displayType() );
metaData.setDisplayNameMode( d->mDisplayNameWidget->displayType() );
// custom pages
foreach ( Akonadi::ContactEditorPagePlugin *plugin, d->mCustomPages ) {
plugin->storeContact( contact );
// custom pages
foreach ( Akonadi::ContactEditorPagePlugin *plugin, d->mCustomPages ) {
plugin->storeContact( contact );
}
}
}
......@@ -752,11 +769,13 @@ void ContactEditorWidget::setReadOnly( bool readOnly )
// widgets from family group
d->mPartnerWidget->setReadOnly( readOnly );
// widgets from custom fields group
d->mCustomFieldsWidget->setReadOnly( readOnly );
if(d->mDisplayMode == FullMode) {
// widgets from custom fields group
d->mCustomFieldsWidget->setReadOnly( readOnly );
// custom pages
foreach ( Akonadi::ContactEditorPagePlugin *plugin, d->mCustomPages ) {
plugin->setReadOnly( readOnly );
// custom pages
foreach ( Akonadi::ContactEditorPagePlugin *plugin, d->mCustomPages ) {
plugin->setReadOnly( readOnly );
}
}
}
......@@ -42,7 +42,13 @@ class ContactEditorWidget : public Akonadi::AbstractContactEditorWidget
*
* @param parent The parent widget.
*/
ContactEditorWidget( QWidget *parent = 0 );
enum DisplayMode {
FullMode, //Show all pages
VCardMode //Show just pages with elements stored in vcard.
};
explicit ContactEditorWidget( QWidget *parent = 0 );
ContactEditorWidget( DisplayMode displayMode, QWidget *parent );
/**
* Destroys the contact editor widget.
......
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