summaryrefslogtreecommitdiffabout
path: root/kaddressbook/emaileditwidget.cpp
Unidiff
Diffstat (limited to 'kaddressbook/emaileditwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/emaileditwidget.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/kaddressbook/emaileditwidget.cpp b/kaddressbook/emaileditwidget.cpp
index e72face..09df47f 100644
--- a/kaddressbook/emaileditwidget.cpp
+++ b/kaddressbook/emaileditwidget.cpp
@@ -7,76 +7,78 @@
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qstring.h> 28#include <qstring.h>
29#include <qtoolbutton.h> 29#include <qtoolbutton.h>
30#include <qtooltip.h> 30#include <qtooltip.h>
31#include <qlistbox.h> 31#include <q3listbox.h>
32//Added by qt3to4:
33#include <Q3GridLayout>
32 34
33#ifndef KAB_EMBEDDED 35#ifndef KAB_EMBEDDED
34#include <kaccelmanager.h> 36#include <kaccelmanager.h>
35#endif //KAB_EMBEDDED 37#endif //KAB_EMBEDDED
36#include <kconfig.h> 38#include <kconfig.h>
37#include <kcombobox.h> 39#include <kcombobox.h>
38#include <kdebug.h> 40#include <kdebug.h>
39#include <kglobal.h> 41#include <kglobal.h>
40#include <kdialog.h> 42#include <kdialog.h>
41#include <kiconloader.h> 43#include <kiconloader.h>
42#include <klineedit.h> 44#include <klineedit.h>
43#include <klocale.h> 45#include <klocale.h>
44#include <kmessagebox.h> 46#include <kmessagebox.h>
45 47
46#include "emaileditwidget.h" 48#include "emaileditwidget.h"
47 49
48EmailEditWidget::EmailEditWidget( QWidget *parent, const char *name ) 50EmailEditWidget::EmailEditWidget( QWidget *parent, const char *name )
49 : QWidget( parent, name ) 51 : QWidget( parent, name )
50{ 52{
51 QGridLayout *topLayout = new QGridLayout( this, 2, 2 ); 53 Q3GridLayout *topLayout = new Q3GridLayout( this, 2, 2 );
52 topLayout->setSpacing( KDialog::spacingHint() ); 54 topLayout->setSpacing( KDialog::spacingHint() );
53 QLabel* label = new QLabel( this ); 55 QLabel* label = new QLabel( this );
54 56
55 label->setPixmap( KGlobal::iconLoader()->loadIcon( "mail_send", KIcon::Desktop, 0) ); 57 label->setPixmap( KGlobal::iconLoader()->loadIcon( "mail_send", KIcon::Desktop, 0) );
56 58
57 topLayout->addWidget( label, 0, 0 ); 59 topLayout->addWidget( label, 0, 0 );
58 label->setAlignment( AlignCenter ); 60 label->setAlignment( Qt::AlignCenter );
59 QPushButton *editButton = new QPushButton( i18n( "Edit Email Addresses..." ), this); 61 QPushButton *editButton = new QPushButton( i18n( "Edit Email Addresses..." ), this);
60 topLayout->addWidget( editButton, 0, 1 ); 62 topLayout->addWidget( editButton, 0, 1 );
61 label = new QLabel( i18n( "Email:" ), this ); 63 label = new QLabel( i18n( "Email:" ), this );
62 topLayout->addWidget( label, 1, 0 ); 64 topLayout->addWidget( label, 1, 0 );
63 65
64 mEmailEdit = new KLineEdit( this ); 66 mEmailEdit = new KLineEdit( this );
65 connect( mEmailEdit, SIGNAL( textChanged( const QString& ) ), 67 connect( mEmailEdit, SIGNAL( textChanged( const QString& ) ),
66 SLOT( textChanged( const QString& ) ) ); 68 SLOT( textChanged( const QString& ) ) );
67 connect( mEmailEdit, SIGNAL( textChanged( const QString& ) ), 69 connect( mEmailEdit, SIGNAL( textChanged( const QString& ) ),
68 SIGNAL( modified() ) ); 70 SIGNAL( modified() ) );
69 label->setBuddy( mEmailEdit ); 71 label->setBuddy( mEmailEdit );
70 topLayout->addWidget( mEmailEdit, 1, 1 ); 72 topLayout->addWidget( mEmailEdit, 1, 1 );
71 73
72 74
73 connect( editButton, SIGNAL( clicked() ), SLOT( edit() ) ); 75 connect( editButton, SIGNAL( clicked() ), SLOT( edit() ) );
74 76
75 topLayout->activate(); 77 topLayout->activate();
76} 78}
77 79
78EmailEditWidget::~EmailEditWidget() 80EmailEditWidget::~EmailEditWidget()
79{ 81{
80} 82}
81 83
82void EmailEditWidget::setEmails( const QStringList &list ) 84void EmailEditWidget::setEmails( const QStringList &list )
@@ -116,66 +118,66 @@ void EmailEditWidget::edit()
116 mEmailList = dlg.emails(); 118 mEmailList = dlg.emails();
117 mEmailEdit->setText( mEmailList[ 0 ] ); 119 mEmailEdit->setText( mEmailList[ 0 ] );
118 emit modified(); 120 emit modified();
119 } 121 }
120 } 122 }
121} 123}
122 124
123void EmailEditWidget::textChanged( const QString &text ) 125void EmailEditWidget::textChanged( const QString &text )
124{ 126{
125 if ( mEmailList.count() > 0 ) 127 if ( mEmailList.count() > 0 )
126 mEmailList.remove( mEmailList.begin() ); 128 mEmailList.remove( mEmailList.begin() );
127 129
128 mEmailList.prepend( text ); 130 mEmailList.prepend( text );
129} 131}
130 132
131 133
132EmailEditDialog::EmailEditDialog( const QStringList &list, QWidget *parent, 134EmailEditDialog::EmailEditDialog( const QStringList &list, QWidget *parent,
133 const char *name ) 135 const char *name )
134 : KDialogBase( KDialogBase::Plain, i18n( "Edit Email Addresses" ), 136 : KDialogBase( KDialogBase::Plain, i18n( "Edit Email Addresses" ),
135 KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, 137 KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok,
136 parent, name, true ) 138 parent, name, true )
137{ 139{
138 QWidget *page = plainPage(); 140 QWidget *page = plainPage();
139 141
140 QGridLayout *topLayout = new QGridLayout( page, 4, 3 ); 142 Q3GridLayout *topLayout = new Q3GridLayout( page, 4, 3 );
141 143
142 QLabel *label = new QLabel( i18n( "Email address:" ), page ); 144 QLabel *label = new QLabel( i18n( "Email address:" ), page );
143 topLayout->addWidget( label, 0, 0 ); 145 topLayout->addWidget( label, 0, 0 );
144 146
145 mEmailEdit = new KLineEdit( page ); 147 mEmailEdit = new KLineEdit( page );
146 label->setBuddy( mEmailEdit ); 148 label->setBuddy( mEmailEdit );
147 topLayout->addWidget( mEmailEdit, 0, 1 ); 149 topLayout->addWidget( mEmailEdit, 0, 1 );
148 connect( mEmailEdit, SIGNAL( returnPressed() ), SLOT( add() ) ); 150 connect( mEmailEdit, SIGNAL( returnPressed() ), SLOT( add() ) );
149 connect( mEmailEdit, SIGNAL( textChanged( const QString& ) ), 151 connect( mEmailEdit, SIGNAL( textChanged( const QString& ) ),
150 SLOT( emailChanged() ) ); 152 SLOT( emailChanged() ) );
151 153
152 mAddButton = new QPushButton( i18n( "Add" ), page ); 154 mAddButton = new QPushButton( i18n( "Add" ), page );
153 mAddButton->setEnabled( false ); 155 mAddButton->setEnabled( false );
154 connect( mAddButton, SIGNAL( clicked() ), SLOT( add() ) ); 156 connect( mAddButton, SIGNAL( clicked() ), SLOT( add() ) );
155 topLayout->addWidget( mAddButton, 0, 2 ); 157 topLayout->addWidget( mAddButton, 0, 2 );
156 158
157 mEmailListBox = new QListBox( page ); 159 mEmailListBox = new Q3ListBox( page );
158 160
159 // Make sure there is room for the scrollbar 161 // Make sure there is room for the scrollbar
160 mEmailListBox->setMinimumHeight( mEmailListBox->sizeHint().height() + 30 ); 162 mEmailListBox->setMinimumHeight( mEmailListBox->sizeHint().height() + 30 );
161 connect( mEmailListBox, SIGNAL( highlighted( int ) ), 163 connect( mEmailListBox, SIGNAL( highlighted( int ) ),
162 SLOT( selectionChanged( int ) ) ); 164 SLOT( selectionChanged( int ) ) );
163 topLayout->addMultiCellWidget( mEmailListBox, 1, 3, 0, 1 ); 165 topLayout->addMultiCellWidget( mEmailListBox, 1, 3, 0, 1 );
164 166
165 mEditButton = new QPushButton( i18n( "Change" ), page ); 167 mEditButton = new QPushButton( i18n( "Change" ), page );
166 connect( mEditButton, SIGNAL( clicked() ), SLOT( edit() ) ); 168 connect( mEditButton, SIGNAL( clicked() ), SLOT( edit() ) );
167 topLayout->addWidget( mEditButton, 1, 2 ); 169 topLayout->addWidget( mEditButton, 1, 2 );
168 170
169 mRemoveButton = new QPushButton( i18n( "Remove" ), page ); 171 mRemoveButton = new QPushButton( i18n( "Remove" ), page );
170 connect( mRemoveButton, SIGNAL( clicked() ), SLOT( remove() ) ); 172 connect( mRemoveButton, SIGNAL( clicked() ), SLOT( remove() ) );
171 topLayout->addWidget( mRemoveButton, 2, 2 ); 173 topLayout->addWidget( mRemoveButton, 2, 2 );
172 174
173 mStandardButton = new QPushButton( i18n( "Set Standard" ), page ); 175 mStandardButton = new QPushButton( i18n( "Set Standard" ), page );
174 connect( mStandardButton, SIGNAL( clicked() ), SLOT( standard() ) ); 176 connect( mStandardButton, SIGNAL( clicked() ), SLOT( standard() ) );
175 topLayout->addWidget( mStandardButton, 3, 2 ); 177 topLayout->addWidget( mStandardButton, 3, 2 );
176 178
177 topLayout->activate(); 179 topLayout->activate();
178 QStringList items = list; 180 QStringList items = list;
179 181
180qDebug("EmailEditDialog::EmailEditDialog has to be changed (lowPrio)"); 182qDebug("EmailEditDialog::EmailEditDialog has to be changed (lowPrio)");
181//US must be fixed !!! 183//US must be fixed !!!
@@ -251,27 +253,27 @@ bool EmailEditDialog::changed() const
251void EmailEditDialog::standard() 253void EmailEditDialog::standard()
252{ 254{
253 QString text = mEmailListBox->currentText(); 255 QString text = mEmailListBox->currentText();
254 mEmailListBox->removeItem( mEmailListBox->currentItem() ); 256 mEmailListBox->removeItem( mEmailListBox->currentItem() );
255 mEmailListBox->insertItem( text, 0 ); 257 mEmailListBox->insertItem( text, 0 );
256 mEmailListBox->setSelected( 0, true ); 258 mEmailListBox->setSelected( 0, true );
257 259
258 mChanged = true; 260 mChanged = true;
259} 261}
260 262
261void EmailEditDialog::selectionChanged( int index ) 263void EmailEditDialog::selectionChanged( int index )
262{ 264{
263 bool value = ( index >= 0 ); // An item is selected 265 bool value = ( index >= 0 ); // An item is selected
264 266
265 mRemoveButton->setEnabled( value ); 267 mRemoveButton->setEnabled( value );
266 mEditButton->setEnabled( value ); 268 mEditButton->setEnabled( value );
267 mStandardButton->setEnabled( value ); 269 mStandardButton->setEnabled( value );
268} 270}
269 271
270void EmailEditDialog::emailChanged() 272void EmailEditDialog::emailChanged()
271{ 273{
272 mAddButton->setEnabled( !mEmailEdit->text().isEmpty() ); 274 mAddButton->setEnabled( !mEmailEdit->text().isEmpty() );
273} 275}
274 276
275#ifndef KAB_EMBEDDED 277#ifndef KAB_EMBEDDED_
276#include "emaileditwidget.moc" 278#include "moc_emaileditwidget.cpp"
277#endif //KAB_EMBEDDED 279#endif //KAB_EMBEDDED