mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Ref T190, improved display of text messages
* tooltip * using QStringBuilder
This commit is contained in:
@@ -81,5 +81,15 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant CTextMessageListModel::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
if (role == Qt::ToolTipRole)
|
||||||
|
{
|
||||||
|
// the underlying model object as summary
|
||||||
|
const CTextMessage model(this->at(index));
|
||||||
|
return model.asHtmlSummary("<br>");
|
||||||
|
}
|
||||||
|
return CListModelBase::data(index, role);
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ namespace BlackGui
|
|||||||
//! Mode
|
//! Mode
|
||||||
TextMessageMode getTextMessageMode() const { return m_textMessageMode; }
|
TextMessageMode getTextMessageMode() const { return m_textMessageMode; }
|
||||||
|
|
||||||
|
//! \copydoc QAbstractItemModel::data
|
||||||
|
virtual QVariant data(const QModelIndex &index, int role) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TextMessageMode m_textMessageMode = NotSet;
|
TextMessageMode m_textMessageMode = NotSet;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ namespace BlackGui
|
|||||||
this->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
this->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||||
this->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
this->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||||
this->setWordWrap(true);
|
this->setWordWrap(true);
|
||||||
|
this->setTextElideMode(Qt::ElideMiddle);
|
||||||
|
|
||||||
// shortcuts
|
// shortcuts
|
||||||
QShortcut *filter = new QShortcut(CShortcut::keyDisplayFilter(), this, SLOT(ps_displayFilterDialog()), nullptr, Qt::WidgetShortcut);
|
QShortcut *filter = new QShortcut(CShortcut::keyDisplayFilter(), this, SLOT(ps_displayFilterDialog()), nullptr, Qt::WidgetShortcut);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include <Qt>
|
#include <Qt>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <QStringBuilder>
|
||||||
|
|
||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
@@ -37,17 +38,13 @@ namespace BlackMisc
|
|||||||
|
|
||||||
QString CTextMessage::convertToQString(bool i18n) const
|
QString CTextMessage::convertToQString(bool i18n) const
|
||||||
{
|
{
|
||||||
QString s(m_message);
|
|
||||||
if (this->isPrivateMessage())
|
if (this->isPrivateMessage())
|
||||||
{
|
{
|
||||||
s.append(" ").append(m_senderCallsign.toQString(i18n));
|
return m_message %
|
||||||
s.append(" ").append(m_recipientCallsign.toQString(i18n));
|
QStringLiteral(" ") % m_senderCallsign.toQString(i18n) %
|
||||||
|
QStringLiteral(" ") % m_recipientCallsign.toQString(i18n);
|
||||||
}
|
}
|
||||||
else
|
return m_message % QStringLiteral(" ") % m_frequency.toQString(i18n);
|
||||||
{
|
|
||||||
s.append(" ").append(m_frequency.toQString(i18n));
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CTextMessage::isPrivateMessage() const
|
bool CTextMessage::isPrivateMessage() const
|
||||||
@@ -171,6 +168,11 @@ namespace BlackMisc
|
|||||||
return { this, CStatusMessage::SeverityInfo, m };
|
return { this, CStatusMessage::SeverityInfo, m };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CTextMessage::asHtmlSummary(const QString &separator) const
|
||||||
|
{
|
||||||
|
return this->asString(true, true, separator);
|
||||||
|
}
|
||||||
|
|
||||||
void CTextMessage::toggleSenderRecipient()
|
void CTextMessage::toggleSenderRecipient()
|
||||||
{
|
{
|
||||||
qSwap(m_senderCallsign, m_recipientCallsign);
|
qSwap(m_senderCallsign, m_recipientCallsign);
|
||||||
|
|||||||
@@ -119,6 +119,9 @@ namespace BlackMisc
|
|||||||
//! \param separator values separated by given value
|
//! \param separator values separated by given value
|
||||||
CStatusMessage asStatusMessage(bool withSender, bool withRecipient, const QString &separator = ", ") const;
|
CStatusMessage asStatusMessage(bool withSender, bool withRecipient, const QString &separator = ", ") const;
|
||||||
|
|
||||||
|
//! Summary HTML code
|
||||||
|
QString asHtmlSummary(const QString &separator = "<br>") const;
|
||||||
|
|
||||||
//! Toggle sender receiver, can be used to ping my own message
|
//! Toggle sender receiver, can be used to ping my own message
|
||||||
void toggleSenderRecipient();
|
void toggleSenderRecipient();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user