mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 19:35:32 +08:00
Utility functions to sort text messages by timestamp (ascending/descending)
* compare function for text message * resort function * text message edit can display HTML text messages with ascending/descending timestamp * made CTextMessageListModel -> CListModelTimestampObject
This commit is contained in:
committed by
Mat Sutcliffe
parent
25eb13a83f
commit
e12dc3a73a
@@ -21,15 +21,19 @@ namespace BlackGui
|
||||
CTextMessageView::CTextMessageView(QWidget *parent) : CViewBase(parent)
|
||||
{
|
||||
this->standardInit(new CTextMessageListModel(CTextMessageListModel::FromTo, this));
|
||||
this->m_menus |= MenuClear;
|
||||
m_menus |= MenuClear;
|
||||
}
|
||||
|
||||
void CTextMessageView::setTextMessageMode(CTextMessageListModel::TextMessageMode mode)
|
||||
{
|
||||
Q_ASSERT(this->m_model);
|
||||
this->m_model->setTextMessageMode(mode);
|
||||
Q_ASSERT(m_model);
|
||||
m_model->setTextMessageMode(mode);
|
||||
this->setSortIndicator();
|
||||
}
|
||||
|
||||
}
|
||||
bool CTextMessageView::isSortedByTimestampProperty() const
|
||||
{
|
||||
return m_model->isSortedByTimestampProperty();
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -32,7 +32,11 @@ namespace BlackGui
|
||||
|
||||
//! Set display mode
|
||||
void setTextMessageMode(BlackGui::Models::CTextMessageListModel::TextMessageMode mode);
|
||||
|
||||
//! Sorted by a timestamp property
|
||||
bool isSortedByTimestampProperty() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -107,8 +107,8 @@ namespace BlackGui
|
||||
|
||||
Q_UNUSED(sort);
|
||||
ModelClass *model = this->derivedModel();
|
||||
auto sortColumn = model->getSortColumn();
|
||||
auto sortOrder = model->getSortOrder();
|
||||
const auto sortColumn = model->getSortColumn();
|
||||
const auto sortOrder = model->getSortOrder();
|
||||
this->showLoadIndicator(container.size());
|
||||
CWorker *worker = CWorker::fromTask(this, "ViewSort", [model, container, sortColumn, sortOrder]()
|
||||
{
|
||||
@@ -300,7 +300,7 @@ namespace BlackGui
|
||||
if (!hasSelection()) { return 0; }
|
||||
int c = 0;
|
||||
|
||||
int lastUpdatedRow = -1;
|
||||
int lastUpdatedRow = -1;
|
||||
int firstUpdatedRow = -1;
|
||||
const CPropertyIndexList propertyIndexes(vm.indexes());
|
||||
const QModelIndexList indexes = this->selectedRows();
|
||||
@@ -503,6 +503,18 @@ namespace BlackGui
|
||||
m_model->sortByPropertyIndex(propertyIndex, order);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void CViewBase<T>::sort()
|
||||
{
|
||||
m_model->sort();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void CViewBase<T>::resort()
|
||||
{
|
||||
m_model->resort();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
QJsonObject CViewBase<T>::toJson(bool selectedOnly) const
|
||||
{
|
||||
|
||||
@@ -750,6 +750,12 @@ namespace BlackGui
|
||||
virtual Qt::SortOrder getSortOrder() const override { return m_model->getSortOrder(); }
|
||||
//! @}
|
||||
|
||||
//! Sort if columns or order changed
|
||||
void sort();
|
||||
|
||||
//! Resort ("forced sorting")
|
||||
void resort();
|
||||
|
||||
//! Column count
|
||||
int columnCount() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user