Commit ebd65080 authored by Tobias Koenig's avatar Tobias Koenig

Do some refactoring and implement second ctor of ContactEditor

svn path=/trunk/KDE/kdepimlibs/; revision=1018515
parent 9dae3c9e
......@@ -26,6 +26,7 @@
#include "autoqpointer_p.h"
#include "contactmetadata_p.h"
#include "contactmetadataattribute_p.h"
#include "editor/contacteditorwidget.h"
#include <akonadi/collectionfetchjob.h>
#include <akonadi/itemcreatejob.h>
......@@ -45,9 +46,18 @@ using namespace Akonadi;
class ContactEditor::Private
{
public:
Private( ContactEditor *parent )
: mParent( parent ), mMonitor( 0 ), mReadOnly( false )
Private( ContactEditor::Mode mode, AbstractContactEditorWidget *editorWidget, ContactEditor *parent )
: mParent( parent ), mMode( mode ), mMonitor( 0 ), mReadOnly( false )
{
if ( editorWidget )
mEditorWidget = editorWidget;
else
mEditorWidget = new ContactEditorWidget();
QVBoxLayout *layout = new QVBoxLayout( mParent );
layout->setMargin( 0 );
layout->setSpacing( 0 );
layout->addWidget( mEditorWidget );
}
~Private()
......@@ -177,16 +187,14 @@ void ContactEditor::Private::setupMonitor()
}
ContactEditor::ContactEditor( Mode mode, AbstractContactEditorWidget *editorWidget, QWidget *parent )
: QWidget( parent ), d( new Private( this ) )
ContactEditor::ContactEditor( Mode mode, QWidget *parent )
: QWidget( parent ), d( new Private( mode, 0, this ) )
{
d->mMode = mode;
d->mEditorWidget = editorWidget;
}
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setMargin( 0 );
layout->setSpacing( 0 );
layout->addWidget( d->mEditorWidget );
ContactEditor::ContactEditor( Mode mode, AbstractContactEditorWidget *editorWidget, QWidget *parent )
: QWidget( parent ), d( new Private( mode, editorWidget, this ) )
{
}
ContactEditor::~ContactEditor()
......
......@@ -67,7 +67,7 @@ class AKONADI_CONTACT_EXPORT ContactEditor : public QWidget
* @param editorWidget The contact editor widget that shall be used for editing.
* @param parent The parent widget of the editor.
*/
explicit ContactEditor( Mode mode, AbstractContactEditorWidget *editorWidget, QWidget *parent = 0 );
ContactEditor( Mode mode, AbstractContactEditorWidget *editorWidget, QWidget *parent = 0 );
/**
* Destroys the contact editor.
......
......@@ -22,7 +22,6 @@
#include "addressbookcombobox_p.h"
#include "contacteditor.h"
#include "editor/contacteditorwidget.h"
#include <akonadi/item.h>
......@@ -50,8 +49,10 @@ class ContactEditorDialog::Private
QGridLayout *layout = new QGridLayout( mainWidget );
mEditor = new ContactEditor( mode == ContactEditorDialog::CreateMode ? ContactEditor::CreateMode : ContactEditor::EditMode,
editorWidget ? editorWidget : new ContactEditorWidget(), q );
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 );
if ( mode == ContactEditorDialog::CreateMode ) {
QLabel *label = new QLabel( i18n( "Add to:" ), mainWidget );
......
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