Ref T529, allow to explicitly set no sort order in model/view

This commit is contained in:
Klaus Basan
2019-02-04 16:52:50 +01:00
committed by Mat Sutcliffe
parent 14c3c51585
commit 3aee73840d
5 changed files with 31 additions and 3 deletions

View File

@@ -38,7 +38,7 @@ namespace BlackGui
void CStatusMessagesDetail::appendStatusMessageToList(const CStatusMessage &message)
{
if (message.isEmpty()) { return; }
m_pending.push_front(message); // in many cases we want to havethe latest "on top"
m_pending.push_front(message); // in many cases we want to have the latest "on top"
m_dsDeferredUpdate.inputSignal();
}
@@ -87,6 +87,16 @@ namespace BlackGui
ui->filter_LogMessages->useRadioButtonDescriptiveIcons(oneCharacterText);
}
void CStatusMessagesDetail::setSorting(const CPropertyIndex &propertyIndex, Qt::SortOrder order)
{
ui->tvp_StatusMessages->setSorting(propertyIndex, order);
}
void CStatusMessagesDetail::setNoSorting()
{
ui->tvp_StatusMessages->setNoSorting();
}
void CStatusMessagesDetail::deferredUpdate()
{
if (m_pending.isEmpty()) { return; }

View File

@@ -69,6 +69,12 @@ namespace BlackGui
//! \copydoc BlackGui::Filters::CStatusMessageFilterBar::useRadioButtonDescriptiveIcons
void filterUseRadioButtonDescriptiveIcons(bool oneCharacterText);
//! Sorting for view
void setSorting(const BlackMisc::CPropertyIndex &propertyIndex, Qt::SortOrder order = Qt::AscendingOrder);
//! Disable sorting
void setNoSorting();
signals:
//! \copydoc BlackGui::Views::CStatusMessageView::modelDataChangedDigest
void modelDataChangedDigest(int count, bool withFilter);

View File

@@ -104,6 +104,12 @@ namespace BlackGui
bool CListModelBaseNonTemplate::setSorting(const CPropertyIndex &propertyIndex, Qt::SortOrder order)
{
if (propertyIndex.isEmpty())
{
this->setNoSorting();
return false;
}
const bool changedColumn = this->setSortColumnByPropertyIndex(propertyIndex);
const bool changedOrder = (m_sortOrder == order);
m_sortOrder = order;
@@ -112,7 +118,6 @@ namespace BlackGui
bool CListModelBaseNonTemplate::hasValidSortColumn() const
{
if (!(m_sortColumn >= 0 && m_sortColumn < m_columns.size())) { return false; }
return m_columns.isSortable(m_sortColumn);
}

View File

@@ -74,6 +74,9 @@ namespace BlackGui
//! Set sort column
virtual void setSortColumn(int column) { m_sortColumn = column; }
//! Disable sorting
void setNoSorting() { this->setSortColumn(-1); }
//! Sort by index
void sortByPropertyIndex(const BlackMisc::CPropertyIndex &propertyIndex, Qt::SortOrder order = Qt::AscendingOrder);

View File

@@ -171,9 +171,12 @@ namespace BlackGui
//! \copydoc BlackGui::Models::CListModelBaseNonTemplate::setSorting
virtual bool setSorting(const BlackMisc::CPropertyIndex &propertyIndex, Qt::SortOrder order = Qt::AscendingOrder) = 0;
//! Sort by index
//! \copydoc BlackGui::Models::CListModelBaseNonTemplate::sortByPropertyIndex
virtual void sortByPropertyIndex(const BlackMisc::CPropertyIndex &propertyIndex, Qt::SortOrder order = Qt::AscendingOrder) = 0;
//! \copydoc BlackGui::Models::CListModelBaseNonTemplate::setNoSorting
virtual void setNoSorting() = 0;
//! Allow to drag and/or drop value objects
virtual void allowDragDrop(bool allowDrag, bool allowDrop, bool allowDropJsonFile = false) = 0;
@@ -715,6 +718,7 @@ namespace BlackGui
virtual bool acceptDrop(const QMimeData *mimeData) const override;
virtual bool setSorting(const BlackMisc::CPropertyIndex &propertyIndex, Qt::SortOrder order = Qt::AscendingOrder) override;
virtual void sortByPropertyIndex(const BlackMisc::CPropertyIndex &propertyIndex, Qt::SortOrder order = Qt::AscendingOrder) override;
virtual void setNoSorting() override { m_model->setNoSorting(); }
//! @}
//! Column count