~ubuntu-branches/ubuntu/intrepid/konversation/intrepid

« back to all changes in this revision

Viewing changes to konversation/src/servergroupdialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Brandon Holtsclaw
  • Date: 2006-10-12 10:03:06 UTC
  • mfrom: (10.1.9 edgy)
  • Revision ID: james.westby@ubuntu.com-20061012100306-zsjbecusqvupyct6
Tags: 1.0.1-0ubuntu1
* New Upstream Bugfix Release ( UVFe approved by mdz )
* Closes Malone: #64488

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <klocale.h>
27
27
#include <kiconloader.h>
28
28
#include <kmessagebox.h>
 
29
#include <kcombobox.h>
 
30
#include <klistbox.h>
 
31
#include <kpushbutton.h>
29
32
 
30
33
#include "identity.h"
31
34
#include "konversationapplication.h"
34
37
#include "serverdialog.h"
35
38
#include "channeldialog.h"
36
39
#include "identitydialog.h"
 
40
#include "servergroupdialogui.h"
37
41
 
38
42
namespace Konversation
39
43
{
40
44
 
41
45
    ServerGroupDialog::ServerGroupDialog(const QString& title, QWidget *parent, const char *name)
42
 
        : KDialogBase(Plain, title, Ok|Cancel, Ok, parent, name)
 
46
        : KDialogBase(Swallow, title, Ok|Cancel, Ok, parent, name)
43
47
    {
44
48
        m_id = -1;
45
49
        m_identitiesNeedsUpdate = false;
46
50
        m_editedServer = false;
47
51
 
48
 
        QFrame* mainWidget = plainPage();
49
 
        QGridLayout* mainLayout = new QGridLayout(mainWidget, 1, 2, 0, spacingHint());
50
 
        mainLayout->setColStretch(1, 10);
51
 
 
52
 
        QLabel* nameLbl = new QLabel(i18n("&Network:"), mainWidget);
53
 
        m_nameEdit = new QLineEdit(mainWidget);
54
 
        QWhatsThis::add(m_nameEdit, i18n("Enter the name of the Network here. You may create as many entries in the Server List screen with the same Network as you like."));
55
 
        nameLbl->setBuddy(m_nameEdit);
56
 
 
57
 
        QLabel* identityLbl = new QLabel(i18n("&Identity:"), mainWidget);
58
 
        m_identityCBox = new QComboBox(mainWidget);
59
 
        QWhatsThis::add(m_identityCBox,i18n("Choose an existing Identity or click the Edit button to add a new Identity or edit an existing one. The Identity will identify you and determine your nickname when you connect to the network."));
60
 
        identityLbl->setBuddy(m_identityCBox);
61
 
        QPushButton* editIdentityBtn = new QPushButton(i18n("Edit..."), mainWidget);
62
 
        connect(editIdentityBtn, SIGNAL(clicked()), this, SLOT(editIdentity()));
 
52
        m_mainWidget = new ServerGroupDialogUI(this);
 
53
        setMainWidget(m_mainWidget);
 
54
 
 
55
        QWhatsThis::add(m_mainWidget->m_nameEdit, i18n("Enter the name of the Network here. You may create as many entries in the Server List screen with the same Network as you like."));
 
56
        m_mainWidget->m_networkLabel->setBuddy(m_mainWidget->m_nameEdit);
 
57
 
 
58
        QWhatsThis::add(m_mainWidget->m_identityCBox,i18n("Choose an existing Identity or click the Edit button to add a new Identity or edit an existing one. The Identity will identify you and determine your nickname when you connect to the network."));
 
59
        m_mainWidget->m_identityLabel->setBuddy(m_mainWidget->m_identityCBox);
 
60
        connect(m_mainWidget->m_editIdentityButton, SIGNAL(clicked()), this, SLOT(editIdentity()));
63
61
 
64
62
        QValueList<IdentityPtr> identities = Preferences::identityList();
65
63
 
66
64
        for(QValueList<IdentityPtr>::iterator it = identities.begin(); it != identities.end(); ++it)
67
65
        {
68
 
            m_identityCBox->insertItem((*it)->getName());
 
66
            m_mainWidget->m_identityCBox->insertItem((*it)->getName());
69
67
        }
70
68
 
71
 
        QLabel* commandLbl = new QLabel(i18n("Co&mmands:"), mainWidget);
72
 
        m_commandEdit = new QLineEdit(mainWidget);
73
 
        QWhatsThis::add(m_commandEdit, i18n("Optional. This command will be sent to the server after connecting. Example: <b>/msg NickServ IDENTIFY <i>konvirocks</i></b>. This example is for the freenode network, which requires users to register their nickname with a password and login when connecting. <i>konvirocks<i> is the password for the nickname given in Identity. You may enter more than one command by separating them with semicolons."));
74
 
        commandLbl->setBuddy(m_commandEdit);
75
 
 
76
 
        m_autoConnectCBox = new QCheckBox(i18n("Connect on &application start up"), mainWidget);
77
 
        QWhatsThis::add(m_autoConnectCBox, i18n("Check here if you want Konversation to automatically connect to this network whenever you open Konversation."));
78
 
 
79
 
        QWidget* groupWidget = new QWidget(mainWidget);
80
 
        QGridLayout* groupLayout = new QGridLayout(groupWidget, 1, 2, 0, spacingHint());
81
 
 
82
 
        QGroupBox* serverGBox = new QGroupBox(0, Qt::Horizontal, i18n("Servers"), groupWidget);
83
 
        serverGBox->setMargin(marginHint());
84
 
        QGridLayout* serverLayout = new QGridLayout(serverGBox->layout(), 1, 2, spacingHint());
85
 
 
86
 
        m_serverLBox = new QListBox(serverGBox);
87
 
        QWhatsThis::add(m_serverLBox, i18n("This is a list of IRC Servers in the network. When connecting to the network, Konversation will attempt to connect to the top server first. If this fails, it will attempt the second server. If this fails, it will attempt the third, and so on. At least one server must be specified. Click a server to highlight it."));
88
 
        QPushButton* addServerBtn = new QPushButton(i18n("Add..."), serverGBox);
89
 
        QPushButton* changeServerBtn = new QPushButton(i18n("Edit..."), serverGBox);
90
 
        QPushButton* removeServerBtn = new QPushButton(i18n("Delete"), serverGBox);
91
 
        m_upServerBtn = new QToolButton(serverGBox);
92
 
        m_upServerBtn->setIconSet(SmallIconSet("up"));
93
 
        m_upServerBtn->setAutoRepeat(true);
94
 
        m_upServerBtn->setEnabled(false);
95
 
        m_downServerBtn = new QToolButton(serverGBox);
96
 
        m_downServerBtn->setIconSet(SmallIconSet("down"));
97
 
        m_downServerBtn->setAutoRepeat(true);
98
 
        m_downServerBtn->setEnabled(false);
99
 
 
100
 
        connect(addServerBtn, SIGNAL(clicked()), this, SLOT(addServer()));
101
 
        connect(changeServerBtn, SIGNAL(clicked()), this, SLOT(editServer()));
102
 
        connect(removeServerBtn, SIGNAL(clicked()), this, SLOT(deleteServer()));
103
 
        connect(m_serverLBox, SIGNAL(selectionChanged()), this, SLOT(updateServerArrows()));
104
 
        connect(m_upServerBtn, SIGNAL(clicked()), this, SLOT(moveServerUp()));
105
 
        connect(m_downServerBtn, SIGNAL(clicked()), this, SLOT(moveServerDown()));
106
 
 
107
 
        serverLayout->setColStretch(0, 10);
108
 
        serverLayout->setRowStretch(4, 10);
109
 
        serverLayout->addMultiCellWidget(m_serverLBox, 0, 4, 0, 0);
110
 
        serverLayout->addMultiCellWidget(addServerBtn, 0, 0, 1, 4);
111
 
        serverLayout->addMultiCellWidget(changeServerBtn, 1, 1, 1, 4);
112
 
        serverLayout->addMultiCellWidget(removeServerBtn, 2, 2, 1, 4);
113
 
        serverLayout->addWidget(m_upServerBtn, 3, 2);
114
 
        serverLayout->addWidget(m_downServerBtn, 3, 3);
115
 
 
116
 
        QGroupBox* channelGBox = new QGroupBox(0, Qt::Horizontal, i18n("Auto Join Channels"), groupWidget);
117
 
        channelGBox->setMargin(marginHint());
118
 
        QGridLayout* channelLayout = new QGridLayout(channelGBox->layout(), 1, 2, spacingHint());
119
 
 
120
 
        m_channelLBox = new QListBox(channelGBox);
121
 
        QWhatsThis::add(m_channelLBox, i18n("Optional. This is a list of the channels that will be automatically joined once Konversation has connected to a server. You may leave this blank if you wish to not automatically join any channels."));
122
 
        QPushButton* addChannelBtn = new QPushButton(i18n("Add..."), channelGBox);
123
 
        QPushButton* changeChannelBtn = new QPushButton(i18n("Edit..."), channelGBox);
124
 
        QPushButton* removeChannelBtn = new QPushButton(i18n("Delete"), channelGBox);
125
 
        m_upChannelBtn = new QToolButton(channelGBox);
126
 
        m_upChannelBtn->setIconSet(SmallIconSet("up"));
127
 
        m_upChannelBtn->setAutoRepeat(true);
128
 
        m_upChannelBtn->setEnabled(false);
129
 
        m_downChannelBtn = new QToolButton(channelGBox);
130
 
        m_downChannelBtn->setIconSet(SmallIconSet("down"));
131
 
        m_downChannelBtn->setAutoRepeat(true);
132
 
        m_downChannelBtn->setEnabled(false);
133
 
 
134
 
        connect(addChannelBtn, SIGNAL(clicked()), this, SLOT(addChannel()));
135
 
        connect(changeChannelBtn, SIGNAL(clicked()), this, SLOT(editChannel()));
136
 
        connect(removeChannelBtn, SIGNAL(clicked()), this, SLOT(deleteChannel()));
137
 
        connect(m_channelLBox, SIGNAL(selectionChanged()), this, SLOT(updateChannelArrows()));
138
 
        connect(m_upChannelBtn, SIGNAL(clicked()), this, SLOT(moveChannelUp()));
139
 
        connect(m_downChannelBtn, SIGNAL(clicked()), this, SLOT(moveChannelDown()));
140
 
 
141
 
        channelLayout->setColStretch(0, 10);
142
 
        channelLayout->setRowStretch(4, 10);
143
 
        channelLayout->addMultiCellWidget(m_channelLBox, 0, 4, 0, 0);
144
 
        channelLayout->addMultiCellWidget(addChannelBtn, 0, 0, 1, 4);
145
 
        channelLayout->addMultiCellWidget(changeChannelBtn, 1, 1, 1, 4);
146
 
        channelLayout->addMultiCellWidget(removeChannelBtn, 2, 2, 1, 4);
147
 
        channelLayout->addWidget(m_upChannelBtn, 3, 2);
148
 
        channelLayout->addWidget(m_downChannelBtn, 3, 3);
149
 
 
150
 
        mainLayout->addWidget(nameLbl, 0, 0);
151
 
        mainLayout->addMultiCellWidget(m_nameEdit, 0, 0, 1, 2);
152
 
        mainLayout->addWidget(identityLbl, 2, 0);
153
 
        mainLayout->addWidget(m_identityCBox, 2, 1);
154
 
        mainLayout->addWidget(editIdentityBtn, 2, 2);
155
 
        mainLayout->addWidget(commandLbl, 3, 0);
156
 
        mainLayout->addMultiCellWidget(m_commandEdit, 3, 3, 1, 2);
157
 
        mainLayout->addMultiCellWidget(m_autoConnectCBox, 4, 4, 0, 2);
158
 
        mainLayout->addMultiCellWidget(groupWidget, 5, 5, 0, 2);
159
 
        mainLayout->setColStretch(1, 10);
160
 
        groupLayout->addWidget(serverGBox, 0, 0);
161
 
        groupLayout->addWidget(channelGBox, 0, 1);
 
69
        QWhatsThis::add(m_mainWidget->m_commandEdit, i18n("Optional. This command will be sent to the server after connecting. Example: <b>/msg NickServ IDENTIFY <i>konvirocks</i></b>. This example is for the freenode network, which requires users to register their nickname with a password and login when connecting. <i>konvirocks<i> is the password for the nickname given in Identity. You may enter more than one command by separating them with semicolons."));
 
70
        m_mainWidget->m_commandsLabel->setBuddy(m_mainWidget->m_commandEdit);
 
71
 
 
72
        QWhatsThis::add(m_mainWidget->m_autoConnectCBox, i18n("Check here if you want Konversation to automatically connect to this network whenever you open Konversation."));
 
73
 
 
74
        QWhatsThis::add(m_mainWidget->m_serverLBox, i18n("This is a list of IRC Servers in the network. When connecting to the network, Konversation will attempt to connect to the top server first. If this fails, it will attempt the second server. If this fails, it will attempt the third, and so on. At least one server must be specified. Click a server to highlight it."));
 
75
        m_mainWidget->m_removeServerButton->setIconSet(SmallIconSet("editdelete"));
 
76
        m_mainWidget->m_removeServerButton->setTextLabel(i18n("Delete"));
 
77
        m_mainWidget->m_upServerBtn->setIconSet(SmallIconSet("up"));
 
78
        m_mainWidget->m_downServerBtn->setIconSet(SmallIconSet("down"));
 
79
 
 
80
        connect(m_mainWidget->m_addServerButton, SIGNAL(clicked()), this, SLOT(addServer()));
 
81
        connect(m_mainWidget->m_changeServerButton, SIGNAL(clicked()), this, SLOT(editServer()));
 
82
        connect(m_mainWidget->m_removeServerButton, SIGNAL(clicked()), this, SLOT(deleteServer()));
 
83
        connect(m_mainWidget->m_serverLBox, SIGNAL(selectionChanged()), this, SLOT(updateServerArrows()));
 
84
        connect(m_mainWidget->m_upServerBtn, SIGNAL(clicked()), this, SLOT(moveServerUp()));
 
85
        connect(m_mainWidget->m_downServerBtn, SIGNAL(clicked()), this, SLOT(moveServerDown()));
 
86
 
 
87
        QWhatsThis::add(m_mainWidget->m_channelLBox, i18n("Optional. This is a list of the channels that will be automatically joined once Konversation has connected to a server. You may leave this blank if you wish to not automatically join any channels."));
 
88
        m_mainWidget->m_removeChannelButton->setIconSet(SmallIconSet("editdelete"));
 
89
        m_mainWidget->m_removeChannelButton->setTextLabel(i18n("Delete"));
 
90
        m_mainWidget->m_upChannelBtn->setIconSet(SmallIconSet("up"));
 
91
        m_mainWidget->m_downChannelBtn->setIconSet(SmallIconSet("down"));
 
92
 
 
93
        connect(m_mainWidget->m_addChannelButton, SIGNAL(clicked()), this, SLOT(addChannel()));
 
94
        connect(m_mainWidget->m_changeChannelButton, SIGNAL(clicked()), this, SLOT(editChannel()));
 
95
        connect(m_mainWidget->m_removeChannelButton, SIGNAL(clicked()), this, SLOT(deleteChannel()));
 
96
        connect(m_mainWidget->m_channelLBox, SIGNAL(selectionChanged()), this, SLOT(updateChannelArrows()));
 
97
        connect(m_mainWidget->m_upChannelBtn, SIGNAL(clicked()), this, SLOT(moveChannelUp()));
 
98
        connect(m_mainWidget->m_downChannelBtn, SIGNAL(clicked()), this, SLOT(moveChannelDown()));
162
99
 
163
100
        setButtonOK(KGuiItem(i18n("&OK"), "button_ok", i18n("Change network information")));
164
101
        setButtonCancel(KGuiItem(i18n("&Cancel"), "button_cancel", i18n("Discards all changes made")));
165
102
 
166
 
        m_nameEdit->setFocus();
 
103
        m_mainWidget->m_nameEdit->setFocus();
167
104
    }
168
105
 
169
106
    ServerGroupDialog::~ServerGroupDialog()
176
113
        m_sortIndex = settings->sortIndex();
177
114
        m_expanded = settings->expanded();
178
115
        m_enableNotifications = settings->enableNotifications();
179
 
        m_nameEdit->setText(settings->name());
180
 
        m_identityCBox->setCurrentText(settings->identity()->getName());
181
 
        m_commandEdit->setText(settings->connectCommands());
182
 
        m_autoConnectCBox->setChecked(settings->autoConnectEnabled());
 
116
        m_mainWidget->m_nameEdit->setText(settings->name());
 
117
        m_mainWidget->m_identityCBox->setCurrentText(settings->identity()->getName());
 
118
        m_mainWidget->m_commandEdit->setText(settings->connectCommands());
 
119
        m_mainWidget->m_autoConnectCBox->setChecked(settings->autoConnectEnabled());
183
120
        m_serverList = settings->serverList(true);
184
121
        m_channelHistory = settings->channelHistory();
185
122
        ServerList::iterator it;
186
 
        m_serverLBox->clear();
 
123
        m_mainWidget->m_serverLBox->clear();
187
124
 
188
125
        for(it = m_serverList.begin(); it != m_serverList.end(); ++it)
189
126
        {
190
 
            m_serverLBox->insertItem((*it).server());
 
127
            m_mainWidget->m_serverLBox->insertItem((*it).server());
191
128
        }
192
129
 
193
130
        m_channelList = settings->channelList();
195
132
 
196
133
        for(it2 = m_channelList.begin(); it2 != m_channelList.end(); ++it2)
197
134
        {
198
 
            m_channelLBox->insertItem((*it2).name());
 
135
            m_mainWidget->m_channelLBox->insertItem((*it2).name());
199
136
        }
200
137
    }
201
138
 
203
140
    {
204
141
        ServerGroupSettingsPtr settings = new ServerGroupSettings(m_id);
205
142
        settings->setSortIndex(m_sortIndex);
206
 
        settings->setName(m_nameEdit->text());
 
143
        settings->setName(m_mainWidget->m_nameEdit->text());
207
144
        QValueList<IdentityPtr> identities = Preferences::identityList();
208
 
        settings->setIdentityId(identities[m_identityCBox->currentItem()]->id());
209
 
        settings->setConnectCommands(m_commandEdit->text());
210
 
        settings->setAutoConnectEnabled(m_autoConnectCBox->isChecked());
 
145
        settings->setIdentityId(identities[m_mainWidget->m_identityCBox->currentItem()]->id());
 
146
        settings->setConnectCommands(m_mainWidget->m_commandEdit->text());
 
147
        settings->setAutoConnectEnabled(m_mainWidget->m_autoConnectCBox->isChecked());
211
148
        settings->setServerList(m_serverList);
212
149
        settings->setChannelList(m_channelList);
213
150
        settings->setChannelHistory(m_channelHistory);
241
178
        if(dlg.exec() == KDialog::Accepted)
242
179
        {
243
180
            ServerSettings server = dlg.serverSettings();
244
 
            m_serverLBox->insertItem(server.server());
 
181
            m_mainWidget->m_serverLBox->insertItem(server.server());
245
182
            m_serverList.append(server);
246
183
            updateServerArrows();
247
184
        }
249
186
 
250
187
    void ServerGroupDialog::editServer()
251
188
    {
252
 
        uint current = m_serverLBox->currentItem();
 
189
        uint current = m_mainWidget->m_serverLBox->currentItem();
253
190
 
254
191
        if(current < m_serverList.count())
255
192
        {
259
196
            if(dlg.exec() == KDialog::Accepted)
260
197
            {
261
198
                ServerSettings server = dlg.serverSettings();
262
 
                m_serverLBox->changeItem(server.server(), current);
 
199
                m_mainWidget->m_serverLBox->changeItem(server.server(), current);
263
200
                m_serverList[current] = server;
264
201
            }
265
202
        }
271
208
        // and find out which server to select in the listbox
272
209
        m_editedServer = true;
273
210
        m_editedServerIndex = m_serverList.findIndex(server);
274
 
        m_serverLBox->setCurrentItem(m_editedServerIndex);
 
211
        m_mainWidget->m_serverLBox->setCurrentItem(m_editedServerIndex);
275
212
 
276
213
        editServer();
277
214
    }
278
215
 
279
216
    void ServerGroupDialog::deleteServer()
280
217
    {
281
 
        uint current = m_serverLBox->currentItem();
 
218
        uint current = m_mainWidget->m_serverLBox->currentItem();
282
219
 
283
220
        if (current < m_serverList.count())
284
221
        {
285
222
            m_serverList.remove(m_serverList.at(current));
286
 
            m_serverLBox->removeItem(current);
 
223
            m_mainWidget->m_serverLBox->removeItem(current);
287
224
 
288
225
            // Track the server the Server List dialog told us to edit
289
226
            if (m_editedServer && m_editedServerIndex==current)
295
232
 
296
233
    void ServerGroupDialog::updateServerArrows()
297
234
    {
298
 
        m_upServerBtn->setEnabled( m_serverLBox->count()>1 && m_serverLBox->currentItem()>0 );
 
235
        m_mainWidget->m_upServerBtn->setEnabled( m_mainWidget->m_serverLBox->count()>1 && m_mainWidget->m_serverLBox->currentItem()>0 );
299
236
 
300
237
        // FIXME: find another way than casting to overcome signedness warning
301
 
        m_downServerBtn->setEnabled( m_serverLBox->count()>1 &&
302
 
            m_serverLBox->currentItem()< static_cast<int>(m_serverLBox->count()-1) );
 
238
        m_mainWidget->m_downServerBtn->setEnabled( m_mainWidget->m_serverLBox->count()>1 &&
 
239
            m_mainWidget->m_serverLBox->currentItem()< static_cast<int>(m_mainWidget->m_serverLBox->count()-1) );
 
240
        bool enabled = m_mainWidget->m_serverLBox->currentItem() >= 0;
 
241
        m_mainWidget->m_removeServerButton->setEnabled(enabled);
 
242
        m_mainWidget->m_changeServerButton->setEnabled(enabled);
303
243
    }
304
244
 
305
245
    void ServerGroupDialog::moveServerUp()
306
246
    {
307
 
        uint current = m_serverLBox->currentItem();
 
247
        uint current = m_mainWidget->m_serverLBox->currentItem();
308
248
 
309
249
        if (current > 0)
310
250
        {
311
251
            ServerSettings server = m_serverList[current];
312
 
            m_serverLBox->removeItem(current);
313
 
            m_serverLBox->insertItem(server.server(), current - 1);
314
 
            m_serverLBox->setCurrentItem(current - 1);
 
252
            m_mainWidget->m_serverLBox->removeItem(current);
 
253
            m_mainWidget->m_serverLBox->insertItem(server.server(), current - 1);
 
254
            m_mainWidget->m_serverLBox->setCurrentItem(current - 1);
315
255
            ServerList::iterator it = m_serverList.remove(m_serverList.at(current));
316
256
            --it;
317
257
            m_serverList.insert(it, server);
326
266
 
327
267
    void ServerGroupDialog::moveServerDown()
328
268
    {
329
 
        uint current = m_serverLBox->currentItem();
 
269
        uint current = m_mainWidget->m_serverLBox->currentItem();
330
270
 
331
271
        if (current < (m_serverList.count() - 1))
332
272
        {
333
273
            ServerSettings server = m_serverList[current];
334
 
            m_serverLBox->removeItem(current);
335
 
            m_serverLBox->insertItem(server.server(), current + 1);
336
 
            m_serverLBox->setCurrentItem(current + 1);
 
274
            m_mainWidget->m_serverLBox->removeItem(current);
 
275
            m_mainWidget->m_serverLBox->insertItem(server.server(), current + 1);
 
276
            m_mainWidget->m_serverLBox->setCurrentItem(current + 1);
337
277
            ServerList::iterator it = m_serverList.remove(m_serverList.at(current));
338
278
            ++it;
339
279
            m_serverList.insert(it, server);
353
293
        if(dlg.exec() == KDialog::Accepted)
354
294
        {
355
295
            ChannelSettings channel = dlg.channelSettings();
356
 
            m_channelLBox->insertItem(channel.name());
 
296
            m_mainWidget->m_channelLBox->insertItem(channel.name());
357
297
            m_channelList.append(channel);
358
298
            updateChannelArrows();
359
299
        }
361
301
 
362
302
    void ServerGroupDialog::editChannel()
363
303
    {
364
 
        uint current = m_channelLBox->currentItem();
 
304
        uint current = m_mainWidget->m_channelLBox->currentItem();
365
305
 
366
306
        if(current < m_channelList.count())
367
307
        {
371
311
            if(dlg.exec() == KDialog::Accepted)
372
312
            {
373
313
                ChannelSettings channel = dlg.channelSettings();
374
 
                m_channelLBox->changeItem(channel.name(), current);
 
314
                m_mainWidget->m_channelLBox->changeItem(channel.name(), current);
375
315
                m_channelList[current] = channel;
376
316
            }
377
317
        }
379
319
 
380
320
    void ServerGroupDialog::deleteChannel()
381
321
    {
382
 
        uint current = m_channelLBox->currentItem();
 
322
        uint current = m_mainWidget->m_channelLBox->currentItem();
383
323
 
384
324
        if(current < m_channelList.count())
385
325
        {
386
326
            m_channelList.remove(m_channelList.at(current));
387
 
            m_channelLBox->removeItem(current);
 
327
            m_mainWidget->m_channelLBox->removeItem(current);
388
328
            updateChannelArrows();
389
329
        }
390
330
    }
391
331
 
392
332
    void ServerGroupDialog::updateChannelArrows()
393
333
    {
394
 
        m_upChannelBtn->setEnabled( m_channelLBox->count()>1 && m_channelLBox->currentItem()>0 );
 
334
        m_mainWidget->m_upChannelBtn->setEnabled( m_mainWidget->m_channelLBox->count()>1 && m_mainWidget->m_channelLBox->currentItem()>0 );
395
335
 
396
336
        // FIXME: find another way than casting to overcome signedness warning
397
 
        m_downChannelBtn->setEnabled( m_channelLBox->count()>1 &&
398
 
            m_channelLBox->currentItem()< static_cast<int>(m_channelLBox->count()-1) );
 
337
        m_mainWidget->m_downChannelBtn->setEnabled( m_mainWidget->m_channelLBox->count()>1 &&
 
338
            m_mainWidget->m_channelLBox->currentItem()< static_cast<int>(m_mainWidget->m_channelLBox->count()-1) );
 
339
        bool selected = m_mainWidget->m_channelLBox->currentItem() >= 0;
 
340
        m_mainWidget->m_removeChannelButton->setEnabled(selected);
 
341
        m_mainWidget->m_changeChannelButton->setEnabled(selected);
399
342
    }
400
343
 
401
344
    void ServerGroupDialog::moveChannelUp()
402
345
    {
403
 
        uint current = m_channelLBox->currentItem();
 
346
        uint current = m_mainWidget->m_channelLBox->currentItem();
404
347
 
405
348
        if(current > 0)
406
349
        {
407
350
            ChannelSettings channel = m_channelList[current];
408
 
            m_channelLBox->removeItem(current);
409
 
            m_channelLBox->insertItem(channel.name(), current - 1);
410
 
            m_channelLBox->setCurrentItem(current - 1);
 
351
            m_mainWidget->m_channelLBox->removeItem(current);
 
352
            m_mainWidget->m_channelLBox->insertItem(channel.name(), current - 1);
 
353
            m_mainWidget->m_channelLBox->setCurrentItem(current - 1);
411
354
            ChannelList::iterator it = m_channelList.remove(m_channelList.at(current));
412
355
            --it;
413
356
            m_channelList.insert(it, channel);
418
361
 
419
362
    void ServerGroupDialog::moveChannelDown()
420
363
    {
421
 
        uint current = m_channelLBox->currentItem();
 
364
        uint current = m_mainWidget->m_channelLBox->currentItem();
422
365
 
423
366
        if(current < (m_channelList.count() - 1))
424
367
        {
425
368
            ChannelSettings channel = m_channelList[current];
426
 
            m_channelLBox->removeItem(current);
427
 
            m_channelLBox->insertItem(channel.name(), current + 1);
428
 
            m_channelLBox->setCurrentItem(current + 1);
 
369
            m_mainWidget->m_channelLBox->removeItem(current);
 
370
            m_mainWidget->m_channelLBox->insertItem(channel.name(), current + 1);
 
371
            m_mainWidget->m_channelLBox->setCurrentItem(current + 1);
429
372
            ChannelList::iterator it = m_channelList.remove(m_channelList.at(current));
430
373
            ++it;
431
374
            m_channelList.insert(it, channel);
437
380
    void ServerGroupDialog::editIdentity()
438
381
    {
439
382
        IdentityDialog dlg(this);
440
 
        dlg.setCurrentIdentity(m_identityCBox->currentItem());
 
383
        dlg.setCurrentIdentity(m_mainWidget->m_identityCBox->currentItem());
441
384
        QValueList<IdentityPtr> identities = Preferences::identityList();
442
 
        int identityId = identities[m_identityCBox->currentItem()]->id();
 
385
        int identityId = identities[m_mainWidget->m_identityCBox->currentItem()]->id();
443
386
 
444
387
        if(dlg.exec() == KDialog::Accepted)
445
388
        {
446
389
            identities = Preferences::identityList();
447
 
            m_identityCBox->clear();
 
390
            m_mainWidget->m_identityCBox->clear();
448
391
 
449
392
            for(QValueList<IdentityPtr>::iterator it = identities.begin(); it != identities.end(); ++it)
450
393
            {
451
 
                m_identityCBox->insertItem((*it)->getName());
 
394
                m_mainWidget->m_identityCBox->insertItem((*it)->getName());
452
395
            }
453
396
 
454
 
            m_identityCBox->setCurrentText(Preferences::identityById(identityId)->getName());
 
397
            m_mainWidget->m_identityCBox->setCurrentText(Preferences::identityById(identityId)->getName());
455
398
            m_identitiesNeedsUpdate = true;
456
399
        }
457
400
    }
458
401
 
459
402
    void ServerGroupDialog::slotOk()
460
403
    {
461
 
        if (m_nameEdit->text().isEmpty())
 
404
        if (m_mainWidget->m_nameEdit->text().isEmpty())
462
405
        {
463
406
            KMessageBox::error(this, i18n("The network name is required."));
464
407
        }