Support for an empty column

This commit is contained in:
Klaus Basan
2019-04-26 01:16:39 +02:00
parent c51dce8bfd
commit 99c6a03b6f
9 changed files with 64 additions and 2 deletions

View File

@@ -73,6 +73,13 @@ namespace BlackGui
return CColumn(headerName, toolTip, propertyIndex, new CIntegerFormatter(alignment));
}
CColumn CColumn::emptyColumn()
{
CColumn col = CColumn("", "", CPropertyIndex::GlobalIndexEmpty, new CEmptyFormatter());
col.setWidthPercentage(1);
return col;
}
// --------------- columns ----------------------------------------------
CColumns::CColumns(const QString &translationContext, QObject *parent) :
@@ -236,6 +243,19 @@ namespace BlackGui
return widths;
}
void CColumns::insertEmptyColumn()
{
if (this->endsWithEmptyColumn()) { return; }
this->addColumn(CColumn::emptyColumn());
}
bool CColumns::endsWithEmptyColumn() const
{
if (m_columns.isEmpty()) { return false; }
const CColumn c = m_columns.last();
return c.getPropertyIndex() == CPropertyIndex::GlobalIndexEmpty;
}
const CDefaultFormatter *CColumns::getFormatter(const QModelIndex &index) const
{
if (!isValidColumn(index)) { return nullptr; }