10 #include "gui/menus/menuaction.h"
15 using namespace swift::misc::aviation;
20 CAircraftCategoryTreeView::CAircraftCategoryTreeView(QWidget *parent) : QTreeView(parent)
23 this->setContextMenuPolicy(Qt::CustomContextMenu);
24 connect(
this, &CAircraftCategoryTreeView::customContextMenuRequested,
this,
25 &CAircraftCategoryTreeView::customMenu);
26 connect(
this, &CAircraftCategoryTreeView::expanded,
this, &CAircraftCategoryTreeView::onExpanded,
27 Qt::QueuedConnection);
32 if (!this->categoryModel()) {
return; }
44 if (!this->categoryModel()) {
return; }
45 this->categoryModel()->
clear();
52 if (this->categoryModel()) { this->categoryModel()->
setColumns(columns); }
55 void CAircraftCategoryTreeView::fullResizeToContentsImpl()
57 if (this->
isEmpty()) {
return; }
58 const int cc = this->categoryModel()->columnCount();
59 for (
int c = 0; c < cc; c++) { this->resizeColumnToContents(c); }
66 return qobject_cast<const CAircraftCategoryTreeModel *>(this->model());
71 return qobject_cast<CAircraftCategoryTreeModel *>(this->model());
81 void CAircraftCategoryTreeView::onExpanded(
const QModelIndex &index)
87 void CAircraftCategoryTreeView::customMenu(
const QPoint &point)
89 if (!this->categoryModel()) {
return; }
90 if (this->categoryModel()->container().
isEmpty()) {
return; }
92 QMenu *menu =
new QMenu(
this);
93 QAction *resize =
new QAction(CIcons::resize16(),
"Resize",
this);
94 connect(resize, &QAction::triggered,
this, &CAircraftCategoryTreeView::fullResizeToContentsImpl);
96 menu->addAction(resize);
97 menu->popup(this->viewport()->mapToGlobal(point));
void clear()
Clear everything.
const swift::misc::aviation::CAircraftCategoryList & container() const
Get container.
void updateContainer(const swift::misc::aviation::CAircraftCategoryList &categories)
Update container.
void setColumns(const CColumns &columns)
Set columns.
void fullResizeToContents()
Resize all columns.
void updateContainer(const swift::misc::aviation::CAircraftCategoryList &categories)
Update container.
bool isEmpty() const
Empty data.
void setColumns(const models::CColumns &columns)
Set columns.
void inputSignal()
Received input signal, or manually trigger.
const_reference frontOrDefault() const
Access the first element, or a default-initialized value if the sequence is empty.
Value object for aircraft categories.
Value object encapsulating a list of ICAO codes.
Models to be used with views, mainly QTableView.
Views, mainly QTableView.
Free functions in swift::misc.