summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/pim/addressbook/TODO2
-rw-r--r--core/pim/addressbook/contacteditor.cpp166
-rw-r--r--core/pim/addressbook/contacteditor.h2
3 files changed, 157 insertions, 13 deletions
diff --git a/core/pim/addressbook/TODO b/core/pim/addressbook/TODO
index 1eb537f..76247c1 100644
--- a/core/pim/addressbook/TODO
+++ b/core/pim/addressbook/TODO
@@ -25,32 +25,34 @@ Bugs but not in addressbook:
Urgent:
--------
ContactEditor:
- Contact-Editor is temporarely reenabled. Wait for replacement.
- Redesign of Contacteditor
- Store last settings of combo-boxes
- Category is on the wrong position after changing to personal and back to normal
( Temporarily workaround: Category is never deactivated.. :S )
- Personal and Business Web-page is not editable
Important:
----------
+- If new contact is added (contacteditor closed): focus (table, card) to
+ this entry !
- Implement a picker/combo for the default email.
- After search (Started with Return): KeyFocus should be on Tabelle
- "What's this" should be added (Deleyed after Feature Freeze)
Less important:
---------------
- Reload if contacts were changed externally
- Overview window cleanup needed..
- The picker (alphabetical sort widget) should be
placed verticaly or horizontally (configurable)
- Find a smart solution for activating/deactivating the "send email" event
Should be Fixed (not absolute sure, need further validation):
-------------------------------------------------------------
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index c5ad0c4..37e3a54 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -33,32 +33,33 @@
#include <qcombobox.h>
#include <qlabel.h>
#include <qtabwidget.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qmultilineedit.h>
#include <qscrollview.h>
#include <qtoolbutton.h>
#include <qpushbutton.h>
#include <qmainwindow.h>
#include <qvaluelist.h>
#include <qpopupmenu.h>
#include <qlistbox.h>
#include <qhbox.h>
#include <qaction.h>
#include <qiconset.h>
+#include <qmessagebox.h>
#include <assert.h>
static inline bool containsAlphaNum( const QString &str );
static inline bool constainsWhiteSpace( const QString &str );
// helper functions, convert our comma delimited list to proper
// file format...
void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
QString &strAll );
// helper convert from file format to comma delimited...
void parseEmailTo( const QString &strDefaultEmail,
const QString &strOtherEmail, QString &strBack );
ContactEditor::ContactEditor( const OContact &entry,
@@ -632,98 +633,215 @@ void ContactEditor::init() {
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);
+ defaultEmail = cmbDefaultEmail->text(i);
+ qDebug ("Changed to: %s", defaultEmail.latin1());
+
}
void ContactEditor::populateDefaultEmailCmb(){
+
+ // if the default-email combo was not selected and therfore not created
+ // we get a lot of trouble.. Therfore create an invisible one..
+ if ( !cmbDefaultEmail ){
+ cmbDefaultEmail = new QComboBox(this);
+ cmbDefaultEmail -> hide();
+ }
cmbDefaultEmail->clear();
cmbDefaultEmail->insertStringList(emails);
+ // cmbDefaultEmail->show();
+
+ // Select default email in combo..
+ bool found = false;
for ( int i = 0; i < cmbDefaultEmail->count(); i++){
- qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<",cmbDefaultEmail->text( i ).latin1(),defaultEmail.latin1());
+ qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<",
+ cmbDefaultEmail->text( i ).latin1(), defaultEmail.latin1());
+
if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){
cmbDefaultEmail->setCurrentItem( i );
qDebug("set");
+ found = true;
}
}
+
+ // If the current default email is not found in the list, we choose the
+ // first one..
+ if ( !found )
+ defaultEmail = cmbDefaultEmail->text(0);
}
-void ContactEditor::chooserChange( const QString &textChanged, int index, QLineEdit *inputWid, int widgetPos ) {
+// Called when any combobox was changed.
+// "true" returned if the change was chandled by this function, else it should
+// be handled by something else..
+bool ContactEditor::cmbChooserChange( 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 );
+ qWarning("ContactEditor::cmbChooserChange -> Type: %s", type.latin1() );
+
+ // Create and connect combobox for selecting the default email
if ( type == "Default Email"){
- defaultEmail = textChanged;
+ qWarning("Choosing default-email ");
+
+ // More than one defaul-email chooser is not allowed !
+ if ( ( defaultEmailChooserPosition != -1 ) &&
+ defaultEmailChooserPosition != widgetPos ){
+ chooserError( widgetPos );
+ return true;
+ }
+
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)));
+
+ cmbDefaultEmail->clear();
+ cmbDefaultEmail->insertStringList( emails );
+ cmbDefaultEmail->show();
+
defaultEmailChooserPosition = widgetPos;
+
+ // Set current default email
+ populateDefaultEmailCmb();
+
+
+ } else {
+ // Something else was selected: Hide combo..
+ qWarning(" Hiding default-email combo" );
+ if ( defaultEmailChooserPosition == widgetPos ){
+ defaultEmailChooserPosition = -1;
+ if ( cmbDefaultEmail )
+ cmbDefaultEmail->hide();
+
+ }
+
+ // Caller should initialize the responsible textfield, therefore
+ // "false" is returned
+ return false;
+ }
+
+ // Everything is worked off ..
+ return true;
+
+}
+
+// Currently accessed when we select default-email more than once !
+void ContactEditor::chooserError( int index )
+{
+ qWarning("ContactEditor::chooserError( %d )", index);
+ QMessageBox::warning( this, "Chooser Error",
+ "Multiple selection of this\n"
+ "Item is not allowed !\n\n"
+ "First deselect the previous one !",
+ "&OK", 0, 0,
+ 0, 0 );
+
+ // Reset the selected Chooser. Unfortunately the chooser
+ // generates no signal, therfore we have to
+ // call the cmbChooserChange function manually..
+ switch( index ){
+ case 1:
+ cmbChooserField1 -> setCurrentItem( 0 );
+ slotCmbChooser1Change( 0 );
+ break;
+ case 2:
+ cmbChooserField2 -> setCurrentItem( 0 );
+ slotCmbChooser2Change( 0 );
+ break;
+ case 3:
+ cmbChooserField3 -> setCurrentItem( 0 );
+ slotCmbChooser3Change( 0 );
+ break;
+ case 4:
+ cmbChooserField4 -> setCurrentItem( 0 );
+ slotCmbChooser4Change( 0 );
+ break;
+ }
+}
+
+// Called when something was changed in a textfield (shouldn't it called textchanged? (se))
+void ContactEditor::chooserChange( const QString &textChanged, int index,
+ QLineEdit* , 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"){
+ qWarning ("??? Wozu??: %s", textChanged.latin1());
+ defaultEmail = textChanged;
+
+ populateDefaultEmailCmb();
+
}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 );
- if ( cmbDefaultEmail )
populateDefaultEmailCmb();
}
-
-
slChooserValues[index] = textChanged;
}
void ContactEditor::slotChooser1Change( const QString &textChanged ) {
+ qWarning("ContactEditor::slotChooser1Change( %s )", textChanged.latin1());
chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1);
}
void ContactEditor::slotChooser2Change( const QString &textChanged ) {
+ qWarning("ContactEditor::slotChooser2Change( %s )", textChanged.latin1());
chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2, 2);
}
void ContactEditor::slotChooser3Change( const QString &textChanged ) {
+ qWarning("ContactEditor::slotChooser3Change( %s )", textChanged.latin1());
chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3, 3);
}
void ContactEditor::slotChooser4Change( const QString &textChanged ) {
+ qWarning("ContactEditor::slotChooser4Change( %s )", textChanged.latin1());
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;
@@ -767,56 +885,75 @@ void ContactEditor::slotZipChange( const QString &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 ) {
+ qWarning("ContactEditor::slotCmbChooser1Change( %d )", index);
+
+ if ( !cmbChooserChange( cmbChooserField1->currentItem(), txtChooserField1, 1) ){
txtChooserField1->setText( slChooserValues[index] );
txtChooserField1->setFocus();
+
+ }
+
}
void ContactEditor::slotCmbChooser2Change( int index ) {
+ qWarning("ContactEditor::slotCmbChooser2Change( %d )", index);
+
+ if ( !cmbChooserChange( cmbChooserField2->currentItem(), txtChooserField2, 2) ){
txtChooserField2->setText( slChooserValues[index] );
txtChooserField2->setFocus();
+
+ }
}
void ContactEditor::slotCmbChooser3Change( int index ) {
+ qWarning("ContactEditor::slotCmbChooser3Change( %d )", index);
+
+ if ( !cmbChooserChange( cmbChooserField3->currentItem(), txtChooserField3, 3) ){
txtChooserField3->setText( slChooserValues[index] );
txtChooserField3->setFocus();
}
+}
void ContactEditor::slotCmbChooser4Change( int index ) {
+ qWarning("ContactEditor::slotCmbChooser4Change( %d )", index);
+
+ if ( !cmbChooserChange( cmbChooserField4->currentItem(), txtChooserField4, 4) ){
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 {
@@ -1435,40 +1572,43 @@ void ContactEditor::saveEntry() {
QStringList::ConstIterator itV;
for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) {
if ( ( *it == "Business Phone" ) || ( *it == "Work Phone" ) )
ent.setBusinessPhone( *itV );
if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) )
ent.setBusinessFax( *itV );
if ( ( *it == "Business Mobile" ) || ( *it == "Work Mobile" ) )
ent.setBusinessMobile( *itV );
if ( *it == "Emails" ){
QString allemail;
QString defaultmail;
- parseEmailFrom( *itV, defaultmail, allemail );
- // ent.clearEmails();
-// ent.setDefaultEmail( defaultmail );
+ parseEmailFrom( emails.join(","), defaultmail, allemail );
+ if ( defaultEmail.isEmpty() ){
+ qWarning("Default email was not set by user!");
+ qWarning("Using first email in list: %s", defaultmail.latin1());
+ ent.setDefaultEmail( defaultmail );
+ }
ent.setEmails( allemail );
}
if ( *it == "Default Email")
- ent.setDefaultEmail( *itV );
+ ent.setDefaultEmail( defaultEmail /* *itV */ );
if ( *it == "Home Phone" )
ent.setHomePhone( *itV );
if ( *it == "Home Fax" )
ent.setHomeFax( *itV );
if ( *it == "Home Mobile" )
ent.setHomeMobile( *itV );
if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) )
ent.setBusinessPager( *itV );
if ( *it == "Home Web Page" )
ent.setHomeWebpage( *itV );
diff --git a/core/pim/addressbook/contacteditor.h b/core/pim/addressbook/contacteditor.h
index bcef679..4fa48d1 100644
--- a/core/pim/addressbook/contacteditor.h
+++ b/core/pim/addressbook/contacteditor.h
@@ -65,60 +65,62 @@ class ContactEditor : public QDialog {
public slots:
void slotNote();
void slotName();
void setEntry(const OContact &entry);
protected slots:
void accept();
private:
void init();
void saveEntry();
bool isEmpty();
void cleanupFields();
void updateDatePicker();
QString parseName( QString fullName, int type );
+ void chooserError( int index );
private slots:
void slotChooser1Change( const QString &textChanged );
void slotChooser2Change( const QString &textChanged );
void slotChooser3Change( const QString &textChanged );
void slotChooser4Change( const QString &textChanged );
void slotCmbChooser1Change( int index );
void slotCmbChooser2Change( int index );
void slotCmbChooser3Change( int index );
void slotCmbChooser4Change( int index );
void slotAddressTypeChange( int index );
void slotAddressChange( const QString &textChanged );
void slotAddress2Change( const QString &textChanged );
void slotPOBoxChange( const QString &textChanged );
void slotCityChange( const QString &textChanged );
void slotStateChange( const QString &textChanged );
void slotZipChange( const QString &textChanged );
void slotCountryChange( const QString &textChanged );
void slotFullNameChange( const QString &textChanged );
void slotAnniversaryDateChanged( int year, int month, int day);
void slotBirthdayDateChanged( int year, int month, int day);
void slotRemoveBirthday();
void slotRemoveAnniversary();
void defaultEmailChanged(int);
private:
int defaultEmailChooserPosition;
void populateDefaultEmailCmb();
void chooserChange( const QString&, int , QLineEdit*, int );
+ bool cmbChooserChange( int , QLineEdit*, int );
bool useFullName;
OContact ent;
QDialog *dlgNote;
QDialog *dlgName;
QList<QLineEdit> listValue;
QList<QLabel> listName;
QStringList slDynamicEntries;
QStringList trlDynamicEntries;
bool m_personalView;