From: Manuel Nickschas Date: Thu, 4 Oct 2007 23:25:22 +0000 (+0000) Subject: consistent_naming++ X-Git-Tag: 0.1.0~145 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=6d021114c9dbcccbfe5e7c485c8e705404f35123 consistent_naming++ --- diff --git a/src/common/message.cpp b/src/common/message.cpp index 7adedef5..c4c9bf13 100644 --- a/src/common/message.cpp +++ b/src/common/message.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005/06 by The Quassel Team * + * Copyright (C) 2005-07 by the Quassel IRC Development Team * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/qtgui/chatline.cpp b/src/qtgui/chatline.cpp index ef847774..7c6ffaa5 100644 --- a/src/qtgui/chatline.cpp +++ b/src/qtgui/chatline.cpp @@ -41,13 +41,13 @@ ChatLine::~ChatLine() { void ChatLine::formatMsg(Message msg) { QTextOption tsOption, senderOption, textOption; - tsFormatted = Style::internalToFormatted(msg.formattedTimeStamp()); - senderFormatted = Style::internalToFormatted(msg.formattedSender()); - textFormatted = Style::internalToFormatted(msg.formattedText()); + styledTimeStamp = Style::formattedToStyled(msg.formattedTimeStamp()); + styledSender = Style::formattedToStyled(msg.formattedSender()); + styledText = Style::formattedToStyled(msg.formattedText()); precomputeLine(); } -QList ChatLine::calcFormatRanges(const Style::FormattedString &fs, QTextLayout::FormatRange additional) { +QList ChatLine::calcFormatRanges(const Style::StyledString &fs, QTextLayout::FormatRange additional) { QList ranges; QList formats = fs.formats; formats.append(additional); @@ -87,9 +87,9 @@ void ChatLine::setSelection(SelectionMode mode, int start, int end) { QTextLayout::FormatRange tsSel, senderSel, textSel; switch (mode) { case None: - tsFormat = calcFormatRanges(tsFormatted); - senderFormat = calcFormatRanges(senderFormatted); - textFormat = calcFormatRanges(textFormatted); + tsFormat = calcFormatRanges(styledTimeStamp); + senderFormat = calcFormatRanges(styledSender); + textFormat = calcFormatRanges(styledText); break; case Partial: selectionStart = qMin(start, end); selectionEnd = qMax(start, end); @@ -98,22 +98,22 @@ void ChatLine::setSelection(SelectionMode mode, int start, int end) { textSel.start = selectionStart; textSel.length = selectionEnd - selectionStart; //textFormat.append(textSel); - textFormat = calcFormatRanges(textFormatted, textSel); + textFormat = calcFormatRanges(styledText, textSel); foreach(FormatRange fr, textFormat); break; case Full: tsSel.format.setForeground(pal.brush(QPalette::HighlightedText)); tsSel.format.setBackground(pal.brush(QPalette::Highlight)); - tsSel.start = 0; tsSel.length = tsFormatted.text.length(); - tsFormat = calcFormatRanges(tsFormatted, tsSel); + tsSel.start = 0; tsSel.length = styledTimeStamp.text.length(); + tsFormat = calcFormatRanges(styledTimeStamp, tsSel); senderSel.format.setForeground(pal.brush(QPalette::HighlightedText)); senderSel.format.setBackground(pal.brush(QPalette::Highlight)); - senderSel.start = 0; senderSel.length = senderFormatted.text.length(); - senderFormat = calcFormatRanges(senderFormatted, senderSel); + senderSel.start = 0; senderSel.length = styledSender.text.length(); + senderFormat = calcFormatRanges(styledSender, senderSel); textSel.format.setForeground(pal.brush(QPalette::HighlightedText)); textSel.format.setBackground(pal.brush(QPalette::Highlight)); - textSel.start = 0; textSel.length = textFormatted.text.length(); - textFormat = calcFormatRanges(textFormatted, textSel); + textSel.start = 0; textSel.length = styledText.text.length(); + textFormat = calcFormatRanges(styledText, textSel); break; } } @@ -131,11 +131,11 @@ QDateTime ChatLine::timeStamp() const { } QString ChatLine::sender() const { - return senderFormatted.text; + return styledSender.text; } QString ChatLine::text() const { - return textFormatted.text; + return styledText.text; } bool ChatLine::isUrl(int c) const { @@ -146,7 +146,7 @@ bool ChatLine::isUrl(int c) const { QUrl ChatLine::getUrl(int c) const { if(c < 0 || c >= charUrlIdx.count()) return QUrl(); int i = charUrlIdx[c]; - if(i >= 0) return textFormatted.urls[i].url; + if(i >= 0) return styledText.urls[i].url; else return QUrl(); } @@ -174,20 +174,20 @@ int ChatLine::posToCursor(QPointF pos) { } void ChatLine::precomputeLine() { - tsFormat = calcFormatRanges(tsFormatted); - senderFormat = calcFormatRanges(senderFormatted); - textFormat = calcFormatRanges(textFormatted); + tsFormat = calcFormatRanges(styledTimeStamp); + senderFormat = calcFormatRanges(styledSender); + textFormat = calcFormatRanges(styledText); minHeight = 0; foreach(FormatRange fr, tsFormat) minHeight = qMax(minHeight, fr.height); foreach(FormatRange fr, senderFormat) minHeight = qMax(minHeight, fr.height); words.clear(); - charPos.resize(textFormatted.text.length() + 1); - charHeights.resize(textFormatted.text.length()); - charUrlIdx.fill(-1, textFormatted.text.length()); - for(int i = 0; i < textFormatted.urls.count(); i++) { - Style::UrlInfo url = textFormatted.urls[i]; + charPos.resize(styledText.text.length() + 1); + charHeights.resize(styledText.text.length()); + charUrlIdx.fill(-1, styledText.text.length()); + for(int i = 0; i < styledText.urls.count(); i++) { + Style::UrlInfo url = styledText.urls[i]; for(int j = url.start; j < url.end; j++) charUrlIdx[j] = i; } if(!textFormat.count()) return; @@ -195,10 +195,10 @@ void ChatLine::precomputeLine() { QFontMetrics metrics(textFormat[0].format.font()); Word wr; wr.start = -1; wr.trailing = -1; - for(int i = 0; i < textFormatted.text.length(); ) { + for(int i = 0; i < styledText.text.length(); ) { charPos[i] = w; charHeights[i] = textFormat[idx].height; - w += metrics.charWidth(textFormatted.text, i); - if(!textFormatted.text[i].isSpace()) { + w += metrics.charWidth(styledText.text, i); + if(!styledText.text[i].isSpace()) { if(wr.trailing >= 0) { // new word after space words.append(wr); @@ -216,13 +216,13 @@ void ChatLine::precomputeLine() { wr.trailing++; } } - if(++i < textFormatted.text.length() && ++cnt >= textFormat[idx].length) { + if(++i < styledText.text.length() && ++cnt >= textFormat[idx].length) { cnt = 0; idx++; Q_ASSERT(idx < textFormat.count()); metrics = QFontMetrics(textFormat[idx].format.font()); } } - charPos[textFormatted.text.length()] = w; + charPos[styledText.text.length()] = w; if(wr.start >= 0) words.append(wr); } @@ -318,14 +318,14 @@ void ChatLine::draw(QPainter *p, const QPointF &pos) { foreach(FormatRange fr, tsFormat) { p->setFont(fr.format.font()); p->setPen(QPen(fr.format.foreground(), 0)); p->setBackground(fr.format.background()); - p->drawText(rect, Qt::AlignLeft|Qt::TextSingleLine, tsFormatted.text.mid(fr.start, fr.length), &brect); + p->drawText(rect, Qt::AlignLeft|Qt::TextSingleLine, styledTimeStamp.text.mid(fr.start, fr.length), &brect); rect.setLeft(brect.right()); } rect = QRectF(pos + QPointF(tsWidth + Style::sepTsSender(), 0), QSizeF(senderWidth, minHeight)); for(int i = senderFormat.count() - 1; i >= 0; i--) { FormatRange fr = senderFormat[i]; p->setFont(fr.format.font()); p->setPen(QPen(fr.format.foreground(), 0)); p->setBackground(fr.format.background()); - p->drawText(rect, Qt::AlignRight|Qt::TextSingleLine, senderFormatted.text.mid(fr.start, fr.length), &brect); + p->drawText(rect, Qt::AlignRight|Qt::TextSingleLine, styledSender.text.mid(fr.start, fr.length), &brect); rect.setRight(brect.left()); } QPointF tpos = pos + QPointF(tsWidth + Style::sepTsSender() + senderWidth + Style::sepSenderText(), 0); @@ -342,7 +342,7 @@ void ChatLine::draw(QPainter *p, const QPointF &pos) { llend = lineLayouts[l].start + lineLayouts[l].length; start = qMax(fr.start, lineLayouts[l].start); end = qMin(frend, llend); rect.setLeft(tpos.x() + charPos[start] - offset); - p->drawText(rect, Qt::AlignLeft|Qt::TextSingleLine, textFormatted.text.mid(start, end - start), &brect); + p->drawText(rect, Qt::AlignLeft|Qt::TextSingleLine, styledText.text.mid(start, end - start), &brect); if(llend <= end) { h += lineLayouts[l].height; l++; diff --git a/src/qtgui/chatline.h b/src/qtgui/chatline.h index b42982c8..ac803634 100644 --- a/src/qtgui/chatline.h +++ b/src/qtgui/chatline.h @@ -70,7 +70,7 @@ class ChatLine : public QObject, public AbstractUiMsg { qreal hght; Message msg; qreal tsWidth, senderWidth, textWidth; - Style::FormattedString tsFormatted, senderFormatted, textFormatted; + Style::StyledString styledTimeStamp, styledSender, styledText; struct FormatRange { int start; @@ -103,7 +103,7 @@ class ChatLine : public QObject, public AbstractUiMsg { int selectionStart, selectionEnd; void formatMsg(Message); void precomputeLine(); - QList calcFormatRanges(const Style::FormattedString &, QTextLayout::FormatRange additional = QTextLayout::FormatRange()); + QList calcFormatRanges(const Style::StyledString &, QTextLayout::FormatRange additional = QTextLayout::FormatRange()); }; #endif diff --git a/src/qtgui/style.cpp b/src/qtgui/style.cpp index 87af6787..67e53a81 100644 --- a/src/qtgui/style.cpp +++ b/src/qtgui/style.cpp @@ -160,10 +160,10 @@ void Style::init() { * describing the formats of the string. * \param s string in internal format (% style format codes) */ -Style::FormattedString Style::internalToFormatted(QString s) { +Style::StyledString Style::formattedToStyled(QString s) { QHash toggles; QString p; - FormattedString sf; + StyledString sf; QTextLayout::FormatRange rng; rng.format = formats["default"]; rng.start = 0; rng.length = -1; sf.formats.append(rng); toggles["default"] = sf.formats.count() - 1; diff --git a/src/qtgui/style.h b/src/qtgui/style.h index a10a9698..68b52dac 100644 --- a/src/qtgui/style.h +++ b/src/qtgui/style.h @@ -35,15 +35,13 @@ class Style { QUrl url; }; - struct FormattedString { + struct StyledString { QString text; QList formats; QList urls; }; - static QString mircToInternal(QString); - //static QString internalToMirc(QString); - static FormattedString internalToFormatted(QString); + static StyledString formattedToStyled(QString); static int sepTsSender() { return 10; } static int sepSenderText() { return 10; }