MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / rowsInserted

Method rowsInserted

launcher/ui/widgets/LogView.cpp:128–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128void 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
162void LogView::rowsRemoved(const QModelIndex& parent, int first, int last)
163{

Callers

nothing calls this directly

Calls 7

setFontMethod · 0.80
setForegroundMethod · 0.80
setBackgroundMethod · 0.80
indexMethod · 0.45
toStringMethod · 0.45
dataMethod · 0.45
isValidMethod · 0.45

Tested by

no test coverage detected