summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/addresseeeditorwidget.cpp32
-rw-r--r--kaddressbook/addresseeeditorwidget.h2
2 files changed, 28 insertions, 6 deletions
diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp
index 29abd6f..310d628 100644
--- a/kaddressbook/addresseeeditorwidget.cpp
+++ b/kaddressbook/addresseeeditorwidget.cpp
@@ -95,329 +95,349 @@ AddresseeEditorWidget::AddresseeEditorWidget( KABCore *core, bool isExtension,
// Load the empty addressee as defaults
load();
mDirty = false;
}
AddresseeEditorWidget::~AddresseeEditorWidget()
{
kdDebug(5720) << "~AddresseeEditorWidget()" << endl;
}
void AddresseeEditorWidget::contactsSelectionChanged()
{
KABC::Addressee::List list = selectedContacts();
mAddressee = list[ 0 ];
load();
}
void AddresseeEditorWidget::setAddressee( const KABC::Addressee &addr )
{
mAddressee = addr;
load();
}
const KABC::Addressee &AddresseeEditorWidget::addressee()
{
return mAddressee;
}
void AddresseeEditorWidget::textChanged( const QString& )
{
emitModified();
}
void AddresseeEditorWidget::initGUI()
{
QVBoxLayout *layout = new QVBoxLayout( this );
mTabWidget = new QTabWidget( this );
layout->addWidget( mTabWidget );
setupTab1();
setupTab1_1();
setupTab2();
setupTab2_1();
setupTab3();
setupTab3_1();
mNameEdit->setFocus();
connect( mTabWidget, SIGNAL( currentChanged(QWidget*) ),
SLOT( pageChanged(QWidget*) ) );
}
void AddresseeEditorWidget::setupTab1()
{
// This is the General tab
QWidget *tab1 = new QWidget( mTabWidget );
//US QGridLayout *layout = new QGridLayout( tab1, 11, 7 );
QGridLayout *layout = new QGridLayout( tab1, 7, 1 );
layout->setMargin( KDialogBase::marginHintSmall() );
layout->setSpacing( KDialogBase::spacingHintSmall() );
QLabel *label;
KSeparator* bar;
QPushButton *button;
//////////////////////////////////
// Upper left group (person info)
// Person icon
/* LR
label = new QLabel( tab1 );
//US ambiguous call. Add one more parameter
//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) );
label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) );
layout->addMultiCellWidget( label, 0, 1, 0, 0 );
*/
// First name
button = new QPushButton( i18n( "Name..." ), tab1 );
//US QToolTip::add( button, i18n( "Edit the contact's name" ) );
mNameEdit = new KLineEdit( tab1, "mNameEdit" );
connect( mNameEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( nameTextChanged( const QString& ) ) );
connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) );
mNameLabel = new KSqueezedTextLabel( tab1 );
mNameLabel->hide();
layout->addWidget( button, 0, 0 );
layout->addWidget( mNameEdit, 0, 1 );
layout->addWidget( mNameLabel, 0, 1 );
- label = new QLabel( i18n( "Role:" ), tab1 );
+ button = new QPushButton( i18n( "Role:" ), tab1 );
+ connect( button, SIGNAL( clicked() ), SLOT( setRole2FN() ) );
+ //label = new QLabel( i18n( "Role:" ), tab1 );
mRoleEdit = new KLineEdit( tab1 );
connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( textChanged( const QString& ) ) );
- label->setBuddy( mRoleEdit );
- layout->addWidget( label, 1, 0 );
+ //label->setBuddy( mRoleEdit );
+ layout->addWidget( button, 1, 0 );
layout->addWidget( mRoleEdit, 1, 1 );
// Organization
- label = new QLabel( i18n( "Organization:" ), tab1 );
+ button = new QPushButton( i18n( "Organization:" ), tab1 );
+ connect( button, SIGNAL( clicked() ), SLOT( setCompany2FN() ) );
+ //label = new QLabel( i18n( "Organization:" ), tab1 );
mOrgEdit = new KLineEdit( tab1 );
- label->setBuddy( mOrgEdit );
+ //label->setBuddy( mOrgEdit );
connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( textChanged( const QString& ) ) );
- layout->addWidget( label, 2, 0 );
+ layout->addWidget( button, 2, 0 );
layout->addWidget( mOrgEdit, 2, 1 );
// File as (formatted name)
label = new QLabel( i18n( "Formatted name:" ), tab1 );
mFormattedNameLabel = new KSqueezedTextLabel( tab1 );
layout->addWidget( label, 3, 0 );
layout->addWidget( mFormattedNameLabel, 3, 1 );
/* LR
// Left hand separator. This separator doesn't go all the way
// across so the dialog still flows from top to bottom
bar = new KSeparator( KSeparator::HLine, tab1 );
layout->addMultiCellWidget( bar, 4, 4, 0, 2 );
*/
//////////////////////////////////////
/* LR
// Phone numbers (upper right)
label = new QLabel( tab1 );
//US loadIcon call is ambiguous. Add one more parameter
//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) );
label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) );
//US layout->addMultiCellWidget( label, 0, 1, 3, 3 );
layout->addMultiCellWidget( label, 5, 6, 0, 0 );
*/
mPhoneEditWidget = new PhoneEditWidget( tab1 );
connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
//US layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 );
int iii;
#ifndef DESKTOP_VERSION
iii = 7;
#else
iii = 8;
#endif
layout->addMultiCellWidget( mPhoneEditWidget, 4, iii, 0, 1 );
++iii;
/* LR
bar = new KSeparator( KSeparator::HLine, tab1 );
//US layout->addMultiCellWidget( bar, 4, 4, 3, 6 );
layout->addMultiCellWidget( bar, 9, 9, 0, 2 );
*/
/*US
//////////////////////////////////////
// Addresses (lower left)
label = new QLabel( tab1 );
//US loadIcon call is ambiguous. Add one more parameter
//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop ) );
label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) );
layout->addMultiCellWidget( label, 5, 6, 0, 0 );
mAddressEditWidget = new AddressEditWidget( tab1 );
connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
layout->addMultiCellWidget( mAddressEditWidget, 5, 9, 1, 2 );
//////////////////////////////////////
// Email / Web (lower right)
label = new QLabel( tab1 );
//US loadIcon call is ambiguous. Add one more parameter
//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop) );
label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop, 0) );
layout->addMultiCellWidget( label, 5, 6, 3, 3 );
mEmailWidget = new EmailEditWidget( tab1 );
connect( mEmailWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
layout->addMultiCellWidget( mEmailWidget, 5, 6, 4, 6 );
// add the separator
bar = new KSeparator( KSeparator::HLine, tab1 );
layout->addMultiCellWidget( bar, 7, 7, 3, 6 );
label = new QLabel( tab1 );
//US loadIcon call is ambiguous. Add one more parameter
//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop) );
label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop, 0) );
layout->addMultiCellWidget( label, 8, 9, 3, 3 );
label = new QLabel( i18n( "URL:" ), tab1 );
mURLEdit = new KLineEdit( tab1 );
connect( mURLEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( textChanged( const QString& ) ) );
label->setBuddy( mURLEdit );
layout->addWidget( label, 8, 4 );
layout->addMultiCellWidget( mURLEdit, 8, 8, 5, 6 );
label = new QLabel( i18n( "&IM address:" ), tab1 );
mIMAddressEdit = new KLineEdit( tab1 );
connect( mIMAddressEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( textChanged( const QString& ) ) );
label->setBuddy( mIMAddressEdit );
layout->addWidget( label, 9, 4 );
layout->addMultiCellWidget( mIMAddressEdit, 9, 9, 5, 6 );
layout->addColSpacing( 6, 50 );
bar = new KSeparator( KSeparator::HLine, tab1 );
layout->addMultiCellWidget( bar, 10, 10, 0, 6 );
*/
///////////////////////////////////////
QHBox *categoryBox = new QHBox( tab1 ,"cato");
categoryBox->setSpacing( KDialogBase::spacingHint() );
categoryBox->setMargin( KDialogBase::marginHintSmall() );
// Categories
button = new QPushButton( i18n( "Categories" ), categoryBox );
connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) );
mCategoryEdit = new KLineEdit( categoryBox );
mCategoryEdit->setReadOnly( true );
connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( textChanged( const QString& ) ) );
mSecrecyWidget = new SecrecyWidget( categoryBox );
connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
//US layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 );
layout->addMultiCellWidget( categoryBox, iii, iii, 0, 1 );
// Build the layout and add to the tab widget
layout->activate(); // required
mTabWidget->addTab( tab1, i18n( "&General" ) );
}
+void AddresseeEditorWidget::setRole2FN()
+{
+ if ( mRoleEdit->text().isEmpty() ) return;
+ mFormattedNameType = NameEditDialog::CustomName;
+ mAddressee.setFormattedName( mRoleEdit->text() );
+ mFormattedNameLabel->setText( mRoleEdit->text() );
+ mDirty = true;
+}
+void AddresseeEditorWidget::setCompany2FN()
+{
+ if ( mOrgEdit->text().isEmpty() ) return;
+ mFormattedNameType = NameEditDialog::CustomName;
+ mAddressee.setFormattedName( mOrgEdit->text() );
+ mFormattedNameLabel->setText( mOrgEdit->text() );
+ mDirty = true;
+}
void AddresseeEditorWidget::setupTab1_1()
{
// This is the Address tab
QWidget *tab1_1 = new QWidget( mTabWidget );
//US QGridLayout *layout = new QGridLayout( tab1_1, 11, 7 );
QGridLayout *layout = new QGridLayout( tab1_1, 7, 2 );
layout->setMargin( KDialogBase::marginHintSmall() );
layout->setSpacing( KDialogBase::spacingHintSmall() );
QLabel *label;
KSeparator* bar;
QPushButton *button;
/*US
//////////////////////////////////
// Upper left group (person info)
// Person icon
label = new QLabel( tab1 );
//US ambiguous call. Add one more parameter
//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) );
label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) );
layout->addMultiCellWidget( label, 0, 1, 0, 0 );
// First name
button = new QPushButton( i18n( "Name..." ), tab1 );
QToolTip::add( button, i18n( "Edit the contact's name" ) );
mNameEdit = new KLineEdit( tab1, "mNameEdit" );
connect( mNameEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( nameTextChanged( const QString& ) ) );
connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) );
#ifndef KAB_EMBEDDED
mNameLabel = new KSqueezedTextLabel( tab1 );
mNameLabel->hide();
#else //KAB_EMBEDDED
qDebug("AddresseeEditorWidget::setupTab1 has to be changed");
#endif //KAB_EMBEDDED
layout->addWidget( button, 0, 1 );
layout->addWidget( mNameEdit, 0, 2 );
#ifndef KAB_EMBEDDED
layout->addWidget( mNameLabel, 0, 2 );
#else //KAB_EMBEDDED
qDebug("AddresseeEditorWidget::setupTab1 has to be changed");
#endif //KAB_EMBEDDED
label = new QLabel( i18n( "Role:" ), tab1 );
mRoleEdit = new KLineEdit( tab1 );
connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( textChanged( const QString& ) ) );
label->setBuddy( mRoleEdit );
layout->addWidget( label, 1, 1 );
layout->addWidget( mRoleEdit, 1, 2 );
// Organization
label = new QLabel( i18n( "Organization:" ), tab1 );
mOrgEdit = new KLineEdit( tab1 );
label->setBuddy( mOrgEdit );
connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( textChanged( const QString& ) ) );
layout->addWidget( label, 2, 1 );
layout->addWidget( mOrgEdit, 2, 2 );
// File as (formatted name)
label = new QLabel( i18n( "Formatted name:" ), tab1 );
#ifndef KAB_EMBEDDED
mFormattedNameLabel = new KSqueezedTextLabel( tab1 );
#else //KAB_EMBEDDED
qDebug("AddresseeEditorWidget::setupTab1 has to be changed");
#endif //KAB_EMBEDDED
layout->addWidget( label, 3, 1 );
#ifndef KAB_EMBEDDED
layout->addWidget( mFormattedNameLabel, 3, 2 );
#else //KAB_EMBEDDED
qDebug("AddresseeEditorWidget::setupTab1 has to be changed");
#endif //KAB_EMBEDDED
// Left hand separator. This separator doesn't go all the way
// across so the dialog still flows from top to bottom
bar = new KSeparator( KSeparator::HLine, tab1 );
layout->addMultiCellWidget( bar, 4, 4, 0, 2 );
//////////////////////////////////////
// Phone numbers (upper right)
label = new QLabel( tab1 );
//US loadIcon call is ambiguous. Add one more parameter
//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) );
label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) );
layout->addMultiCellWidget( label, 0, 1, 3, 3 );
mPhoneEditWidget = new PhoneEditWidget( tab1 );
connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
diff --git a/kaddressbook/addresseeeditorwidget.h b/kaddressbook/addresseeeditorwidget.h
index 995f30e..eaf5b16 100644
--- a/kaddressbook/addresseeeditorwidget.h
+++ b/kaddressbook/addresseeeditorwidget.h
@@ -1,186 +1,188 @@
/*
This file is part of KAddressBook.
Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef ADDRESSEEEDITORWIDGET_H
#define ADDRESSEEEDITORWIDGET_H
#include <qdatetime.h>
#include <kabc/addressee.h>
#include <kdialogbase.h>
#include <kjanuswidget.h>
#include "extensionwidget.h"
class AddresseeConfig;
class QCheckBox;
class QSpinBox;
class QTabWidget;
#ifndef KAB_EMBEDDED
class QTextEdit;
#else //KAB_EMBEDDED
class QMultiLineEdit;
#endif //KAB_EMBEDDED
class KComboBox;
class KDateEdit;
class KLineEdit;
class KSqueezedTextLabel;
class AddressEditWidget;
class EmailEditWidget;
class GeoWidget;
class ImageWidget;
class KABCore;
class KeyWidget;
class PhoneEditWidget;
class SecrecyWidget;
class SoundWidget;
namespace KPIM
{
class CategorySelectDialog;
class CategoryEditDialog;
}
namespace KABC { class AddressBook; }
class AddresseeEditorWidget : public ExtensionWidget
{
Q_OBJECT
public:
AddresseeEditorWidget( KABCore *core, bool isExtension,
QWidget *parent, const char *name = 0 );
~AddresseeEditorWidget();
void setAddressee( const KABC::Addressee& );
const KABC::Addressee &addressee();
void contactsSelectionChanged();
void load();
void save();
bool dirty();
QString title() const;
QString identifier() const;
protected slots:
+ void setRole2FN();
+ void setCompany2FN();
void textChanged( const QString& );
void pageChanged( QWidget *wdg );
/**
Emits the modified signal and sets the dirty flag. Any slot
that modifies data should use this method instead of calling emit
modified() directly.
*/
void emitModified();
void dateChanged( QDate );
void invalidDate();
void nameTextChanged( const QString& );
void nameBoxChanged();
void nameButtonClicked();
void categoryButtonClicked();
/**
Called whenever the categories change in the categories dialog.
*/
void categoriesSelected( const QStringList& );
/**
Edits which categories are available in the CategorySelectDialog.
*/
void editCategories();
private:
AddresseeConfig * mAConfig;
void initGUI();
void setupTab1();
void setupTab1_1();
void setupTab2();
void setupTab2_1();
void setupTab3();
void setupTab3_1();
KABC::Addressee mAddressee;
int mFormattedNameType;
bool mDirty;
bool mIsExtension;
bool mBlockSignals;
// GUI
KPIM::CategorySelectDialog *mCategoryDialog;
KPIM::CategoryEditDialog *mCategoryEditDialog;
QTabWidget *mTabWidget;
// Tab1 and Tab1_1
KLineEdit *mNameEdit;
KLineEdit *mRoleEdit;
KLineEdit *mOrgEdit;
KSqueezedTextLabel *mFormattedNameLabel;
AddressEditWidget *mAddressEditWidget;
EmailEditWidget *mEmailWidget;
PhoneEditWidget *mPhoneEditWidget;
KLineEdit *mURLEdit;
KLineEdit *mIMAddressEdit;
KLineEdit *mCategoryEdit;
SecrecyWidget *mSecrecyWidget;
KSqueezedTextLabel *mNameLabel;
// Tab2 and Tab2_2
KLineEdit *mDepartmentEdit;
KLineEdit *mOfficeEdit;
KLineEdit *mProfessionEdit;
KLineEdit *mManagerEdit;
KLineEdit *mAssistantEdit;
KLineEdit *mNicknameEdit;
KLineEdit *mSpouseEdit;
KLineEdit *mChildEdit;
QComboBox *mGenderBox;
KDateEdit *mBirthdayPicker;
KDateEdit *mAnniversaryPicker;
#ifndef KAB_EMBEDDED
QTextEdit *mNoteEdit;
#else //KAB_EMBEDDED
QMultiLineEdit *mNoteEdit;
#endif //KAB_EMBEDDED
QSpinBox *mTimeZoneSpin;
QSpinBox *mGeoLat;
QSpinBox *mGeoLon;
// Tab3
GeoWidget *mGeoWidget;
ImageWidget *mImageWidget;
#ifndef KAB_EMBEDDED
SoundWidget *mSoundWidget;
#endif //KAB_EMBEDDED
KeyWidget *mKeyWidget;
};
#endif