subsurface/qt-ui/divelogimportdialog.h
Tomaz Canabrava 79e81d70ec Implement LoadFileContents
This will get the first 10 lines of data, try to separate
them using the separator specified, and then try to make
things display correctly on the table.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-06 19:37:46 -08:00

111 lines
2.6 KiB
C++

#ifndef DIVELOGIMPORTDIALOG_H
#define DIVELOGIMPORTDIALOG_H
#include <QDialog>
#include <QAbstractListModel>
#include <QListView>
#include <QDragLeaveEvent>
#include <QTableView>
#include <QAbstractTableModel>
#include "../dive.h"
#include "../divelist.h"
namespace Ui {
class DiveLogImportDialog;
}
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;
private:
QStringList columnNames;
};
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;
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
void setColumnValues(QList<QStringList> columns);
private:
QList<QStringList> columnValues;
QStringList columnNames;
};
class ColumnNameView : public QListView {
Q_OBJECT
public:
ColumnNameView(QWidget *parent);
protected:
void mousePressEvent(QMouseEvent *press);
void dragLeaveEvent(QDragLeaveEvent *leave);
void dragEnterEvent(QDragEnterEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
void dropEvent(QDropEvent *event);
private:
int currentDraggedIndex;
};
class ColumnDropCSVView : public QTableView {
Q_OBJECT
public:
ColumnDropCSVView(QWidget *parent);
protected:
void dragLeaveEvent(QDragLeaveEvent *leave);
void dragEnterEvent(QDragEnterEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
void dropEvent(QDropEvent *event);
private:
QStringList columns;
};
class DiveLogImportDialog : public QDialog {
Q_OBJECT
public:
explicit DiveLogImportDialog(QStringList fn, QWidget *parent = 0);
~DiveLogImportDialog();
private
slots:
void on_buttonBox_accepted();
void on_knownImports_currentIndexChanged(int index);
void unknownImports();
void loadFileContents();
private:
bool selector;
QStringList fileNames;
Ui::DiveLogImportDialog *ui;
QList<int> specialCSV;
int column;
ColumnNameResult *resultModel;
struct CSVAppConfig {
QString name;
int time;
int depth;
int temperature;
int po2;
int cns;
int ndl;
int tts;
int stopdepth;
int pressure;
QString separator;
};
#define CSVAPPS 7
static const CSVAppConfig CSVApps[CSVAPPS];
};
#endif // DIVELOGIMPORTDIALOG_H