2013-12-29 16:11:20 +00:00
|
|
|
#ifndef DIVELOGIMPORTDIALOG_H
|
|
|
|
#define DIVELOGIMPORTDIALOG_H
|
|
|
|
|
|
|
|
#include <QDialog>
|
2015-01-06 16:32:03 +00:00
|
|
|
#include <QAbstractListModel>
|
2015-01-06 16:54:58 +00:00
|
|
|
#include <QListView>
|
2015-01-06 17:14:14 +00:00
|
|
|
#include <QDragLeaveEvent>
|
2015-01-06 17:56:08 +00:00
|
|
|
#include <QTableView>
|
2015-01-06 18:01:21 +00:00
|
|
|
#include <QAbstractTableModel>
|
2015-01-07 17:04:15 +00:00
|
|
|
#include <QStyledItemDelegate>
|
2014-06-26 17:01:31 +00:00
|
|
|
|
2013-12-29 16:11:20 +00:00
|
|
|
#include "../dive.h"
|
|
|
|
#include "../divelist.h"
|
|
|
|
|
2014-05-22 18:40:22 +00:00
|
|
|
namespace Ui {
|
2014-02-28 04:09:57 +00:00
|
|
|
class DiveLogImportDialog;
|
2013-12-29 16:11:20 +00:00
|
|
|
}
|
|
|
|
|
2015-01-06 16:32:03 +00:00
|
|
|
class ColumnNameProvider : public QAbstractListModel {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
ColumnNameProvider(QObject *parent);
|
|
|
|
bool insertRows(int row, int count, const QModelIndex &parent);
|
|
|
|
bool removeRows(int row, int count, const QModelIndex &parent);
|
|
|
|
bool setData(const QModelIndex &index, const QVariant &value, int role);
|
|
|
|
QVariant data(const QModelIndex &index, int role) const;
|
|
|
|
int rowCount(const QModelIndex &parent) const;
|
2015-01-07 20:27:20 +00:00
|
|
|
int mymatch(QString value) const;
|
2015-01-06 16:32:03 +00:00
|
|
|
private:
|
|
|
|
QStringList columnNames;
|
|
|
|
};
|
|
|
|
|
2015-01-06 18:01:21 +00:00
|
|
|
class ColumnNameResult : public QAbstractTableModel {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
ColumnNameResult(QObject *parent);
|
|
|
|
bool setData(const QModelIndex &index, const QVariant &value, int role);
|
|
|
|
QVariant data(const QModelIndex &index, int role) const;
|
2015-01-06 18:30:59 +00:00
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
2015-01-06 18:05:06 +00:00
|
|
|
void setColumnValues(QList<QStringList> columns);
|
2015-01-06 20:12:48 +00:00
|
|
|
QStringList result() const;
|
2015-01-07 17:40:10 +00:00
|
|
|
void swapValues(int firstIndex, int secondIndex);
|
2015-01-06 18:01:21 +00:00
|
|
|
private:
|
|
|
|
QList<QStringList> columnValues;
|
|
|
|
QStringList columnNames;
|
|
|
|
};
|
|
|
|
|
2015-01-06 16:54:58 +00:00
|
|
|
class ColumnNameView : public QListView {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
ColumnNameView(QWidget *parent);
|
|
|
|
protected:
|
|
|
|
void mousePressEvent(QMouseEvent *press);
|
2015-01-07 00:24:46 +00:00
|
|
|
void dragLeaveEvent(QDragLeaveEvent *leave);
|
|
|
|
void dragEnterEvent(QDragEnterEvent *event);
|
|
|
|
void dragMoveEvent(QDragMoveEvent *event);
|
|
|
|
void dropEvent(QDropEvent *event);
|
2015-01-06 17:14:14 +00:00
|
|
|
private:
|
|
|
|
int currentDraggedIndex;
|
2015-01-06 16:54:58 +00:00
|
|
|
};
|
|
|
|
|
2015-01-06 17:56:08 +00:00
|
|
|
class ColumnDropCSVView : public QTableView {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
ColumnDropCSVView(QWidget *parent);
|
|
|
|
protected:
|
2015-01-06 23:49:48 +00:00
|
|
|
void mousePressEvent(QMouseEvent *press);
|
2015-01-06 17:56:08 +00:00
|
|
|
void dragLeaveEvent(QDragLeaveEvent *leave);
|
|
|
|
void dragEnterEvent(QDragEnterEvent *event);
|
|
|
|
void dragMoveEvent(QDragMoveEvent *event);
|
|
|
|
void dropEvent(QDropEvent *event);
|
|
|
|
private:
|
|
|
|
QStringList columns;
|
|
|
|
};
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
class DiveLogImportDialog : public QDialog {
|
2013-12-29 16:11:20 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2015-01-06 18:11:27 +00:00
|
|
|
explicit DiveLogImportDialog(QStringList fn, QWidget *parent = 0);
|
2013-12-29 16:11:20 +00:00
|
|
|
~DiveLogImportDialog();
|
2015-01-08 01:02:42 +00:00
|
|
|
enum whatChanged { INITIAL, SEPARATOR, KNOWNTYPES };
|
2014-02-28 04:09:57 +00:00
|
|
|
private
|
|
|
|
slots:
|
2013-12-29 16:11:20 +00:00
|
|
|
void on_buttonBox_accepted();
|
2015-01-08 01:02:42 +00:00
|
|
|
void loadFileContentsSeperatorSelected(int value);
|
|
|
|
void loadFileContentsKnownTypesSelected(int value);
|
|
|
|
void loadFileContents(int value, enum whatChanged triggeredBy);
|
|
|
|
|
2014-01-14 17:58:20 +00:00
|
|
|
private:
|
2013-12-29 16:11:20 +00:00
|
|
|
bool selector;
|
2014-01-07 20:01:28 +00:00
|
|
|
QStringList fileNames;
|
2013-12-29 16:11:20 +00:00
|
|
|
Ui::DiveLogImportDialog *ui;
|
2014-01-16 20:50:16 +00:00
|
|
|
QList<int> specialCSV;
|
2014-12-25 13:25:29 +00:00
|
|
|
int column;
|
2015-01-06 18:21:50 +00:00
|
|
|
ColumnNameResult *resultModel;
|
2015-03-22 15:13:47 +00:00
|
|
|
QString delta;
|
2013-12-29 16:11:20 +00:00
|
|
|
|
|
|
|
struct CSVAppConfig {
|
|
|
|
QString name;
|
|
|
|
int time;
|
|
|
|
int depth;
|
|
|
|
int temperature;
|
|
|
|
int po2;
|
|
|
|
int cns;
|
2014-07-09 20:13:37 +00:00
|
|
|
int ndl;
|
2014-07-09 20:13:38 +00:00
|
|
|
int tts;
|
2013-12-29 16:11:20 +00:00
|
|
|
int stopdepth;
|
2014-07-10 18:54:18 +00:00
|
|
|
int pressure;
|
2013-12-29 16:11:20 +00:00
|
|
|
QString separator;
|
|
|
|
};
|
|
|
|
|
2014-12-26 14:11:38 +00:00
|
|
|
#define CSVAPPS 7
|
2013-12-29 16:11:20 +00:00
|
|
|
static const CSVAppConfig CSVApps[CSVAPPS];
|
|
|
|
};
|
|
|
|
|
2015-01-07 17:04:15 +00:00
|
|
|
class TagDragDelegate : public QStyledItemDelegate {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
TagDragDelegate(QObject *parent);
|
|
|
|
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
|
|
|
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
|
|
|
};
|
|
|
|
|
2013-12-29 16:11:20 +00:00
|
|
|
#endif // DIVELOGIMPORTDIALOG_H
|