Diffstat (limited to 'noncore/net/opieirc/ircmisc.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircmisc.cpp | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/noncore/net/opieirc/ircmisc.cpp b/noncore/net/opieirc/ircmisc.cpp index dd7292c..2e7f316 100644 --- a/noncore/net/opieirc/ircmisc.cpp +++ b/noncore/net/opieirc/ircmisc.cpp | |||
@@ -31,19 +31,22 @@ QColor IRCFramedColorLabel::color() { | |||
31 | } | 31 | } |
32 | 32 | ||
33 | |||
33 | IRCTabBar::IRCTabBar(QWidget *parent, const char *name) : QTabBar(parent, name) { | 34 | IRCTabBar::IRCTabBar(QWidget *parent, const char *name) : QTabBar(parent, name) { |
34 | } | 35 | } |
35 | 36 | ||
36 | int IRCTabBar::insertTab(QTab *tab, int index = -1) { | 37 | int IRCTabBar::insertTab(QTab *tab, int index = -1) { |
37 | if (m_colors.size() == (unsigned int)count()) | 38 | /* FIXME: find some nicer way to do this */ |
38 | m_colors.resize(m_colors.size() * 2 + 1); | 39 | QExtTab *ext = new QExtTab(); |
39 | if (index == -1) | 40 | ext->color = black; |
40 | m_colors.insert(count(), &black); | 41 | ext->label = tab->text(); |
41 | else | 42 | ext->r = tab->rect(); |
42 | m_colors.insert(index, &black); | 43 | ext->enabled = tab->isEnabled(); |
43 | return QTabBar::insertTab(tab, index); | 44 | ext->iconset = tab->iconSet(); |
45 | delete tab; | ||
46 | return QTabBar::insertTab(ext, index); | ||
44 | } | 47 | } |
45 | 48 | ||
46 | void IRCTabBar::setTabColor(int index, const QColor *color) { | 49 | void IRCTabBar::setTabColor(int index, QColor color) { |
47 | m_colors.insert(index, color); | 50 | ((QExtTab *)tab(index))->color = color; |
48 | update(); | 51 | update(); |
49 | } | 52 | } |
@@ -54,5 +57,5 @@ void IRCTabBar::paintLabel(QPainter* p, const QRect& br, QTab* t, bool focus) co | |||
54 | if (t->id == currentTab()) | 57 | if (t->id == currentTab()) |
55 | r.setBottom(r.bottom() - style().defaultFrameWidth()); | 58 | r.setBottom(r.bottom() - style().defaultFrameWidth()); |
56 | p->setPen(*m_colors.at(t->id)); | 59 | p->setPen(((QExtTab *)t)->color); |
57 | p->drawText(r, AlignCenter | ShowPrefix, t->label); | 60 | p->drawText(r, AlignCenter | ShowPrefix, t->label); |
58 | } | 61 | } |
@@ -62,5 +65,33 @@ IRCTabWidget::IRCTabWidget(QWidget *parent, const char *name) : QTabWidget(paren | |||
62 | } | 65 | } |
63 | 66 | ||
64 | void IRCTabWidget::setTabColor(int index, const QColor *color) { | 67 | void IRCTabWidget::setTabColor(int index, QColor color) { |
65 | ((IRCTabBar *)tabBar())->setTabColor(index, color); | 68 | ((IRCTabBar *)tabBar())->setTabColor(index, color); |
66 | } | 69 | } |
70 | |||
71 | |||
72 | IRCHistoryLineEdit::IRCHistoryLineEdit(QWidget *parent, const char *name) : QLineEdit(parent, name) { | ||
73 | m_index = -1; | ||
74 | } | ||
75 | |||
76 | void IRCHistoryLineEdit::keyPressEvent(QKeyEvent *event) { | ||
77 | int key = event->key(); | ||
78 | if (key == Key_Up) { | ||
79 | if (m_history.count() > 0 && m_index < (signed int)m_history.count()-1) { | ||
80 | m_index++; | ||
81 | setText(m_history[m_index]); | ||
82 | } | ||
83 | } else if (key == Key_Down) { | ||
84 | if (m_history.count() > 0 && m_index > 0) { | ||
85 | m_index--; | ||
86 | setText(m_history[m_index]); | ||
87 | } | ||
88 | if (m_index == 0) { | ||
89 | m_index = -1; | ||
90 | setText(""); | ||
91 | } | ||
92 | } else if (key == Key_Return) { | ||
93 | m_history.prepend(text()); | ||
94 | m_index = -1; | ||
95 | } | ||
96 | QLineEdit::keyPressEvent(event); | ||
97 | } | ||