summaryrefslogtreecommitdiff
authoreilers <eilers>2002-12-27 13:03:34 (UTC)
committer eilers <eilers>2002-12-27 13:03:34 (UTC)
commit158fd475abbc652613d5eed362dae79f94b17803 (patch) (side-by-side diff)
tree60b38278a274ac97d0ebb1226cfd881418d735bf
parent8ae81608ed194e36236ea68c5fbed54ac6c0275c (diff)
downloadopie-158fd475abbc652613d5eed362dae79f94b17803.zip
opie-158fd475abbc652613d5eed362dae79f94b17803.tar.gz
opie-158fd475abbc652613d5eed362dae79f94b17803.tar.bz2
Fixing nullpointer crash if "emails" selected
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/contacteditor.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index 1b83308..b68d88c 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -478,402 +478,406 @@ void ContactEditor::init() {
int counter = 0;
// Birthday
QHBox* hBox = new QHBox( container );
l = new QLabel( tr("Birthday"), container );
gl->addWidget( l, counter, 0 );
QPopupMenu* m1 = new QPopupMenu( container );
birthdayPicker = new DateBookMonth( m1, 0, TRUE );
m1->insertItem( birthdayPicker );
birthdayButton= new QToolButton( hBox, "buttonStart" );
birthdayButton->setPopup( m1 );
birthdayButton->setPopupDelay(0);
QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ),
tr( "Delete" ),
hBox, 0 );
gl->addWidget( hBox, counter , 1 );
connect( birthdayPicker, SIGNAL( dateClicked( int, int, int ) ),
this, SLOT( slotBirthdayDateChanged( int, int, int ) ) );
connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) );
++counter;
// Anniversary
hBox = new QHBox( container );
l = new QLabel( tr("Anniversary"), container );
gl->addWidget( l, counter, 0 );
m1 = new QPopupMenu( container );
anniversaryPicker = new DateBookMonth( m1, 0, TRUE );
m1->insertItem( anniversaryPicker );
anniversaryButton= new QToolButton( hBox, "buttonStart" );
anniversaryButton->setPopup( m1 );
anniversaryButton->setPopupDelay(0);
deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ),
tr( "Delete" ),
hBox, 0 );
gl->addWidget( hBox, counter , 1 );
connect( anniversaryPicker, SIGNAL( dateClicked( int, int, int ) ),
this, SLOT( slotAnniversaryDateChanged( int, int, int ) ) );
connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) );
++counter;
// Gender
l = new QLabel( tr("Gender"), container );
gl->addWidget( l, counter, 0 );
cmbGender = new QComboBox( container );
cmbGender->insertItem( "", 0 );
cmbGender->insertItem( tr("Male"), 1);
cmbGender->insertItem( tr("Female"), 2);
gl->addWidget( cmbGender, counter, 1 );
++counter;
// Create Labels and lineedit fields for every dynamic entry
QStringList::ConstIterator it = slDynamicEntries.begin();
QStringList::ConstIterator trit = trlDynamicEntries.begin();
for (i = counter; it != slDynamicEntries.end(); i++, ++it, ++trit) {
if (((*it) == "Anniversary") ||
((*it) == "Birthday")|| ((*it) == "Gender")) continue;
l = new QLabel( (*it).utf8() , container );
listName.append( l );
gl->addWidget( l, i, 0 );
QLineEdit *e = new QLineEdit( container );
listValue.append( e );
gl->addWidget( e, i, 1);
}
// Fill labels with names..
// loadFields();
tabMain->insertTab( tabViewport, tr( "Details" ) );
dlgNote = new QDialog( this, "Note Dialog", TRUE );
dlgNote->setCaption( tr("Enter Note") );
QVBoxLayout *vbNote = new QVBoxLayout( dlgNote );
txtNote = new QMultiLineEdit( dlgNote );
vbNote->addWidget( txtNote );
connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) );
dlgName = new QDialog( this, "Name Dialog", TRUE );
dlgName->setCaption( tr("Edit Name") );
gl = new QGridLayout( dlgName, 5, 2, 2, 3 );
l = new QLabel( tr("First Name"), dlgName );
gl->addWidget( l, 0, 0 );
txtFirstName = new QLineEdit( dlgName );
gl->addWidget( txtFirstName, 0, 1 );
l = new QLabel( tr("Middle Name"), dlgName );
gl->addWidget( l, 1, 0 );
txtMiddleName = new QLineEdit( dlgName );
gl->addWidget( txtMiddleName, 1, 1 );
l = new QLabel( tr("Last Name"), dlgName );
gl->addWidget( l, 2, 0 );
txtLastName = new QLineEdit( dlgName );
gl->addWidget( txtLastName, 2, 1 );
l = new QLabel( tr("Suffix"), dlgName );
gl->addWidget( l, 3, 0 );
txtSuffix = new QLineEdit( dlgName );
gl->addWidget( txtSuffix, 3, 1 );
space = new QSpacerItem(1,1,
QSizePolicy::Maximum,
QSizePolicy::MinimumExpanding );
gl->addItem( space, 4, 0 );
cmbChooserField1->insertStringList( trlChooserNames );
cmbChooserField2->insertStringList( trlChooserNames );
cmbChooserField3->insertStringList( trlChooserNames );
cmbChooserField4->insertStringList( trlChooserNames );
cmbChooserField1->setCurrentItem( 0 );
cmbChooserField2->setCurrentItem( 1 );
cmbChooserField3->setCurrentItem( 2 );
connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) );
connect( txtFullName, SIGNAL(textChanged(const QString &)), this, SLOT(slotFullNameChange(const QString &)) );
connect( txtChooserField1, SIGNAL(textChanged(const QString &)),
this, SLOT(slotChooser1Change(const QString &)) );
connect( txtChooserField2, SIGNAL(textChanged(const QString &)),
this, SLOT(slotChooser2Change(const QString &)) );
connect( txtChooserField3, SIGNAL(textChanged(const QString &)),
this, SLOT(slotChooser3Change(const QString &)) );
connect( txtChooserField4, SIGNAL(textChanged(const QString &)),
this, SLOT(slotChooser4Change(const QString &)) );
connect( txtAddress, SIGNAL(textChanged(const QString &)),
this, SLOT(slotAddressChange(const QString &)) );
connect( txtCity, SIGNAL(textChanged(const QString &)),
this, SLOT(slotCityChange(const QString &)) );
connect( txtState, SIGNAL(textChanged(const QString &)),
this, SLOT(slotStateChange(const QString &)) );
connect( txtZip, SIGNAL(textChanged(const QString &)),
this, SLOT(slotZipChange(const QString &)) );
connect( cmbCountry, SIGNAL(textChanged(const QString &)),
this, SLOT(slotCountryChange(const QString &)) );
connect( cmbCountry, SIGNAL(activated(const QString &)),
this, SLOT(slotCountryChange(const QString &)) );
connect( cmbChooserField1, SIGNAL(activated(int)),
this, SLOT(slotCmbChooser1Change(int)) );
connect( cmbChooserField2, SIGNAL(activated(int)),
this, SLOT(slotCmbChooser2Change(int)) );
connect( cmbChooserField3, SIGNAL(activated(int)),
this, SLOT(slotCmbChooser3Change(int)) );
connect( cmbChooserField4, SIGNAL(activated(int)),
this, SLOT(slotCmbChooser4Change(int)) );
connect( cmbAddress, SIGNAL(activated(int)),
this, SLOT(slotAddressTypeChange(int)) );
new QPEDialogListener(this);
setPersonalView ( m_personalView );
}
void ContactEditor::defaultEmailChanged(int i){
qDebug("defaultEmailChanged");
int index = cmbChooserField1->currentItem();
slChooserValues[index] = cmbDefaultEmail->text(i);
}
void ContactEditor::populateDefaultEmailCmb(){
cmbDefaultEmail->clear();
cmbDefaultEmail->insertStringList(emails);
for ( int i = 0; i < cmbDefaultEmail->count(); i++){
qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<",cmbDefaultEmail->text( i ).latin1(),defaultEmail.latin1());
if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){
cmbDefaultEmail->setCurrentItem( i );
qDebug("set");
}
}
}
void ContactEditor::chooserChange( const QString &textChanged, int index, QLineEdit *inputWid, int widgetPos ) {
QString type = slChooserNames[index];
qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i",type.latin1(),textChanged.latin1(), index, widgetPos );
if ( type == "Default Email"){
defaultEmail = textChanged;
- if (cmbDefaultEmail) delete cmbDefaultEmail;
+ if (cmbDefaultEmail){
+ delete cmbDefaultEmail;
+ cmbDefaultEmail = 0l;
+ }
cmbDefaultEmail = new QComboBox(inputWid->parentWidget());
cmbDefaultEmail->setGeometry(inputWid->frameGeometry());
cmbDefaultEmail->show();
populateDefaultEmailCmb();
connect(cmbDefaultEmail,SIGNAL(activated(int)),
SLOT(defaultEmailChanged(int)));
defaultEmailChooserPosition = widgetPos;
}else if (defaultEmailChooserPosition == widgetPos){
qDebug("cmbDefaultEmail->hide()");
if (cmbDefaultEmail) cmbDefaultEmail->hide();
widgetPos=-1;
}else if (type == "Emails"){
qDebug("emails");
QString de;
emails = QStringList::split (",", textChanged );
- populateDefaultEmailCmb();
+ if ( cmbDefaultEmail )
+ populateDefaultEmailCmb();
}
slChooserValues[index] = textChanged;
}
void ContactEditor::slotChooser1Change( const QString &textChanged ) {
chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1);
}
void ContactEditor::slotChooser2Change( const QString &textChanged ) {
chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2, 2);
}
void ContactEditor::slotChooser3Change( const QString &textChanged ) {
chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3, 3);
}
void ContactEditor::slotChooser4Change( const QString &textChanged ) {
chooserChange( textChanged, cmbChooserField4->currentItem(), txtChooserField4, 4);
}
void ContactEditor::slotAddressChange( const QString &textChanged ) {
if ( cmbAddress->currentItem() == 0 ) {
slBusinessAddress[0] = textChanged;
} else {
slHomeAddress[0] = textChanged;
}
}
void ContactEditor::slotAddress2Change( const QString &textChanged ) {
if ( cmbAddress->currentItem() == 0 ) {
slBusinessAddress[1] = textChanged;
} else {
slHomeAddress[1] = textChanged;
}
}
void ContactEditor::slotPOBoxChange( const QString &textChanged ) {
if ( cmbAddress->currentItem() == 0 ) {
slBusinessAddress[2] = textChanged;
} else {
slHomeAddress[2] = textChanged;
}
}
void ContactEditor::slotCityChange( const QString &textChanged ) {
if ( cmbAddress->currentItem() == 0 ) {
slBusinessAddress[3] = textChanged;
} else {
slHomeAddress[3] = textChanged;
}
}
void ContactEditor::slotStateChange( const QString &textChanged ) {
if ( cmbAddress->currentItem() == 0 ) {
slBusinessAddress[4] = textChanged;
} else {
slHomeAddress[4] = textChanged;
}
}
void ContactEditor::slotZipChange( const QString &textChanged ) {
if ( cmbAddress->currentItem() == 0 ) {
slBusinessAddress[5] = textChanged;
} else {
slHomeAddress[5] = textChanged;
}
}
void ContactEditor::slotCountryChange( const QString &textChanged ) {
if ( cmbAddress->currentItem() == 0 ) {
slBusinessAddress[6] = textChanged;
} else {
slHomeAddress[6] = textChanged;
}
}
void ContactEditor::slotCmbChooser1Change( int index ) {
txtChooserField1->setText( slChooserValues[index] );
txtChooserField1->setFocus();
}
void ContactEditor::slotCmbChooser2Change( int index ) {
txtChooserField2->setText( slChooserValues[index] );
txtChooserField2->setFocus();
}
void ContactEditor::slotCmbChooser3Change( int index ) {
txtChooserField3->setText( slChooserValues[index] );
txtChooserField3->setFocus();
}
void ContactEditor::slotCmbChooser4Change( int index ) {
txtChooserField4->setText( slChooserValues[index] );
txtChooserField4->setFocus();
}
void ContactEditor::slotAddressTypeChange( int index ) {
if ( index == 0 ) {
txtAddress->setText( slBusinessAddress[0] );
//txtAddress2->setText( (*slBusinessAddress)[1] );
//txtPOBox->setText( (*slBusinessAddress)[2] );
txtCity->setText( slBusinessAddress[3] );
txtState->setText( slBusinessAddress[4] );
txtZip->setText( slBusinessAddress[5] );
QLineEdit *txtTmp = cmbCountry->lineEdit();
txtTmp->setText( slBusinessAddress[6] );
} else {
txtAddress->setText( slHomeAddress[0] );
//txtAddress2->setText( (*slHomeAddress)[1] );
//txtPOBox->setText( (*slHomeAddress)[2] );
txtCity->setText( slHomeAddress[3] );
txtState->setText( slHomeAddress[4] );
txtZip->setText( slHomeAddress[5] );
QLineEdit *txtTmp = cmbCountry->lineEdit();
txtTmp->setText( slHomeAddress[6] );
}
}
void ContactEditor::slotFullNameChange( const QString &textChanged ) {
int index = cmbFileAs->currentItem();
cmbFileAs->clear();
cmbFileAs->insertItem( parseName( textChanged, 0 ) );
cmbFileAs->insertItem( parseName( textChanged, 1 ) );
cmbFileAs->insertItem( parseName( textChanged, 2 ) );
cmbFileAs->insertItem( parseName( textChanged, 3 ) );
cmbFileAs->setCurrentItem( index );
useFullName = true;
}
void ContactEditor::accept() {
if ( isEmpty() ) {
cleanupFields();
reject();
} else {
saveEntry();
cleanupFields();
QDialog::accept();
}
}
void ContactEditor::slotNote() {
dlgNote->showMaximized();
if ( !dlgNote->exec() ) {
txtNote->setText( ent.notes() );
}
}
void ContactEditor::slotName() {
QString tmpName;
if (useFullName) {
txtFirstName->setText( parseName(txtFullName->text(), NAME_F) );
txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) );
txtLastName->setText( parseName(txtFullName->text(), NAME_L) );
txtSuffix->setText( parseName(txtFullName->text(), NAME_S) );
}
dlgName->showMaximized();