summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc/ircquerytab.cpp
Unidiff
Diffstat (limited to 'noncore/net/opieirc/ircquerytab.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opieirc/ircquerytab.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/noncore/net/opieirc/ircquerytab.cpp b/noncore/net/opieirc/ircquerytab.cpp
index b946174..869e4f7 100644
--- a/noncore/net/opieirc/ircquerytab.cpp
+++ b/noncore/net/opieirc/ircquerytab.cpp
@@ -2,31 +2,41 @@
2#include "ircquerytab.h" 2#include "ircquerytab.h"
3#include "ircservertab.h" 3#include "ircservertab.h"
4 4
5IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 5IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
6 m_mainWindow = mainWindow; 6 m_mainWindow = mainWindow;
7 m_parentTab = parentTab; 7 m_parentTab = parentTab;
8 m_lines = 0;
8 m_person = new IRCPerson(*person); /* We need this (the person might sign off and the original IRCPerson gets deleted) */ 9 m_person = new IRCPerson(*person); /* We need this (the person might sign off and the original IRCPerson gets deleted) */
9 m_description->setText(tr("Talking to ") + " <b>" + person->nick() + "</b>"); 10 m_description->setText(tr("Talking to ") + " <b>" + person->nick() + "</b>");
10 QHBox *hbox = new QHBox(this); 11 QHBox *hbox = new QHBox(this);
11 m_textview = new QTextView(hbox); 12 m_textview = new QTextView(hbox);
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_field = new QLineEdit(this); 16 m_field = new IRCHistoryLineEdit(this);
16 m_layout->add(hbox); 17 m_layout->add(hbox);
17 hbox->show(); 18 hbox->show();
18 m_layout->add(m_field); 19 m_layout->add(m_field);
19 m_field->setFocus(); 20 m_field->setFocus();
20 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 21 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
21 settingsChanged(); 22 settingsChanged();
22} 23}
23 24
24void IRCQueryTab::appendText(QString text) { 25void IRCQueryTab::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
31IRCQueryTab::~IRCQueryTab() { 41IRCQueryTab::~IRCQueryTab() {
32 m_parentTab->removeQueryTab(this); 42 m_parentTab->removeQueryTab(this);
@@ -60,12 +70,13 @@ void IRCQueryTab::display(IRCOutput output) {
60 appendText("<font color=\"" + m_otherColor + "\">" + output.htmlMessage() + "<br>"); 70 appendText("<font color=\"" + m_otherColor + "\">" + output.htmlMessage() + "<br>");
61 } 71 }
62} 72}
63 73
64void IRCQueryTab::settingsChanged() { 74void IRCQueryTab::settingsChanged() {
65 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); 75 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
76 m_lines = 0;
66} 77}
67 78
68QString IRCQueryTab::title() { 79QString IRCQueryTab::title() {
69 return m_person->nick(); 80 return m_person->nick();
70} 81}
71 82