-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index 7682399..0b65a10 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp | |||
@@ -44,192 +44,194 @@ | |||
44 | #include <qpopupmenu.h> | 44 | #include <qpopupmenu.h> |
45 | #include <qlistbox.h> | 45 | #include <qlistbox.h> |
46 | #include <qhbox.h> | 46 | #include <qhbox.h> |
47 | #include <qaction.h> | 47 | #include <qaction.h> |
48 | #include <qiconset.h> | 48 | #include <qiconset.h> |
49 | #include <qmessagebox.h> | 49 | #include <qmessagebox.h> |
50 | 50 | ||
51 | #include <assert.h> | 51 | #include <assert.h> |
52 | 52 | ||
53 | static inline bool containsAlphaNum( const QString &str ); | 53 | static inline bool containsAlphaNum( const QString &str ); |
54 | static inline bool constainsWhiteSpace( const QString &str ); | 54 | static inline bool constainsWhiteSpace( const QString &str ); |
55 | 55 | ||
56 | // helper functions, convert our comma delimited list to proper | 56 | // helper functions, convert our comma delimited list to proper |
57 | // file format... | 57 | // file format... |
58 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, | 58 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, |
59 | QString &strAll ); | 59 | QString &strAll ); |
60 | 60 | ||
61 | // helper convert from file format to comma delimited... | 61 | // helper convert from file format to comma delimited... |
62 | void parseEmailTo( const QString &strDefaultEmail, | 62 | void parseEmailTo( const QString &strDefaultEmail, |
63 | const QString &strOtherEmail, QString &strBack ); | 63 | const QString &strOtherEmail, QString &strBack ); |
64 | 64 | ||
65 | ContactEditor::ContactEditor(const OContact &entry, | 65 | ContactEditor::ContactEditor(const OContact &entry, |
66 | QWidget *parent, | 66 | QWidget *parent, |
67 | const char *name, | 67 | const char *name, |
68 | WFlags fl ) | 68 | WFlags fl ) |
69 | : QDialog( parent, name, TRUE, fl ), | 69 | : QDialog( parent, name, TRUE, fl ), |
70 | defaultEmailChooserPosition( -1 ), | 70 | defaultEmailChooserPosition( -1 ), |
71 | m_personalView ( false ), | 71 | m_personalView ( false ), |
72 | cmbDefaultEmail( 0 ), | 72 | cmbDefaultEmail( 0 ), |
73 | initializing ( false ) | 73 | initializing ( false ) |
74 | { | 74 | { |
75 | 75 | ||
76 | initializing = true; | 76 | initializing = true; |
77 | 77 | ||
78 | init(); | 78 | init(); |
79 | setEntry( entry ); | 79 | setEntry( entry ); |
80 | // cmbDefaultEmail = 0; | 80 | // cmbDefaultEmail = 0; |
81 | // defaultEmailChooserPosition = -1; | 81 | // defaultEmailChooserPosition = -1; |
82 | 82 | ||
83 | initializing = false; | 83 | initializing = false; |
84 | } | 84 | } |
85 | 85 | ||
86 | ContactEditor::~ContactEditor() { | 86 | ContactEditor::~ContactEditor() { |
87 | } | 87 | } |
88 | 88 | ||
89 | void ContactEditor::init() { | 89 | void ContactEditor::init() { |
90 | qWarning("init() START"); | 90 | qWarning("init() START"); |
91 | 91 | ||
92 | uint i = 0; | 92 | uint i = 0; |
93 | 93 | ||
94 | QStringList trlChooserNames; | 94 | QStringList trlChooserNames; |
95 | 95 | ||
96 | for (i = 0; i <= 6; i++) { | 96 | for (i = 0; i <= 6; i++) { |
97 | slHomeAddress.append( "" ); | 97 | slHomeAddress.append( "" ); |
98 | slBusinessAddress.append( "" ); | 98 | slBusinessAddress.append( "" ); |
99 | } | 99 | } |
100 | 100 | ||
101 | trlChooserNames = OContactFields::trphonefields( false ); | 101 | trlChooserNames = OContactFields::trphonefields( false ); |
102 | slChooserNames = OContactFields::untrphonefields( false ); | 102 | slChooserNames = OContactFields::untrphonefields( false ); |
103 | slDynamicEntries = OContactFields::untrdetailsfields( false ); | 103 | slDynamicEntries = OContactFields::untrdetailsfields( false ); |
104 | trlDynamicEntries = OContactFields::trdetailsfields( false ); | 104 | trlDynamicEntries = OContactFields::trdetailsfields( false ); |
105 | 105 | ||
106 | // Ok, we have to remove elements from the list of dynamic entries | 106 | // Ok, we have to remove elements from the list of dynamic entries |
107 | // which are now stored in special (not dynamic) widgets.. | 107 | // which are now stored in special (not dynamic) widgets.. |
108 | // Otherwise we will get problems with field assignments! (se) | 108 | // Otherwise we will get problems with field assignments! (se) |
109 | slDynamicEntries.remove("Anniversary"); | 109 | slDynamicEntries.remove("Anniversary"); |
110 | slDynamicEntries.remove("Birthday"); | 110 | slDynamicEntries.remove("Birthday"); |
111 | slDynamicEntries.remove("Gender"); | 111 | slDynamicEntries.remove("Gender"); |
112 | 112 | ||
113 | // The same with translated fields.. But I will | 113 | // The same with translated fields.. But I will |
114 | // use the translation map to avoid mismatches.. | 114 | // use the translation map to avoid mismatches.. |
115 | QMap<int, QString> translMap = OContactFields::idToTrFields(); | 115 | QMap<int, QString> translMap = OContactFields::idToTrFields(); |
116 | trlDynamicEntries.remove( translMap[Qtopia::Anniversary] ); | 116 | trlDynamicEntries.remove( translMap[Qtopia::Anniversary] ); |
117 | trlDynamicEntries.remove( translMap[Qtopia::Birthday] ); | 117 | trlDynamicEntries.remove( translMap[Qtopia::Birthday] ); |
118 | trlDynamicEntries.remove( translMap[Qtopia::Gender] ); | 118 | trlDynamicEntries.remove( translMap[Qtopia::Gender] ); |
119 | 119 | ||
120 | // Last Check to be sure.. | 120 | // Last Check to be sure.. |
121 | assert( slDynamicEntries.count() == trlDynamicEntries.count() ); | 121 | assert( slDynamicEntries.count() == trlDynamicEntries.count() ); |
122 | assert( slChooserNames.count() == trlChooserNames.count() ); | 122 | assert( slChooserNames.count() == trlChooserNames.count() ); |
123 | 123 | ||
124 | for (i = 0; i < slChooserNames.count(); i++) | 124 | for (i = 0; i < slChooserNames.count(); i++) |
125 | slChooserValues.append(""); | 125 | slChooserValues.append(""); |
126 | 126 | ||
127 | 127 | ||
128 | QVBoxLayout *vb = new QVBoxLayout( this ); | 128 | QVBoxLayout *vb = new QVBoxLayout( this ); |
129 | 129 | ||
130 | tabMain = new QTabWidget( this ); | 130 | tabMain = new QTabWidget( this ); |
131 | vb->addWidget( tabMain ); | 131 | vb->addWidget( tabMain ); |
132 | 132 | ||
133 | QWidget *tabViewport = new QWidget ( tabMain ); | 133 | QWidget *tabViewport = new QWidget ( tabMain ); |
134 | 134 | ||
135 | vb = new QVBoxLayout( tabViewport ); | 135 | vb = new QVBoxLayout( tabViewport ); |
136 | 136 | ||
137 | svGeneral = new QScrollView( tabViewport ); | 137 | svGeneral = new QScrollView( tabViewport ); |
138 | vb->addWidget( svGeneral, 0, 0 ); | 138 | vb->addWidget( svGeneral, 0, 0 ); |
139 | svGeneral->setResizePolicy( QScrollView::AutoOneFit ); | 139 | svGeneral->setResizePolicy( QScrollView::AutoOneFit ); |
140 | // svGeneral->setHScrollBarMode( QScrollView::AlwaysOff ); | ||
141 | // svGeneral->setVScrollBarMode( QScrollView::AlwaysOff ); | ||
140 | svGeneral->setFrameStyle( QFrame::NoFrame ); | 142 | svGeneral->setFrameStyle( QFrame::NoFrame ); |
141 | 143 | ||
142 | QWidget *container = new QWidget( svGeneral->viewport() ); | 144 | QWidget *container = new QWidget( svGeneral->viewport() ); |
143 | svGeneral->addChild( container ); | 145 | svGeneral->addChild( container ); |
144 | 146 | ||
145 | QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 4 ); | 147 | QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 4 ); |
146 | gl->setResizeMode( QLayout::FreeResize ); | 148 | gl->setResizeMode( QLayout::FreeResize ); |
147 | 149 | ||
148 | btnFullName = new QPushButton( tr( "Full Name..." ), container ); | 150 | btnFullName = new QPushButton( tr( "Full Name..." ), container ); |
149 | gl->addWidget( btnFullName, 0, 0 ); | 151 | gl->addWidget( btnFullName, 0, 0 ); |
150 | txtFullName = new QLineEdit( container ); | 152 | txtFullName = new QLineEdit( container ); |
151 | gl->addWidget( txtFullName, 0, 1 ); | 153 | gl->addWidget( txtFullName, 0, 1 ); |
152 | 154 | ||
153 | QLabel *l = new QLabel( tr( "Job Title" ), container ); | 155 | QLabel *l = new QLabel( tr( "Job Title" ), container ); |
154 | gl->addWidget( l, 1, 0 ); | 156 | gl->addWidget( l, 1, 0 ); |
155 | txtJobTitle = new QLineEdit( container ); | 157 | txtJobTitle = new QLineEdit( container ); |
156 | gl->addWidget( txtJobTitle, 1, 1 ); | 158 | gl->addWidget( txtJobTitle, 1, 1 ); |
157 | 159 | ||
158 | l = new QLabel( tr("Suffix"), container ); | 160 | l = new QLabel( tr("Suffix"), container ); |
159 | gl->addWidget( l, 2, 0 ); | 161 | gl->addWidget( l, 2, 0 ); |
160 | txtSuffix = new QLineEdit( container ); | 162 | txtSuffix = new QLineEdit( container ); |
161 | gl->addWidget( txtSuffix, 2, 1 ); | 163 | gl->addWidget( txtSuffix, 2, 1 ); |
162 | 164 | ||
163 | l = new QLabel( tr( "Organization" ), container ); | 165 | l = new QLabel( tr( "Organization" ), container ); |
164 | gl->addWidget( l, 3, 0 ); | 166 | gl->addWidget( l, 3, 0 ); |
165 | txtOrganization = new QLineEdit( container ); | 167 | txtOrganization = new QLineEdit( container ); |
166 | gl->addWidget( txtOrganization, 3, 1 ); | 168 | gl->addWidget( txtOrganization, 3, 1 ); |
167 | 169 | ||
168 | // Chooser 1 | 170 | // Chooser 1 |
169 | cmbChooserField1 = new QComboBox( FALSE, container ); | 171 | cmbChooserField1 = new QComboBox( FALSE, container ); |
170 | cmbChooserField1->setMaximumWidth( 90 ); | 172 | cmbChooserField1->setMaximumWidth( 90 ); |
171 | gl->addWidget( cmbChooserField1, 4, 0 ); | 173 | gl->addWidget( cmbChooserField1, 4, 0 ); |
172 | // Textfield for chooser 1. | 174 | // Textfield for chooser 1. |
173 | // Now use Widgetstack to contain the textfield and the default-email combo ! | 175 | // Now use Widgetstack to contain the textfield and the default-email combo ! |
174 | m_widgetStack1 = new QWidgetStack( container ); | 176 | m_widgetStack1 = new QWidgetStack( container ); |
175 | txtChooserField1 = new QLineEdit( m_widgetStack1 ); | 177 | txtChooserField1 = new QLineEdit( m_widgetStack1 ); |
176 | m_widgetStack1 -> addWidget( txtChooserField1, TextField ); | 178 | m_widgetStack1 -> addWidget( txtChooserField1, TextField ); |
177 | gl->addWidget( m_widgetStack1, 4, 1 ); | 179 | gl->addWidget( m_widgetStack1, 4, 1 ); |
178 | m_widgetStack1 -> raiseWidget( TextField ); | 180 | m_widgetStack1 -> raiseWidget( TextField ); |
179 | 181 | ||
180 | // Chooser 2 | 182 | // Chooser 2 |
181 | cmbChooserField2 = new QComboBox( FALSE, container ); | 183 | cmbChooserField2 = new QComboBox( FALSE, container ); |
182 | cmbChooserField2->setMaximumWidth( 90 ); | 184 | cmbChooserField2->setMaximumWidth( 90 ); |
183 | gl->addWidget( cmbChooserField2, 5, 0 ); | 185 | gl->addWidget( cmbChooserField2, 5, 0 ); |
184 | // Textfield for chooser 2 | 186 | // Textfield for chooser 2 |
185 | // Now use WidgetStack to contain the textfield and the default-email combo! | 187 | // Now use WidgetStack to contain the textfield and the default-email combo! |
186 | m_widgetStack2 = new QWidgetStack( container ); | 188 | m_widgetStack2 = new QWidgetStack( container ); |
187 | txtChooserField2 = new QLineEdit( m_widgetStack2 ); | 189 | txtChooserField2 = new QLineEdit( m_widgetStack2 ); |
188 | m_widgetStack2 -> addWidget( txtChooserField2, TextField ); | 190 | m_widgetStack2 -> addWidget( txtChooserField2, TextField ); |
189 | gl->addWidget( m_widgetStack2, 5, 1 ); | 191 | gl->addWidget( m_widgetStack2, 5, 1 ); |
190 | m_widgetStack2 -> raiseWidget( TextField ); | 192 | m_widgetStack2 -> raiseWidget( TextField ); |
191 | 193 | ||
192 | // Chooser 3 | 194 | // Chooser 3 |
193 | cmbChooserField3 = new QComboBox( FALSE, container ); | 195 | cmbChooserField3 = new QComboBox( FALSE, container ); |
194 | cmbChooserField3->setMaximumWidth( 90 ); | 196 | cmbChooserField3->setMaximumWidth( 90 ); |
195 | gl->addWidget( cmbChooserField3, 6, 0 ); | 197 | gl->addWidget( cmbChooserField3, 6, 0 ); |
196 | // Textfield for chooser 2 | 198 | // Textfield for chooser 2 |
197 | // Now use WidgetStack to contain the textfield and the default-email combo! | 199 | // Now use WidgetStack to contain the textfield and the default-email combo! |
198 | m_widgetStack3 = new QWidgetStack( container ); | 200 | m_widgetStack3 = new QWidgetStack( container ); |
199 | txtChooserField3 = new QLineEdit( m_widgetStack3 ); | 201 | txtChooserField3 = new QLineEdit( m_widgetStack3 ); |
200 | m_widgetStack3 -> addWidget( txtChooserField3, TextField ); | 202 | m_widgetStack3 -> addWidget( txtChooserField3, TextField ); |
201 | gl->addWidget( m_widgetStack3, 6, 1 ); | 203 | gl->addWidget( m_widgetStack3, 6, 1 ); |
202 | m_widgetStack3 -> raiseWidget( TextField ); | 204 | m_widgetStack3 -> raiseWidget( TextField ); |
203 | 205 | ||
204 | l = new QLabel( tr( "File As" ), container ); | 206 | l = new QLabel( tr( "File As" ), container ); |
205 | gl->addWidget( l, 7, 0 ); | 207 | gl->addWidget( l, 7, 0 ); |
206 | cmbFileAs = new QComboBox( TRUE, container ); | 208 | cmbFileAs = new QComboBox( TRUE, container ); |
207 | gl->addWidget( cmbFileAs, 7, 1 ); | 209 | gl->addWidget( cmbFileAs, 7, 1 ); |
208 | 210 | ||
209 | labCat = new QLabel( tr( "Category" ), container ); | 211 | labCat = new QLabel( tr( "Category" ), container ); |
210 | gl->addWidget( labCat, 8, 0 ); | 212 | gl->addWidget( labCat, 8, 0 ); |
211 | cmbCat = new CategorySelect( container ); | 213 | cmbCat = new CategorySelect( container ); |
212 | gl->addWidget( cmbCat, 8, 1 ); | 214 | gl->addWidget( cmbCat, 8, 1 ); |
213 | labCat->show(); | 215 | labCat->show(); |
214 | cmbCat->show(); | 216 | cmbCat->show(); |
215 | 217 | ||
216 | btnNote = new QPushButton( tr( "Notes..." ), container ); | 218 | btnNote = new QPushButton( tr( "Notes..." ), container ); |
217 | gl->addWidget( btnNote, 9, 1 ); | 219 | gl->addWidget( btnNote, 9, 1 ); |
218 | 220 | ||
219 | tabMain->insertTab( tabViewport, tr( "General" ) ); | 221 | tabMain->insertTab( tabViewport, tr( "General" ) ); |
220 | 222 | ||
221 | tabViewport = new QWidget ( tabMain ); | 223 | tabViewport = new QWidget ( tabMain ); |
222 | 224 | ||
223 | vb = new QVBoxLayout( tabViewport ); | 225 | vb = new QVBoxLayout( tabViewport ); |
224 | 226 | ||
225 | svAddress = new QScrollView( tabViewport ); | 227 | svAddress = new QScrollView( tabViewport ); |
226 | vb->addWidget( svAddress, 0, 0 ); | 228 | vb->addWidget( svAddress, 0, 0 ); |
227 | svAddress->setResizePolicy( QScrollView::AutoOneFit ); | 229 | svAddress->setResizePolicy( QScrollView::AutoOneFit ); |
228 | svAddress->setFrameStyle( QFrame::NoFrame ); | 230 | svAddress->setFrameStyle( QFrame::NoFrame ); |
229 | 231 | ||
230 | container = new QWidget( svAddress->viewport() ); | 232 | container = new QWidget( svAddress->viewport() ); |
231 | svAddress->addChild( container ); | 233 | svAddress->addChild( container ); |
232 | 234 | ||
233 | gl = new QGridLayout( container, 8, 3, 2, 4 ); // row 7 QSpacerItem | 235 | gl = new QGridLayout( container, 8, 3, 2, 4 ); // row 7 QSpacerItem |
234 | 236 | ||
235 | cmbAddress = new QComboBox( FALSE, container ); | 237 | cmbAddress = new QComboBox( FALSE, container ); |
@@ -681,201 +683,200 @@ void ContactEditor::init() { | |||
681 | setPersonalView ( m_personalView ); | 683 | setPersonalView ( m_personalView ); |
682 | 684 | ||
683 | qWarning("init() END"); | 685 | qWarning("init() END"); |
684 | } | 686 | } |
685 | 687 | ||
686 | void ContactEditor::defaultEmailChanged(int i){ | 688 | void ContactEditor::defaultEmailChanged(int i){ |
687 | qDebug("defaultEmailChanged"); | 689 | qDebug("defaultEmailChanged"); |
688 | 690 | ||
689 | // was sollte das ? (se) | 691 | // was sollte das ? (se) |
690 | // int index = cmbChooserField1->currentItem(); | 692 | // int index = cmbChooserField1->currentItem(); |
691 | // slChooserValues[index] = cmbDefaultEmail->text(i); | 693 | // slChooserValues[index] = cmbDefaultEmail->text(i); |
692 | 694 | ||
693 | defaultEmail = cmbDefaultEmail->text(i); | 695 | defaultEmail = cmbDefaultEmail->text(i); |
694 | qDebug ("Changed to: %s", defaultEmail.latin1()); | 696 | qDebug ("Changed to: %s", defaultEmail.latin1()); |
695 | 697 | ||
696 | } | 698 | } |
697 | 699 | ||
698 | void ContactEditor::populateDefaultEmailCmb(){ | 700 | void ContactEditor::populateDefaultEmailCmb(){ |
699 | 701 | ||
700 | // if the default-email combo was not selected and therfore not created | 702 | // if the default-email combo was not selected and therfore not created |
701 | // we get a lot of trouble.. Therfore create an invisible one.. | 703 | // we get a lot of trouble.. Therfore create an invisible one.. |
702 | if ( !cmbDefaultEmail ){ | 704 | if ( !cmbDefaultEmail ){ |
703 | cmbDefaultEmail = new QComboBox(this); | 705 | cmbDefaultEmail = new QComboBox(this); |
704 | cmbDefaultEmail -> hide(); | 706 | cmbDefaultEmail -> hide(); |
705 | } | 707 | } |
706 | cmbDefaultEmail->clear(); | 708 | cmbDefaultEmail->clear(); |
707 | cmbDefaultEmail->insertStringList( emails ); | 709 | cmbDefaultEmail->insertStringList( emails ); |
708 | // cmbDefaultEmail->show(); | 710 | // cmbDefaultEmail->show(); |
709 | 711 | ||
710 | // Select default email in combo.. | 712 | // Select default email in combo.. |
711 | bool found = false; | 713 | bool found = false; |
712 | for ( int i = 0; i < cmbDefaultEmail->count(); i++){ | 714 | for ( int i = 0; i < cmbDefaultEmail->count(); i++){ |
713 | qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<", | 715 | qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<", |
714 | cmbDefaultEmail->text( i ).latin1(), defaultEmail.latin1()); | 716 | cmbDefaultEmail->text( i ).latin1(), defaultEmail.latin1()); |
715 | 717 | ||
716 | if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){ | 718 | if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){ |
717 | cmbDefaultEmail->setCurrentItem( i ); | 719 | cmbDefaultEmail->setCurrentItem( i ); |
718 | qDebug("set"); | 720 | qDebug("set"); |
719 | found = true; | 721 | found = true; |
720 | } | 722 | } |
721 | } | 723 | } |
722 | 724 | ||
723 | // If the current default email is not found in the list, we choose the | 725 | // If the current default email is not found in the list, we choose the |
724 | // first one.. | 726 | // first one.. |
725 | if ( !found ) | 727 | if ( !found ) |
726 | defaultEmail = cmbDefaultEmail->text(0); | 728 | defaultEmail = cmbDefaultEmail->text(0); |
727 | } | 729 | } |
728 | 730 | ||
729 | // Called when any combobox was changed. | 731 | // Called when any combobox was changed. |
730 | // "true" returned if the change was chandled by this function, else it should | 732 | // "true" returned if the change was chandled by this function, else it should |
731 | // be handled by something else.. | 733 | // be handled by something else.. |
732 | bool ContactEditor::cmbChooserChange( int index, QWidgetStack* inputStack, int widgetPos ) { | 734 | bool ContactEditor::cmbChooserChange( int index, QWidgetStack* inputStack, int widgetPos ) { |
733 | QString type = slChooserNames[index]; | 735 | QString type = slChooserNames[index]; |
734 | qWarning("ContactEditor::cmbChooserChange -> Type: %s, WidgetPos: %d", type.latin1(), widgetPos ); | 736 | qWarning("ContactEditor::cmbChooserChange -> Type: %s, WidgetPos: %d", type.latin1(), widgetPos ); |
735 | 737 | ||
736 | if ( !initializing ) | 738 | if ( !initializing ) |
737 | contactfields.setFieldOrder( widgetPos-1, index ); | 739 | contactfields.setFieldOrder( widgetPos-1, index ); |
738 | 740 | ||
739 | // Create and connect combobox for selecting the default email | 741 | // Create and connect combobox for selecting the default email |
740 | if ( type == "Default Email"){ | 742 | if ( type == "Default Email"){ |
741 | qWarning("Choosing default-email (defaultEmailChooserPosition= %d) ", defaultEmailChooserPosition); | 743 | qWarning("Choosing default-email (defaultEmailChooserPosition= %d) ", defaultEmailChooserPosition); |
742 | 744 | ||
743 | // More than one default-email chooser is not allowed ! | 745 | // More than one default-email chooser is not allowed ! |
744 | if ( ( defaultEmailChooserPosition != -1 ) && | 746 | if ( ( defaultEmailChooserPosition != -1 ) && |
745 | defaultEmailChooserPosition != widgetPos && !initializing){ | 747 | defaultEmailChooserPosition != widgetPos && !initializing){ |
746 | chooserError( widgetPos ); | 748 | chooserError( widgetPos ); |
747 | return true; | 749 | return true; |
748 | } | 750 | } |
749 | 751 | ||
750 | QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo ); | 752 | QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo ); |
751 | if ( cmbo ){ | 753 | if ( cmbo ){ |
752 | inputStack->raiseWidget( TextField ); | 754 | inputStack->raiseWidget( TextField ); |
753 | inputStack -> removeWidget( cmbo ); | 755 | inputStack -> removeWidget( cmbo ); |
754 | delete cmbo; | 756 | delete cmbo; |
755 | } | 757 | } |
756 | cmbo = new QComboBox( inputStack ); | 758 | cmbo = new QComboBox( inputStack ); |
757 | cmbo -> insertStringList( emails ); | 759 | cmbo -> insertStringList( emails ); |
758 | 760 | ||
759 | inputStack -> addWidget( cmbo, Combo ); | 761 | inputStack -> addWidget( cmbo, Combo ); |
760 | inputStack -> raiseWidget( Combo ); | 762 | inputStack -> raiseWidget( Combo ); |
761 | 763 | ||
762 | defaultEmailChooserPosition = widgetPos; | 764 | defaultEmailChooserPosition = widgetPos; |
763 | cmbDefaultEmail = cmbo; | 765 | cmbDefaultEmail = cmbo; |
764 | 766 | ||
765 | connect( cmbo,SIGNAL( activated(int) ), | 767 | connect( cmbo,SIGNAL( activated(int) ), |
766 | SLOT( defaultEmailChanged(int) ) ); | 768 | SLOT( defaultEmailChanged(int) ) ); |
767 | 769 | ||
768 | // Set current default email | 770 | // Set current default email |
769 | populateDefaultEmailCmb(); | 771 | populateDefaultEmailCmb(); |
770 | 772 | ||
771 | 773 | ||
772 | } else { | 774 | } else { |
773 | // Something else was selected: Hide combo.. | 775 | // Something else was selected: Hide combo.. |
774 | qWarning(" Hiding default-email combo" ); | 776 | qWarning(" Hiding default-email combo" ); |
775 | if ( defaultEmailChooserPosition == widgetPos ){ | 777 | if ( defaultEmailChooserPosition == widgetPos ){ |
776 | defaultEmailChooserPosition = -1; | 778 | defaultEmailChooserPosition = -1; |
777 | QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo ); | 779 | } |
778 | if ( cmbo ){ | 780 | QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo ); |
779 | inputStack->raiseWidget( TextField ); | 781 | if ( cmbo ){ |
780 | inputStack -> removeWidget( cmbo ); | 782 | inputStack->raiseWidget( TextField ); |
781 | cmbDefaultEmail = 0l; | 783 | inputStack -> removeWidget( cmbo ); |
782 | delete cmbo; | 784 | cmbDefaultEmail = 0l; |
783 | } | 785 | delete cmbo; |
784 | 786 | } | |
785 | } | ||
786 | 787 | ||
787 | // Caller should initialize the responsible textfield, therefore | 788 | // Caller should initialize the responsible textfield, therefore |
788 | // "false" is returned | 789 | // "false" is returned |
789 | return false; | 790 | return false; |
790 | } | 791 | } |
791 | 792 | ||
792 | // Everything is worked off .. | 793 | // Everything is worked off .. |
793 | return true; | 794 | return true; |
794 | 795 | ||
795 | } | 796 | } |
796 | 797 | ||
797 | // Currently accessed when we select default-email more than once ! | 798 | // Currently accessed when we select default-email more than once ! |
798 | void ContactEditor::chooserError( int index ) | 799 | void ContactEditor::chooserError( int index ) |
799 | { | 800 | { |
800 | qWarning("ContactEditor::chooserError( %d )", index); | 801 | qWarning("ContactEditor::chooserError( %d )", index); |
801 | QMessageBox::warning( this, "Chooser Error", | 802 | QMessageBox::warning( this, "Chooser Error", |
802 | "Multiple selection of this\n" | 803 | "Multiple selection of this\n" |
803 | "Item is not allowed !\n\n" | 804 | "Item is not allowed !\n\n" |
804 | "First deselect the previous one !", | 805 | "First deselect the previous one !", |
805 | "&OK", 0, 0, | 806 | "&OK", 0, 0, |
806 | 0, 0 ); | 807 | 0, 0 ); |
807 | 808 | ||
808 | // Reset the selected Chooser. Unfortunately the chooser | 809 | // Reset the selected Chooser. Unfortunately the chooser |
809 | // generates no signal, therfore we have to | 810 | // generates no signal, therfore we have to |
810 | // call the cmbChooserChange function manually.. | 811 | // call the cmbChooserChange function manually.. |
811 | switch( index ){ | 812 | switch( index ){ |
812 | case 1: | 813 | case 1: |
813 | cmbChooserField1 -> setCurrentItem( 0 ); | 814 | cmbChooserField1 -> setCurrentItem( 0 ); |
814 | slotCmbChooser1Change( 0 ); | 815 | slotCmbChooser1Change( 0 ); |
815 | break; | 816 | break; |
816 | case 2: | 817 | case 2: |
817 | cmbChooserField2 -> setCurrentItem( 0 ); | 818 | cmbChooserField2 -> setCurrentItem( 0 ); |
818 | slotCmbChooser2Change( 0 ); | 819 | slotCmbChooser2Change( 0 ); |
819 | break; | 820 | break; |
820 | case 3: | 821 | case 3: |
821 | cmbChooserField3 -> setCurrentItem( 0 ); | 822 | cmbChooserField3 -> setCurrentItem( 0 ); |
822 | slotCmbChooser3Change( 0 ); | 823 | slotCmbChooser3Change( 0 ); |
823 | break; | 824 | break; |
824 | case 4: | 825 | case 4: |
825 | cmbChooserField4 -> setCurrentItem( 0 ); | 826 | cmbChooserField4 -> setCurrentItem( 0 ); |
826 | slotCmbChooser4Change( 0 ); | 827 | slotCmbChooser4Change( 0 ); |
827 | break; | 828 | break; |
828 | } | 829 | } |
829 | } | 830 | } |
830 | 831 | ||
831 | // Called when something was changed in a textfield (shouldn't it called textchanged? (se)) | 832 | // Called when something was changed in a textfield (shouldn't it called textchanged? (se)) |
832 | void ContactEditor::chooserChange( const QString &textChanged, int index, | 833 | void ContactEditor::chooserChange( const QString &textChanged, int index, |
833 | QLineEdit* , int widgetPos ) { | 834 | QLineEdit* , int widgetPos ) { |
834 | 835 | ||
835 | QString type = slChooserNames[index]; // :SX | 836 | QString type = slChooserNames[index]; // :SX |
836 | qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i", | 837 | qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i", |
837 | type.latin1(),textChanged.latin1(), index, widgetPos ); | 838 | type.latin1(),textChanged.latin1(), index, widgetPos ); |
838 | 839 | ||
839 | if ( type == "Default Email"){ | 840 | if ( type == "Default Email"){ |
840 | qWarning ("??? Wozu??: %s", textChanged.latin1()); | 841 | qWarning ("??? Wozu??: %s", textChanged.latin1()); |
841 | defaultEmail = textChanged; | 842 | defaultEmail = textChanged; |
842 | 843 | ||
843 | populateDefaultEmailCmb(); | 844 | populateDefaultEmailCmb(); |
844 | 845 | ||
845 | }else if (type == "Emails"){ | 846 | }else if (type == "Emails"){ |
846 | qDebug("emails"); | 847 | qDebug("emails"); |
847 | 848 | ||
848 | QString de; | 849 | QString de; |
849 | emails = QStringList::split (",", textChanged ); | 850 | emails = QStringList::split (",", textChanged ); |
850 | 851 | ||
851 | populateDefaultEmailCmb(); | 852 | populateDefaultEmailCmb(); |
852 | } | 853 | } |
853 | 854 | ||
854 | slChooserValues[index] = textChanged; | 855 | slChooserValues[index] = textChanged; |
855 | 856 | ||
856 | } | 857 | } |
857 | 858 | ||
858 | void ContactEditor::slotChooser1Change( const QString &textChanged ) { | 859 | void ContactEditor::slotChooser1Change( const QString &textChanged ) { |
859 | qWarning("ContactEditor::slotChooser1Change( %s )", textChanged.latin1()); | 860 | qWarning("ContactEditor::slotChooser1Change( %s )", textChanged.latin1()); |
860 | chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1); | 861 | chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1); |
861 | } | 862 | } |
862 | 863 | ||
863 | void ContactEditor::slotChooser2Change( const QString &textChanged ) { | 864 | void ContactEditor::slotChooser2Change( const QString &textChanged ) { |
864 | qWarning("ContactEditor::slotChooser2Change( %s )", textChanged.latin1()); | 865 | qWarning("ContactEditor::slotChooser2Change( %s )", textChanged.latin1()); |
865 | chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2, 2); | 866 | chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2, 2); |
866 | 867 | ||
867 | } | 868 | } |
868 | 869 | ||
869 | void ContactEditor::slotChooser3Change( const QString &textChanged ) { | 870 | void ContactEditor::slotChooser3Change( const QString &textChanged ) { |
870 | qWarning("ContactEditor::slotChooser3Change( %s )", textChanged.latin1()); | 871 | qWarning("ContactEditor::slotChooser3Change( %s )", textChanged.latin1()); |
871 | chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3, 3); | 872 | chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3, 3); |
872 | } | 873 | } |
873 | 874 | ||
874 | void ContactEditor::slotChooser4Change( const QString &textChanged ) { | 875 | void ContactEditor::slotChooser4Change( const QString &textChanged ) { |
875 | qWarning("ContactEditor::slotChooser4Change( %s )", textChanged.latin1()); | 876 | qWarning("ContactEditor::slotChooser4Change( %s )", textChanged.latin1()); |
876 | chooserChange( textChanged, cmbChooserField4->currentItem(), txtChooserField4, 4); | 877 | chooserChange( textChanged, cmbChooserField4->currentItem(), txtChooserField4, 4); |
877 | } | 878 | } |
878 | 879 | ||
879 | void ContactEditor::slotAddressChange( const QString &textChanged ) { | 880 | void ContactEditor::slotAddressChange( const QString &textChanged ) { |
880 | 881 | ||
881 | if ( cmbAddress->currentItem() == 0 ) { | 882 | if ( cmbAddress->currentItem() == 0 ) { |