2013-10-16 19:05:19 +00:00
|
|
|
#include <QtDebug>
|
|
|
|
#include <QFileDialog>
|
2014-04-25 17:44:23 +00:00
|
|
|
#include <QShortcut>
|
2013-12-29 16:11:20 +00:00
|
|
|
#include "divelogimportdialog.h"
|
2013-10-16 19:05:19 +00:00
|
|
|
#include "mainwindow.h"
|
2013-12-29 16:11:20 +00:00
|
|
|
#include "ui_divelogimportdialog.h"
|
2015-01-06 16:32:03 +00:00
|
|
|
#include <QAbstractListModel>
|
|
|
|
#include <QAbstractTableModel>
|
2015-01-06 17:03:58 +00:00
|
|
|
#include <QMouseEvent>
|
|
|
|
#include <QDrag>
|
|
|
|
#include <QMimeData>
|
2015-01-06 18:11:27 +00:00
|
|
|
#include <QFile>
|
|
|
|
|
2015-01-06 19:32:29 +00:00
|
|
|
static QString subsurface_mimedata = "subsurface/csvcolumns";
|
|
|
|
|
2013-12-29 16:11:20 +00:00
|
|
|
const DiveLogImportDialog::CSVAppConfig DiveLogImportDialog::CSVApps[CSVAPPS] = {
|
2014-07-10 18:54:18 +00:00
|
|
|
// time, depth, temperature, po2, cns, ndl, tts, stopdepth, pressure
|
2015-01-06 20:12:48 +00:00
|
|
|
{ "Manual Import", },
|
2014-07-10 18:54:18 +00:00
|
|
|
{ "APD Log Viewer", 1, 2, 16, 7, 18, -1, -1, 19, -1, "Tab" },
|
|
|
|
{ "XP5", 1, 2, 10, -1, -1, -1, -1, -1, -1, "Tab" },
|
|
|
|
{ "SensusCSV", 10, 11, -1, -1, -1, -1, -1, -1, -1, "," },
|
|
|
|
{ "Seabear CSV", 1, 2, 6, -1, -1, 3, 4, 5, 7, ";" },
|
2014-12-26 14:11:38 +00:00
|
|
|
{ "SubsurfaceCSV", -1, -1, -1, -1, -1, -1, -1, -1, -1, "," },
|
2014-02-28 04:09:57 +00:00
|
|
|
{ NULL, }
|
2013-10-16 19:05:19 +00:00
|
|
|
};
|
|
|
|
|
2015-01-06 16:45:49 +00:00
|
|
|
ColumnNameProvider::ColumnNameProvider(QObject *parent) : QAbstractListModel(parent)
|
2015-01-06 16:32:03 +00:00
|
|
|
{
|
2015-01-06 16:39:56 +00:00
|
|
|
columnNames << tr("Dive #") << tr("Date") << tr("Time") << tr("Duration") << tr("Location") << tr("GPS") << tr("Weight") << tr("Cyl size") << tr("Start Pressure")
|
|
|
|
<< tr("End Press") << tr("Max depth") << tr("Mean depth") << tr("Buddy") << tr("Notes") << tr("Tags") << tr("Air temp") << tr("Water temp")
|
|
|
|
<< tr("O₂") << tr("He");
|
2015-01-06 16:32:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ColumnNameProvider::insertRows(int row, int count, const QModelIndex &parent)
|
|
|
|
{
|
2015-01-06 17:30:59 +00:00
|
|
|
beginInsertRows(QModelIndex(), row, row);
|
|
|
|
columnNames.append(QString());
|
|
|
|
endInsertRows();
|
2015-01-06 23:09:40 +00:00
|
|
|
return true;
|
2015-01-06 16:32:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ColumnNameProvider::removeRows(int row, int count, const QModelIndex &parent)
|
|
|
|
{
|
2015-01-06 17:26:19 +00:00
|
|
|
beginRemoveRows(QModelIndex(), row, row);
|
|
|
|
columnNames.removeAt(row);
|
|
|
|
endRemoveRows();
|
2015-01-06 23:09:40 +00:00
|
|
|
return true;
|
2015-01-06 16:32:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ColumnNameProvider::setData(const QModelIndex &index, const QVariant &value, int role)
|
|
|
|
{
|
2015-01-06 17:26:19 +00:00
|
|
|
if (role == Qt::EditRole) {
|
|
|
|
columnNames[index.row()] = value.toString();
|
|
|
|
}
|
|
|
|
dataChanged(index, index);
|
2015-01-06 23:09:40 +00:00
|
|
|
return true;
|
2015-01-06 16:32:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QVariant ColumnNameProvider::data(const QModelIndex &index, int role) const
|
|
|
|
{
|
2015-01-06 16:39:56 +00:00
|
|
|
if (!index.isValid())
|
|
|
|
return QVariant();
|
|
|
|
|
|
|
|
if (role != Qt::DisplayRole)
|
|
|
|
return QVariant();
|
2015-01-06 16:32:03 +00:00
|
|
|
|
2015-01-06 16:39:56 +00:00
|
|
|
return QVariant(columnNames[index.row()]);
|
2015-01-06 16:32:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ColumnNameProvider::rowCount(const QModelIndex &parent) const
|
|
|
|
{
|
2015-01-06 16:39:56 +00:00
|
|
|
Q_UNUSED(parent)
|
|
|
|
return columnNames.count();
|
2015-01-06 16:32:03 +00:00
|
|
|
}
|
|
|
|
|
2015-01-06 16:54:58 +00:00
|
|
|
ColumnNameView::ColumnNameView(QWidget *parent)
|
|
|
|
{
|
2015-01-06 17:14:14 +00:00
|
|
|
setAcceptDrops(true);
|
|
|
|
setDragEnabled(true);
|
2015-01-06 16:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ColumnNameView::mousePressEvent(QMouseEvent *press)
|
|
|
|
{
|
2015-01-06 17:03:58 +00:00
|
|
|
QModelIndex atClick = indexAt(press->pos());
|
|
|
|
if (!atClick.isValid())
|
|
|
|
return;
|
|
|
|
|
2015-01-06 17:42:50 +00:00
|
|
|
QRect indexRect = visualRect(atClick);
|
|
|
|
QPixmap pix(indexRect.width(), indexRect.height());
|
|
|
|
pix.fill(QColor(0,0,0,0));
|
|
|
|
render(&pix, QPoint(0, 0),QRegion(indexRect));
|
|
|
|
|
2015-01-06 17:03:58 +00:00
|
|
|
QDrag *drag = new QDrag(this);
|
|
|
|
QMimeData *mimeData = new QMimeData;
|
2015-01-06 19:32:29 +00:00
|
|
|
mimeData->setData(subsurface_mimedata, atClick.data().toByteArray());
|
2015-01-06 17:26:19 +00:00
|
|
|
model()->removeRow(atClick.row());
|
2015-01-06 17:42:50 +00:00
|
|
|
drag->setPixmap(pix);
|
2015-01-06 17:03:58 +00:00
|
|
|
drag->setMimeData(mimeData);
|
2015-01-06 19:19:08 +00:00
|
|
|
if (drag->exec() == Qt::IgnoreAction){
|
|
|
|
model()->insertRow(model()->rowCount());
|
|
|
|
QModelIndex idx = model()->index(model()->rowCount()-1, 0);
|
2015-01-06 19:32:29 +00:00
|
|
|
model()->setData(idx, mimeData->data(subsurface_mimedata));
|
2015-01-06 19:19:08 +00:00
|
|
|
}
|
2015-01-06 17:14:14 +00:00
|
|
|
}
|
|
|
|
|
2015-01-07 00:24:46 +00:00
|
|
|
void ColumnNameView::dragLeaveEvent(QDragLeaveEvent *leave)
|
|
|
|
{
|
|
|
|
Q_UNUSED(leave);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ColumnNameView::dragEnterEvent(QDragEnterEvent *event)
|
|
|
|
{
|
|
|
|
event->acceptProposedAction();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ColumnNameView::dragMoveEvent(QDragMoveEvent *event)
|
|
|
|
{
|
|
|
|
QModelIndex curr = indexAt(event->pos());
|
|
|
|
if (!curr.isValid() || curr.row() != 0)
|
|
|
|
return;
|
|
|
|
event->acceptProposedAction();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ColumnNameView::dropEvent(QDropEvent *event)
|
|
|
|
{
|
|
|
|
const QMimeData *mimeData = event->mimeData();
|
|
|
|
if (mimeData->data(subsurface_mimedata).count()) {
|
|
|
|
if (event->source() != this) {
|
|
|
|
event->acceptProposedAction();
|
|
|
|
QVariant value = QString(mimeData->data(subsurface_mimedata));
|
|
|
|
model()->insertRow(model()->rowCount());
|
|
|
|
model()->setData(model()->index(model()->rowCount()-1, 0), value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-06 17:56:08 +00:00
|
|
|
ColumnDropCSVView::ColumnDropCSVView(QWidget *parent)
|
|
|
|
{
|
2015-01-06 18:52:15 +00:00
|
|
|
setAcceptDrops(true);
|
2015-01-06 17:56:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ColumnDropCSVView::dragLeaveEvent(QDragLeaveEvent *leave)
|
|
|
|
{
|
2015-01-06 18:52:15 +00:00
|
|
|
Q_UNUSED(leave);
|
2015-01-06 17:56:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ColumnDropCSVView::dragEnterEvent(QDragEnterEvent *event)
|
|
|
|
{
|
2015-01-06 18:52:15 +00:00
|
|
|
event->acceptProposedAction();
|
2015-01-06 17:56:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ColumnDropCSVView::dragMoveEvent(QDragMoveEvent *event)
|
|
|
|
{
|
2015-01-06 18:52:15 +00:00
|
|
|
QModelIndex curr = indexAt(event->pos());
|
|
|
|
if (!curr.isValid() || curr.row() != 0)
|
|
|
|
return;
|
|
|
|
event->acceptProposedAction();
|
2015-01-06 17:56:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ColumnDropCSVView::dropEvent(QDropEvent *event)
|
|
|
|
{
|
2015-01-06 18:54:50 +00:00
|
|
|
QModelIndex curr = indexAt(event->pos());
|
|
|
|
if (!curr.isValid() || curr.row() != 0)
|
|
|
|
return;
|
2015-01-06 17:56:08 +00:00
|
|
|
|
2015-01-06 18:54:50 +00:00
|
|
|
const QMimeData *mimeData = event->mimeData();
|
2015-01-07 01:30:46 +00:00
|
|
|
if (!mimeData->data(subsurface_mimedata).count())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (event->source() == this ) {
|
|
|
|
QString value_old = QString(mimeData->data(subsurface_mimedata));
|
|
|
|
QString value_new = curr.data().toString();
|
|
|
|
ColumnNameResult *m = qobject_cast<ColumnNameResult*>(model());
|
|
|
|
m->swapValues(value_old, value_new);
|
|
|
|
event->acceptProposedAction();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (curr.data().toString().isEmpty()) {
|
|
|
|
QVariant value = QString(mimeData->data(subsurface_mimedata));
|
|
|
|
model()->setData(curr, value);
|
|
|
|
event->acceptProposedAction();
|
2015-01-06 18:54:50 +00:00
|
|
|
}
|
2015-01-06 17:56:08 +00:00
|
|
|
}
|
2015-01-06 17:14:14 +00:00
|
|
|
|
2015-01-06 18:41:49 +00:00
|
|
|
ColumnNameResult::ColumnNameResult(QObject *parent) : QAbstractTableModel(parent)
|
2015-01-06 18:01:21 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-01-07 00:12:05 +00:00
|
|
|
void ColumnNameResult::swapValues(const QString &one, const QString &other) {
|
|
|
|
int firstIndex = columnNames.indexOf(one);
|
|
|
|
int secondIndex = columnNames.indexOf(other);
|
2015-01-07 01:20:54 +00:00
|
|
|
setData(index(0, firstIndex), QVariant(other), Qt::EditRole);
|
|
|
|
setData(index(0, secondIndex), QVariant(one), Qt::EditRole);
|
2015-01-07 00:12:05 +00:00
|
|
|
}
|
|
|
|
|
2015-01-06 18:01:21 +00:00
|
|
|
bool ColumnNameResult::setData(const QModelIndex &index, const QVariant &value, int role)
|
|
|
|
{
|
2015-01-07 01:20:54 +00:00
|
|
|
if (!index.isValid() || index.row() != 0) {
|
2015-01-06 18:40:51 +00:00
|
|
|
return false;
|
2015-01-07 01:20:54 +00:00
|
|
|
}
|
2015-01-06 18:40:51 +00:00
|
|
|
if (role == Qt::EditRole) {
|
|
|
|
columnNames[index.column()] = value.toString();
|
|
|
|
dataChanged(index, index);
|
|
|
|
}
|
2015-01-06 23:09:40 +00:00
|
|
|
return true;
|
2015-01-06 18:01:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QVariant ColumnNameResult::data(const QModelIndex &index, int role) const
|
|
|
|
{
|
2015-01-06 18:37:36 +00:00
|
|
|
if (!index.isValid())
|
|
|
|
return QVariant();
|
|
|
|
if (role != Qt::DisplayRole)
|
|
|
|
return QVariant();
|
2015-01-06 18:01:21 +00:00
|
|
|
|
2015-01-06 18:37:36 +00:00
|
|
|
if (index.row() == 0) {
|
|
|
|
return (columnNames[index.column()]);
|
|
|
|
}
|
|
|
|
return QVariant(columnValues[index.row() -1][index.column()]);
|
2015-01-06 18:01:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ColumnNameResult::rowCount(const QModelIndex &parent) const
|
|
|
|
{
|
2015-01-06 18:30:59 +00:00
|
|
|
Q_UNUSED(parent);
|
|
|
|
return columnValues.count() + 1; // +1 == the header.
|
2015-01-06 18:01:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ColumnNameResult::columnCount(const QModelIndex &parent) const
|
|
|
|
{
|
2015-01-06 18:30:59 +00:00
|
|
|
Q_UNUSED(parent);
|
|
|
|
return columnNames.count();
|
2015-01-06 18:01:21 +00:00
|
|
|
}
|
|
|
|
|
2015-01-06 20:12:48 +00:00
|
|
|
QStringList ColumnNameResult::result() const
|
|
|
|
{
|
|
|
|
return columnNames;
|
|
|
|
}
|
|
|
|
|
2015-01-06 18:05:06 +00:00
|
|
|
void ColumnNameResult::setColumnValues(QList<QStringList> columns)
|
|
|
|
{
|
2015-01-06 18:30:59 +00:00
|
|
|
if (rowCount() != 1) {
|
|
|
|
beginRemoveRows(QModelIndex(), 1, rowCount()-1);
|
|
|
|
columnValues.clear();
|
|
|
|
endRemoveRows();
|
|
|
|
}
|
|
|
|
if (columnCount() != 0) {
|
|
|
|
beginRemoveColumns(QModelIndex(), 0, columnCount()-1);
|
|
|
|
columnNames.clear();
|
|
|
|
endRemoveColumns();
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList first = columns.first();
|
|
|
|
beginInsertColumns(QModelIndex(), 0, first.count()-1);
|
|
|
|
for(int i = 0; i < first.count(); i++){
|
|
|
|
columnNames.append(QString());
|
|
|
|
}
|
|
|
|
endInsertColumns();
|
2015-01-06 18:05:06 +00:00
|
|
|
|
2015-01-06 18:30:59 +00:00
|
|
|
beginInsertRows(QModelIndex(), 0, columns.count()-1);
|
|
|
|
columnValues = columns;
|
|
|
|
endInsertRows();
|
2015-01-06 18:05:06 +00:00
|
|
|
}
|
|
|
|
|
2015-01-06 23:49:48 +00:00
|
|
|
void ColumnDropCSVView::mousePressEvent(QMouseEvent *press)
|
|
|
|
{
|
|
|
|
QModelIndex atClick = indexAt(press->pos());
|
|
|
|
if (!atClick.isValid() || atClick.row())
|
|
|
|
return;
|
|
|
|
|
|
|
|
QRect indexRect = visualRect(atClick);
|
|
|
|
QPixmap pix(indexRect.width(), indexRect.height());
|
|
|
|
pix.fill(QColor(0,0,0,0));
|
|
|
|
render(&pix, QPoint(0, 0),QRegion(indexRect));
|
|
|
|
|
|
|
|
QDrag *drag = new QDrag(this);
|
|
|
|
QMimeData *mimeData = new QMimeData;
|
|
|
|
mimeData->setData(subsurface_mimedata, atClick.data().toByteArray());
|
|
|
|
drag->setPixmap(pix);
|
|
|
|
drag->setMimeData(mimeData);
|
|
|
|
if (drag->exec() != Qt::IgnoreAction){
|
2015-01-07 01:20:54 +00:00
|
|
|
QObject *target = drag->target();
|
|
|
|
if (target->objectName() == "qt_scrollarea_viewport")
|
|
|
|
target = target->parent();
|
|
|
|
|
|
|
|
|
|
|
|
if (target != drag->source()) {
|
2015-01-07 00:41:57 +00:00
|
|
|
model()->setData(atClick, QString());
|
|
|
|
}
|
2015-01-06 23:49:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-06 18:11:27 +00:00
|
|
|
DiveLogImportDialog::DiveLogImportDialog(QStringList fn, QWidget *parent) : QDialog(parent),
|
2013-10-16 19:05:19 +00:00
|
|
|
selector(true),
|
2013-12-29 16:11:20 +00:00
|
|
|
ui(new Ui::DiveLogImportDialog)
|
2013-10-16 19:05:19 +00:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2015-01-06 18:11:27 +00:00
|
|
|
fileNames = fn;
|
2014-12-25 13:25:29 +00:00
|
|
|
column = 0;
|
2013-10-16 19:05:19 +00:00
|
|
|
|
2014-01-16 20:50:16 +00:00
|
|
|
/* Add indexes of XSLTs requiring special handling to the list */
|
|
|
|
specialCSV << 3;
|
2014-12-26 14:11:38 +00:00
|
|
|
specialCSV << 5;
|
2014-01-16 20:50:16 +00:00
|
|
|
|
2013-10-16 19:05:19 +00:00
|
|
|
for (int i = 0; !CSVApps[i].name.isNull(); ++i)
|
|
|
|
ui->knownImports->addItem(CSVApps[i].name);
|
|
|
|
|
2015-01-06 18:37:36 +00:00
|
|
|
ui->CSVSeparator->addItems( QStringList() << tr("Tab") << ";" << ",");
|
2013-10-16 19:05:19 +00:00
|
|
|
ui->knownImports->setCurrentIndex(1);
|
2014-12-25 13:25:29 +00:00
|
|
|
|
2015-01-06 16:45:49 +00:00
|
|
|
ColumnNameProvider *provider = new ColumnNameProvider(this);
|
|
|
|
ui->avaliableColumns->setModel(provider);
|
|
|
|
|
2015-01-06 18:21:50 +00:00
|
|
|
resultModel = new ColumnNameResult(this);
|
|
|
|
ui->tableView->setModel(resultModel);
|
2015-01-06 18:05:06 +00:00
|
|
|
|
2015-01-06 18:11:27 +00:00
|
|
|
loadFileContents();
|
|
|
|
|
2014-12-25 13:25:29 +00:00
|
|
|
/* manually import CSV file */
|
2014-04-25 17:44:23 +00:00
|
|
|
QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this);
|
|
|
|
connect(close, SIGNAL(activated()), this, SLOT(close()));
|
|
|
|
QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this);
|
|
|
|
connect(quit, SIGNAL(activated()), parent, SLOT(close()));
|
2015-01-06 18:37:36 +00:00
|
|
|
|
|
|
|
connect(ui->CSVSeparator, SIGNAL(currentIndexChanged(int)), this, SLOT(loadFileContents()));
|
2013-10-16 19:05:19 +00:00
|
|
|
}
|
|
|
|
|
2013-12-29 16:11:20 +00:00
|
|
|
DiveLogImportDialog::~DiveLogImportDialog()
|
2013-10-16 19:05:19 +00:00
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2015-01-06 18:11:27 +00:00
|
|
|
void DiveLogImportDialog::loadFileContents() {
|
|
|
|
QFile f(fileNames.first());
|
2015-01-06 18:21:50 +00:00
|
|
|
QList<QStringList> fileColumns;
|
|
|
|
QStringList currColumns;
|
|
|
|
|
|
|
|
f.open(QFile::ReadOnly);
|
|
|
|
int rows = 0;
|
|
|
|
while (rows < 10 || !f.atEnd()) {
|
|
|
|
QString currLine = f.readLine();
|
2015-01-06 18:37:36 +00:00
|
|
|
QString separator = ui->CSVSeparator->currentText() == tr("Tab") ? "\t"
|
|
|
|
: ui->CSVSeparator->currentText();
|
|
|
|
currColumns = currLine.split(separator);
|
2015-01-06 18:21:50 +00:00
|
|
|
fileColumns.append(currColumns);
|
|
|
|
rows += 1;
|
|
|
|
}
|
|
|
|
resultModel->setColumnValues(fileColumns);
|
2015-01-06 18:11:27 +00:00
|
|
|
}
|
|
|
|
|
2013-12-29 16:11:20 +00:00
|
|
|
void DiveLogImportDialog::on_buttonBox_accepted()
|
2013-10-16 19:05:19 +00:00
|
|
|
{
|
2015-01-06 20:12:48 +00:00
|
|
|
QStringList r = resultModel->result();
|
|
|
|
if (ui->knownImports->currentText() != "Manual Import") {
|
|
|
|
for (int i = 0; i < fileNames.size(); ++i) {
|
|
|
|
if (ui->knownImports->currentText() == "Seabear CSV") {
|
|
|
|
parse_seabear_csv_file(fileNames[i].toUtf8().data(),
|
|
|
|
r.indexOf(tr("Time")),
|
|
|
|
r.indexOf(tr("Max Depth")),
|
|
|
|
r.indexOf(tr("Water temp")),
|
|
|
|
r.indexOf(tr("PO₂")),
|
|
|
|
r.indexOf(tr("CNS")),
|
|
|
|
r.indexOf(tr("NDL")),
|
|
|
|
r.indexOf(tr("TTS")),
|
|
|
|
r.indexOf(tr("Stopped Depth")),
|
|
|
|
r.indexOf(tr("Pressure")),
|
|
|
|
ui->CSVSeparator->currentIndex(),
|
|
|
|
specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv",
|
|
|
|
ui->CSVUnits->currentIndex()
|
|
|
|
);
|
2014-10-28 09:14:00 +00:00
|
|
|
|
2015-01-06 16:12:29 +00:00
|
|
|
// Seabear CSV stores NDL and TTS in Minutes, not seconds
|
2014-10-28 09:14:00 +00:00
|
|
|
struct dive *dive = dive_table.dives[dive_table.nr - 1];
|
|
|
|
for(int s_nr = 0 ; s_nr <= dive->dc.samples ; s_nr++) {
|
|
|
|
struct sample *sample = dive->dc.sample + s_nr;
|
|
|
|
sample->ndl.seconds *= 60;
|
|
|
|
sample->tts.seconds *= 60;
|
|
|
|
}
|
2015-01-06 20:12:48 +00:00
|
|
|
} else {
|
|
|
|
parse_csv_file(fileNames[i].toUtf8().data(),
|
|
|
|
r.indexOf(tr("Time")),
|
|
|
|
r.indexOf(tr("Max Depth")),
|
|
|
|
r.indexOf(tr("Water temp")),
|
|
|
|
r.indexOf(tr("PO₂")),
|
|
|
|
r.indexOf(tr("CNS")),
|
|
|
|
r.indexOf(tr("NDL")),
|
|
|
|
r.indexOf(tr("TTS")),
|
|
|
|
r.indexOf(tr("Stopped Depth")),
|
|
|
|
r.indexOf(tr("Pressure")),
|
|
|
|
ui->CSVSeparator->currentIndex(),
|
|
|
|
specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv",
|
|
|
|
ui->CSVUnits->currentIndex()
|
|
|
|
);
|
|
|
|
}
|
2014-01-25 07:49:22 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (int i = 0; i < fileNames.size(); ++i) {
|
|
|
|
parse_manual_file(fileNames[i].toUtf8().data(),
|
2015-01-06 20:12:48 +00:00
|
|
|
ui->CSVSeparator->currentIndex(),
|
|
|
|
ui->CSVUnits->currentIndex(),
|
|
|
|
ui->DateFormat->currentIndex(),
|
|
|
|
ui->DurationFormat->currentIndex(),
|
|
|
|
r.indexOf(tr("Dive #")),
|
|
|
|
r.indexOf(tr("Date")),
|
|
|
|
r.indexOf(tr("Time")),
|
|
|
|
r.indexOf(tr("Duration")),
|
|
|
|
r.indexOf(tr("Location")),
|
|
|
|
r.indexOf(tr("GPS")),
|
|
|
|
r.indexOf(tr("Max depth")),
|
|
|
|
r.indexOf(tr("Mean depth")),
|
|
|
|
r.indexOf(tr("Buddy")),
|
|
|
|
r.indexOf(tr("Notes")),
|
|
|
|
r.indexOf(tr("Weight")),
|
|
|
|
r.indexOf(tr("Tags")),
|
|
|
|
r.indexOf(tr("Cyl size")),
|
|
|
|
r.indexOf(tr("Start Pressure")),
|
|
|
|
r.indexOf(tr("End Pressure")),
|
|
|
|
r.indexOf(tr("O₂")),
|
|
|
|
r.indexOf(tr("He")),
|
|
|
|
r.indexOf(tr("Air Temp")),
|
|
|
|
r.indexOf(tr("Water Temp"))
|
|
|
|
);
|
2013-12-29 16:11:19 +00:00
|
|
|
}
|
2013-10-16 19:05:19 +00:00
|
|
|
}
|
2014-01-15 08:30:42 +00:00
|
|
|
process_dives(true, false);
|
2014-02-12 14:22:54 +00:00
|
|
|
MainWindow::instance()->refreshDisplay();
|
2013-10-16 19:05:19 +00:00
|
|
|
}
|