summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2015-01-06 16:21:50 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-06 19:37:46 -0800
commit79e81d70ec009a99354676bff1aaa36fc5707233 (patch)
tree5b2bf123e594dbdf9bfa65b0a1b1af7837832dc6 /qt-ui
parentba30e938b3580bc04eda860b67e757aa3ecae305 (diff)
downloadsubsurface-79e81d70ec009a99354676bff1aaa36fc5707233.tar.gz
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>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/divelogimportdialog.cpp17
-rw-r--r--qt-ui/divelogimportdialog.h1
2 files changed, 15 insertions, 3 deletions
diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 41144b81c..541485d51 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -195,8 +195,8 @@ DiveLogImportDialog::DiveLogImportDialog(QStringList fn, QWidget *parent) : QDia
ColumnNameProvider *provider = new ColumnNameProvider(this);
ui->avaliableColumns->setModel(provider);
- ColumnNameResult *result = new ColumnNameResult(this);
- ui->tableView->setModel(result);
+ resultModel = new ColumnNameResult(this);
+ ui->tableView->setModel(resultModel);
loadFileContents();
@@ -214,7 +214,18 @@ DiveLogImportDialog::~DiveLogImportDialog()
void DiveLogImportDialog::loadFileContents() {
QFile f(fileNames.first());
-
+ QList<QStringList> fileColumns;
+ QStringList currColumns;
+
+ f.open(QFile::ReadOnly);
+ int rows = 0;
+ while (rows < 10 || !f.atEnd()) {
+ QString currLine = f.readLine();
+ currColumns = currLine.split( ui->CSVSeparator->currentText() );
+ fileColumns.append(currColumns);
+ rows += 1;
+ }
+ resultModel->setColumnValues(fileColumns);
}
#define VALUE_IF_CHECKED(x) (ui->x->isEnabled() ? ui->x->value() - 1 : -1)
diff --git a/qt-ui/divelogimportdialog.h b/qt-ui/divelogimportdialog.h
index bca7ecc36..b5eaa906d 100644
--- a/qt-ui/divelogimportdialog.h
+++ b/qt-ui/divelogimportdialog.h
@@ -88,6 +88,7 @@ private:
Ui::DiveLogImportDialog *ui;
QList<int> specialCSV;
int column;
+ ColumnNameResult *resultModel;
struct CSVAppConfig {
QString name;