mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Merge branch 'Qt' into RenderStarsOnTable
This commit is contained in:
commit
e5ad47e459
12 changed files with 342 additions and 56 deletions
2
Makefile
2
Makefile
|
@ -31,6 +31,7 @@ EXTRA_FLAGS = $(QTCXXFLAGS) $(GTKCFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) \
|
|||
|
||||
HEADERS = \
|
||||
qt-ui/addcylinderdialog.h \
|
||||
qt-ui/addweightsystemdialog.h \
|
||||
qt-ui/divelistview.h \
|
||||
qt-ui/maintab.h \
|
||||
qt-ui/mainwindow.h \
|
||||
|
@ -70,6 +71,7 @@ SOURCES = \
|
|||
webservice.c \
|
||||
qt-gui.cpp \
|
||||
qt-ui/addcylinderdialog.cpp \
|
||||
qt-ui/addweightsystemdialog.cpp \
|
||||
qt-ui/divelistview.cpp \
|
||||
qt-ui/maintab.cpp \
|
||||
qt-ui/mainwindow.cpp \
|
||||
|
|
39
qt-ui/addweightsystemdialog.cpp
Normal file
39
qt-ui/addweightsystemdialog.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* addweightsystemdialog.cpp
|
||||
*
|
||||
* classes for the add weightsystem dialog of Subsurface
|
||||
*
|
||||
*/
|
||||
#include "addweightsystemdialog.h"
|
||||
#include "ui_addweightsystemdialog.h"
|
||||
#include <QComboBox>
|
||||
#include <QDoubleSpinBox>
|
||||
#include "../conversions.h"
|
||||
#include "models.h"
|
||||
|
||||
AddWeightsystemDialog::AddWeightsystemDialog(QWidget *parent) : ui(new Ui::AddWeightsystemDialog())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
currentWeightsystem = NULL;
|
||||
}
|
||||
|
||||
void AddWeightsystemDialog::setWeightsystem(weightsystem_t *ws)
|
||||
{
|
||||
currentWeightsystem = ws;
|
||||
|
||||
ui->description->insert(QString(ws->description));
|
||||
if (get_units()->weight == units::KG)
|
||||
ui->weight->setValue(ws->weight.grams / 1000);
|
||||
else
|
||||
ui->weight->setValue(grams_to_lbs(ws->weight.grams));
|
||||
}
|
||||
|
||||
void AddWeightsystemDialog::updateWeightsystem()
|
||||
{
|
||||
currentWeightsystem->description = strdup(ui->description->text().toUtf8().data());
|
||||
if (get_units()->weight == units::KG)
|
||||
currentWeightsystem->weight.grams = ui->weight->value() * 1000;
|
||||
else
|
||||
currentWeightsystem->weight.grams = lbs_to_grams(ui->weight->value());
|
||||
}
|
||||
|
30
qt-ui/addweightsystemdialog.h
Normal file
30
qt-ui/addweightsystemdialog.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* addweightsystemdialog.h
|
||||
*
|
||||
* header file for the add weightsystem dialog of Subsurface
|
||||
*
|
||||
*/
|
||||
#ifndef ADDWEIGHTSYSTEMDIALOG_H
|
||||
#define ADDWEIGHTSYSTEMDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "../dive.h"
|
||||
|
||||
namespace Ui{
|
||||
class AddWeightsystemDialog;
|
||||
}
|
||||
|
||||
class AddWeightsystemDialog : public QDialog{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AddWeightsystemDialog(QWidget* parent = 0);
|
||||
void setWeightsystem(weightsystem_t *ws);
|
||||
void updateWeightsystem();
|
||||
|
||||
private:
|
||||
Ui::AddWeightsystemDialog *ui;
|
||||
weightsystem_t *currentWeightsystem;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
109
qt-ui/addweightsystemdialog.ui
Normal file
109
qt-ui/addweightsystemdialog.ui
Normal file
|
@ -0,0 +1,109 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AddWeightsystemDialog</class>
|
||||
<widget class="QDialog" name="AddWeightsystemDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>408</width>
|
||||
<height>186</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Weightsystem</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Weight</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="weight">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="inputMethodHints">
|
||||
<set>Qt::ImhFormattedNumbersOnly</set>
|
||||
</property>
|
||||
<property name="accelerated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="description"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>AddWeightsystemDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>269</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>AddWeightsystemDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>290</x>
|
||||
<y>269</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -7,6 +7,7 @@
|
|||
#include "maintab.h"
|
||||
#include "ui_maintab.h"
|
||||
#include "addcylinderdialog.h"
|
||||
#include "addweightsystemdialog.h"
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
|
@ -61,6 +62,9 @@ void MainTab::clearStats()
|
|||
|
||||
void MainTab::on_addCylinder_clicked()
|
||||
{
|
||||
if (cylindersModel->rowCount() >= MAX_CYLINDERS)
|
||||
return;
|
||||
|
||||
AddCylinderDialog dialog(this);
|
||||
cylinder_t *newCylinder = (cylinder_t*) malloc(sizeof(cylinder_t));
|
||||
newCylinder->type.description = "";
|
||||
|
@ -83,6 +87,33 @@ void MainTab::on_delCylinder_clicked()
|
|||
{
|
||||
}
|
||||
|
||||
void MainTab::on_addWeight_clicked()
|
||||
{
|
||||
if (weightModel->rowCount() >= MAX_WEIGHTSYSTEMS)
|
||||
return;
|
||||
|
||||
AddWeightsystemDialog dialog(this);
|
||||
weightsystem_t newWeightsystem;
|
||||
newWeightsystem.description = "";
|
||||
newWeightsystem.weight.grams = 0;
|
||||
|
||||
dialog.setWeightsystem(&newWeightsystem);
|
||||
int result = dialog.exec();
|
||||
if (result == QDialog::Rejected)
|
||||
return;
|
||||
|
||||
dialog.updateWeightsystem();
|
||||
weightModel->add(&newWeightsystem);
|
||||
}
|
||||
|
||||
void MainTab::on_editWeight_clicked()
|
||||
{
|
||||
}
|
||||
|
||||
void MainTab::on_delWeight_clicked()
|
||||
{
|
||||
}
|
||||
|
||||
void MainTab::reload()
|
||||
{
|
||||
cylindersModel->update();
|
||||
|
|
|
@ -31,6 +31,9 @@ public Q_SLOTS:
|
|||
void on_addCylinder_clicked();
|
||||
void on_editCylinder_clicked();
|
||||
void on_delCylinder_clicked();
|
||||
void on_addWeight_clicked();
|
||||
void on_editWeight_clicked();
|
||||
void on_delWeight_clicked();
|
||||
|
||||
private:
|
||||
Ui::MainTab *ui;
|
||||
|
|
|
@ -152,14 +152,14 @@
|
|||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_4">
|
||||
<widget class="QPushButton" name="editWeight">
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_5">
|
||||
<widget class="QPushButton" name="addWeight">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
|
@ -179,7 +179,7 @@
|
|||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_6">
|
||||
<widget class="QPushButton" name="delWeight">
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include <QtDebug>
|
||||
#include <QDateTime>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QSettings>
|
||||
#include <QCloseEvent>
|
||||
|
||||
#include "divelistview.h"
|
||||
#include "starwidget.h"
|
||||
|
@ -31,6 +33,7 @@ MainWindow::MainWindow() : ui(new Ui::MainWindow()),
|
|||
ui->ListWidget->setModel(sortModel);
|
||||
|
||||
setWindowIcon(QIcon(":subsurface-icon"));
|
||||
readSettings();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionNew_triggered()
|
||||
|
@ -41,9 +44,8 @@ void MainWindow::on_actionNew_triggered()
|
|||
void MainWindow::on_actionOpen_triggered()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::homePath(), filter());
|
||||
if (filename.isEmpty()) {
|
||||
if (filename.isEmpty())
|
||||
return;
|
||||
}
|
||||
|
||||
// Needed to convert to char*
|
||||
QByteArray fileNamePtr = filename.toLocal8Bit();
|
||||
|
@ -54,15 +56,13 @@ void MainWindow::on_actionOpen_triggered()
|
|||
parse_file(fileNamePtr.data(), &error);
|
||||
set_filename(fileNamePtr.data(), TRUE);
|
||||
|
||||
if (error != NULL)
|
||||
{
|
||||
if (error != NULL) {
|
||||
QMessageBox::warning(this, "Error", error->message);
|
||||
g_error_free(error);
|
||||
error = NULL;
|
||||
}
|
||||
|
||||
//WARNING: Port This method to Qt
|
||||
report_dives(FALSE, FALSE);
|
||||
process_dives(FALSE, FALSE);
|
||||
|
||||
ui->InfoWidget->reload();
|
||||
|
||||
|
@ -84,15 +84,12 @@ void MainWindow::on_actionSaveAs_triggered()
|
|||
void MainWindow::on_actionClose_triggered()
|
||||
{
|
||||
if (unsaved_changes() && (askSaveChanges() == FALSE))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* free the dives and trips */
|
||||
while (dive_table.nr)
|
||||
{
|
||||
delete_single_dive(0);
|
||||
}
|
||||
|
||||
mark_divelist_changed(FALSE);
|
||||
|
||||
/* clear the selection and the statistics */
|
||||
|
@ -139,6 +136,8 @@ void MainWindow::on_actionPreferences_triggered()
|
|||
void MainWindow::on_actionQuit_triggered()
|
||||
{
|
||||
qDebug("actionQuit");
|
||||
if (unsaved_changes() && (askSaveChanges() == FALSE))
|
||||
return;
|
||||
}
|
||||
|
||||
void MainWindow::on_actionDownloadDC_triggered()
|
||||
|
@ -285,3 +284,36 @@ bool MainWindow::askSaveChanges()
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MainWindow::readSettings()
|
||||
{
|
||||
QSettings settings("hohndel.org","subsurface");
|
||||
|
||||
settings.beginGroup("MainWindow");
|
||||
QSize sz = settings.value("size").value<QSize>();
|
||||
resize(sz);
|
||||
ui->mainSplitter->restoreState(settings.value("mainSplitter").toByteArray());
|
||||
ui->infoProfileSplitter->restoreState(settings.value("infoProfileSplitter").toByteArray());
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
void MainWindow::writeSettings()
|
||||
{
|
||||
QSettings settings("hohndel.org","subsurface");
|
||||
settings.beginGroup("MainWindow");
|
||||
settings.setValue("size",size());
|
||||
settings.setValue("mainSplitter", ui->mainSplitter->saveState());
|
||||
settings.setValue("infoProfileSplitter", ui->infoProfileSplitter->saveState());
|
||||
settings.endGroup();
|
||||
/* other groups here; avoid '/' and '\' in keys with setValue(...) please */
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (unsaved_changes() && (askSaveChanges() == FALSE)) {
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
event->accept();
|
||||
writeSettings();
|
||||
}
|
||||
|
|
|
@ -66,12 +66,17 @@ private Q_SLOTS:
|
|||
void on_actionAboutSubsurface_triggered();
|
||||
void on_actionUserManual_triggered();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
DiveTripModel *model;
|
||||
QSortFilterProxyModel *sortModel;
|
||||
QString filter();
|
||||
bool askSaveChanges();
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter_3">
|
||||
<widget class="QSplitter" name="mainSplitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="QSplitter" name="splitter_2">
|
||||
<widget class="QSplitter" name="infoProfileSplitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
|
@ -34,13 +34,6 @@
|
|||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
|
@ -49,7 +42,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>763</width>
|
||||
<height>25</height>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
|
|
@ -60,9 +60,7 @@ QVariant CylindersModel::data(const QModelIndex& index, int role) const
|
|||
if (!index.isValid() || index.row() >= MAX_CYLINDERS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct dive *d = get_dive(selected_dive);
|
||||
cylinder_t& cyl = d->cylinder[index.row()];
|
||||
cylinder_t& cyl = current_dive->cylinder[index.row()];
|
||||
|
||||
if (role == Qt::DisplayRole) {
|
||||
switch(index.column()) {
|
||||
|
@ -94,67 +92,93 @@ QVariant CylindersModel::data(const QModelIndex& index, int role) const
|
|||
|
||||
int CylindersModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
return usedRows[currentDive];
|
||||
return usedRows[current_dive];
|
||||
}
|
||||
|
||||
void CylindersModel::add(cylinder_t* cyl)
|
||||
{
|
||||
if (usedRows[currentDive] >= MAX_CYLINDERS) {
|
||||
if (usedRows[current_dive] >= MAX_CYLINDERS) {
|
||||
free(cyl);
|
||||
return;
|
||||
}
|
||||
|
||||
int row = usedRows[currentDive];
|
||||
int row = usedRows[current_dive];
|
||||
|
||||
cylinder_t& cylinder = currentDive->cylinder[row];
|
||||
cylinder_t& cylinder = current_dive->cylinder[row];
|
||||
|
||||
cylinder.end.mbar = cyl->end.mbar;
|
||||
cylinder.start.mbar = cyl->start.mbar;
|
||||
|
||||
beginInsertRows(QModelIndex(), row, row);
|
||||
usedRows[currentDive]++;
|
||||
usedRows[current_dive]++;
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void CylindersModel::update()
|
||||
{
|
||||
if (usedRows[currentDive] > 0) {
|
||||
beginRemoveRows(QModelIndex(), 0, usedRows[currentDive]-1);
|
||||
if (usedRows[current_dive] > 0) {
|
||||
beginRemoveRows(QModelIndex(), 0, usedRows[current_dive]-1);
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
currentDive = get_dive(selected_dive);
|
||||
if (usedRows[currentDive] > 0) {
|
||||
beginInsertRows(QModelIndex(), 0, usedRows[currentDive]-1);
|
||||
if (usedRows[current_dive] > 0) {
|
||||
beginInsertRows(QModelIndex(), 0, usedRows[current_dive]-1);
|
||||
endInsertRows();
|
||||
}
|
||||
}
|
||||
|
||||
void CylindersModel::clear()
|
||||
{
|
||||
if (usedRows[currentDive] > 0) {
|
||||
beginRemoveRows(QModelIndex(), 0, usedRows[currentDive]-1);
|
||||
usedRows[currentDive] = 0;
|
||||
if (usedRows[current_dive] > 0) {
|
||||
beginRemoveRows(QModelIndex(), 0, usedRows[current_dive]-1);
|
||||
usedRows[current_dive] = 0;
|
||||
endRemoveRows();
|
||||
}
|
||||
}
|
||||
|
||||
void WeightModel::clear()
|
||||
{
|
||||
if (usedRows[current_dive] > 0) {
|
||||
beginRemoveRows(QModelIndex(), 0, usedRows[current_dive]-1);
|
||||
usedRows[current_dive] = 0;
|
||||
endRemoveRows();
|
||||
}
|
||||
}
|
||||
|
||||
int WeightModel::columnCount(const QModelIndex& parent) const
|
||||
{
|
||||
return 0;
|
||||
return 2;
|
||||
}
|
||||
|
||||
QVariant WeightModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
return QVariant();
|
||||
QVariant ret;
|
||||
if (!index.isValid() || index.row() >= MAX_WEIGHTSYSTEMS) {
|
||||
return ret;
|
||||
}
|
||||
weightsystem_t *ws = ¤t_dive->weightsystem[index.row()];
|
||||
|
||||
if (role == Qt::DisplayRole) {
|
||||
switch(index.column()) {
|
||||
case TYPE:
|
||||
ret = QString(ws->description);
|
||||
break;
|
||||
case WEIGHT:
|
||||
if (get_units()->weight == units::KG) {
|
||||
int gr = ws->weight.grams % 1000;
|
||||
int kg = ws->weight.grams / 1000;
|
||||
ret = QString("%1.%2").arg(kg).arg((unsigned)(gr + 500) / 100);
|
||||
} else {
|
||||
ret = QString("%1").arg((unsigned)(grams_to_lbs(ws->weight.grams) + 0.5));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int WeightModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
return rows;
|
||||
return usedRows[current_dive];
|
||||
}
|
||||
|
||||
QVariant WeightModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
|
@ -164,19 +188,36 @@ QVariant WeightModel::headerData(int section, Qt::Orientation orientation, int r
|
|||
return ret;
|
||||
}
|
||||
|
||||
switch(section) {
|
||||
case TYPE:
|
||||
ret = tr("Type");
|
||||
break;
|
||||
case WEIGHT:
|
||||
ret = tr("Weight");
|
||||
break;
|
||||
if (role == Qt::DisplayRole) {
|
||||
switch(section) {
|
||||
case TYPE:
|
||||
ret = tr("Type");
|
||||
break;
|
||||
case WEIGHT:
|
||||
ret = tr("Weight");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void WeightModel::add(weight_t* weight)
|
||||
void WeightModel::add(weightsystem_t* weight)
|
||||
{
|
||||
if (usedRows[current_dive] >= MAX_WEIGHTSYSTEMS) {
|
||||
free(weight);
|
||||
return;
|
||||
}
|
||||
|
||||
int row = usedRows[current_dive];
|
||||
|
||||
weightsystem_t *ws = ¤t_dive->weightsystem[row];
|
||||
|
||||
ws->description = weight->description;
|
||||
ws->weight.grams = weight->weight.grams;
|
||||
|
||||
beginInsertRows(QModelIndex(), row, row);
|
||||
usedRows[current_dive]++;
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void WeightModel::update()
|
||||
|
|
|
@ -50,28 +50,29 @@ public:
|
|||
void clear();
|
||||
void update();
|
||||
private:
|
||||
dive *currentDive;
|
||||
|
||||
/* Since the dive doesn`t stores the number of cylinders that
|
||||
* it has ( max 8 ) and since I don`t want to make a
|
||||
* model-for-each-dive, let`s hack this here instead. */
|
||||
QMap<dive*, int> usedRows;
|
||||
QMap<struct dive *, int> usedRows;
|
||||
};
|
||||
|
||||
/* Encapsulation of the Weight Model, that represents
|
||||
* the current weights on a dive. */
|
||||
class WeightModel : public QAbstractTableModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Column {TYPE, WEIGHT};
|
||||
/*reimp*/ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
/*reimp*/ int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
||||
/*reimp*/ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||
/*reimp*/ int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
||||
|
||||
void add(weight_t *weight);
|
||||
void add(weightsystem_t *weight);
|
||||
void clear();
|
||||
void update();
|
||||
private:
|
||||
int rows;
|
||||
/* Remember the number of rows in a dive */
|
||||
QMap<struct dive *, int> usedRows;
|
||||
};
|
||||
|
||||
/*! An AbstractItemModel for recording dive trip information such as a list of dives.
|
||||
|
|
Loading…
Reference in a new issue