summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc/ircchanneltab.cpp
Unidiff
Diffstat (limited to 'noncore/net/opieirc/ircchanneltab.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircchanneltab.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp
index b6e3954..7610058 100644
--- a/noncore/net/opieirc/ircchanneltab.cpp
+++ b/noncore/net/opieirc/ircchanneltab.cpp
@@ -12,56 +12,57 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW
12 QHBox *hbox = new QHBox(this); 12 QHBox *hbox = new QHBox(this);
13 m_textview = new QTextView(hbox); 13 m_textview = new QTextView(hbox);
14 m_textview->setHScrollBarMode(QScrollView::AlwaysOff); 14 m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
15 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 15 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
16 m_listVisible = TRUE; 16 m_listVisible = TRUE;
17 m_listButton = new QPushButton(">", m_textview); 17 m_listButton = new QPushButton(">", m_textview);
18 m_listButton->setFlat( true );
18 m_textview->setCornerWidget(m_listButton); 19 m_textview->setCornerWidget(m_listButton);
19 m_textview->setTextFormat(RichText); 20 m_textview->setTextFormat(RichText);
20 QWhatsThis::add(m_textview, tr("Channel discussion")); 21 QWhatsThis::add(m_textview, tr("Channel discussion"));
21 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); 22 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList()));
22 m_list = new IRCChannelList(m_channel, hbox); 23 m_list = new IRCChannelList(m_channel, hbox);
23 m_list->update(); 24 m_list->update();
24 m_list->setMaximumWidth(LISTWIDTH); 25 m_list->setMaximumWidth(LISTWIDTH);
25 m_field = new IRCHistoryLineEdit(this); 26 m_field = new IRCHistoryLineEdit(this);
26 connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab())); 27 connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab()));
27 connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab())); 28 connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab()));
28 connect(m_field, SIGNAL(closeTab()), this, SIGNAL(closeTab())); 29 connect(m_field, SIGNAL(closeTab()), this, SLOT(remove()));
29 connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus())); 30 connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus()));
30 31
31 QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion")); 32 QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion"));
32 m_popup = new QPopupMenu(m_list); 33 m_popup = new QPopupMenu(m_list);
33 m_lines = 0; 34 m_lines = 0;
34 /* Required so that embedded-style "right" clicks work */ 35 /* Required so that embedded-style "right" clicks work */
35 QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold); 36 QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold);
36 connect(m_list, SIGNAL(mouseButtonPressed(int,QListBoxItem*,const QPoint&)), this, SLOT(mouseButtonPressed(int,QListBoxItem*,const QPoint&))); 37 connect(m_list, SIGNAL(mouseButtonPressed(int,QListBoxItem*,const QPoint&)), this, SLOT(mouseButtonPressed(int,QListBoxItem*,const QPoint&)));
37 /* Construct the popup menu */ 38 /* Construct the popup menu */
38 QPopupMenu *ctcpMenu = new QPopupMenu(m_list); 39 QPopupMenu *ctcpMenu = new QPopupMenu(m_list);
39 m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu);
40 m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery())); 40 m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery()));
41 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing())); 41 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing()));
42 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion())); 42 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion()));
43 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois())); 43 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois()));
44 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); 44 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
45 m_layout->add(hbox); 45 m_layout->add(hbox);
46 hbox->show(); 46 hbox->show();
47 m_layout->add(m_field); 47 m_layout->add(m_field);
48 m_field->setFocus(); 48 m_field->setFocus();
49 m_field->setActiveWindow(); 49 m_field->setActiveWindow();
50 50
51 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 51 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
52 connect(m_list, SIGNAL(doubleClicked ( QListBoxItem * ) ), this, SLOT(popupQuery( QListBoxItem * ) ));
52 settingsChanged(); 53 settingsChanged();
53} 54}
54 55
55void IRCChannelTab::scrolling(){ 56void IRCChannelTab::scrolling(){
56 m_textview->ensureVisible(0, m_textview->contentsHeight()); 57 m_textview->ensureVisible(0, m_textview->contentsHeight());
57} 58}
58 59
59void IRCChannelTab::appendText(QString text) { 60void IRCChannelTab::appendText(QString text) {
60 /* not using append because it creates layout problems */ 61 /* not using append because it creates layout problems */
61 QString txt = m_textview->text() + text + "\n"; 62 QString txt = m_textview->text() + IRCTab::appendTimestamp( text );
62 if (m_maxLines > 0 && m_lines >= m_maxLines) { 63 if (m_maxLines > 0 && m_lines >= m_maxLines) {
63 int firstBreak = txt.find('\n'); 64 int firstBreak = txt.find('\n');
64 if (firstBreak != -1) { 65 if (firstBreak != -1) {
65 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); 66 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1));
66 } 67 }
67 } else { 68 } else {
@@ -69,13 +70,15 @@ void IRCChannelTab::appendText(QString text) {
69 } 70 }
70 m_textview->ensureVisible(0, m_textview->contentsHeight()); 71 m_textview->ensureVisible(0, m_textview->contentsHeight());
71 m_textview->setText(txt); 72 m_textview->setText(txt);
72 m_textview->ensureVisible(0, m_textview->contentsHeight()); 73 m_textview->ensureVisible(0, m_textview->contentsHeight());
73 74
74 int p1, p2; 75 int p1, p2;
75 if ( (p1 = text.find("ping", 0, false) )!= -1 && (p2 = text.find( m_parentTab->server()->nick(), 0,false )) != -1 ) { 76 if ( text.contains( IRCMessageParser::tr("Received a CTCP PING from ") ) )
77 emit ping( title() );
78 else if ( (p1 = text.find("ping", 0, false) )!= -1 && (p2 = text.find( m_parentTab->server()->nick(), 0,false )) != -1 ) {
76 int col = text.findRev("color", -1, false); 79 int col = text.findRev("color", -1, false);
77 if ( col < p2 ) 80 if ( col < p2 )
78 emit ping( title() ); 81 emit ping( title() );
79 82
80 } 83 }
81 84
@@ -129,26 +132,31 @@ void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &
129 case 2: 132 case 2:
130 m_popup->popup(point); 133 m_popup->popup(point);
131 break; 134 break;
132 }; 135 };
133} 136}
134 137
135void IRCChannelTab::popupQuery() { 138void IRCChannelTab::popupQuery( QListBoxItem *item) {
136 if (m_list->currentItem() != -1) { 139 if (item) {
137 IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text()); 140 IRCPerson *person = session()->getPerson(item->text());
138 if (person) { 141 if (person) {
139 IRCQueryTab *tab = m_parentTab->getTabForQuery(person); 142 IRCQueryTab *tab = m_parentTab->getTabForQuery(person);
140 if (!tab) { 143 if (!tab) {
141 tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent()); 144 tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent());
142 m_parentTab->addQueryTab(tab); 145 m_parentTab->addQueryTab(tab);
143 m_mainWindow->addTab(tab); 146 m_mainWindow->addTab(tab);
144 } 147 }
145 } 148 }
146 } 149 }
147} 150}
148 151
152void IRCChannelTab::popupQuery() {
153 if ( m_list->currentItem() != -1 )
154 popupQuery( m_list->item(m_list->currentItem()));
155}
156
149void IRCChannelTab::popupPing() { 157void IRCChannelTab::popupPing() {
150 //HAHA, no wonder these don't work 158 //HAHA, no wonder these don't work
151} 159}
152 160
153void IRCChannelTab::popupVersion() { 161void IRCChannelTab::popupVersion() {
154} 162}