summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2005-01-16 23:41:18 (UTC)
committer zautrix <zautrix>2005-01-16 23:41:18 (UTC)
commit33c04477896c52e9cfea2a29facd959f82cbf17a (patch) (side-by-side diff)
treed7e5a882604b3bfb64087738dd61d702d2d96a60 /kaddressbook
parent507b362d42d5eed6277ad17422b6ba61acca636e (diff)
downloadkdepimpi-33c04477896c52e9cfea2a29facd959f82cbf17a.zip
kdepimpi-33c04477896c52e9cfea2a29facd959f82cbf17a.tar.gz
kdepimpi-33c04477896c52e9cfea2a29facd959f82cbf17a.tar.bz2
several fixes
Diffstat (limited to 'kaddressbook') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/addresseeeditorwidget.cpp12
-rw-r--r--kaddressbook/imagewidget.cpp28
-rw-r--r--kaddressbook/imagewidget.h2
3 files changed, 36 insertions, 6 deletions
diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp
index c6993e9..bd32859 100644
--- a/kaddressbook/addresseeeditorwidget.cpp
+++ b/kaddressbook/addresseeeditorwidget.cpp
@@ -977,48 +977,58 @@ void AddresseeEditorWidget::load()
blockSignals( true );
mBlockSignals = true; // used for internal signal blocking
mNameEdit->setText( mAddressee.assembledName() );
if ( mAddressee.formattedName().isEmpty() ) {
//US KConfig config( "kaddressbookrc" );
KConfig config( locateLocal("config", "kabcrc") );
config.setGroup( "General" );
mFormattedNameType = config.readNumEntry( "FormattedNameType", 1 );
mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) );
} else {;
if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::SimpleName ) )
mFormattedNameType = NameEditDialog::SimpleName;
else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::FullName ) )
mFormattedNameType = NameEditDialog::FullName;
else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseName ) )
mFormattedNameType = NameEditDialog::ReverseName;
else
mFormattedNameType = NameEditDialog::CustomName;
}
mFormattedNameLabel->setText( mAddressee.formattedName() );
+ mAConfig->setUid( mAddressee.uid() );
+ if ( mAConfig->automaticNameParsing() ) {
+ mNameLabel->hide();
+ mNameEdit->show();
+ } else {
+ mNameEdit->hide();
+ mNameLabel->setText( mNameEdit->text() );
+ mNameLabel->show();
+ }
+
mRoleEdit->setText( mAddressee.role() );
mOrgEdit->setText( mAddressee.organization() );
//US mURLEdit->setURL( mAddressee.url().url() );
mURLEdit->setText( mAddressee.url().prettyURL() );
//US?? mURLEdit->home( false );
// mNoteEdit->setText( mAddressee.note() );
mNoteEdit->setText( mAddressee.note() );
mEmailWidget->setEmails( mAddressee.emails() );
mPhoneEditWidget->setPhoneNumbers( mAddressee.phoneNumbers() );
mAddressEditWidget->setAddresses( mAddressee, mAddressee.addresses() );
mBirthdayPicker->setDate( mAddressee.birthday().date() );
//US mAnniversaryPicker->setDate( QDate::fromString( mAddressee.custom(
//US "KADDRESSBOOK", "X-Anniversary" ), Qt::ISODate) );
QDate dt = KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ),
"%Y-%m-%d"); // = Qt::ISODate
mAnniversaryPicker->setDate( dt );
mNicknameEdit->setText( mAddressee.nickName() );
mCategoryEdit->setText( mAddressee.categories().join( "," ) );
@@ -1184,51 +1194,51 @@ bool AddresseeEditorWidget::dirty()
}
void AddresseeEditorWidget::nameTextChanged( const QString &text )
{
if ( mBlockSignals )
return;
// use the addressee class to parse the name for us
mAConfig->setUid( mAddressee.uid() );
if ( mAConfig->automaticNameParsing() ) {
if ( !mAddressee.formattedName().isEmpty() ) {
QString fn = mAddressee.formattedName();
mAddressee.setNameFromString( text );
mAddressee.setFormattedName( fn );
} else {
// use extra addressee to avoid a formatted name assignment
Addressee addr;
addr.setNameFromString( text );
mAddressee.setPrefix( addr.prefix() );
mAddressee.setGivenName( addr.givenName() );
mAddressee.setAdditionalName( addr.additionalName() );
mAddressee.setFamilyName( addr.familyName() );
mAddressee.setSuffix( addr.suffix() );
}
}
-
nameBoxChanged();
+
emitModified();
}
void AddresseeEditorWidget::nameBoxChanged()
{
KABC::Addressee addr;
mAConfig->setUid( mAddressee.uid() );
if ( mAConfig->automaticNameParsing() ) {
addr.setNameFromString( mNameEdit->text() );
mNameLabel->hide();
mNameEdit->show();
} else {
addr = mAddressee;
mNameEdit->hide();
mNameLabel->setText( mNameEdit->text() );
mNameLabel->show();
}
if ( mFormattedNameType != NameEditDialog::CustomName ) {
mFormattedNameLabel->setText( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) );
mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) );
}
}
diff --git a/kaddressbook/imagewidget.cpp b/kaddressbook/imagewidget.cpp
index 48370e3..9ee4eac 100644
--- a/kaddressbook/imagewidget.cpp
+++ b/kaddressbook/imagewidget.cpp
@@ -20,110 +20,120 @@
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include <kabc/picture.h>
#ifndef KAB_EMBEDDED
#include <kaccelmanager.h>
#include <kio/netaccess.h>
#include <kimageio.h>
#endif //KAB_EMBEDDED
#include <kdebug.h>
#include <kdialog.h>
#include <kiconloader.h>
#include <klocale.h>
#include <kurlrequester.h>
#include <kurl.h>
#include <qcheckbox.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qpixmap.h>
+#include <qpushbutton.h>
#include <qapplication.h>
#include "imagewidget.h"
ImageWidget::ImageWidget( QWidget *parent, const char *name )
: QWidget( parent, name )
{
QGridLayout *topLayout = new QGridLayout( this, 2, 1, KDialog::marginHint(),
KDialog::spacingHint() );
QGroupBox *photoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Photo" ), this );
- QGridLayout *boxLayout = new QGridLayout( photoBox->layout(), 3, 2,
+ QGridLayout *boxLayout = new QGridLayout( photoBox->layout(), 4, 2,
KDialog::spacingHint() );
boxLayout->setRowStretch( 2, 1 );
mPhotoLabel = new QLabel( photoBox );
int fac = 9;
if ( QApplication::desktop()->width() > 320 )
fac = 6;
mPhotoLabel->setFixedSize( 50*9/fac, 70*9/fac );
mPhotoLabel->setScaledContents( true );
mPhotoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken );
- boxLayout->addMultiCellWidget( mPhotoLabel, 0, 2, 0, 0 );
+ boxLayout->addMultiCellWidget( mPhotoLabel, 0, 3, 0, 0 );
mPhotoUrl = new KURLRequester( photoBox );
#ifndef KAB_EMBEDDED
mPhotoUrl->setFilter( KImageIO::pattern() );
#else //KAB_EMBEDDED
//US qDebug("ImageWidget::ImageWidget KImageIO not defined. Does this harm ???");
#endif //KAB_EMBEDDED
boxLayout->addWidget( mPhotoUrl, 0, 1 );
mUsePhotoUrl = new QCheckBox( i18n( "Store as URL" ), photoBox );
mUsePhotoUrl->setEnabled( false );
boxLayout->addWidget( mUsePhotoUrl, 1, 1 );
+ QPushButton * pb = new QPushButton( i18n( "Remove" ), photoBox );
+ connect( pb, SIGNAL( clicked() ),this, SLOT( removePhoto() ) );
+ boxLayout->addWidget( pb, 2, 1 );
+ boxLayout->addWidget( new QLabel( photoBox ), 3, 1 );
+
topLayout->addWidget( photoBox, 0, 0 );
QGroupBox *logoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Logo" ), this );
- boxLayout = new QGridLayout( logoBox->layout(), 3, 2, KDialog::spacingHint() );
+ boxLayout = new QGridLayout( logoBox->layout(), 4, 2, KDialog::spacingHint() );
boxLayout->setRowStretch( 2, 1 );
mLogoLabel = new QLabel( logoBox );
mLogoLabel->setFixedSize( 50*9/fac, 70*9/fac );
mLogoLabel->setScaledContents( true );
mLogoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken );
- boxLayout->addMultiCellWidget( mLogoLabel, 0, 2, 0, 0 );
+ boxLayout->addMultiCellWidget( mLogoLabel, 0, 3, 0, 0 );
mLogoUrl = new KURLRequester( logoBox );
#ifndef KAB_EMBEDDED
mLogoUrl->setFilter( KImageIO::pattern() );
#else //KAB_EMBEDDED
//US qDebug("ImageWidget::ImageWidget KImageIO not defined 2");
#endif //KAB_EMBEDDED
boxLayout->addWidget( mLogoUrl, 0, 1 );
mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), logoBox );
mUseLogoUrl->setEnabled( false );
boxLayout->addWidget( mUseLogoUrl, 1, 1 );
+ pb = new QPushButton( i18n( "Remove" ), logoBox );
+ connect( pb, SIGNAL( clicked() ),this, SLOT( removeLogo() ) );
+ boxLayout->addWidget( pb, 2, 1 );
+ boxLayout->addWidget( new QLabel( logoBox ), 3, 1 );
topLayout->addWidget( logoBox, 1, 0 );
connect( mPhotoUrl, SIGNAL( textChanged( const QString& ) ),
SIGNAL( changed() ) );
connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ),
SLOT( loadPhoto() ) );
connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ),
SIGNAL( changed() ) );
connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ),
SLOT( updateGUI() ) );
connect( mUsePhotoUrl, SIGNAL( toggled( bool ) ),
SIGNAL( changed() ) );
connect( mLogoUrl, SIGNAL( textChanged( const QString& ) ),
SIGNAL( changed() ) );
connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ),
SLOT( loadLogo() ) );
connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ),
SIGNAL( changed() ) );
connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ),
SLOT( updateGUI() ) );
connect( mUseLogoUrl, SIGNAL( toggled( bool ) ),
SIGNAL( changed() ) );
@@ -217,51 +227,59 @@ void ImageWidget::setLogo( const KABC::Picture &logo )
}
KABC::Picture ImageWidget::logo() const
{
KABC::Picture logo;
if ( mUseLogoUrl->isChecked() )
logo.setUrl( mLogoUrl->url() );
else {
QPixmap *px = mLogoLabel->pixmap();
if ( px ) {
#ifndef KAB_EMBEDDED
if ( px->height() > px->width() )
logo.setData( px->convertToImage().scaleHeight( 140 ) );
else
logo.setData( px->convertToImage().scaleWidth( 100 ) );
#else //KAB_EMBEDDED
logo.setData( px->convertToImage() );
#endif //KAB_EMBEDDED
logo.setType( "PNG" );
}
}
-
return logo;
}
+void ImageWidget::removePhoto()
+{
+ setPhoto(KABC::Picture() );
+}
+
+void ImageWidget::removeLogo()
+{
+ setLogo(KABC::Picture() );
+}
void ImageWidget::loadPhoto()
{
mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) );
}
void ImageWidget::loadLogo()
{
mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) );
}
void ImageWidget::updateGUI()
{
KURLRequester *ptr = (KURLRequester*)sender();
if ( ptr == mPhotoUrl )
mUsePhotoUrl->setEnabled( true );
else if ( ptr == mLogoUrl )
mUseLogoUrl->setEnabled( true );
}
QPixmap ImageWidget::loadPixmap( const KURL &url )
{
diff --git a/kaddressbook/imagewidget.h b/kaddressbook/imagewidget.h
index b3ca0bd..afb9aa7 100644
--- a/kaddressbook/imagewidget.h
+++ b/kaddressbook/imagewidget.h
@@ -48,39 +48,41 @@ class ImageWidget : public QWidget
*/
void setPhoto( const KABC::Picture &photo );
/**
Returns a photo object.
*/
KABC::Picture photo() const;
/**
Sets the logo object.
*/
void setLogo( const KABC::Picture &photo );
/**
Returns a logo object.
*/
KABC::Picture logo() const;
signals:
void changed();
private slots:
void loadPhoto();
void loadLogo();
+ void removePhoto();
+ void removeLogo();
void updateGUI();
private:
QPixmap loadPixmap( const KURL &url );
KURLRequester *mPhotoUrl;
KURLRequester *mLogoUrl;
QCheckBox *mUsePhotoUrl;
QCheckBox *mUseLogoUrl;
QLabel *mPhotoLabel;
QLabel *mLogoLabel;
};
#endif