From 76bafb5fb7741b8d67062abd1a2e1d00ea4ac4d4 Mon Sep 17 00:00:00 2001 From: chenyong Date: Mon, 3 Oct 2016 22:43:06 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=9C=E8=89=B2=E5=8C=BA=E5=88=86=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=98=AF=E8=87=AA=E5=B7=B1=E5=8F=91=E9=80=81=E7=9A=84?= =?UTF-8?q?=E8=BF=98=E6=98=AF=E6=8E=A5=E6=94=B6=E8=87=AA=E5=A5=BD=E5=8F=8B?= =?UTF-8?q?=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mainwindow.ui | 3 +++ recvtextedit.cpp | 44 ++++++++++++++++++++++++++++---------------- recvtextedit.h | 2 ++ 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/mainwindow.ui b/mainwindow.ui index ccd54aa..63de6cb 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -146,6 +146,9 @@ 查找 + + Ctrl+S + diff --git a/recvtextedit.cpp b/recvtextedit.cpp index 118ece5..376ef86 100644 --- a/recvtextedit.cpp +++ b/recvtextedit.cpp @@ -27,33 +27,45 @@ void RecvTextEdit::mouseReleaseEvent(QMouseEvent *e) void RecvTextEdit::addFellowContent(const Content *content, long long msSinceEpoch) { + addContent(content, msSinceEpoch, false); +} + +void RecvTextEdit::addMyContent(const Content *content, long long msSinceEpoch) +{ + addContent(content, msSinceEpoch, true); +} + +void RecvTextEdit::addContent(const Content *content, long long msSinceEpoch, bool mySelf) +{ drawDaySeperatorIfNewDay(msSinceEpoch); - QString hint = ""; - if (mFellow) - hint = mFellow->getName().c_str(); - else - hint = "匿名"; - hint = hint+" "+ timeStr(msSinceEpoch)+""; - moveCursor(QTextCursor::End); - insertHtml(hint); - append(""); - showContent(content, false); + showHint(msSinceEpoch, mySelf); + + showContent(content, mySelf); append("\n"); moveCursor(QTextCursor::End); } -void RecvTextEdit::addMyContent(const Content *content, long long msSinceEpoch) +void RecvTextEdit::showHint(long long msSinceEpoch, bool mySelf) { - drawDaySeperatorIfNewDay(msSinceEpoch); + QString name(""); + QString color("black"); + if (mySelf) + { + name = "我"; + color = "blue"; + } + else + { + name = mFellow == nullptr ? "匿名" : mFellow->getName().c_str(); + color = "green"; + } + + QString hint = ""+ name+" "+timeStr(msSinceEpoch)+""; - QString hint = "我 "+timeStr(msSinceEpoch)+""; moveCursor(QTextCursor::End); insertHtml(hint); append(""); - showContent(content, true); - append("\n"); - moveCursor(QTextCursor::End); } void RecvTextEdit::setCurFellow(const Fellow *fellow) diff --git a/recvtextedit.h b/recvtextedit.h index 958703b..508d705 100644 --- a/recvtextedit.h +++ b/recvtextedit.h @@ -31,6 +31,8 @@ signals: private: QString timeStr(long long msSinceEpoch); + void addContent(const Content* content, long long msSinceEpoch, bool mySelf); + void showHint(long long msSinceEpoch, bool mySelf); void showContent(const Content* content, bool mySelf); void showFile(const FileContent* content, bool fromMySelf); void showImage(const ImageContent* content);