mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
Text message view, scroll down if sorted by timestamp
This commit is contained in:
committed by
Mat Sutcliffe
parent
a1ea9a2e10
commit
9dc85da42d
@@ -186,6 +186,7 @@ namespace BlackGui
|
||||
const bool playNotification = sGui && sGui->getIContextAudio();
|
||||
const bool audioCsMentioned = playNotification && m_audioSettings.get().textCallsignMentioned();
|
||||
|
||||
bool addedToAllMessages = false;
|
||||
for (const CTextMessage &message : messages)
|
||||
{
|
||||
bool relevantForMe = false;
|
||||
@@ -246,6 +247,7 @@ namespace BlackGui
|
||||
{
|
||||
ui->tvp_TextMessagesAll->push_back(message); // no sorting
|
||||
ui->tvp_TextMessagesAll->resort();
|
||||
addedToAllMessages = true;
|
||||
}
|
||||
if (!relevantForMe) { continue; }
|
||||
|
||||
@@ -262,6 +264,11 @@ namespace BlackGui
|
||||
}
|
||||
} // message
|
||||
} // for
|
||||
|
||||
if (addedToAllMessages && ui->tvp_TextMessagesAll->isSortedByTimestampPropertyLatestLast())
|
||||
{
|
||||
ui->tvp_TextMessagesAll->scrollToBottom();
|
||||
}
|
||||
}
|
||||
|
||||
void CTextMessageComponent::onChangedAircraftCockpit(const CSimulatedAircraft &aircraft, const CIdentifier &originator)
|
||||
|
||||
@@ -2,14 +2,6 @@
|
||||
<ui version="4.0">
|
||||
<class>CTextMessageComponent</class>
|
||||
<widget class="QFrame" name="CTextMessageComponent">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>300</width>
|
||||
<height>367</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Text messages</string>
|
||||
</property>
|
||||
@@ -56,21 +48,12 @@
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Views::CTextMessageView" name="tvp_TextMessagesAll">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
||||
</property>
|
||||
<property name="autoScroll">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
|
||||
@@ -35,5 +35,11 @@ namespace BlackGui
|
||||
{
|
||||
return m_model->isSortedByTimestampProperty();
|
||||
}
|
||||
|
||||
bool CTextMessageView::isSortedByTimestampPropertyLatestLast() const
|
||||
{
|
||||
return m_model->isSortedByTimestampProperty() && this->getSortOrder() == Qt::AscendingOrder;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -35,6 +35,9 @@ namespace BlackGui
|
||||
|
||||
//! Sorted by a timestamp property
|
||||
bool isSortedByTimestampProperty() const;
|
||||
|
||||
//! Sorted by a timestamp property, latest messages at the end
|
||||
bool isSortedByTimestampPropertyLatestLast() const;
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user