mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
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>
This commit is contained in:
parent
ba30e938b3
commit
79e81d70ec
2 changed files with 14 additions and 2 deletions
|
@ -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)
|
||||
|
|
|
@ -88,6 +88,7 @@ private:
|
|||
Ui::DiveLogImportDialog *ui;
|
||||
QList<int> specialCSV;
|
||||
int column;
|
||||
ColumnNameResult *resultModel;
|
||||
|
||||
struct CSVAppConfig {
|
||||
QString name;
|
||||
|
|
Loading…
Reference in a new issue