-QTextLayout::FormatRange ChatItem::selectionFormat() const {
- QTextLayout::FormatRange selectFmt;
- if(_selectionMode != NoSelection) {
- selectFmt.format.setForeground(QApplication::palette().brush(QPalette::HighlightedText));
- selectFmt.format.setBackground(QApplication::palette().brush(QPalette::Highlight));
- if(_selectionMode == PartialSelection) {
- selectFmt.start = qMin(_selectionStart, _selectionEnd);
- selectFmt.length = qAbs(_selectionStart - _selectionEnd);
- } else { // FullSelection
- selectFmt.start = 0;
- selectFmt.length = data(MessageModel::DisplayRole).toString().length();
- }
- } else {
- selectFmt.start = -1;
- selectFmt.length = 0;
- }
- return selectFmt;
-}
-