void ScreenData::insertLine(int row, int topMargin) { auto row_it = it_for_row(row + 1); const size_t old_content_height = contentHeight(); if (!topMargin && m_height >= m_screen_height) { push_at_most_to_scrollback(1); } else { auto row_top_margin = it_for_row_ensure_single_line_block(topMargin); if (row == topMargin) { (*row_top_margin)->clear(); return; } delete (*row_top_margin); m_screen_blocks.erase(row_top_margin); m_height--; m_block_count--; } Block *block_to_insert = new Block(m_screen); m_screen_blocks.insert(row_it,block_to_insert); m_height++; m_block_count++; emit contentModified(m_scrollback->height() + row + 1, 1, content_height_diff(old_content_height)); }
void MessageFolder::folderContentsModified(const QMailFolderIdList& ids) { foreach (const QMailFolderId& id, ids) if (id == mFolder.id()) { emit contentModified(); return; } }
HTMLEditor::HTMLEditor(HTMLEditorWidget* editorWidget) :Core::IEditor(editorWidget) { d = new HTMLEditorData; d->editorWidget = editorWidget; d->file = new HTMLFile(this, editorWidget); Core::UniqueIDManager* uidm = Core::UniqueIDManager::instance(); d->context << uidm->uniqueIdentifier(HTMLEditorConstants::C_HTMLEDITOR); connect(d->editorWidget, SIGNAL(contentModified()), d->file, SLOT(modified())); connect(d->editorWidget, SIGNAL(titleChanged(QString)), this, SLOT(slotTitleChanged(QString))); connect(d->editorWidget, SIGNAL(contentModified()), this, SIGNAL(changed())); }
const CursorDiff ScreenData::modify(const QPoint &point, const QString &text, const TextStyle &style, bool replace, bool only_latin) { auto it = it_for_row(point.y()); if (it == m_screen_blocks.end()) return { 0, 0 }; Block *block = *it; const int start_char = (point.y() - block->screenIndex()) * m_width + point.x(); const size_t lines_before = block->lineCount(); const int lines_changed = block->lineCountAfterModified(start_char, text.size(), replace) - lines_before; const size_t old_content_height = contentHeight(); m_height += lines_changed; if (lines_changed > 0) { int removed = 0; auto to_merge_inn = it; ++to_merge_inn; while(removed < lines_changed && to_merge_inn != m_screen_blocks.end()) { Block *to_be_reduced = *to_merge_inn; bool remove_block = removed + to_be_reduced->lineCount() <= lines_changed; int lines_to_remove = remove_block ? to_be_reduced->lineCount() : to_be_reduced->lineCount() - (lines_changed - removed); block->moveLinesFromBlock(to_be_reduced, 0, lines_to_remove); removed += lines_to_remove; if (remove_block) { delete to_be_reduced; to_merge_inn = m_screen_blocks.erase(to_merge_inn); m_block_count--; } else { ++to_merge_inn; } } m_height -= removed; } if (m_height > m_screen_height) push_at_most_to_scrollback(m_height - m_screen_height); if (replace) { block->replaceAtPos(start_char, text, style, only_latin); } else { block->insertAtPos(start_char, text, style, only_latin); } int end_char = (start_char + text.size()) % m_width; if (end_char == 0) end_char = m_width -1; int end_line = (start_char + text.size()) / m_width; int line_diff = end_line - (start_char / m_width); emit contentModified(m_scrollback->height() + point.y(), lines_changed, content_height_diff(old_content_height)); return { line_diff, end_char - point.x()}; }
void ScreenData::moveLine(int from, int to) { if (from == to) return; const size_t old_content_height = contentHeight(); if (to > from) to++; auto from_it = it_for_row_ensure_single_line_block(from); auto to_it = it_for_row_ensure_single_line_block(to); (*from_it)->clear(); m_screen_blocks.splice(to_it, m_screen_blocks, from_it); emit contentModified(m_scrollback->height() + to, 1, content_height_diff(old_content_height)); }