aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/divelogimportdialog.h
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2015-09-03 14:20:19 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-10-30 10:36:49 -0700
commite49d6213ad129284a45d53c3fcdc03249e84efe2 (patch)
tree2946a666ab38af3375e7bb2b8c5dd887d4a7f9a1 /desktop-widgets/divelogimportdialog.h
parent588abd019fb2ed3f607682f2b6c7fe86a7a5bb90 (diff)
downloadsubsurface-e49d6213ad129284a45d53c3fcdc03249e84efe2.tar.gz
Move qt-ui to desktop-widgets
Since we have now destkop and mobile versions, 'qt-ui' was a very poor name choice for a folder that contains only destkop-enabled widgets. Also, move the graphicsview-common.h/cpp to subsurface-core because it doesn't depend on qgraphicsview, it merely implements all the colors that we use throughout Subsurface, and we will use colors on both desktop and mobile versions Same thing applies for metrics.h/cpp Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/divelogimportdialog.h')
-rw-r--r--desktop-widgets/divelogimportdialog.h131
1 files changed, 131 insertions, 0 deletions
diff --git a/desktop-widgets/divelogimportdialog.h b/desktop-widgets/divelogimportdialog.h
new file mode 100644
index 000000000..2d12c7cac
--- /dev/null
+++ b/desktop-widgets/divelogimportdialog.h
@@ -0,0 +1,131 @@
+#ifndef DIVELOGIMPORTDIALOG_H
+#define DIVELOGIMPORTDIALOG_H
+
+#include <QDialog>
+#include <QAbstractListModel>
+#include <QListView>
+#include <QDragLeaveEvent>
+#include <QTableView>
+#include <QAbstractTableModel>
+#include <QStyledItemDelegate>
+
+#include "subsurface-core/dive.h"
+#include "subsurface-core/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;
+ int mymatch(QString value) 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 = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ void setColumnValues(QList<QStringList> columns);
+ QStringList result() const;
+ void swapValues(int firstIndex, int secondIndex);
+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:
+};
+
+class ColumnDropCSVView : public QTableView {
+ Q_OBJECT
+public:
+ ColumnDropCSVView(QWidget *parent);
+protected:
+ void mousePressEvent(QMouseEvent *press);
+ 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();
+ enum whatChanged { INITIAL, SEPARATOR, KNOWNTYPES };
+private
+slots:
+ void on_buttonBox_accepted();
+ void loadFileContentsSeperatorSelected(int value);
+ void loadFileContentsKnownTypesSelected(int value);
+ void loadFileContents(int value, enum whatChanged triggeredBy);
+ int setup_csv_params(QStringList r, char **params, int pnr);
+
+private:
+ bool selector;
+ QStringList fileNames;
+ Ui::DiveLogImportDialog *ui;
+ QList<int> specialCSV;
+ int column;
+ ColumnNameResult *resultModel;
+ QString delta;
+ QString hw;
+
+ struct CSVAppConfig {
+ QString name;
+ int time;
+ int depth;
+ int temperature;
+ int po2;
+ int sensor1;
+ int sensor2;
+ int sensor3;
+ int cns;
+ int ndl;
+ int tts;
+ int stopdepth;
+ int pressure;
+ int setpoint;
+ QString separator;
+ };
+
+#define CSVAPPS 8
+ static const CSVAppConfig CSVApps[CSVAPPS];
+};
+
+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;
+};
+
+#endif // DIVELOGIMPORTDIALOG_H