summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc/ircservertab.cpp
Unidiff
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
@@ -4,29 +4,39 @@
4 4
5IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 5IRCServerTab::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
24void IRCServerTab::appendText(QString text) { 25void 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
31IRCServerTab::~IRCServerTab() { 41IRCServerTab::~IRCServerTab() {
32 delete m_session; 42 delete m_session;
@@ -55,12 +65,13 @@ IRCSession *IRCServerTab::session() {
55IRCServer *IRCServerTab::server() { 65IRCServer *IRCServerTab::server() {
56 return &m_server; 66 return &m_server;
57} 67}
58 68
59void IRCServerTab::settingsChanged() { 69void 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
63void IRCServerTab::executeCommand(IRCTab *tab, QString line) { 74void 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;