summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc/ircservertab.cpp
Side-by-side diff
Diffstat (limited to 'noncore/net/opieirc/ircservertab.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircservertab.cpp15
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 @@
#include <qpe/config.h>
#include <qtextstream.h>
#include "ircservertab.h"
IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
m_server = server;
m_session = new IRCSession(&m_server);
m_mainWindow = mainWindow;
m_close = FALSE;
+ m_lines = 0;
m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>");
m_textview = new QTextView(this);
m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
m_textview->setTextFormat(RichText);
m_layout->add(m_textview);
- m_field = new QLineEdit(this);
+ m_field = new IRCHistoryLineEdit(this);
m_layout->add(m_field);
connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
m_field->setFocus();
connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput)));
settingsChanged();
}
void IRCServerTab::appendText(QString text) {
/* not using append because it creates layout problems */
- m_textview->setText(m_textview->text() + text);
+ QString txt = m_textview->text() + text + "\n";
+ if (m_maxLines > 0 && m_lines >= m_maxLines) {
+ int firstBreak = txt.find('\n');
+ if (firstBreak != -1) {
+ txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1));
+ }
+ } else {
+ m_lines++;
+ }
+ m_textview->setText(txt);
m_textview->ensureVisible(0, m_textview->contentsHeight());
emit changed(this);
}
IRCServerTab::~IRCServerTab() {
delete m_session;
}
void IRCServerTab::removeChannelTab(IRCChannelTab *tab) {
m_channelTabs.remove(tab);
}
@@ -49,24 +59,25 @@ QString IRCServerTab::title() {
}
IRCSession *IRCServerTab::session() {
return m_session;
}
IRCServer *IRCServerTab::server() {
return &m_server;
}
void IRCServerTab::settingsChanged() {
m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
+ m_lines = 0;
}
void IRCServerTab::executeCommand(IRCTab *tab, QString line) {
QTextIStream stream(&line);
QString command;
stream >> command;
command = command.upper().right(command.length()-1);
if (command == "JOIN") {
QString channel;
stream >> channel;
if (channel.length() > 0 && (channel.startsWith("#") || channel.startsWith("+"))) {