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() { } + IRCTabBar::IRCTabBar(QWidget *parent, const char *name) : QTabBar(parent, name) { } int IRCTabBar::insertTab(QTab *tab, int index = -1) { - if (m_colors.size() == (unsigned int)count()) - m_colors.resize(m_colors.size() * 2 + 1); - if (index == -1) - m_colors.insert(count(), &black); - else - m_colors.insert(index, &black); - return QTabBar::insertTab(tab, index); + /* FIXME: find some nicer way to do this */ + QExtTab *ext = new QExtTab(); + ext->color = black; + ext->label = tab->text(); + ext->r = tab->rect(); + ext->enabled = tab->isEnabled(); + ext->iconset = tab->iconSet(); + delete tab; + return QTabBar::insertTab(ext, index); } -void IRCTabBar::setTabColor(int index, const QColor *color) { - m_colors.insert(index, color); +void IRCTabBar::setTabColor(int index, QColor color) { + ((QExtTab *)tab(index))->color = color; update(); } @@ -54,5 +57,5 @@ void IRCTabBar::paintLabel(QPainter* p, const QRect& br, QTab* t, bool focus) co if (t->id == currentTab()) r.setBottom(r.bottom() - style().defaultFrameWidth()); - p->setPen(*m_colors.at(t->id)); + p->setPen(((QExtTab *)t)->color); p->drawText(r, AlignCenter | ShowPrefix, t->label); } @@ -62,5 +65,33 @@ IRCTabWidget::IRCTabWidget(QWidget *parent, const char *name) : QTabWidget(paren } -void IRCTabWidget::setTabColor(int index, const QColor *color) { +void IRCTabWidget::setTabColor(int index, QColor color) { ((IRCTabBar *)tabBar())->setTabColor(index, color); } + + +IRCHistoryLineEdit::IRCHistoryLineEdit(QWidget *parent, const char *name) : QLineEdit(parent, name) { + m_index = -1; +} + +void IRCHistoryLineEdit::keyPressEvent(QKeyEvent *event) { + int key = event->key(); + if (key == Key_Up) { + if (m_history.count() > 0 && m_index < (signed int)m_history.count()-1) { + m_index++; + setText(m_history[m_index]); + } + } else if (key == Key_Down) { + if (m_history.count() > 0 && m_index > 0) { + m_index--; + setText(m_history[m_index]); + } + if (m_index == 0) { + m_index = -1; + setText(""); + } + } else if (key == Key_Return) { + m_history.prepend(text()); + m_index = -1; + } + QLineEdit::keyPressEvent(event); +} |