author | wazlaf <wazlaf> | 2002-09-20 23:28:14 (UTC) |
---|---|---|
committer | wazlaf <wazlaf> | 2002-09-20 23:28:14 (UTC) |
commit | 912092425248f7fc5155b4c7c46b7d00ec2676bc (patch) (unidiff) | |
tree | 5bbf746e83b2dffad89542c42031a573c34da751 /noncore/net/opieirc/ircservereditor.cpp | |
parent | cd3df897c1b0ed93c2be3ab411011a0bdfe88bf9 (diff) | |
download | opie-912092425248f7fc5155b4c7c46b7d00ec2676bc.zip opie-912092425248f7fc5155b4c7c46b7d00ec2676bc.tar.gz opie-912092425248f7fc5155b4c7c46b7d00ec2676bc.tar.bz2 |
support for client commands (only /join implemented so far), crash bugfix, fixed 2 leaks, server browser now includes a channel list
Diffstat (limited to 'noncore/net/opieirc/ircservereditor.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircservereditor.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/noncore/net/opieirc/ircservereditor.cpp b/noncore/net/opieirc/ircservereditor.cpp index 798081f..c3a444d 100644 --- a/noncore/net/opieirc/ircservereditor.cpp +++ b/noncore/net/opieirc/ircservereditor.cpp | |||
@@ -1,61 +1,76 @@ | |||
1 | #include <qmessagebox.h> | 1 | #include <qmessagebox.h> |
2 | #include <qlayout.h> | 2 | #include <qlayout.h> |
3 | #include <qlabel.h> | 3 | #include <qlabel.h> |
4 | #include "ircservereditor.h" | 4 | #include "ircservereditor.h" |
5 | 5 | ||
6 | IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal = FALSE, WFlags f) : QDialog(parent, name, modal, f) { | 6 | IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal = FALSE, WFlags f) : QDialog(parent, name, modal, f) { |
7 | QGridLayout *layout = new QGridLayout(this, 6, 2, 5, 5); | 7 | QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 5); |
8 | QLabel *label = new QLabel(tr("Profile name :"), this); | 8 | QLabel *label = new QLabel(tr("Profile name :"), this); |
9 | m_name = new QLineEdit(server.name(), this); | 9 | m_name = new QLineEdit(server.name(), this); |
10 | layout->addWidget(label, 0, 0); | 10 | layout->addWidget(label, 0, 0); |
11 | layout->addWidget(m_name, 0, 1); | 11 | layout->addWidget(m_name, 0, 1); |
12 | label = new QLabel(tr("Hostname :"), this); | 12 | label = new QLabel(tr("Hostname :"), this); |
13 | m_hostname = new QLineEdit(server.hostname(), this); | 13 | m_hostname = new QLineEdit(server.hostname(), this); |
14 | layout->addWidget(label, 1, 0); | 14 | layout->addWidget(label, 1, 0); |
15 | layout->addWidget(m_hostname, 1, 1); | 15 | layout->addWidget(m_hostname, 1, 1); |
16 | label = new QLabel(tr("Port :"), this); | 16 | label = new QLabel(tr("Port :"), this); |
17 | m_port = new QLineEdit(QString::number(server.port()), this); | 17 | m_port = new QLineEdit(QString::number(server.port()), this); |
18 | layout->addWidget(label, 2, 0); | 18 | layout->addWidget(label, 2, 0); |
19 | layout->addWidget(m_port, 2, 1); | 19 | layout->addWidget(m_port, 2, 1); |
20 | label = new QLabel(tr("Nickname :"), this); | 20 | label = new QLabel(tr("Nickname :"), this); |
21 | m_nickname = new QLineEdit(server.nick(), this); | 21 | m_nickname = new QLineEdit(server.nick(), this); |
22 | layout->addWidget(label, 3, 0); | 22 | layout->addWidget(label, 3, 0); |
23 | layout->addWidget(m_nickname, 3, 1); | 23 | layout->addWidget(m_nickname, 3, 1); |
24 | label = new QLabel(tr("Realname :"), this); | 24 | label = new QLabel(tr("Realname :"), this); |
25 | m_realname = new QLineEdit(server.realname(), this); | 25 | m_realname = new QLineEdit(server.realname(), this); |
26 | layout->addWidget(label, 4, 0); | 26 | layout->addWidget(label, 4, 0); |
27 | layout->addWidget(m_realname, 4, 1); | 27 | layout->addWidget(m_realname, 4, 1); |
28 | label = new QLabel(tr("Password :"), this); | 28 | label = new QLabel(tr("Password :"), this); |
29 | m_password = new QLineEdit(server.password(), this); | 29 | m_password = new QLineEdit(server.password(), this); |
30 | layout->addWidget(label, 5, 0); | 30 | layout->addWidget(label, 5, 0); |
31 | layout->addWidget(m_password, 5, 1); | 31 | layout->addWidget(m_password, 5, 1); |
32 | label = new QLabel(tr("Channels :"), this); | ||
33 | m_channels = new QLineEdit(server.channels(), this); | ||
34 | layout->addWidget(label, 6, 0); | ||
35 | layout->addWidget(m_channels, 6, 1); | ||
32 | showMaximized(); | 36 | showMaximized(); |
33 | } | 37 | } |
34 | 38 | ||
35 | 39 | ||
36 | void IRCServerEditor::accept() { | 40 | void IRCServerEditor::accept() { |
37 | if (m_name->text().length()==0) | 41 | if (m_name->text().length()==0) |
38 | QMessageBox::critical(this, tr("Error"), tr("Profile name required")); | 42 | QMessageBox::critical(this, tr("Error"), tr("Profile name required")); |
39 | else if (m_hostname->text().length()==0) | 43 | else if (m_hostname->text().length()==0) |
40 | QMessageBox::critical(this, tr("Error"), tr("Host name required")); | 44 | QMessageBox::critical(this, tr("Error"), tr("Host name required")); |
41 | else if (m_port->text().toInt()<=0) | 45 | else if (m_port->text().toInt()<=0) |
42 | QMessageBox::critical(this, tr("Error"), tr("Port required")); | 46 | QMessageBox::critical(this, tr("Error"), tr("Port required")); |
43 | else if (m_nickname->text().length()==0) | 47 | else if (m_nickname->text().length()==0) |
44 | QMessageBox::critical(this, tr("Error"), tr("Nickname required")); | 48 | QMessageBox::critical(this, tr("Error"), tr("Nickname required")); |
45 | else if (m_realname->text().length()==0) | 49 | else if (m_realname->text().length()==0) |
46 | QMessageBox::critical(this, tr("Error"), tr("Realname required")); | 50 | QMessageBox::critical(this, tr("Error"), tr("Realname required")); |
47 | else | 51 | else { |
52 | /* Now verify whether the channel list has a valid format */ | ||
53 | QStringList channels = QStringList::split(QChar(','), m_channels->text()); | ||
54 | for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) { | ||
55 | QString channelName = (*it).stripWhiteSpace(); | ||
56 | if (!channelName.startsWith("#")) { | ||
57 | QMessageBox::critical(this, tr("Error"), tr("The channel list needs to contain a\ncomma separated list of channel\n names which start with '#'")); | ||
58 | return; | ||
59 | } | ||
60 | } | ||
48 | QDialog::accept(); | 61 | QDialog::accept(); |
62 | } | ||
49 | } | 63 | } |
50 | 64 | ||
51 | IRCServer IRCServerEditor::getServer() { | 65 | IRCServer IRCServerEditor::getServer() { |
52 | IRCServer server; | 66 | IRCServer server; |
53 | server.setName(m_name->text()); | 67 | server.setName(m_name->text()); |
54 | server.setHostname(m_hostname->text()); | 68 | server.setHostname(m_hostname->text()); |
55 | server.setPort(m_port->text().toInt()); | 69 | server.setPort(m_port->text().toInt()); |
56 | server.setNick(m_nickname->text()); | 70 | server.setNick(m_nickname->text()); |
57 | server.setRealname(m_realname->text()); | 71 | server.setRealname(m_realname->text()); |
58 | server.setUsername(m_nickname->text()); | 72 | server.setUsername(m_nickname->text()); |
59 | server.setPassword(m_password->text()); | 73 | server.setPassword(m_password->text()); |
74 | server.setChannels(m_channels->text()); | ||
60 | return server; | 75 | return server; |
61 | } | 76 | } |