Diffstat (limited to 'noncore/net/opieirc/ircmisc.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircmisc.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/noncore/net/opieirc/ircmisc.cpp b/noncore/net/opieirc/ircmisc.cpp index 22387b3..6d93a34 100644 --- a/noncore/net/opieirc/ircmisc.cpp +++ b/noncore/net/opieirc/ircmisc.cpp | |||
@@ -1,83 +1,86 @@ | |||
1 | #include <stdio.h> | ||
2 | #include "ircmisc.h" | 1 | #include "ircmisc.h" |
3 | 2 | ||
3 | /* OPIE */ | ||
4 | #include <opie2/odebug.h> | ||
5 | using namespace Opie::Core; | ||
6 | |||
4 | IRCTabBar::IRCTabBar(QWidget *parent, const char *name) : QTabBar(parent, name) { | 7 | IRCTabBar::IRCTabBar(QWidget *parent, const char *name) : QTabBar(parent, name) { |
5 | } | 8 | } |
6 | 9 | ||
7 | int IRCTabBar::insertTab(QTab *tab, int index) { | 10 | int IRCTabBar::insertTab(QTab *tab, int index) { |
8 | /* FIXME: find some nicer way to do this */ | 11 | /* FIXME: find some nicer way to do this */ |
9 | QExtTab *ext = new QExtTab(); | 12 | QExtTab *ext = new QExtTab(); |
10 | ext->color = black; | 13 | ext->color = black; |
11 | ext->label = tab->text(); | 14 | ext->label = tab->text(); |
12 | ext->r = tab->rect(); | 15 | ext->r = tab->rect(); |
13 | ext->enabled = tab->isEnabled(); | 16 | ext->enabled = tab->isEnabled(); |
14 | ext->iconset = tab->iconSet(); | 17 | ext->iconset = tab->iconSet(); |
15 | delete tab; | 18 | delete tab; |
16 | return QTabBar::insertTab(ext, index); | 19 | return QTabBar::insertTab(ext, index); |
17 | } | 20 | } |
18 | 21 | ||
19 | void IRCTabBar::setTabColor(int index, QColor color) { | 22 | void IRCTabBar::setTabColor(int index, QColor color) { |
20 | ((QExtTab *)tab(index))->color = color; | 23 | ((QExtTab *)tab(index))->color = color; |
21 | update(); | 24 | update(); |
22 | } | 25 | } |
23 | 26 | ||
24 | void IRCTabBar::paintLabel(QPainter* p, const QRect& br, QTab* t, bool focus) const { | 27 | void IRCTabBar::paintLabel(QPainter* p, const QRect& br, QTab* t, bool focus) const { |
25 | QRect r = br; | 28 | QRect r = br; |
26 | QTabBar::paintLabel(p, br, t, focus); | 29 | QTabBar::paintLabel(p, br, t, focus); |
27 | if (t->id == currentTab()) | 30 | if (t->id == currentTab()) |
28 | r.setBottom(r.bottom() - style().defaultFrameWidth()); | 31 | r.setBottom(r.bottom() - style().defaultFrameWidth()); |
29 | p->setPen(((QExtTab *)t)->color); | 32 | p->setPen(((QExtTab *)t)->color); |
30 | p->drawText(r, AlignCenter | ShowPrefix, t->label); | 33 | p->drawText(r, AlignCenter | ShowPrefix, t->label); |
31 | } | 34 | } |
32 | 35 | ||
33 | IRCTabWidget::IRCTabWidget(QWidget *parent, const char *name) : QTabWidget(parent, name) { | 36 | IRCTabWidget::IRCTabWidget(QWidget *parent, const char *name) : QTabWidget(parent, name) { |
34 | setTabBar(new IRCTabBar(this, "tab control")); | 37 | setTabBar(new IRCTabBar(this, "tab control")); |
35 | } | 38 | } |
36 | 39 | ||
37 | void IRCTabWidget::setTabColor(int index, QColor color) { | 40 | void IRCTabWidget::setTabColor(int index, QColor color) { |
38 | ((IRCTabBar *)tabBar())->setTabColor(index, color); | 41 | ((IRCTabBar *)tabBar())->setTabColor(index, color); |
39 | } | 42 | } |
40 | 43 | ||
41 | 44 | ||
42 | IRCHistoryLineEdit::IRCHistoryLineEdit(QWidget *parent, const char *name) : QLineEdit(parent, name) { | 45 | IRCHistoryLineEdit::IRCHistoryLineEdit(QWidget *parent, const char *name) : QLineEdit(parent, name) { |
43 | m_index = -1; | 46 | m_index = -1; |
44 | installEventFilter(this); | 47 | installEventFilter(this); |
45 | } | 48 | } |
46 | 49 | ||
47 | void IRCHistoryLineEdit::keyPressEvent(QKeyEvent *event) { | 50 | void IRCHistoryLineEdit::keyPressEvent(QKeyEvent *event) { |
48 | int key = event->key(); | 51 | int key = event->key(); |
49 | if (key == Key_Up) { | 52 | if (key == Key_Up) { |
50 | if (m_history.count() > 0 && m_index < (signed int)m_history.count()-1) { | 53 | if (m_history.count() > 0 && m_index < (signed int)m_history.count()-1) { |
51 | m_index++; | 54 | m_index++; |
52 | setText(m_history[m_index]); | 55 | setText(m_history[m_index]); |
53 | } | 56 | } |
54 | } else if (key == Key_Down) { | 57 | } else if (key == Key_Down) { |
55 | if (m_history.count() > 0 && m_index > 0) { | 58 | if (m_history.count() > 0 && m_index > 0) { |
56 | m_index--; | 59 | m_index--; |
57 | setText(m_history[m_index]); | 60 | setText(m_history[m_index]); |
58 | } | 61 | } |
59 | if (m_index == 0) { | 62 | if (m_index == 0) { |
60 | m_index = -1; | 63 | m_index = -1; |
61 | setText(""); | 64 | setText(""); |
62 | } | 65 | } |
63 | } else if (key == Key_Return) { | 66 | } else if (key == Key_Return) { |
64 | m_history.prepend(text()); | 67 | m_history.prepend(text()); |
65 | m_index = -1; | 68 | m_index = -1; |
66 | } else if (key == Key_Tab) { | 69 | } else if (key == Key_Tab) { |
67 | printf("got tab\n"); | 70 | odebug << "got tab" << oendl; |
68 | return; | 71 | return; |
69 | } | 72 | } |
70 | QLineEdit::keyPressEvent(event); | 73 | QLineEdit::keyPressEvent(event); |
71 | } | 74 | } |
72 | 75 | ||
73 | bool IRCHistoryLineEdit::eventFilter(QObject *object, QEvent *event) { | 76 | bool IRCHistoryLineEdit::eventFilter(QObject *object, QEvent *event) { |
74 | if (event->type() == QEvent::KeyPress) { | 77 | if (event->type() == QEvent::KeyPress) { |
75 | QKeyEvent *k = (QKeyEvent *) event; | 78 | QKeyEvent *k = (QKeyEvent *) event; |
76 | /* Catch tab characters */ | 79 | /* Catch tab characters */ |
77 | if (k->key() == Key_Tab) { | 80 | if (k->key() == Key_Tab) { |
78 | qDebug("tab!"); | 81 | odebug << "tab!" << oendl; |
79 | return TRUE; | 82 | return TRUE; |
80 | } | 83 | } |
81 | } | 84 | } |
82 | return QLineEdit::eventFilter(object, event); | 85 | return QLineEdit::eventFilter(object, event); |
83 | } | 86 | } |