diff --git a/src/blackgui/views/aircraftcategorytreeview.cpp b/src/blackgui/views/aircraftcategorytreeview.cpp index 2a860bbf9..a965720ee 100644 --- a/src/blackgui/views/aircraftcategorytreeview.cpp +++ b/src/blackgui/views/aircraftcategorytreeview.cpp @@ -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(this->model()); diff --git a/src/blackgui/views/aircraftcategorytreeview.h b/src/blackgui/views/aircraftcategorytreeview.h index 6add0ab07..98d824bfd 100644 --- a/src/blackgui/views/aircraftcategorytreeview.h +++ b/src/blackgui/views/aircraftcategorytreeview.h @@ -52,6 +52,9 @@ namespace BlackGui //! Resize all columns void fullResizeToContents(); + //! Empty data + bool isEmpty() const; + private: //! Used model const Models::CAircraftCategoryTreeModel *categoryModel() const;