subsurface/desktop-widgets/tab-widgets/TabDiveComputer.cpp
Berthold Stoeger 291768b63c desktop: rename table widget in DiveComputerTab to "devices"
The custom TableView widget saves the table width on destruction.
For that, it uses the "objectName()". Since the table of the
DiveComputerTab was simply called "table" in the UI file, the
widths were saved in that generic section. To avoid future
name-conflicts, rename the widget to "devices".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-07 11:37:51 -08:00

33 lines
949 B
C++

// SPDX-License-Identifier: GPL-2.0
#include "TabDiveComputer.h"
#include "ui_TabDiveExtraInfo.h"
TabDiveComputer::TabDiveComputer(QWidget *parent) : TabBase(parent)
{
ui.setupUi(this);
sortedModel.setSourceModel(&model);
ui.devices->setModel(&sortedModel);
ui.devices->view()->setSelectionBehavior(QAbstractItemView::SelectRows);
ui.devices->view()->setSelectionMode(QAbstractItemView::SingleSelection);
ui.devices->view()->setSortingEnabled(true);
ui.devices->view()->sortByColumn(DiveComputerModel::MODEL, Qt::AscendingOrder);
ui.devices->view()->horizontalHeader()->setStretchLastSection(true);
connect(ui.devices, &TableView::itemClicked, this, &TabDiveComputer::tableClicked);
}
void TabDiveComputer::updateData()
{
}
void TabDiveComputer::clear()
{
}
void TabDiveComputer::tableClicked(const QModelIndex &index)
{
if (!index.isValid())
return;
if (index.column() == DiveComputerModel::REMOVE)
sortedModel.remove(index);
}