diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2020-02-09 08:52:03 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-09 08:52:03 -0500 |
| commit | 1f1f99f253f981ae3d11e9df177a144d00dbce0e (patch) | |
| tree | 01d38125329508f5628f9221f797e303180c8fc3 /src/loglist.cpp | |
| parent | 718c2a56f91f824c5eab69d8cc16294f77243370 (diff) | |
| parent | 3a80685189967fbf4cfa002ac2b8a4fa421306ca (diff) | |
Merge pull request #994 from isanae/generic-file-list
New file tree
Diffstat (limited to 'src/loglist.cpp')
| -rw-r--r-- | src/loglist.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/loglist.cpp b/src/loglist.cpp index 5d6710c7..28aae0ff 100644 --- a/src/loglist.cpp +++ b/src/loglist.cpp @@ -27,7 +27,6 @@ const std::size_t MaxLines = 1000; LogModel::LogModel()
{
- connect(this, &LogModel::entryAdded, [&](auto&& e){ onEntryAdded(e); });
}
void LogModel::create()
@@ -42,7 +41,8 @@ LogModel& LogModel::instance() void LogModel::add(MOBase::log::Entry e)
{
- emit entryAdded(std::move(e));
+ QMetaObject::invokeMethod(
+ this, [this, e]{ onEntryAdded(std::move(e)); }, Qt::QueuedConnection);
}
void LogModel::clear()
@@ -173,13 +173,16 @@ LogList::LogList(QWidget* parent) this, &QWidget::customContextMenuRequested,
[&](auto&& pos){ onContextMenu(pos); });
- connect(
- model(), SIGNAL(rowsInserted(const QModelIndex &, int, int)),
- this, SLOT(scrollToBottom()));
+ connect(model(), &LogModel::rowsInserted, this, [&]{ onNewEntry(); });
+ connect(model(), &LogModel::dataChanged, this, [&]{ onNewEntry(); });
- connect(
- model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),
- this, SLOT(scrollToBottom()));
+ m_timer.setSingleShot(true);
+ connect(&m_timer, &QTimer::timeout, [&]{ scrollToBottom(); });
+}
+
+void LogList::onNewEntry()
+{
+ m_timer.start(std::chrono::milliseconds(10));
}
void LogList::setCore(OrganizerCore& core)
|
