summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/tab-widgets/TabDiveComputer.cpp
blob: d4b0f5ccef691a50ca4facfa9c45c8e982ed07a2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// SPDX-License-Identifier: GPL-2.0
#include "TabDiveComputer.h"
#include "ui_TabDiveExtraInfo.h"
#include "qt-models/divecomputermodel.h"

TabDiveComputer::TabDiveComputer(QWidget *parent) : TabBase(parent)
{
	ui.setupUi(this);

	DiveComputerModel *model = new DiveComputerModel(this);
	sortedModel = new DiveComputerSortedModel(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);
}