author | wazlaf <wazlaf> | 2002-09-30 13:43:36 (UTC) |
---|---|---|
committer | wazlaf <wazlaf> | 2002-09-30 13:43:36 (UTC) |
commit | 5db3af80f392f8f063f53cbbad67bbe7c5c6eb6d (patch) (unidiff) | |
tree | 12d8e59152c434e0774f067d5b0163578d603daf /noncore/net/opieirc/ircquerytab.cpp | |
parent | b753c264b7acd26aba9f5a73c1fa0a7deb0b73a3 (diff) | |
download | opie-5db3af80f392f8f063f53cbbad67bbe7c5c6eb6d.zip opie-5db3af80f392f8f063f53cbbad67bbe7c5c6eb6d.tar.gz opie-5db3af80f392f8f063f53cbbad67bbe7c5c6eb6d.tar.bz2 |
history functionality, tabs switch colors, extended settings dialog
Diffstat (limited to 'noncore/net/opieirc/ircquerytab.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircquerytab.cpp | 15 |
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 | ||
5 | IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { | 5 | IRCQueryTab::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 | ||
24 | void IRCQueryTab::appendText(QString text) { | 25 | void 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 | ||
31 | IRCQueryTab::~IRCQueryTab() { | 41 | IRCQueryTab::~IRCQueryTab() { |
32 | m_parentTab->removeQueryTab(this); | 42 | m_parentTab->removeQueryTab(this); |
33 | delete m_person; | 43 | delete m_person; |
34 | } | 44 | } |
35 | 45 | ||
36 | void IRCQueryTab::processCommand() { | 46 | void 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 | ||
56 | void IRCQueryTab::display(IRCOutput output) { | 66 | void IRCQueryTab::display(IRCOutput output) { |
57 | if (output.type() == OUTPUT_QUERYPRIVMSG) { | 67 | if (output.type() == OUTPUT_QUERYPRIVMSG) { |
58 | appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_otherColor + "\">"+m_person->nick()+"</font><font color=\"" + m_textColor + "\">> " + output.htmlMessage() + "</font><br>"); | 68 | appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_otherColor + "\">"+m_person->nick()+"</font><font color=\"" + m_textColor + "\">> " + 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 | ||
64 | void IRCQueryTab::settingsChanged() { | 74 | void 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 | ||
68 | QString IRCQueryTab::title() { | 79 | QString IRCQueryTab::title() { |
69 | return m_person->nick(); | 80 | return m_person->nick(); |
70 | } | 81 | } |
71 | 82 | ||
72 | IRCSession *IRCQueryTab::session() { | 83 | IRCSession *IRCQueryTab::session() { |
73 | return m_parentTab->session(); | 84 | return m_parentTab->session(); |
74 | } | 85 | } |
75 | 86 | ||
76 | void IRCQueryTab::remove() { | 87 | void IRCQueryTab::remove() { |
77 | m_mainWindow->killTab(this); | 88 | m_mainWindow->killTab(this); |