Diffstat (limited to 'noncore/net/opieirc/ircquerytab.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircquerytab.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/noncore/net/opieirc/ircquerytab.cpp b/noncore/net/opieirc/ircquerytab.cpp index 6d24845..642cc5b 100644 --- a/noncore/net/opieirc/ircquerytab.cpp +++ b/noncore/net/opieirc/ircquerytab.cpp | |||
@@ -1,2 +1,78 @@ | |||
1 | #include <qhbox.h> | ||
1 | #include "ircquerytab.h" | 2 | #include "ircquerytab.h" |
3 | #include "ircservertab.h" | ||
4 | |||
5 | IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { | ||
6 | m_mainWindow = mainWindow; | ||
7 | m_parentTab = parentTab; | ||
8 | 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 | QHBox *hbox = new QHBox(this); | ||
11 | m_textview = new QTextView(hbox); | ||
12 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); | ||
13 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); | ||
14 | m_textview->setTextFormat(RichText); | ||
15 | m_field = new QLineEdit(this); | ||
16 | m_layout->add(hbox); | ||
17 | hbox->show(); | ||
18 | m_layout->add(m_field); | ||
19 | m_field->setFocus(); | ||
20 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); | ||
21 | |||
22 | } | ||
23 | |||
24 | void IRCQueryTab::appendText(QString text) { | ||
25 | /* not using append because it creates layout problems */ | ||
26 | m_textview->setText(m_textview->text() + text); | ||
27 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | ||
28 | } | ||
29 | |||
30 | IRCQueryTab::~IRCQueryTab() { | ||
31 | m_parentTab->removeQueryTab(this); | ||
32 | delete m_person; | ||
33 | } | ||
34 | |||
35 | void IRCQueryTab::processCommand() { | ||
36 | QString text = m_field->text(); | ||
37 | if (text.length()>0) { | ||
38 | if (session()->isSessionActive()) { | ||
39 | if (text.startsWith("/") && !text.startsWith("//")) { | ||
40 | /* Command mode */ | ||
41 | m_parentTab->executeCommand(this, text);; | ||
42 | } else { | ||
43 | if (text.startsWith("//")) | ||
44 | text = text.right(text.length()-1); | ||
45 | session()->sendMessage(m_person, m_field->text()); | ||
46 | appendText("<<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>> "+IRCOutput::toHTML(m_field->text())+"<br>"); | ||
47 | } | ||
48 | } else { | ||
49 | appendText("<font color=\"#ff0000\">"+tr("Disconnected")+"</font><br>"); | ||
50 | } | ||
51 | } | ||
52 | m_field->clear(); | ||
53 | } | ||
54 | |||
55 | void IRCQueryTab::display(IRCOutput output) { | ||
56 | if (output.type() == OUTPUT_QUERYPRIVMSG) { | ||
57 | appendText("<<font color=\"#0000dd\">"+m_person->nick()+"</font>> " + output.htmlMessage() + "<br>"); | ||
58 | } else if (output.type() == OUTPUT_QUERYACTION) { | ||
59 | appendText("<font color=\"#0000dd\">" + output.htmlMessage() + "<br>"); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | QString IRCQueryTab::title() { | ||
64 | return m_person->nick(); | ||
65 | } | ||
66 | |||
67 | IRCSession *IRCQueryTab::session() { | ||
68 | return m_parentTab->session(); | ||
69 | } | ||
70 | |||
71 | void IRCQueryTab::remove() { | ||
72 | m_mainWindow->killTab(this); | ||
73 | } | ||
74 | |||
75 | IRCPerson *IRCQueryTab::person() { | ||
76 | return m_person; | ||
77 | } | ||
2 | 78 | ||