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
@@ -1,38 +1,48 @@
1#include <qhbox.h> 1#include <qhbox.h>
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);
33 delete m_person; 43 delete m_person;
34} 44}
35 45
36void IRCQueryTab::processCommand() { 46void IRCQueryTab::processCommand() {
37 QString text = m_field->text(); 47 QString text = m_field->text();
38 if (text.length()>0) { 48 if (text.length()>0) {
@@ -54,24 +64,25 @@ void IRCQueryTab::processCommand() {
54} 64}
55 65
56void IRCQueryTab::display(IRCOutput output) { 66void IRCQueryTab::display(IRCOutput output) {
57 if (output.type() == OUTPUT_QUERYPRIVMSG) { 67 if (output.type() == OUTPUT_QUERYPRIVMSG) {
58 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_otherColor + "\">"+m_person->nick()+"</font><font color=\"" + m_textColor + "\">&gt; " + output.htmlMessage() + "</font><br>"); 68 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_otherColor + "\">"+m_person->nick()+"</font><font color=\"" + m_textColor + "\">&gt; " + output.htmlMessage() + "</font><br>");
59 } else if (output.type() == OUTPUT_QUERYACTION) { 69 } else if (output.type() == OUTPUT_QUERYACTION) {
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
72IRCSession *IRCQueryTab::session() { 83IRCSession *IRCQueryTab::session() {
73 return m_parentTab->session(); 84 return m_parentTab->session();
74} 85}
75 86
76void IRCQueryTab::remove() { 87void IRCQueryTab::remove() {
77 m_mainWindow->killTab(this); 88 m_mainWindow->killTab(this);