From dbdca302fc349d0e3d46aa0d8091c08b2df28af5 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Thu, 8 May 2008 21:48:26 +0000 Subject: [PATCH 1/1] readability++ Renamed stuff, most notably Message::text() -> Message::contents(), StyledString::text -> StyledString::plainText, StyledString::formats -> StyledString::formatList Also made Message() take const_refs where appropriate. --- src/client/client.cpp | 6 ++-- src/common/message.cpp | 18 +++++----- src/common/message.h | 10 +++--- src/core/sqlitestorage.cpp | 2 +- src/qtopia/chatline.cpp | 6 ++-- src/qtopia/chatline.h | 4 +-- src/qtopia/chatwidget.cpp | 10 +++--- src/qtui/chatitem.cpp | 2 +- src/qtui/chatline-old.cpp | 64 +++++++++++++++++----------------- src/qtui/chatline-old.h | 2 +- src/qtui/chatlinemodelitem.cpp | 12 +++---- src/qtui/mainwin.cpp | 2 +- src/qtui/topicbutton.cpp | 8 ++--- src/qtui/topicbutton.h | 2 +- src/uisupport/old-uistyle.cpp | 18 +++++----- src/uisupport/old-uistyle.h | 4 +-- src/uisupport/uistyle.cpp | 16 ++++----- src/uisupport/uistyle.h | 6 ++-- 18 files changed, 96 insertions(+), 96 deletions(-) diff --git a/src/client/client.cpp b/src/client/client.cpp index a8cc7f93..6a7faa9c 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -497,7 +497,7 @@ void Client::recvMessage(const Message &message) { ? net->networkName() + ":" : QString(); QString sender = networkName + msg.bufferInfo().bufferName() + ":" + msg.sender(); - Message mmsg = Message(msg.timestamp(), msg.bufferInfo(), msg.type(), msg.text(), sender, msg.flags()); + Message mmsg = Message(msg.timestamp(), msg.bufferInfo(), msg.type(), msg.contents(), sender, msg.flags()); monitorBuffer()->appendMsg(mmsg); } emit messageReceived(msg); @@ -588,7 +588,7 @@ void Client::checkForHighlight(Message &msg) { QRegExp nickRegExp("^(.*\\W)?" + QRegExp::escape(nickname) + "(\\W.*)?$"); if((msg.type() & (Message::Plain | Message::Notice | Message::Action)) && !(msg.flags() & Message::Self) - && nickRegExp.exactMatch(msg.text())) { + && nickRegExp.exactMatch(msg.contents())) { msg.setFlags(msg.flags() | Message::Highlight); return; } @@ -608,7 +608,7 @@ void Client::checkForHighlight(Message &msg) { } if((msg.type() & (Message::Plain | Message::Notice | Message::Action)) && !(msg.flags() & Message::Self) - && userRegExp.exactMatch(msg.text())) { + && userRegExp.exactMatch(msg.contents())) { msg.setFlags(msg.flags() | Message::Highlight); return; } diff --git a/src/common/message.cpp b/src/common/message.cpp index 63446b10..2ce40f81 100644 --- a/src/common/message.cpp +++ b/src/common/message.cpp @@ -24,20 +24,20 @@ #include -Message::Message(BufferInfo bufferInfo, Type type, QString text, QString sender, Flags flags) +Message::Message(const BufferInfo &bufferInfo, Type type, const QString &contents, const QString &sender, Flags flags) : _timestamp(QDateTime::currentDateTime().toUTC()), _bufferInfo(bufferInfo), - _text(text), + _contents(contents), _sender(sender), _type(type), _flags(flags) { } -Message::Message(QDateTime ts,BufferInfo bufferInfo, Type type, QString text, QString sender, Flags flags) +Message::Message(const QDateTime &ts, const BufferInfo &bufferInfo, Type type, const QString &contents, const QString &sender, Flags flags) : _timestamp(ts), _bufferInfo(bufferInfo), - _text(text), + _contents(contents), _sender(sender), _type(type), _flags(flags) @@ -99,7 +99,7 @@ void Message::format() { QString user = userFromMask(sender()); QString host = hostFromMask(sender()); QString nick = nickFromMask(sender()); - QString txt = mircToInternal(text()); + QString txt = mircToInternal(contents()); QString bufferName = bufferInfo().bufferName(); _formattedTimestamp = tr("%DT[%1]").arg(timestamp().toLocalTime().toString("hh:mm:ss")); @@ -135,12 +135,12 @@ void Message::format() { break; case Message::Nick: s = tr("%Dr<->"); - if(nick == text()) t = tr("%DrYou are now known as %DN%1%DN").arg(txt); + if(nick == contents()) t = tr("%DrYou are now known as %DN%1%DN").arg(txt); else t = tr("%Dr%DN%1%DN is now known as %DN%2%DN").arg(nick, txt); break; case Message::Mode: s = tr("%Dm***"); - if(nick.isEmpty()) t = tr("%DmUser mode: %DM%1%DM").arg(text()); + if(nick.isEmpty()) t = tr("%DmUser mode: %DM%1%DM").arg(contents()); else t = tr("%DmMode %DM%1%DM by %DN%2%DN").arg(txt, nick); break; case Message::Action: @@ -173,7 +173,7 @@ QString Message::formattedText() { QDataStream &operator<<(QDataStream &out, const Message &msg) { out << msg.msgId() << (quint32)msg.timestamp().toTime_t() << (quint32)msg.type() << (quint8)msg.flags() - << msg.bufferInfo() << msg.sender().toUtf8() << msg.text().toUtf8(); + << msg.bufferInfo() << msg.sender().toUtf8() << msg.contents().toUtf8(); return out; } @@ -189,7 +189,7 @@ QDataStream &operator>>(QDataStream &in, Message &msg) { msg._bufferInfo = buf; msg._timestamp = QDateTime::fromTime_t(ts); msg._sender = QString::fromUtf8(s); - msg._text = QString::fromUtf8(m); + msg._contents = QString::fromUtf8(m); return in; } diff --git a/src/common/message.h b/src/common/message.h index c6f4e3ba..797e28b7 100644 --- a/src/common/message.h +++ b/src/common/message.h @@ -57,15 +57,15 @@ public: Q_DECLARE_FLAGS(Flags, Flag) - Message(BufferInfo bufferInfo = BufferInfo(), Type type = Plain, QString text = "", QString sender = "", Flags flags = None); - - Message(QDateTime ts, BufferInfo buffer = BufferInfo(), Type type = Plain, QString text = "", QString sender = "", Flags flags = None); + Message(const BufferInfo &bufferInfo = BufferInfo(), Type type = Plain, const QString &contents = "", const QString &sender = "", Flags flags = None); + Message(const QDateTime &ts, const BufferInfo &buffer = BufferInfo(), Type type = Plain, + const QString &contents = "", const QString &sender = "", Flags flags = None); inline MsgId msgId() const { return _msgId; } inline void setMsgId(MsgId id) { _msgId = id; } inline BufferInfo bufferInfo() const { return _bufferInfo; } - inline QString text() const { return _text; } + inline QString contents() const { return _contents; } inline QString sender() const { return _sender; } inline Type type() const { return _type; } inline Flags flags() const { return _flags; } @@ -90,7 +90,7 @@ private: QDateTime _timestamp; MsgId _msgId; BufferInfo _bufferInfo; - QString _text; + QString _contents; QString _sender; Type _type; Flags _flags; diff --git a/src/core/sqlitestorage.cpp b/src/core/sqlitestorage.cpp index 68120e12..5dab67e5 100644 --- a/src/core/sqlitestorage.cpp +++ b/src/core/sqlitestorage.cpp @@ -631,7 +631,7 @@ MsgId SqliteStorage::logMessage(Message msg) { logMessageQuery->bindValue(":type", msg.type()); logMessageQuery->bindValue(":flags", (int)msg.flags()); logMessageQuery->bindValue(":sender", msg.sender()); - logMessageQuery->bindValue(":message", msg.text()); + logMessageQuery->bindValue(":message", msg.contents()); logMessageQuery->exec(); if(logMessageQuery->lastError().isValid()) { diff --git a/src/qtopia/chatline.cpp b/src/qtopia/chatline.cpp index a380314a..0a709c03 100644 --- a/src/qtopia/chatline.cpp +++ b/src/qtopia/chatline.cpp @@ -26,7 +26,7 @@ ChatLine::ChatLine(Message msg) { _styledSender = QtopiaUi::style()->styleString(msg.formattedSender()); - _styledText = QtopiaUi::style()->styleString(msg.formattedText()); + _styledContents = QtopiaUi::style()->styleString(msg.formattedText()); _timestamp = msg.timestamp(); _msgId = msg.msgId(); _bufferInfo = msg.bufferInfo(); @@ -58,8 +58,8 @@ UiStyle::StyledText ChatLine::styledSender() const { return _styledSender; } -UiStyle::StyledText ChatLine::styledText() const { - return _styledText; +UiStyle::StyledText ChatLine::styledContents() const { + return _styledContents; } diff --git a/src/qtopia/chatline.h b/src/qtopia/chatline.h index 0d3f5e8b..bdaf7d41 100644 --- a/src/qtopia/chatline.h +++ b/src/qtopia/chatline.h @@ -35,11 +35,11 @@ class ChatLine : public AbstractUiMsg { QDateTime timestamp() const; UiStyle::StyledText styledSender() const; - UiStyle::StyledText styledText() const; + UiStyle::StyledText styledContents() const; private: QString _sender, _text, _htmlSender, _htmlText, _htmlTimestamp; - UiStyle::StyledText _styledSender, _styledText; + UiStyle::StyledText _styledSender, _styledContents; MsgId _msgId; BufferInfo _bufferInfo; QDateTime _timestamp; diff --git a/src/qtopia/chatwidget.cpp b/src/qtopia/chatwidget.cpp index 9f8eabb5..b6950c64 100644 --- a/src/qtopia/chatwidget.cpp +++ b/src/qtopia/chatwidget.cpp @@ -53,7 +53,7 @@ void ChatWidget::appendChatLine(ChatLine *line) { if(!document()->isEmpty()) insertPlainText("\n"); insertStyledText(line->styledSender()); insertPlainText(" "); - insertStyledText(line->styledText()); + insertStyledText(line->styledContents()); setTextCursor(cursor); } @@ -69,7 +69,7 @@ void ChatWidget::prependChatLine(ChatLine *line) { bool flg = document()->isEmpty(); insertStyledText(line->styledSender()); insertPlainText(" "); - insertStyledText(line->styledText()); + insertStyledText(line->styledContents()); if(!flg) insertPlainText("\n"); setTextCursor(cursor); } @@ -84,14 +84,14 @@ void ChatWidget::insertChatLine(ChatLine *line) { if(!document()->isEmpty()) insertPlainText("\n"); insertStyledText(line->styledSender()); insertPlainText(" "); - insertStyledText(line->styledText()); + insertStyledText(line->styledContents()); } void ChatWidget::insertStyledText(const QtopiaUiStyle::StyledText &stext) { QTextCursor cursor = textCursor(); - foreach(QTextLayout::FormatRange format, stext.formats) { + foreach(QTextLayout::FormatRange format, stext.formatList) { cursor.setCharFormat(format.format); setTextCursor(cursor); - insertPlainText(stext.text.mid(format.start, format.length)); + insertPlainText(stext.plainText.mid(format.start, format.length)); } } diff --git a/src/qtui/chatitem.cpp b/src/qtui/chatitem.cpp index 1e086059..a677e105 100644 --- a/src/qtui/chatitem.cpp +++ b/src/qtui/chatitem.cpp @@ -78,7 +78,7 @@ QString ChatItem::text() const { void ChatItem::setText(const UiStyle::StyledText &text) { _layout.setText(text.text); - _layout.setAdditionalFormats(text.formats); + _layout.setAdditionalFormats(text.formatList); layout(); } diff --git a/src/qtui/chatline-old.cpp b/src/qtui/chatline-old.cpp index 497017da..3b0dae5c 100644 --- a/src/qtui/chatline-old.cpp +++ b/src/qtui/chatline-old.cpp @@ -51,7 +51,7 @@ void ChatLineOld::formatMsg(Message msg) { QTextOption tsOption, senderOption, textOption; styledTimeStamp = QtUi::style()->styleString(msg.formattedTimestamp()); styledSender = QtUi::style()->styleString(msg.formattedSender()); - styledText = QtUi::style()->styleString(msg.formattedText()); + styledContents = QtUi::style()->styleString(msg.formattedText()); precomputeLine(); } @@ -69,28 +69,28 @@ QList ChatLineOld::calcFormatRanges(const UiStyle::Sty QList ranges; if(additional.length > 0) { - for(int i = 0; i < fs.formats.count(); i++) { - int oldend = fs.formats[i].start + fs.formats[i].length - 1; + for(int i = 0; i < fs.formatList.count(); i++) { + int oldend = fs.formatList[i].start + fs.formatList[i].length - 1; int addend = additional.start + additional.length - 1; if(oldend < additional.start) continue; - fs.formats[i].length = additional.start - fs.formats[i].start; - QTextLayout::FormatRange addfmtrng = fs.formats[i]; + fs.formatList[i].length = additional.start - fs.formatList[i].start; + QTextLayout::FormatRange addfmtrng = fs.formatList[i]; addfmtrng.format.merge(additional.format); addfmtrng.start = additional.start; addfmtrng.length = qMin(oldend, addend) - additional.start + 1; - fs.formats.insert(++i, addfmtrng); + fs.formatList.insert(++i, addfmtrng); if(addend == oldend) break; if(addend < oldend) { - QTextLayout::FormatRange restfmtrng = fs.formats[i-1]; + QTextLayout::FormatRange restfmtrng = fs.formatList[i-1]; restfmtrng.start = addend + 1; restfmtrng.length = oldend - addend; - fs.formats.insert(++i, restfmtrng); + fs.formatList.insert(++i, restfmtrng); break; } } } - foreach(QTextLayout::FormatRange f, fs.formats) { + foreach(QTextLayout::FormatRange f, fs.formatList) { if(f.length <= 0) continue; FormatRange range; range.start = f.start; @@ -112,7 +112,7 @@ void ChatLineOld::setSelection(SelectionMode mode, int start, int end) { case None: tsFormat = calcFormatRanges(styledTimeStamp); senderFormat = calcFormatRanges(styledSender); - textFormat = calcFormatRanges(styledText); + textFormat = calcFormatRanges(styledContents); break; case Partial: selectionStart = qMin(start, end); selectionEnd = qMax(start, end); @@ -120,21 +120,21 @@ void ChatLineOld::setSelection(SelectionMode mode, int start, int end) { textSel.format.setBackground(pal.brush(QPalette::Highlight)); textSel.start = selectionStart; textSel.length = selectionEnd - selectionStart; - textFormat = calcFormatRanges(styledText, textSel); + textFormat = calcFormatRanges(styledContents, textSel); break; case Full: tsSel.format.setForeground(pal.brush(QPalette::HighlightedText)); tsSel.format.setBackground(pal.brush(QPalette::Highlight)); - tsSel.start = 0; tsSel.length = styledTimeStamp.text.length(); + tsSel.start = 0; tsSel.length = styledTimeStamp.plainText.length(); tsFormat = calcFormatRanges(styledTimeStamp, tsSel); senderSel.format.setForeground(pal.brush(QPalette::HighlightedText)); senderSel.format.setBackground(pal.brush(QPalette::Highlight)); - senderSel.start = 0; senderSel.length = styledSender.text.length(); + senderSel.start = 0; senderSel.length = styledSender.plainText.length(); senderFormat = calcFormatRanges(styledSender, senderSel); textSel.format.setForeground(pal.brush(QPalette::HighlightedText)); textSel.format.setBackground(pal.brush(QPalette::Highlight)); - textSel.start = 0; textSel.length = styledText.text.length(); - textFormat = calcFormatRanges(styledText, textSel); + textSel.start = 0; textSel.length = styledContents.plainText.length(); + textFormat = calcFormatRanges(styledContents, textSel); break; } } @@ -152,11 +152,11 @@ QDateTime ChatLineOld::timestamp() const { } QString ChatLineOld::sender() const { - return styledSender.text; + return styledSender.plainText; } QString ChatLineOld::text() const { - return styledText.text; + return styledContents.plainText; } bool ChatLineOld::isUrl(int c) const { @@ -167,7 +167,7 @@ bool ChatLineOld::isUrl(int c) const { QUrl ChatLineOld::getUrl(int c) const { if(c < 0 || c >= charUrlIdx.count()) return QUrl(); int i = charUrlIdx[c]; - if(i >= 0) return styledText.urls[i].url; + if(i >= 0) return styledContents.urls[i].url; else return QUrl(); } @@ -197,18 +197,18 @@ int ChatLineOld::posToCursor(QPointF pos) { void ChatLineOld::precomputeLine() { tsFormat = calcFormatRanges(styledTimeStamp); senderFormat = calcFormatRanges(styledSender); - textFormat = calcFormatRanges(styledText); + textFormat = calcFormatRanges(styledContents); minHeight = 0; foreach(FormatRange fr, tsFormat) minHeight = qMax(minHeight, fr.height); foreach(FormatRange fr, senderFormat) minHeight = qMax(minHeight, fr.height); words.clear(); - 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++) { - QtUiStyle::UrlInfo url = styledText.urls[i]; + charPos.resize(styledContents.plainText.length() + 1); + charHeights.resize(styledContents.plainText.length()); + charUrlIdx.fill(-1, styledContents.plainText.length()); + for(int i = 0; i < styledContents.urls.count(); i++) { + QtUiStyle::UrlInfo url = styledContents.urls[i]; for(int j = url.start; j < url.end; j++) charUrlIdx[j] = i; } if(!textFormat.count()) return; @@ -216,10 +216,10 @@ void ChatLineOld::precomputeLine() { QFontMetrics metrics(textFormat[0].format.font()); Word wr; wr.start = -1; wr.trailing = -1; - for(int i = 0; i < styledText.text.length(); ) { + for(int i = 0; i < styledContents.plainText.length(); ) { charPos[i] = w; charHeights[i] = textFormat[idx].height; - w += metrics.charWidth(styledText.text, i); - if(!styledText.text[i].isSpace()) { + w += metrics.charWidth(styledContents.plainText, i); + if(!styledContents.plainText[i].isSpace()) { if(wr.trailing >= 0) { // new word after space words.append(wr); @@ -237,13 +237,13 @@ void ChatLineOld::precomputeLine() { wr.trailing++; } } - if(++i < styledText.text.length() && ++cnt >= textFormat[idx].length) { + if(++i < styledContents.plainText.length() && ++cnt >= textFormat[idx].length) { cnt = 0; idx++; Q_ASSERT(idx < textFormat.count()); metrics = QFontMetrics(textFormat[idx].format.font()); } } - charPos[styledText.text.length()] = w; + charPos[styledContents.plainText.length()] = w; if(wr.start >= 0) words.append(wr); } @@ -346,14 +346,14 @@ void ChatLineOld::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, styledTimeStamp.text.mid(fr.start, fr.length), &brect); + p->drawText(rect, Qt::AlignLeft|Qt::TextSingleLine, styledTimeStamp.plainText.mid(fr.start, fr.length), &brect); rect.setLeft(brect.right()); } rect = QRectF(pos + QPointF(tsWidth + QtUi::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, styledSender.text.mid(fr.start, fr.length), &brect); + p->drawText(rect, Qt::AlignRight|Qt::TextSingleLine, styledSender.plainText.mid(fr.start, fr.length), &brect); rect.setRight(brect.left()); } QPointF tpos = pos + QPointF(tsWidth + QtUi::style()->sepTsSender() + senderWidth + QtUi::style()->sepSenderText(), 0); @@ -371,7 +371,7 @@ void ChatLineOld::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, styledText.text.mid(start, end - start), &brect); + p->drawText(rect, Qt::AlignLeft|Qt::TextSingleLine, styledContents.plainText.mid(start, end - start), &brect); if(llend <= end) { h += lineLayouts[l].height; l++; diff --git a/src/qtui/chatline-old.h b/src/qtui/chatline-old.h index 5ce5fc3f..b2b9445a 100644 --- a/src/qtui/chatline-old.h +++ b/src/qtui/chatline-old.h @@ -70,7 +70,7 @@ class ChatLineOld : public QObject, public AbstractUiMsg { qreal hght; Message msg; qreal tsWidth, senderWidth, textWidth; - UiStyle::StyledText styledTimeStamp, styledSender, styledText; + UiStyle::StyledText styledTimeStamp, styledSender, styledContents; struct FormatRange { int start; diff --git a/src/qtui/chatlinemodelitem.cpp b/src/qtui/chatlinemodelitem.cpp index 807d40c8..009d535a 100644 --- a/src/qtui/chatlinemodelitem.cpp +++ b/src/qtui/chatlinemodelitem.cpp @@ -26,13 +26,13 @@ ChatlineModelItem::ChatlineModelItem(const Message &msg) : MessageModelItem(msg) { QtUiStyle::StyledMessage m = QtUi::style()->styleMessage(msg); - _timestamp.plainText = m.timestamp.text; - _sender.plainText = m.sender.text; - _contents.plainText = m.text.text; + _timestamp.plainText = m.timestamp.plainText; + _sender.plainText = m.sender.plainText; + _contents.plainText = m.contents.plainText; - _timestamp.formatList = m.timestamp.formats; - _sender.formatList = m.sender.formats; - _contents.formatList = m.text.formats; + _timestamp.formatList = m.timestamp.formatList; + _sender.formatList = m.sender.formatList; + _contents.formatList = m.contents.formatList; } diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 36644dae..64d4fd7c 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -570,7 +570,7 @@ void MainWin::receiveMessage(const Message &msg) { #ifndef SPUTDEV if(uiSettings.value("DisplayPopupMessages", QVariant(true)).toBool()) { // FIXME don't invoke style engine for this! - QString text = QtUi::style()->styleString(Message::mircToInternal(msg.text())).text; + QString text = QtUi::style()->styleString(Message::mircToInternal(msg.contents())).plainText; displayTrayIconMessage(title, text); } #endif diff --git a/src/qtui/topicbutton.cpp b/src/qtui/topicbutton.cpp index 2030a541..f2f60af1 100644 --- a/src/qtui/topicbutton.cpp +++ b/src/qtui/topicbutton.cpp @@ -50,8 +50,8 @@ void TopicButton::paintEvent(QPaintEvent *event) { QRect drawRect = rect(); QRect brect; QString textPart; - foreach(QTextLayout::FormatRange fr, styledText.formats) { - textPart = styledText.text.mid(fr.start, fr.length); + foreach(QTextLayout::FormatRange fr, styledContents.formatList) { + textPart = styledContents.plainText.mid(fr.start, fr.length); painter.setFont(fr.format.font()); painter.setPen(QPen(fr.format.foreground(), 0)); painter.setBackground(fr.format.background()); @@ -68,9 +68,9 @@ void TopicButton::setAndStyleText(const QString &text) { setText(text); // this triggers a repaint event #ifndef SPUTDEV - styledText = QtUi::style()->styleString(Message::mircToInternal(text)); + styledContents = QtUi::style()->styleString(Message::mircToInternal(text)); int height = 1; - foreach(QTextLayout::FormatRange fr, styledText.formats) { + foreach(QTextLayout::FormatRange fr, styledContents.formatList) { height = qMax(height, QFontMetrics(fr.format.font()).height()); } diff --git a/src/qtui/topicbutton.h b/src/qtui/topicbutton.h index ce6aeb42..71e9cd89 100644 --- a/src/qtui/topicbutton.h +++ b/src/qtui/topicbutton.h @@ -39,7 +39,7 @@ protected: private: #ifndef SPUTDEV - UiStyle::StyledText styledText; + UiStyle::StyledText styledContents; #endif QSize _sizeHint; }; diff --git a/src/uisupport/old-uistyle.cpp b/src/uisupport/old-uistyle.cpp index 94c9742b..83024aa4 100644 --- a/src/uisupport/old-uistyle.cpp +++ b/src/uisupport/old-uistyle.cpp @@ -139,7 +139,7 @@ UiStyle::StyledText UiStyle::styleString(const QString &_s) { QTextLayout::FormatRange curFmtRng; curFmtRng.format = format(None); curFmtRng.start = 0; - result.formats.append(curFmtRng); + result.formatList.append(curFmtRng); int pos = 0; int length = 0; int fgCol = -1, bgCol = -1; // marks current mIRC color for(;;) { @@ -216,20 +216,20 @@ UiStyle::StyledText UiStyle::styleString(const QString &_s) { } s.remove(pos, length); // remove format code from string // now see if something changed and else insert the format - if(curFmtRng.format == result.formats.last().format) continue; // no change, so we just ignore + if(curFmtRng.format == result.formatList.last().format) continue; // no change, so we just ignore curFmtRng.start = pos; - if(pos == result.formats.last().start) { + if(pos == result.formatList.last().start) { // same starting point -> we just overwrite the old format - result.formats.last() = curFmtRng; + result.formatList.last() = curFmtRng; } else { // fix length of last format - result.formats.last().length = pos - result.formats.last().start; - result.formats.append(curFmtRng); + result.formatList.last().length = pos - result.formatList.last().start; + result.formatList.append(curFmtRng); } } - result.formats.last().length = s.length() - result.formats.last().start; - if(result.formats.last().length == 0) result.formats.removeLast(); - result.text = s; + result.formatList.last().length = s.length() - result.formatList.last().start; + if(result.formatList.last().length == 0) result.formatList.removeLast(); + result.plainText = s; return result; } diff --git a/src/uisupport/old-uistyle.h b/src/uisupport/old-uistyle.h index ab2d86de..7b58c12f 100644 --- a/src/uisupport/old-uistyle.h +++ b/src/uisupport/old-uistyle.h @@ -53,8 +53,8 @@ class UiStyle { }; struct StyledText { - QString text; - QList formats; + QString plainText; + QList formatList; QList urls; }; diff --git a/src/uisupport/uistyle.cpp b/src/uisupport/uistyle.cpp index e0af5b15..10b25e7d 100644 --- a/src/uisupport/uistyle.cpp +++ b/src/uisupport/uistyle.cpp @@ -164,7 +164,7 @@ QString UiStyle::formatCode(FormatType ftype) const { UiStyle::StyledString UiStyle::styleString(const QString &s_) { QString s = s_; StyledString result; - result.formats.append(qMakePair(0, (quint32)None)); + result.formatList.append(qMakePair(0, (quint32)None)); quint32 curfmt = (quint32)None; int pos = 0; int length = 0; for(;;) { @@ -208,12 +208,12 @@ UiStyle::StyledString UiStyle::styleString(const QString &s_) { length = code.length(); } s.remove(pos, length); - if(pos == result.formats.last().first) - result.formats.last().second = curfmt; + if(pos == result.formatList.last().first) + result.formatList.last().second = curfmt; else - result.formats.append(qMakePair(pos, curfmt)); + result.formatList.append(qMakePair(pos, curfmt)); } - result.text = s; + result.plainText = s; return result; } @@ -265,7 +265,7 @@ UiStyle::StyledMessage UiStyle::styleMessage(const Message &msg) { QString user = userFromMask(msg.sender()); QString host = hostFromMask(msg.sender()); QString nick = nickFromMask(msg.sender()); - QString txt = mircToInternal(msg.text()); + QString txt = mircToInternal(msg.contents()); QString bufferName = msg.bufferInfo().bufferName(); StyledMessage result; @@ -303,7 +303,7 @@ UiStyle::StyledMessage UiStyle::styleMessage(const Message &msg) { break; case Message::Nick: s = tr("%Dr<->"); - if(nick == msg.text()) t = tr("%DrYou are now known as %DN%1%DN").arg(txt); + if(nick == msg.contents()) t = tr("%DrYou are now known as %DN%1%DN").arg(txt); else t = tr("%Dr%DN%1%DN is now known as %DN%2%DN").arg(nick, txt); break; case Message::Mode: @@ -320,7 +320,7 @@ UiStyle::StyledMessage UiStyle::styleMessage(const Message &msg) { t = tr("%De[%1]").arg(txt); } result.sender = styleString(s); - result.text = styleString(t); + result.contents = styleString(t); return result; } diff --git a/src/uisupport/uistyle.h b/src/uisupport/uistyle.h index ce0735ce..426b398e 100644 --- a/src/uisupport/uistyle.h +++ b/src/uisupport/uistyle.h @@ -121,14 +121,14 @@ class UiStyle { }; struct StyledString { - QString text; - FormatList formats; // starting pos, ftypes + QString plainText; + FormatList formatList; // starting pos, ftypes }; struct StyledMessage { StyledString timestamp; StyledString sender; - StyledString text; + StyledString contents; }; StyledString styleString(const QString &); -- 2.20.1