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 | |||
@@ -25,42 +25,73 @@ IRCFramedColorLabel::IRCFramedColorLabel(QColor color, QWidget *parent, const ch | |||
25 | m_label = new IRCColorLabel(color, this); | 25 | m_label = new IRCColorLabel(color, this); |
26 | layout->addWidget(m_label); | 26 | layout->addWidget(m_label); |
27 | } | 27 | } |
28 | 28 | ||
29 | QColor IRCFramedColorLabel::color() { | 29 | QColor IRCFramedColorLabel::color() { |
30 | return m_label->color(); | 30 | return m_label->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 | } |
50 | 53 | ||
51 | void IRCTabBar::paintLabel(QPainter* p, const QRect& br, QTab* t, bool focus) const { | 54 | void IRCTabBar::paintLabel(QPainter* p, const QRect& br, QTab* t, bool focus) const { |
52 | QRect r = br; | 55 | QRect r = br; |
53 | QTabBar::paintLabel(p, br, t, focus); | 56 | QTabBar::paintLabel(p, br, t, focus); |
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 | } |
59 | 62 | ||
60 | IRCTabWidget::IRCTabWidget(QWidget *parent, const char *name) : QTabWidget(parent, name) { | 63 | IRCTabWidget::IRCTabWidget(QWidget *parent, const char *name) : QTabWidget(parent, name) { |
61 | setTabBar(new IRCTabBar(this, "tab control")); | 64 | setTabBar(new IRCTabBar(this, "tab control")); |
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 | } | ||