Ref T472, isEmpty for category tree

This commit is contained in:
Klaus Basan
2019-02-05 16:28:55 +01:00
committed by Mat Sutcliffe
parent 001d90bd6b
commit ac7958367b
2 changed files with 11 additions and 2 deletions

View File

@@ -39,7 +39,7 @@ namespace BlackGui
{
if (!this->categoryModel()) { return; }
this->categoryModel()->updateContainer(categories);
this->expandAll();
if (!this->isEmpty()) { this->expandAll(); }
}
void CAircraftCategoryTreeView::clear()
@@ -55,12 +55,18 @@ namespace BlackGui
void CAircraftCategoryTreeView::fullResizeToContents()
{
for (int c = 0; c < this->model()->columnCount(); c++)
if (this->isEmpty()) { return; }
for (int c = 0; c < this->categoryModel()->columnCount(); c++)
{
this->resizeColumnToContents(c);
}
}
bool CAircraftCategoryTreeView::isEmpty() const
{
return this->categoryModel()->rowCount() < 1;
}
const CAircraftCategoryTreeModel *CAircraftCategoryTreeView::categoryModel() const
{
return qobject_cast<const CAircraftCategoryTreeModel *>(this->model());

View File

@@ -52,6 +52,9 @@ namespace BlackGui
//! Resize all columns
void fullResizeToContents();
//! Empty data
bool isEmpty() const;
private:
//! Used model
const Models::CAircraftCategoryTreeModel *categoryModel() const;