| 140 | } |
| 141 | |
| 142 | void drawColorMessageBody(QPainter* p, const QRect& rcMsg, const QFont& f) const |
| 143 | { |
| 144 | QString strMsg; |
| 145 | if (m_data.messageBody.isEmpty()) |
| 146 | { |
| 147 | strMsg = m_data.title; |
| 148 | Utils::WizStyleHelper::drawText(p, rcMsg, strMsg, 2, Qt::AlignVCenter, p->pen().color(), f); |
| 149 | } |
| 150 | else |
| 151 | { |
| 152 | strMsg = m_data.messageBody; |
| 153 | strMsg.remove(0, m_data.senderAlias.length() + 1); |
| 154 | QString strBeforeTitle = strMsg.left(strMsg.indexOf(m_data.title)); |
| 155 | QString strAfterTitle = strMsg.right(strMsg.length() - strMsg.lastIndexOf(m_data.title) - m_data.title.length()); |
| 156 | // |
| 157 | QColor colorSummary = Qt::black; |
| 158 | QColor colorTitle("#3998d6"); |
| 159 | |
| 160 | QRect rcBeforeTitle = Utils::WizStyleHelper::drawText(p, rcMsg, strBeforeTitle, 1, Qt::AlignVCenter, p->pen().color(), f, false); |
| 161 | if (strBeforeTitle.isEmpty() && rcBeforeTitle.height() < rcMsg.height()) // 第一行有剩余空间 |
| 162 | { |
| 163 | QString strTitle(m_data.title); |
| 164 | QRect rcTitle1(rcMsg.adjusted(rcBeforeTitle.width() - Utils::WizStyleHelper::margin(), 0, 0, 0)); |
| 165 | rcTitle1 = Utils::WizStyleHelper::drawText(p, rcTitle1, strTitle, 1, Qt::AlignVCenter, colorTitle, f, false); |
| 166 | |
| 167 | if (!strTitle.isEmpty()) //继续绘制标题 |
| 168 | { |
| 169 | QRect rcTitle2(rcMsg.adjusted(0, rcBeforeTitle.height(), 0, 0)); |
| 170 | rcTitle2 = Utils::WizStyleHelper::drawText(p, rcTitle2, strTitle, 1, Qt::AlignVCenter, colorTitle, f); |
| 171 | if (strTitle.isEmpty() && rcTitle2.width() < rcMsg.width()) |
| 172 | { |
| 173 | QRect rcAfterTitle(rcMsg.adjusted(rcTitle2.width() - Utils::WizStyleHelper::margin(), rcBeforeTitle.height(), 0, 0)); |
| 174 | Utils::WizStyleHelper::drawText(p, rcAfterTitle, strAfterTitle, 1, Qt::AlignVCenter, colorSummary, f); |
| 175 | } |
| 176 | } |
| 177 | else if (rcTitle1.right() < rcMsg.right()) //在第一行绘制标题后内容 |
| 178 | { |
| 179 | QRect rcAfterTitle1(rcMsg.adjusted(rcBeforeTitle.width() + rcTitle1.width() - Utils::WizStyleHelper::margin() * 2, 0, 0, 0)); |
| 180 | rcAfterTitle1 = Utils::WizStyleHelper::drawText(p, rcAfterTitle1, strAfterTitle, 1, Qt::AlignVCenter, colorSummary, f, false); |
| 181 | |
| 182 | if (!strAfterTitle.isEmpty()) { |
| 183 | QRect rcLine2(rcMsg.adjusted(0, rcAfterTitle1.height(), 0, 0)); |
| 184 | rcLine2 = Utils::WizStyleHelper::drawText(p, rcLine2, strAfterTitle, 1, Qt::AlignVCenter, colorSummary, f); |
| 185 | } |
| 186 | } |
| 187 | else //第一行没剩余空间,在第二行绘制标题后内容 |
| 188 | { |
| 189 | QRect rcLine2(rcMsg.adjusted(0, rcTitle1.height(), 0, 0)); |
| 190 | Utils::WizStyleHelper::drawText(p, rcLine2, strAfterTitle, 1, Qt::AlignVCenter, colorSummary, f); |
| 191 | } |
| 192 | } |
| 193 | else // 第一行没有剩余空间 |
| 194 | { |
| 195 | QRect rcBeforeTitle2(rcMsg.adjusted(0, rcBeforeTitle.height(), 0, 0)); |
| 196 | rcBeforeTitle2 = Utils::WizStyleHelper::drawText(p, rcBeforeTitle2, strBeforeTitle, 1, Qt::AlignVCenter, colorSummary, f); |
| 197 | |
| 198 | if (strBeforeTitle.isEmpty() && rcBeforeTitle2.width() < rcMsg.width()) |
| 199 | { |