Diffstat (limited to 'kabc/distributionlisteditor.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kabc/distributionlisteditor.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/kabc/distributionlisteditor.cpp b/kabc/distributionlisteditor.cpp index 9f5840b..ca5ecb7 100644 --- a/kabc/distributionlisteditor.cpp +++ b/kabc/distributionlisteditor.cpp | |||
@@ -1,197 +1,201 @@ | |||
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 <qpushbutton.h> | 23 | #include <qpushbutton.h> |
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #ifdef DESKTOP_VERSION | 25 | #ifdef DESKTOP_VERSION |
26 | #include <qinputdialog.h> | 26 | #include <qinputdialog.h> |
27 | #else | 27 | #else |
28 | #include <qtcompat/qinputdialog.h> | 28 | #include <qtcompat/qinputdialog.h> |
29 | #endif | 29 | #endif |
30 | #include <qbuttongroup.h> | 30 | #include <q3buttongroup.h> |
31 | #include <qradiobutton.h> | 31 | #include <qradiobutton.h> |
32 | //Added by qt3to4: | ||
33 | #include <Q3HBoxLayout> | ||
34 | #include <Q3Frame> | ||
35 | #include <Q3VBoxLayout> | ||
32 | 36 | ||
33 | #include <klocale.h> | 37 | #include <klocale.h> |
34 | #include <kdebug.h> | 38 | #include <kdebug.h> |
35 | 39 | ||
36 | #include "addressbook.h" | 40 | #include "addressbook.h" |
37 | #include "addresseedialog.h" | 41 | #include "addresseedialog.h" |
38 | #include "distributionlist.h" | 42 | #include "distributionlist.h" |
39 | 43 | ||
40 | #include "distributionlisteditor.h" | 44 | #include "distributionlisteditor.h" |
41 | 45 | ||
42 | //US #include "distributionlisteditor.moc" | 46 | //US #include "distributionlisteditor.moc" |
43 | 47 | ||
44 | using namespace KABC; | 48 | using namespace KABC; |
45 | 49 | ||
46 | EmailSelectDialog::EmailSelectDialog( const QStringList &emails, const QString ¤t, | 50 | EmailSelectDialog::EmailSelectDialog( const QStringList &emails, const QString ¤t, |
47 | QWidget *parent ) : | 51 | QWidget *parent ) : |
48 | KDialogBase( KDialogBase::Plain, i18n("Select Email Address"), Ok, Ok, | 52 | KDialogBase( KDialogBase::Plain, i18n("Select Email Address"), Ok, Ok, |
49 | parent ) | 53 | parent ) |
50 | { | 54 | { |
51 | QFrame *topFrame = plainPage(); | 55 | Q3Frame *topFrame = plainPage(); |
52 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); | 56 | Q3BoxLayout *topLayout = new Q3VBoxLayout( topFrame ); |
53 | 57 | ||
54 | mButtonGroup = new QButtonGroup( 1, Horizontal, i18n("Email Addresses"), | 58 | mButtonGroup = new Q3ButtonGroup( 1, Qt::Horizontal, i18n("Email Addresses"), |
55 | topFrame ); | 59 | topFrame ); |
56 | topLayout->addWidget( mButtonGroup ); | 60 | topLayout->addWidget( mButtonGroup ); |
57 | 61 | ||
58 | QStringList::ConstIterator it; | 62 | QStringList::ConstIterator it; |
59 | for( it = emails.begin(); it != emails.end(); ++it ) { | 63 | for( it = emails.begin(); it != emails.end(); ++it ) { |
60 | QRadioButton *button = new QRadioButton( *it, mButtonGroup ); | 64 | QRadioButton *button = new QRadioButton( *it, mButtonGroup ); |
61 | if ( (*it) == current ) { | 65 | if ( (*it) == current ) { |
62 | button->setDown( true ); | 66 | button->setDown( true ); |
63 | } | 67 | } |
64 | } | 68 | } |
65 | } | 69 | } |
66 | 70 | ||
67 | QString EmailSelectDialog::selected() | 71 | QString EmailSelectDialog::selected() |
68 | { | 72 | { |
69 | QButton *button = mButtonGroup->selected(); | 73 | QAbstractButton *button = mButtonGroup->selected(); |
70 | if ( button ) return button->text(); | 74 | if ( button ) return button->text(); |
71 | return QString::null; | 75 | return QString::null; |
72 | } | 76 | } |
73 | 77 | ||
74 | QString EmailSelectDialog::getEmail( const QStringList &emails, const QString ¤t, | 78 | QString EmailSelectDialog::getEmail( const QStringList &emails, const QString ¤t, |
75 | QWidget *parent ) | 79 | QWidget *parent ) |
76 | { | 80 | { |
77 | 81 | ||
78 | EmailSelectDialog *dlg = new EmailSelectDialog( emails, current, parent ); | 82 | EmailSelectDialog *dlg = new EmailSelectDialog( emails, current, parent ); |
79 | dlg->exec(); | 83 | dlg->exec(); |
80 | 84 | ||
81 | QString result = dlg->selected(); | 85 | QString result = dlg->selected(); |
82 | 86 | ||
83 | delete dlg; | 87 | delete dlg; |
84 | 88 | ||
85 | return result; | 89 | return result; |
86 | } | 90 | } |
87 | 91 | ||
88 | class EditEntryItem : public QListViewItem | 92 | class EditEntryItem : public Q3ListViewItem |
89 | { | 93 | { |
90 | public: | 94 | public: |
91 | EditEntryItem( QListView *parent, const Addressee &addressee, | 95 | EditEntryItem( Q3ListView *parent, const Addressee &addressee, |
92 | const QString &email=QString::null ) : | 96 | const QString &email=QString::null ) : |
93 | QListViewItem( parent ), | 97 | Q3ListViewItem( parent ), |
94 | mAddressee( addressee ), | 98 | mAddressee( addressee ), |
95 | mEmail( email ) | 99 | mEmail( email ) |
96 | { | 100 | { |
97 | setText( 0, addressee.realName() ); | 101 | setText( 0, addressee.realName() ); |
98 | if( email.isEmpty() ) { | 102 | if( email.isEmpty() ) { |
99 | setText( 1, addressee.preferredEmail() ); | 103 | setText( 1, addressee.preferredEmail() ); |
100 | setText( 2, i18n("Yes") ); | 104 | setText( 2, i18n("Yes") ); |
101 | } else { | 105 | } else { |
102 | setText( 1, email ); | 106 | setText( 1, email ); |
103 | setText( 2, i18n("No") ); | 107 | setText( 2, i18n("No") ); |
104 | } | 108 | } |
105 | } | 109 | } |
106 | 110 | ||
107 | Addressee addressee() const | 111 | Addressee addressee() const |
108 | { | 112 | { |
109 | return mAddressee; | 113 | return mAddressee; |
110 | } | 114 | } |
111 | 115 | ||
112 | QString email() const | 116 | QString email() const |
113 | { | 117 | { |
114 | return mEmail; | 118 | return mEmail; |
115 | } | 119 | } |
116 | 120 | ||
117 | private: | 121 | private: |
118 | Addressee mAddressee; | 122 | Addressee mAddressee; |
119 | QString mEmail; | 123 | QString mEmail; |
120 | }; | 124 | }; |
121 | 125 | ||
122 | DistributionListEditor::DistributionListEditor( AddressBook *addressBook, QWidget *parent) : | 126 | DistributionListEditor::DistributionListEditor( AddressBook *addressBook, QWidget *parent) : |
123 | QWidget( parent ), | 127 | QWidget( parent ), |
124 | mAddressBook( addressBook ) | 128 | mAddressBook( addressBook ) |
125 | { | 129 | { |
126 | kdDebug(5700) << "DistributionListEditor()" << endl; | 130 | kdDebug(5700) << "DistributionListEditor()" << endl; |
127 | 131 | ||
128 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 132 | Q3BoxLayout *topLayout = new Q3VBoxLayout( this ); |
129 | topLayout->setMargin( KDialog::marginHint() ); | 133 | topLayout->setMargin( KDialog::marginHint() ); |
130 | topLayout->setSpacing( KDialog::spacingHint() ); | 134 | topLayout->setSpacing( KDialog::spacingHint() ); |
131 | 135 | ||
132 | QBoxLayout *nameLayout = new QHBoxLayout( topLayout) ; | 136 | Q3BoxLayout *nameLayout = new Q3HBoxLayout( topLayout) ; |
133 | 137 | ||
134 | mNameCombo = new QComboBox( this ); | 138 | mNameCombo = new QComboBox( this ); |
135 | nameLayout->addWidget( mNameCombo ); | 139 | nameLayout->addWidget( mNameCombo ); |
136 | connect( mNameCombo, SIGNAL( activated( int ) ), SLOT( updateEntryView() ) ); | 140 | connect( mNameCombo, SIGNAL( activated( int ) ), SLOT( updateEntryView() ) ); |
137 | 141 | ||
138 | newButton = new QPushButton( i18n("New List"), this ); | 142 | newButton = new QPushButton( i18n("New List"), this ); |
139 | nameLayout->addWidget( newButton ); | 143 | nameLayout->addWidget( newButton ); |
140 | connect( newButton, SIGNAL( clicked() ), SLOT( newList() ) ); | 144 | connect( newButton, SIGNAL( clicked() ), SLOT( newList() ) ); |
141 | 145 | ||
142 | removeButton = new QPushButton( i18n("Remove List"), this ); | 146 | removeButton = new QPushButton( i18n("Remove List"), this ); |
143 | nameLayout->addWidget( removeButton ); | 147 | nameLayout->addWidget( removeButton ); |
144 | connect( removeButton, SIGNAL( clicked() ), SLOT( removeList() ) ); | 148 | connect( removeButton, SIGNAL( clicked() ), SLOT( removeList() ) ); |
145 | 149 | ||
146 | mEntryView = new QListView( this ); | 150 | mEntryView = new Q3ListView( this ); |
147 | mEntryView->addColumn( i18n("Name") ); | 151 | mEntryView->addColumn( i18n("Name") ); |
148 | mEntryView->addColumn( i18n("Email") ); | 152 | mEntryView->addColumn( i18n("Email") ); |
149 | mEntryView->addColumn( i18n("Use Preferred") ); | 153 | mEntryView->addColumn( i18n("Use Preferred") ); |
150 | topLayout->addWidget( mEntryView ); | 154 | topLayout->addWidget( mEntryView ); |
151 | connect(mEntryView,SIGNAL(selectionChanged ()),this, SLOT(slotSelectionEntryViewChanged())); | 155 | connect(mEntryView,SIGNAL(selectionChanged ()),this, SLOT(slotSelectionEntryViewChanged())); |
152 | 156 | ||
153 | changeEmailButton = new QPushButton( i18n("Change Email"), this ); | 157 | changeEmailButton = new QPushButton( i18n("Change Email"), this ); |
154 | topLayout->addWidget( changeEmailButton ); | 158 | topLayout->addWidget( changeEmailButton ); |
155 | connect( changeEmailButton, SIGNAL( clicked() ), SLOT( changeEmail() ) ); | 159 | connect( changeEmailButton, SIGNAL( clicked() ), SLOT( changeEmail() ) ); |
156 | 160 | ||
157 | removeEntryButton = new QPushButton( i18n("Remove Entry"), this ); | 161 | removeEntryButton = new QPushButton( i18n("Remove Entry"), this ); |
158 | topLayout->addWidget( removeEntryButton ); | 162 | topLayout->addWidget( removeEntryButton ); |
159 | connect( removeEntryButton, SIGNAL( clicked() ), SLOT( removeEntry() ) ); | 163 | connect( removeEntryButton, SIGNAL( clicked() ), SLOT( removeEntry() ) ); |
160 | 164 | ||
161 | addEntryButton = new QPushButton( i18n("Add Entry"), this ); | 165 | addEntryButton = new QPushButton( i18n("Add Entry"), this ); |
162 | topLayout->addWidget( addEntryButton ); | 166 | topLayout->addWidget( addEntryButton ); |
163 | connect( addEntryButton, SIGNAL( clicked() ), SLOT( addEntry() ) ); | 167 | connect( addEntryButton, SIGNAL( clicked() ), SLOT( addEntry() ) ); |
164 | 168 | ||
165 | mAddresseeView = new QListView( this ); | 169 | mAddresseeView = new Q3ListView( this ); |
166 | mAddresseeView->addColumn( i18n("Name") ); | 170 | mAddresseeView->addColumn( i18n("Name") ); |
167 | mAddresseeView->addColumn( i18n("Preferred Email") ); | 171 | mAddresseeView->addColumn( i18n("Preferred Email") ); |
168 | topLayout->addWidget( mAddresseeView ); | 172 | topLayout->addWidget( mAddresseeView ); |
169 | 173 | ||
170 | 174 | ||
171 | connect(mAddresseeView,SIGNAL(selectionChanged ()),this, SLOT(slotSelectionAddresseeViewChanged())); | 175 | connect(mAddresseeView,SIGNAL(selectionChanged ()),this, SLOT(slotSelectionAddresseeViewChanged())); |
172 | 176 | ||
173 | mManager = new DistributionListManager( mAddressBook ); | 177 | mManager = new DistributionListManager( mAddressBook ); |
174 | mManager->load(); | 178 | mManager->load(); |
175 | 179 | ||
176 | updateAddresseeView(); | 180 | updateAddresseeView(); |
177 | updateNameCombo(); | 181 | updateNameCombo(); |
178 | removeButton->setEnabled(!mManager->listNames().isEmpty()); | 182 | removeButton->setEnabled(!mManager->listNames().isEmpty()); |
179 | } | 183 | } |
180 | 184 | ||
181 | DistributionListEditor::~DistributionListEditor() | 185 | DistributionListEditor::~DistributionListEditor() |
182 | { | 186 | { |
183 | kdDebug(5700) << "~DistributionListEditor()" << endl; | 187 | kdDebug(5700) << "~DistributionListEditor()" << endl; |
184 | 188 | ||
185 | mManager->save(); | 189 | mManager->save(); |
186 | delete mManager; | 190 | delete mManager; |
187 | } | 191 | } |
188 | 192 | ||
189 | void DistributionListEditor::slotSelectionEntryViewChanged() | 193 | void DistributionListEditor::slotSelectionEntryViewChanged() |
190 | { | 194 | { |
191 | //US EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() ); | 195 | //US EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() ); |
192 | EditEntryItem *entryItem = (EditEntryItem *)( mEntryView->selectedItem() ); | 196 | EditEntryItem *entryItem = (EditEntryItem *)( mEntryView->selectedItem() ); |
193 | bool state = (entryItem != 0L); | 197 | bool state = (entryItem != 0L); |
194 | 198 | ||
195 | changeEmailButton->setEnabled(state); | 199 | changeEmailButton->setEnabled(state); |
196 | removeEntryButton->setEnabled(state); | 200 | removeEntryButton->setEnabled(state); |
197 | } | 201 | } |