Diffstat (limited to 'noncore/net/opieirc/ircservertab.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircservertab.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp index 4ed5364..5d1e290 100644 --- a/noncore/net/opieirc/ircservertab.cpp +++ b/noncore/net/opieirc/ircservertab.cpp | |||
@@ -1,38 +1,48 @@ | |||
1 | #include <qpe/config.h> | 1 | #include <qpe/config.h> |
2 | #include <qtextstream.h> | 2 | #include <qtextstream.h> |
3 | #include "ircservertab.h" | 3 | #include "ircservertab.h" |
4 | 4 | ||
5 | IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { | 5 | IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { |
6 | m_server = server; | 6 | m_server = server; |
7 | m_session = new IRCSession(&m_server); | 7 | m_session = new IRCSession(&m_server); |
8 | m_mainWindow = mainWindow; | 8 | m_mainWindow = mainWindow; |
9 | m_close = FALSE; | 9 | m_close = FALSE; |
10 | m_lines = 0; | ||
10 | m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); | 11 | m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); |
11 | m_textview = new QTextView(this); | 12 | m_textview = new QTextView(this); |
12 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); | 13 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); |
13 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); | 14 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); |
14 | m_textview->setTextFormat(RichText); | 15 | m_textview->setTextFormat(RichText); |
15 | m_layout->add(m_textview); | 16 | m_layout->add(m_textview); |
16 | m_field = new QLineEdit(this); | 17 | m_field = new IRCHistoryLineEdit(this); |
17 | m_layout->add(m_field); | 18 | m_layout->add(m_field); |
18 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); | 19 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); |
19 | m_field->setFocus(); | 20 | m_field->setFocus(); |
20 | connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); | 21 | connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); |
21 | settingsChanged(); | 22 | settingsChanged(); |
22 | } | 23 | } |
23 | 24 | ||
24 | void IRCServerTab::appendText(QString text) { | 25 | void IRCServerTab::appendText(QString text) { |
25 | /* not using append because it creates layout problems */ | 26 | /* not using append because it creates layout problems */ |
26 | m_textview->setText(m_textview->text() + text); | 27 | QString txt = m_textview->text() + text + "\n"; |
28 | if (m_maxLines > 0 && m_lines >= m_maxLines) { | ||
29 | int firstBreak = txt.find('\n'); | ||
30 | if (firstBreak != -1) { | ||
31 | txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); | ||
32 | } | ||
33 | } else { | ||
34 | m_lines++; | ||
35 | } | ||
36 | m_textview->setText(txt); | ||
27 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 37 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
28 | emit changed(this); | 38 | emit changed(this); |
29 | } | 39 | } |
30 | 40 | ||
31 | IRCServerTab::~IRCServerTab() { | 41 | IRCServerTab::~IRCServerTab() { |
32 | delete m_session; | 42 | delete m_session; |
33 | } | 43 | } |
34 | 44 | ||
35 | void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { | 45 | void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { |
36 | m_channelTabs.remove(tab); | 46 | m_channelTabs.remove(tab); |
37 | } | 47 | } |
38 | 48 | ||
@@ -49,24 +59,25 @@ QString IRCServerTab::title() { | |||
49 | } | 59 | } |
50 | 60 | ||
51 | IRCSession *IRCServerTab::session() { | 61 | IRCSession *IRCServerTab::session() { |
52 | return m_session; | 62 | return m_session; |
53 | } | 63 | } |
54 | 64 | ||
55 | IRCServer *IRCServerTab::server() { | 65 | IRCServer *IRCServerTab::server() { |
56 | return &m_server; | 66 | return &m_server; |
57 | } | 67 | } |
58 | 68 | ||
59 | void IRCServerTab::settingsChanged() { | 69 | void IRCServerTab::settingsChanged() { |
60 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); | 70 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); |
71 | m_lines = 0; | ||
61 | } | 72 | } |
62 | 73 | ||
63 | void IRCServerTab::executeCommand(IRCTab *tab, QString line) { | 74 | void IRCServerTab::executeCommand(IRCTab *tab, QString line) { |
64 | QTextIStream stream(&line); | 75 | QTextIStream stream(&line); |
65 | QString command; | 76 | QString command; |
66 | stream >> command; | 77 | stream >> command; |
67 | command = command.upper().right(command.length()-1); | 78 | command = command.upper().right(command.length()-1); |
68 | 79 | ||
69 | if (command == "JOIN") { | 80 | if (command == "JOIN") { |
70 | QString channel; | 81 | QString channel; |
71 | stream >> channel; | 82 | stream >> channel; |
72 | if (channel.length() > 0 && (channel.startsWith("#") || channel.startsWith("+"))) { | 83 | if (channel.length() > 0 && (channel.startsWith("#") || channel.startsWith("+"))) { |