1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
|
#include <tqradiobutton.h>
#include <tqcheckbox.h>
#include <tqlineedit.h>
#include <tqpushbutton.h>
#include <tqlayout.h>
#include <tqgroupbox.h>
#include <tqbuttongroup.h>
#include <tqlistview.h>
#include <tqhbox.h>
#include <knuminput.h>
#include <kurl.h>
#include <kmessagebox.h>
#include <kiconloader.h>
#include <kdebug.h>
#include "mailsender.h"
#include "kbbprefs.h"
#include "kbbmainwindow.h"
#include "serverconfigdialog.h"
#include "bugsystem.h"
#include "bugserver.h"
#include "bugserverconfig.h"
#include "preferencesdialog.h"
class ServerItem : public TQListViewItem
{
public:
ServerItem( TQListView *listView, const BugServerConfig &cfg )
: TQListViewItem( listView )
{
setServerConfig( cfg );
}
void setServerConfig( const BugServerConfig &cfg )
{
mServerConfig = cfg;
setText( 0, cfg.name() );
setText( 1, cfg.baseUrl().prettyURL() );
setText( 2, cfg.user() );
setText( 3, cfg.bugzillaVersion() );
}
const BugServerConfig &serverConfig() const { return mServerConfig; }
private:
BugServerConfig mServerConfig;
};
class ServerListView : public TQListView
{
public:
ServerListView( TQWidget *tqparent ) : TQListView( tqparent )
{
addColumn( i18n("Name") );
addColumn( i18n("Base URL") );
addColumn( i18n("User") );
addColumn( i18n("Version") );
}
};
PreferencesDialog::PreferencesDialog( TQWidget* tqparent, const char* name )
: KDialogBase ( IconList, i18n("Preferences"), Ok|Apply|Cancel, Ok,
tqparent, name, false, true )
{
setupServerPage();
setupAdvancedPage();
readConfig();
}
PreferencesDialog::~PreferencesDialog()
{
}
void PreferencesDialog::setupServerPage()
{
TQFrame *topFrame = addPage( i18n("Servers"), 0,
DesktopIcon( "gohome", KIcon::SizeMedium ) );
TQBoxLayout *tqlayout = new TQVBoxLayout( topFrame );
tqlayout->setSpacing( spacingHint() );
mServerList = new ServerListView( topFrame );
tqlayout->addWidget( mServerList );
TQHBox *buttonBox = new TQHBox( topFrame );
buttonBox->setSpacing( spacingHint() );
tqlayout->addWidget( buttonBox );
TQPushButton *addButton = new TQPushButton( i18n("Add Server..."), buttonBox );
connect( addButton, TQT_SIGNAL( clicked() ), TQT_SLOT( addServer() ) );
TQPushButton *editButton = new TQPushButton( i18n("Edit Server..."), buttonBox );
connect( editButton, TQT_SIGNAL( clicked() ), TQT_SLOT( editServer() ) );
TQPushButton *removeButton = new TQPushButton( i18n("Delete Server"), buttonBox );
connect( removeButton, TQT_SIGNAL( clicked() ), TQT_SLOT( removeServer() ) );
TQPushButton *button = new TQPushButton( i18n("Select Server From List..."),
topFrame );
tqlayout->addWidget( button );
connect( button, TQT_SIGNAL( clicked() ), TQT_SLOT( selectServer() ) );
connect( mServerList, TQT_SIGNAL( doubleClicked ( TQListViewItem *)), this, TQT_SLOT( editServer()));
}
void PreferencesDialog::setupAdvancedPage()
{
TQFrame *topFrame = addPage( i18n("Advanced"), 0,
DesktopIcon( "misc", KIcon::SizeMedium ) );
TQBoxLayout *tqlayout = new TQVBoxLayout( topFrame );
tqlayout->setSpacing( spacingHint() );
TQButtonGroup *mailGroup = new TQButtonGroup( 1,Qt::Horizontal,
i18n( "Mail Client" ), topFrame );
tqlayout->addWidget( mailGroup );
mKMailButton = new TQRadioButton( i18n( "&KMail" ), mailGroup );
mDirectButton = new TQRadioButton( i18n( "D&irect" ), mailGroup );
mSendmailButton = new TQRadioButton( i18n( "&Sendmail" ), mailGroup );
mShowClosedCheckBox = new TQCheckBox( i18n( "Show closed bugs" ), topFrame );
tqlayout->addWidget( mShowClosedCheckBox );
mShowWishesCheckBox = new TQCheckBox( i18n( "Show wishes" ), topFrame );
tqlayout->addWidget( mShowWishesCheckBox );
mShowVotedCheckBox = new TQCheckBox( i18n( "Show bugs with number of votes greater than:" ), topFrame );
tqlayout->addWidget( mShowVotedCheckBox );
mMinVotesInput = new KIntNumInput( topFrame );
mMinVotesInput->setMinValue( 0 );
connect( mShowVotedCheckBox, TQT_SIGNAL(toggled(bool)),
mMinVotesInput, TQT_SLOT(setEnabled(bool)) );
tqlayout->addWidget( mMinVotesInput );
mSendBccCheckBox = new TQCheckBox( i18n( "Send BCC to myself" ), topFrame );
tqlayout->addWidget( mSendBccCheckBox );
}
void PreferencesDialog::setDefaults()
{
KBBPrefs::instance()->setDefaults();
readConfig();
}
void PreferencesDialog::slotApply()
{
writeConfig();
}
void PreferencesDialog::slotOk()
{
writeConfig();
accept();
}
void PreferencesDialog::slotCancel()
{
hide();
}
void PreferencesDialog::addServer()
{
ServerConfigDialog *dlg = new ServerConfigDialog( this );
int result = dlg->exec();
if ( result == TQDialog::Accepted ) {
new ServerItem( mServerList, dlg->serverConfig() );
}
}
void PreferencesDialog::editServer()
{
ServerItem *item = static_cast<ServerItem *>( mServerList->currentItem() );
if ( !item ) return;
ServerConfigDialog *dlg = new ServerConfigDialog( this );
dlg->setServerConfig( item->serverConfig() );
int result = dlg->exec();
if ( result == TQDialog::Accepted ) {
item->setServerConfig( dlg->serverConfig() );
}
}
void PreferencesDialog::removeServer()
{
TQListViewItem *item = mServerList->currentItem();
if ( !item ) return;
delete item;
}
void PreferencesDialog::selectServer()
{
SelectServerDlg *dlg =new SelectServerDlg( this, "Select Server" );
int result = dlg->exec();
if ( result == TQDialog::Accepted ) {
ServerItem *item = dlg->serverSelected();
if ( item ) {
new ServerItem( mServerList, item->serverConfig() );
}
}
delete dlg;
}
void PreferencesDialog::createServerItem( ServerListView *listView,
const TQString &name,
const TQString &url,
const TQString &version )
{
BugServerConfig cfg( name, KURL( url ) );
cfg.setBugzillaVersion( version );
new ServerItem( listView, cfg );
}
void PreferencesDialog::readConfig()
{
int client = KBBPrefs::instance()->mMailClient;
switch(client) {
default:
case MailSender::KMail:
mKMailButton->setChecked(true);
break;
case MailSender::Sendmail:
mSendmailButton->setChecked(true);
break;
case MailSender::Direct:
mDirectButton->setChecked(true);
break;
}
mShowClosedCheckBox->setChecked( KBBPrefs::instance()->mShowClosedBugs );
mShowWishesCheckBox->setChecked( KBBPrefs::instance()->mShowWishes );
mShowVotedCheckBox->setChecked( KBBPrefs::instance()->mShowVoted );
mMinVotesInput->setValue( KBBPrefs::instance()->mMinVotes );
mSendBccCheckBox->setChecked( KBBPrefs::instance()->mSendBCC );
mServerList->clear();
TQValueList<BugServer *> servers = BugSystem::self()->serverList();
TQValueList<BugServer *>::ConstIterator it;
for( it = servers.begin(); it != servers.end(); ++it ) {
new ServerItem( mServerList, (*it)->serverConfig() );
}
}
void PreferencesDialog::writeConfig()
{
MailSender::MailClient client = MailSender::KMail;
if (mKMailButton->isChecked()) client = MailSender::KMail;
if (mSendmailButton->isChecked()) client = MailSender::Sendmail;
if (mDirectButton->isChecked()) client = MailSender::Direct;
KBBPrefs::instance()->mMailClient = client;
KBBPrefs::instance()->mShowClosedBugs = mShowClosedCheckBox->isChecked();
KBBPrefs::instance()->mShowWishes = mShowWishesCheckBox->isChecked();
KBBPrefs::instance()->mShowVoted = mShowVotedCheckBox->isChecked();
KBBPrefs::instance()->mMinVotes = mMinVotesInput->value();
KBBPrefs::instance()->mSendBCC = mSendBccCheckBox->isChecked();
KBBPrefs::instance()->writeConfig();
TQValueList<BugServerConfig> servers;
TQListViewItem *item;
for ( item = mServerList->firstChild(); item;
item = item->nextSibling() ) {
servers.append( static_cast<ServerItem *>( item )->serverConfig() );
}
BugSystem::self()->setServerList( servers );
emit configChanged();
}
SelectServerDlg::SelectServerDlg(PreferencesDialog *tqparent, const char */*name*/ )
:KDialogBase(tqparent, 0, true, i18n("Select Server"),
KDialogBase::Ok | KDialogBase::Cancel)
{
list = new ServerListView(this );
setMainWidget( list );
tqparent->createServerItem( list, "KDE", "http://bugs.kde.org", "KDE" );
tqparent->createServerItem( list, "GNOME", "http://bugzilla.gnome.org", "2.10" );
tqparent->createServerItem( list, "Mozilla", "http://bugzilla.mozilla.org", "2.17.1" );
tqparent->createServerItem( list, "Apache", "http://nagoya.apache.org/bugzilla/", "2.14.2" );
tqparent->createServerItem( list, "XFree86", "http://bugs.xfree86.org/cgi-bin/bugzilla/", "2.14.2" );
tqparent->createServerItem( list, "Ximian", "http://bugzilla.ximian.com", "2.10" );
tqparent->createServerItem( list, "RedHat", "http://bugzilla.redhat.com/bugzilla/", "2.17.1" );
tqparent->createServerItem( list, "Mandriva", "http://qa.mandriva.com/", "2.17.4" );
connect( list, TQT_SIGNAL( doubleClicked ( TQListViewItem *)), this, TQT_SLOT( slotDoubleClicked( TQListViewItem *)));
}
ServerItem *SelectServerDlg::serverSelected()
{
return static_cast<ServerItem *>( list->currentItem() );
}
void SelectServerDlg::slotDoubleClicked( TQListViewItem *)
{
accept();
}
#include "preferencesdialog.moc"
|