summaryrefslogtreecommitdiff
path: root/widgets/displaytext.cpp
diff options
context:
space:
mode:
authorChristoph Berg <christoph.berg@credativ.de>2019-03-11 14:19:23 +0100
committerChristoph Berg <christoph.berg@credativ.de>2019-03-11 14:19:23 +0100
commit200de07a95209a55d6019ba87f0abc78d302bf4c (patch)
tree3b2922eb5d89b01ad214cae492e871c3bfb5df18 /widgets/displaytext.cpp
parente0737c56c1e384e05064a0c6e1ac46979371041b (diff)
New upstream version 2.0.1+repackupstream/2.0.1+repack
Diffstat (limited to 'widgets/displaytext.cpp')
-rw-r--r--widgets/displaytext.cpp55
1 files changed, 49 insertions, 6 deletions
diff --git a/widgets/displaytext.cpp b/widgets/displaytext.cpp
index 73df8af6..ca3372f4 100644
--- a/widgets/displaytext.cpp
+++ b/widgets/displaytext.cpp
@@ -12,6 +12,8 @@
#include <QAction>
#include <QListIterator>
#include <QRegularExpression>
+#include <QScrollBar>
+#include <QDebug>
#include "Configuration.hpp"
#include "LotWUsers.hpp"
@@ -25,6 +27,8 @@ DisplayText::DisplayText(QWidget *parent)
: QTextEdit(parent)
, m_config {nullptr}
, erase_action_ {new QAction {tr ("&Erase"), this}}
+ , high_volume_ {false}
+ , modified_vertical_scrollbar_max_ {-1}
{
setReadOnly (true);
setUndoRedoEnabled (false);
@@ -68,14 +72,16 @@ void DisplayText::setContentFont(QFont const& font)
cursor.movePosition (QTextCursor::StartOfLine);
cursor.endEditBlock ();
- setTextCursor (cursor);
- ensureCursorVisible ();
+ if (!high_volume_ || !m_config || !m_config->decodes_from_top ())
+ {
+ setTextCursor (cursor);
+ ensureCursorVisible ();
+ }
}
void DisplayText::mouseDoubleClickEvent(QMouseEvent *e)
{
Q_EMIT selectCallsign(e->modifiers ());
- QTextEdit::mouseDoubleClickEvent(e);
}
void DisplayText::insertLineSpacer(QString const& line)
@@ -198,11 +204,44 @@ void DisplayText::appendText(QString const& text, QColor bg, QColor fg
// position so viewport scrolled to left
cursor.movePosition (QTextCursor::StartOfLine);
- setTextCursor (cursor);
- ensureCursorVisible ();
+ if (!high_volume_ || !m_config || !m_config->decodes_from_top ())
+ {
+ setTextCursor (cursor);
+ ensureCursorVisible ();
+ }
document ()->setMaximumBlockCount (document ()->maximumBlockCount ());
}
+void DisplayText::extend_vertical_scrollbar (int min, int max)
+{
+ if (high_volume_
+ && m_config && m_config->decodes_from_top ())
+ {
+ if (max && max != modified_vertical_scrollbar_max_)
+ {
+ auto vp_margins = viewportMargins ();
+ // add enough to vertical scroll bar range to allow last
+ // decode to just scroll of the top of the view port
+ max += viewport ()->height () - vp_margins.top () - vp_margins.bottom ();
+ modified_vertical_scrollbar_max_ = max;
+ }
+ verticalScrollBar ()->setRange (min, max);
+ }
+}
+
+void DisplayText::new_period ()
+{
+ extend_vertical_scrollbar (verticalScrollBar ()->minimum (), verticalScrollBar ()->maximum ());
+ if (high_volume_ && m_config && m_config->decodes_from_top () && !vertical_scroll_connection_)
+ {
+ vertical_scroll_connection_ = connect (verticalScrollBar (), &QScrollBar::rangeChanged
+ , [this] (int min, int max) {
+ extend_vertical_scrollbar (min, max );
+ });
+ }
+ verticalScrollBar ()->setSliderPosition (verticalScrollBar ()->maximum ());
+}
+
QString DisplayText::appendWorkedB4 (QString message, QString call, QString const& grid,
QColor * bg, QColor * fg, LogBook const& logBook,
QString const& currentBand, QString const& currentMode)
@@ -400,7 +439,11 @@ void DisplayText::displayDecodedText(DecodedText const& decodedText, QString con
}
else
{
- highlight_types types {Highlight::CQ, Highlight::LotW};
+ highlight_types types {Highlight::CQ};
+ if (m_config && m_config->lotw_users ().user (decodedText.CQersCall()))
+ {
+ types.push_back (Highlight::LotW);
+ }
set_colours (m_config, &bg, &fg, types);
}
}