| 126 | } |
| 127 | |
| 128 | void LogView::rowsInserted(const QModelIndex& parent, int first, int last) |
| 129 | { |
| 130 | for(int i = first; i <= last; i++) |
| 131 | { |
| 132 | auto idx = m_model->index(i, 0, parent); |
| 133 | auto text = m_model->data(idx, Qt::DisplayRole).toString(); |
| 134 | QTextCharFormat format(*m_defaultFormat); |
| 135 | auto font = m_model->data(idx, Qt::FontRole); |
| 136 | if(font.isValid()) |
| 137 | { |
| 138 | format.setFont(font.value<QFont>()); |
| 139 | } |
| 140 | auto fg = m_model->data(idx, Qt::ForegroundRole); |
| 141 | if(fg.isValid()) |
| 142 | { |
| 143 | format.setForeground(fg.value<QColor>()); |
| 144 | } |
| 145 | auto bg = m_model->data(idx, Qt::BackgroundRole); |
| 146 | if(bg.isValid()) |
| 147 | { |
| 148 | format.setBackground(bg.value<QColor>()); |
| 149 | } |
| 150 | auto workCursor = textCursor(); |
| 151 | workCursor.movePosition(QTextCursor::End); |
| 152 | workCursor.insertText(text, format); |
| 153 | workCursor.insertBlock(); |
| 154 | } |
| 155 | if(m_scroll && !m_scrolling) |
| 156 | { |
| 157 | m_scrolling = true; |
| 158 | QMetaObject::invokeMethod( this, "scrollToBottom", Qt::QueuedConnection); |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | void LogView::rowsRemoved(const QModelIndex& parent, int first, int last) |
| 163 | { |
nothing calls this directly
no test coverage detected