From 46683949163047405c55efc42fdd3c79e96cde0d Mon Sep 17 00:00:00 2001 From: deva Date: Mon, 4 Apr 2011 09:17:03 +0000 Subject: Fix journal view scrollbar jumpiness. Fix scroll to view on open of new macro. Added new attribute 'type' to checkgroupbox. --- client/viewer.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'client/viewer.cc') diff --git a/client/viewer.cc b/client/viewer.cc index eabcf16..4a194b4 100644 --- a/client/viewer.cc +++ b/client/viewer.cc @@ -112,7 +112,7 @@ Viewer::Viewer(QString cpr, QString templs, QString host, quint16 port, } #endif - journal = new QTextEdit(); + journal = new QPlainTextEdit(); journal->setReadOnly(true); journal->setFont(*fixedfont); l->addWidget(journal); @@ -199,7 +199,6 @@ void Viewer::update() } QString filename = journalpath + "/" + cpr.mid(2,2) + "/" + crypt + "/JOURNAL.TXT"; - // filename = "/home/senator/JOURNAL.TXT"; QTextCodec *cp850 = QTextCodec::codecForName("cp850"); if(!cp850) { @@ -213,12 +212,17 @@ void Viewer::update() QString jstrip; for(int i = 0; i < j.length(); i++) { - if(j[i] != '·') jstrip += j[i]; // Remove end of line symbols. + if(j[i] != '·' && j[i] != '') + jstrip += j[i]; // Remove end of line and file symbols. } - if(journal->toPlainText() != jstrip) { + if(jlast != jstrip) { + int max = journal->verticalScrollBar()->maximum(); int pos = journal->verticalScrollBar()->value(); journal->setPlainText(jstrip); + // Scroll to bottom if we were there already or on first update. + if(pos == max || jlast == "") pos = journal->verticalScrollBar()->maximum(); journal->verticalScrollBar()->setValue(pos); + jlast = jstrip; } } -- cgit v1.2.3