Diffstat (limited to 'kabc/distributionlistdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kabc/distributionlistdialog.cpp | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/kabc/distributionlistdialog.cpp b/kabc/distributionlistdialog.cpp index d2e1144..82883e6 100644 --- a/kabc/distributionlistdialog.cpp +++ b/kabc/distributionlistdialog.cpp | |||
@@ -1,216 +1,222 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library 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 GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <qlistview.h> | 21 | #include <q3listview.h> |
22 | #include <qlayout.h> | 22 | #include <qlayout.h> |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qpushbutton.h> | 24 | #include <qpushbutton.h> |
25 | #include <qcombobox.h> | 25 | #include <qcombobox.h> |
26 | //Added by qt3to4: | ||
27 | #include <Q3HBoxLayout> | ||
28 | #include <Q3GridLayout> | ||
29 | #include <Q3Frame> | ||
30 | #include <Q3VBoxLayout> | ||
26 | #include <klineeditdlg.h> | 31 | #include <klineeditdlg.h> |
27 | #include <qbuttongroup.h> | 32 | #include <q3buttongroup.h> |
33 | #include <Q3Button> | ||
28 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
29 | 35 | ||
30 | #include <klocale.h> | 36 | #include <klocale.h> |
31 | #include <kdebug.h> | 37 | #include <kdebug.h> |
32 | #include <kmessagebox.h> | 38 | #include <kmessagebox.h> |
33 | 39 | ||
34 | #include "addressbook.h" | 40 | #include "addressbook.h" |
35 | #include "addresseedialog.h" | 41 | #include "addresseedialog.h" |
36 | #include "distributionlist.h" | 42 | #include "distributionlist.h" |
37 | 43 | ||
38 | #include "distributionlistdialog.h" | 44 | #include "distributionlistdialog.h" |
39 | 45 | ||
40 | //US #include "distributionlistdialog.moc" | 46 | //US #include "distributionlistdialog.moc" |
41 | 47 | ||
42 | using namespace KABC; | 48 | using namespace KABC; |
43 | 49 | ||
44 | DistributionListDialog::DistributionListDialog( AddressBook *addressBook, QWidget *parent) | 50 | DistributionListDialog::DistributionListDialog( AddressBook *addressBook, QWidget *parent) |
45 | : KDialogBase( parent, "", true, i18n("Configure Distribution Lists"), Ok, Ok, true) | 51 | : KDialogBase( parent, "", true, i18n("Configure Distribution Lists"), Ok, Ok, true) |
46 | { | 52 | { |
47 | mEditor = new DistributionListEditorWidget( addressBook, this ); | 53 | mEditor = new DistributionListEditorWidget( addressBook, this ); |
48 | setMainWidget( mEditor ); | 54 | setMainWidget( mEditor ); |
49 | 55 | ||
50 | connect( this, SIGNAL( okClicked() ), mEditor, SLOT( save() ) ); | 56 | connect( this, SIGNAL( okClicked() ), mEditor, SLOT( save() ) ); |
51 | } | 57 | } |
52 | 58 | ||
53 | DistributionListDialog::~DistributionListDialog() | 59 | DistributionListDialog::~DistributionListDialog() |
54 | { | 60 | { |
55 | } | 61 | } |
56 | 62 | ||
57 | 63 | ||
58 | EmailSelector::EmailSelector( const QStringList &emails, const QString ¤t, | 64 | EmailSelector::EmailSelector( const QStringList &emails, const QString ¤t, |
59 | QWidget *parent ) : | 65 | QWidget *parent ) : |
60 | KDialogBase( KDialogBase::Plain, i18n("Select Email Address"), Ok, Ok, | 66 | KDialogBase( KDialogBase::Plain, i18n("Select Email Address"), Ok, Ok, |
61 | parent ) | 67 | parent ) |
62 | { | 68 | { |
63 | QFrame *topFrame = plainPage(); | 69 | Q3Frame *topFrame = plainPage(); |
64 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); | 70 | Q3BoxLayout *topLayout = new Q3VBoxLayout( topFrame ); |
65 | 71 | ||
66 | mButtonGroup = new QButtonGroup( 1, Horizontal, i18n("Email Addresses"), | 72 | mButtonGroup = new Q3ButtonGroup( 1, Qt::Horizontal, i18n("Email Addresses"), |
67 | topFrame ); | 73 | topFrame ); |
68 | topLayout->addWidget( mButtonGroup ); | 74 | topLayout->addWidget( mButtonGroup ); |
69 | 75 | ||
70 | QStringList::ConstIterator it; | 76 | QStringList::ConstIterator it; |
71 | for( it = emails.begin(); it != emails.end(); ++it ) { | 77 | for( it = emails.begin(); it != emails.end(); ++it ) { |
72 | QRadioButton *button = new QRadioButton( *it, mButtonGroup ); | 78 | QRadioButton *button = new QRadioButton( *it, mButtonGroup ); |
73 | if ( (*it) == current ) { | 79 | if ( (*it) == current ) { |
74 | button->setDown( true ); | 80 | button->setDown( true ); |
75 | } | 81 | } |
76 | } | 82 | } |
77 | } | 83 | } |
78 | 84 | ||
79 | QString EmailSelector::selected() | 85 | QString EmailSelector::selected() |
80 | { | 86 | { |
81 | QButton *button = mButtonGroup->selected(); | 87 | QAbstractButton *button = mButtonGroup->selected(); |
82 | if ( button ) return button->text(); | 88 | if ( button ) return button->text(); |
83 | return QString::null; | 89 | return QString::null; |
84 | } | 90 | } |
85 | 91 | ||
86 | QString EmailSelector::getEmail( const QStringList &emails, const QString ¤t, | 92 | QString EmailSelector::getEmail( const QStringList &emails, const QString ¤t, |
87 | QWidget *parent ) | 93 | QWidget *parent ) |
88 | { | 94 | { |
89 | EmailSelector *dlg = new EmailSelector( emails, current, parent ); | 95 | EmailSelector *dlg = new EmailSelector( emails, current, parent ); |
90 | dlg->exec(); | 96 | dlg->exec(); |
91 | 97 | ||
92 | QString result = dlg->selected(); | 98 | QString result = dlg->selected(); |
93 | 99 | ||
94 | delete dlg; | 100 | delete dlg; |
95 | 101 | ||
96 | return result; | 102 | return result; |
97 | } | 103 | } |
98 | 104 | ||
99 | class EntryItem : public QListViewItem | 105 | class EntryItem : public Q3ListViewItem |
100 | { | 106 | { |
101 | public: | 107 | public: |
102 | EntryItem( QListView *parent, const Addressee &addressee, | 108 | EntryItem( Q3ListView *parent, const Addressee &addressee, |
103 | const QString &email=QString::null ) : | 109 | const QString &email=QString::null ) : |
104 | QListViewItem( parent ), | 110 | Q3ListViewItem( parent ), |
105 | mAddressee( addressee ), | 111 | mAddressee( addressee ), |
106 | mEmail( email ) | 112 | mEmail( email ) |
107 | { | 113 | { |
108 | setText( 0, addressee.realName() ); | 114 | setText( 0, addressee.realName() ); |
109 | if( email.isEmpty() ) { | 115 | if( email.isEmpty() ) { |
110 | setText( 1, addressee.preferredEmail() ); | 116 | setText( 1, addressee.preferredEmail() ); |
111 | setText( 2, i18n("Yes") ); | 117 | setText( 2, i18n("Yes") ); |
112 | } else { | 118 | } else { |
113 | setText( 1, email ); | 119 | setText( 1, email ); |
114 | setText( 2, i18n("No") ); | 120 | setText( 2, i18n("No") ); |
115 | } | 121 | } |
116 | } | 122 | } |
117 | 123 | ||
118 | Addressee addressee() const | 124 | Addressee addressee() const |
119 | { | 125 | { |
120 | return mAddressee; | 126 | return mAddressee; |
121 | } | 127 | } |
122 | 128 | ||
123 | QString email() const | 129 | QString email() const |
124 | { | 130 | { |
125 | return mEmail; | 131 | return mEmail; |
126 | } | 132 | } |
127 | 133 | ||
128 | private: | 134 | private: |
129 | Addressee mAddressee; | 135 | Addressee mAddressee; |
130 | QString mEmail; | 136 | QString mEmail; |
131 | }; | 137 | }; |
132 | 138 | ||
133 | DistributionListEditorWidget::DistributionListEditorWidget( AddressBook *addressBook, QWidget *parent) : | 139 | DistributionListEditorWidget::DistributionListEditorWidget( AddressBook *addressBook, QWidget *parent) : |
134 | QWidget( parent ), | 140 | QWidget( parent ), |
135 | mAddressBook( addressBook ) | 141 | mAddressBook( addressBook ) |
136 | { | 142 | { |
137 | kdDebug(5700) << "DistributionListEditor()" << endl; | 143 | kdDebug(5700) << "DistributionListEditor()" << endl; |
138 | 144 | ||
139 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 145 | Q3BoxLayout *topLayout = new Q3VBoxLayout( this ); |
140 | topLayout->setSpacing( KDialog::spacingHint() ); | 146 | topLayout->setSpacing( KDialog::spacingHint() ); |
141 | 147 | ||
142 | QBoxLayout *nameLayout = new QHBoxLayout( topLayout) ; | 148 | Q3BoxLayout *nameLayout = new Q3HBoxLayout( topLayout) ; |
143 | 149 | ||
144 | mNameCombo = new QComboBox( this ); | 150 | mNameCombo = new QComboBox( this ); |
145 | nameLayout->addWidget( mNameCombo ); | 151 | nameLayout->addWidget( mNameCombo ); |
146 | connect( mNameCombo, SIGNAL( activated( int ) ), SLOT( updateEntryView() ) ); | 152 | connect( mNameCombo, SIGNAL( activated( int ) ), SLOT( updateEntryView() ) ); |
147 | 153 | ||
148 | mNewButton = new QPushButton( i18n("New List..."), this ); | 154 | mNewButton = new QPushButton( i18n("New List..."), this ); |
149 | nameLayout->addWidget( mNewButton ); | 155 | nameLayout->addWidget( mNewButton ); |
150 | connect( mNewButton, SIGNAL( clicked() ), SLOT( newList() ) ); | 156 | connect( mNewButton, SIGNAL( clicked() ), SLOT( newList() ) ); |
151 | 157 | ||
152 | mEditButton = new QPushButton( i18n("Rename List..."), this ); | 158 | mEditButton = new QPushButton( i18n("Rename List..."), this ); |
153 | nameLayout->addWidget( mEditButton ); | 159 | nameLayout->addWidget( mEditButton ); |
154 | connect( mEditButton, SIGNAL( clicked() ), SLOT( editList() ) ); | 160 | connect( mEditButton, SIGNAL( clicked() ), SLOT( editList() ) ); |
155 | 161 | ||
156 | mRemoveButton = new QPushButton( i18n("Remove List"), this ); | 162 | mRemoveButton = new QPushButton( i18n("Remove List"), this ); |
157 | nameLayout->addWidget( mRemoveButton ); | 163 | nameLayout->addWidget( mRemoveButton ); |
158 | connect( mRemoveButton, SIGNAL( clicked() ), SLOT( removeList() ) ); | 164 | connect( mRemoveButton, SIGNAL( clicked() ), SLOT( removeList() ) ); |
159 | 165 | ||
160 | QGridLayout *gridLayout = new QGridLayout( topLayout, 3, 3 ); | 166 | Q3GridLayout *gridLayout = new Q3GridLayout( topLayout, 3, 3 ); |
161 | gridLayout->setColStretch(1, 1); | 167 | gridLayout->setColStretch(1, 1); |
162 | 168 | ||
163 | QLabel *listLabel = new QLabel( i18n("Available addresses:"), this ); | 169 | QLabel *listLabel = new QLabel( i18n("Available addresses:"), this ); |
164 | gridLayout->addWidget( listLabel, 0, 0 ); | 170 | gridLayout->addWidget( listLabel, 0, 0 ); |
165 | 171 | ||
166 | mListLabel = new QLabel( this ); | 172 | mListLabel = new QLabel( this ); |
167 | gridLayout->addMultiCellWidget( mListLabel, 0, 0, 1, 2 ); | 173 | gridLayout->addMultiCellWidget( mListLabel, 0, 0, 1, 2 ); |
168 | 174 | ||
169 | mAddresseeView = new QListView( this ); | 175 | mAddresseeView = new Q3ListView( this ); |
170 | mAddresseeView->addColumn( i18n("Name") ); | 176 | mAddresseeView->addColumn( i18n("Name") ); |
171 | mAddresseeView->addColumn( i18n("Preferred Email") ); | 177 | mAddresseeView->addColumn( i18n("Preferred Email") ); |
172 | mAddresseeView->setAllColumnsShowFocus( true ); | 178 | mAddresseeView->setAllColumnsShowFocus( true ); |
173 | gridLayout->addWidget( mAddresseeView, 1, 0 ); | 179 | gridLayout->addWidget( mAddresseeView, 1, 0 ); |
174 | connect( mAddresseeView, SIGNAL( selectionChanged() ), | 180 | connect( mAddresseeView, SIGNAL( selectionChanged() ), |
175 | SLOT( slotSelectionAddresseeViewChanged() ) ); | 181 | SLOT( slotSelectionAddresseeViewChanged() ) ); |
176 | connect( mAddresseeView, SIGNAL( doubleClicked( QListViewItem * ) ), | 182 | connect( mAddresseeView, SIGNAL( doubleClicked( Q3ListViewItem * ) ), |
177 | SLOT( addEntry() ) ); | 183 | SLOT( addEntry() ) ); |
178 | 184 | ||
179 | mAddEntryButton = new QPushButton( i18n("Add Entry"), this ); | 185 | mAddEntryButton = new QPushButton( i18n("Add Entry"), this ); |
180 | mAddEntryButton->setEnabled(false); | 186 | mAddEntryButton->setEnabled(false); |
181 | gridLayout->addWidget( mAddEntryButton, 2, 0 ); | 187 | gridLayout->addWidget( mAddEntryButton, 2, 0 ); |
182 | connect( mAddEntryButton, SIGNAL( clicked() ), SLOT( addEntry() ) ); | 188 | connect( mAddEntryButton, SIGNAL( clicked() ), SLOT( addEntry() ) ); |
183 | 189 | ||
184 | mEntryView = new QListView( this ); | 190 | mEntryView = new Q3ListView( this ); |
185 | mEntryView->addColumn( i18n("Name") ); | 191 | mEntryView->addColumn( i18n("Name") ); |
186 | mEntryView->addColumn( i18n("Email") ); | 192 | mEntryView->addColumn( i18n("Email") ); |
187 | mEntryView->addColumn( i18n("Use Preferred") ); | 193 | mEntryView->addColumn( i18n("Use Preferred") ); |
188 | mEntryView->setEnabled(false); | 194 | mEntryView->setEnabled(false); |
189 | mEntryView->setAllColumnsShowFocus( true ); | 195 | mEntryView->setAllColumnsShowFocus( true ); |
190 | gridLayout->addMultiCellWidget( mEntryView, 1, 1, 1, 2 ); | 196 | gridLayout->addMultiCellWidget( mEntryView, 1, 1, 1, 2 ); |
191 | connect( mEntryView, SIGNAL( selectionChanged() ), | 197 | connect( mEntryView, SIGNAL( selectionChanged() ), |
192 | SLOT( slotSelectionEntryViewChanged() ) ); | 198 | SLOT( slotSelectionEntryViewChanged() ) ); |
193 | 199 | ||
194 | mChangeEmailButton = new QPushButton( i18n("Change Email..."), this ); | 200 | mChangeEmailButton = new QPushButton( i18n("Change Email..."), this ); |
195 | gridLayout->addWidget( mChangeEmailButton, 2, 1 ); | 201 | gridLayout->addWidget( mChangeEmailButton, 2, 1 ); |
196 | connect( mChangeEmailButton, SIGNAL( clicked() ), SLOT( changeEmail() ) ); | 202 | connect( mChangeEmailButton, SIGNAL( clicked() ), SLOT( changeEmail() ) ); |
197 | 203 | ||
198 | mRemoveEntryButton = new QPushButton( i18n("Remove Entry"), this ); | 204 | mRemoveEntryButton = new QPushButton( i18n("Remove Entry"), this ); |
199 | gridLayout->addWidget( mRemoveEntryButton, 2, 2 ); | 205 | gridLayout->addWidget( mRemoveEntryButton, 2, 2 ); |
200 | connect( mRemoveEntryButton, SIGNAL( clicked() ), SLOT( removeEntry() ) ); | 206 | connect( mRemoveEntryButton, SIGNAL( clicked() ), SLOT( removeEntry() ) ); |
201 | 207 | ||
202 | mManager = new DistributionListManager( mAddressBook ); | 208 | mManager = new DistributionListManager( mAddressBook ); |
203 | mManager->load(); | 209 | mManager->load(); |
204 | 210 | ||
205 | updateAddresseeView(); | 211 | updateAddresseeView(); |
206 | updateNameCombo(); | 212 | updateNameCombo(); |
207 | } | 213 | } |
208 | 214 | ||
209 | DistributionListEditorWidget::~DistributionListEditorWidget() | 215 | DistributionListEditorWidget::~DistributionListEditorWidget() |
210 | { | 216 | { |
211 | kdDebug(5700) << "~DistributionListEditor()" << endl; | 217 | kdDebug(5700) << "~DistributionListEditor()" << endl; |
212 | 218 | ||
213 | delete mManager; | 219 | delete mManager; |
214 | } | 220 | } |
215 | 221 | ||
216 | void DistributionListEditorWidget::save() | 222 | void DistributionListEditorWidget::save() |