aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCerapter <cerap@protonmail.com>2018-08-14 18:32:41 +0200
committerCerapter <cerap@protonmail.com>2018-08-14 18:32:41 +0200
commitaf4a62b65d07d9afff137d55906e38cef6356300 (patch)
tree0dd68496a457f5f7ab3051431d7ae4dc7c7d1ff5
parent0f8cb919e289d433d8a7e84b16b934c2b04c7dd2 (diff)
Fixed chatlog not working properly.
-rw-r--r--courtroom.cpp82
1 files changed, 40 insertions, 42 deletions
diff --git a/courtroom.cpp b/courtroom.cpp
index 8d500157..293b39d5 100644
--- a/courtroom.cpp
+++ b/courtroom.cpp
@@ -1421,6 +1421,16 @@ void Courtroom::append_ic_text(QString p_text, QString p_name)
ui_ic_chatlog->textCursor().insertText(p_text, normal);
+ // If we got too many blocks in the current log, delete some from the top.
+ while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks)
+ {
+ ui_ic_chatlog->moveCursor(QTextCursor::Start);
+ ui_ic_chatlog->textCursor().select(QTextCursor::BlockUnderCursor);
+ ui_ic_chatlog->textCursor().removeSelectedText();
+ ui_ic_chatlog->textCursor().deleteChar();
+ //qDebug() << ui_ic_chatlog->document()->blockCount() << " < " << log_maximum_blocks;
+ }
+
if (old_cursor.hasSelection() || !is_scrolled_down)
{
// The user has selected text or scrolled away from the bottom: maintain position.
@@ -1433,16 +1443,6 @@ void Courtroom::append_ic_text(QString p_text, QString p_name)
ui_ic_chatlog->moveCursor(QTextCursor::End);
ui_ic_chatlog->verticalScrollBar()->setValue(ui_ic_chatlog->verticalScrollBar()->maximum());
}
-
- // Finally, if we got too many blocks in the current log, delete some from the top.
- while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks)
- {
- ui_ic_chatlog->moveCursor(QTextCursor::Start);
- ui_ic_chatlog->textCursor().select(QTextCursor::BlockUnderCursor);
- ui_ic_chatlog->textCursor().removeSelectedText();
- ui_ic_chatlog->textCursor().deleteChar();
- //qDebug() << ui_ic_chatlog->document()->blockCount() << " < " << log_maximum_blocks;
- }
}
else
{
@@ -1453,6 +1453,16 @@ void Courtroom::append_ic_text(QString p_text, QString p_name)
ui_ic_chatlog->textCursor().insertText(p_name, bold);
ui_ic_chatlog->textCursor().insertText(p_text + '\n', normal);
+ // If we got too many blocks in the current log, delete some from the bottom.
+ while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks)
+ {
+ ui_ic_chatlog->moveCursor(QTextCursor::End);
+ ui_ic_chatlog->textCursor().select(QTextCursor::BlockUnderCursor);
+ ui_ic_chatlog->textCursor().removeSelectedText();
+ ui_ic_chatlog->textCursor().deletePreviousChar();
+ //qDebug() << ui_ic_chatlog->document()->blockCount() << " < " << log_maximum_blocks;
+ }
+
if (old_cursor.hasSelection() || !is_scrolled_up)
{
// The user has selected text or scrolled away from the top: maintain position.
@@ -1465,17 +1475,6 @@ void Courtroom::append_ic_text(QString p_text, QString p_name)
ui_ic_chatlog->moveCursor(QTextCursor::Start);
ui_ic_chatlog->verticalScrollBar()->setValue(ui_ic_chatlog->verticalScrollBar()->minimum());
}
-
-
- // Finally, if we got too many blocks in the current log, delete some from the bottom.
- while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks)
- {
- ui_ic_chatlog->moveCursor(QTextCursor::End);
- ui_ic_chatlog->textCursor().select(QTextCursor::BlockUnderCursor);
- ui_ic_chatlog->textCursor().removeSelectedText();
- ui_ic_chatlog->textCursor().deletePreviousChar();
- //qDebug() << ui_ic_chatlog->document()->blockCount() << " < " << log_maximum_blocks;
- }
}
}
@@ -1511,6 +1510,16 @@ void Courtroom::append_ic_songchange(QString p_songname, QString p_name)
ui_ic_chatlog->textCursor().insertText(p_songname, italics);
ui_ic_chatlog->textCursor().insertText(".", normal);
+ // If we got too many blocks in the current log, delete some from the top.
+ while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks)
+ {
+ ui_ic_chatlog->moveCursor(QTextCursor::Start);
+ ui_ic_chatlog->textCursor().select(QTextCursor::BlockUnderCursor);
+ ui_ic_chatlog->textCursor().removeSelectedText();
+ ui_ic_chatlog->textCursor().deleteChar();
+ //qDebug() << ui_ic_chatlog->document()->blockCount() << " < " << log_maximum_blocks;
+ }
+
if (old_cursor.hasSelection() || !is_scrolled_down)
{
// The user has selected text or scrolled away from the bottom: maintain position.
@@ -1523,16 +1532,6 @@ void Courtroom::append_ic_songchange(QString p_songname, QString p_name)
ui_ic_chatlog->moveCursor(QTextCursor::End);
ui_ic_chatlog->verticalScrollBar()->setValue(ui_ic_chatlog->verticalScrollBar()->maximum());
}
-
- // Finally, if we got too many blocks in the current log, delete some from the top.
- while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks)
- {
- ui_ic_chatlog->moveCursor(QTextCursor::Start);
- ui_ic_chatlog->textCursor().select(QTextCursor::BlockUnderCursor);
- ui_ic_chatlog->textCursor().removeSelectedText();
- ui_ic_chatlog->textCursor().deleteChar();
- //qDebug() << ui_ic_chatlog->document()->blockCount() << " < " << log_maximum_blocks;
- }
}
else
{
@@ -1546,6 +1545,16 @@ void Courtroom::append_ic_songchange(QString p_songname, QString p_name)
ui_ic_chatlog->textCursor().insertText(p_songname, italics);
ui_ic_chatlog->textCursor().insertText(".", normal);
+ // If we got too many blocks in the current log, delete some from the bottom.
+ while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks)
+ {
+ ui_ic_chatlog->moveCursor(QTextCursor::End);
+ ui_ic_chatlog->textCursor().select(QTextCursor::BlockUnderCursor);
+ ui_ic_chatlog->textCursor().removeSelectedText();
+ ui_ic_chatlog->textCursor().deletePreviousChar();
+ //qDebug() << ui_ic_chatlog->document()->blockCount() << " < " << log_maximum_blocks;
+ }
+
if (old_cursor.hasSelection() || !is_scrolled_up)
{
// The user has selected text or scrolled away from the top: maintain position.
@@ -1558,17 +1567,6 @@ void Courtroom::append_ic_songchange(QString p_songname, QString p_name)
ui_ic_chatlog->moveCursor(QTextCursor::Start);
ui_ic_chatlog->verticalScrollBar()->setValue(ui_ic_chatlog->verticalScrollBar()->minimum());
}
-
-
- // Finally, if we got too many blocks in the current log, delete some from the bottom.
- while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks)
- {
- ui_ic_chatlog->moveCursor(QTextCursor::End);
- ui_ic_chatlog->textCursor().select(QTextCursor::BlockUnderCursor);
- ui_ic_chatlog->textCursor().removeSelectedText();
- ui_ic_chatlog->textCursor().deletePreviousChar();
- //qDebug() << ui_ic_chatlog->document()->blockCount() << " < " << log_maximum_blocks;
- }
}
}