From 7bc93d424254e4d544eb828f2374c652382bda6b Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Tue, 6 Jan 2015 14:39:56 -0200 Subject: Add data, row count and the string list that populate the model I know that there is a QStringListModel, but that doesn't have add and remove methods, and thus I cannot use it. ;) Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/divelogimportdialog.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'qt-ui/divelogimportdialog.cpp') diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp index 69639e2ec..cff386404 100644 --- a/qt-ui/divelogimportdialog.cpp +++ b/qt-ui/divelogimportdialog.cpp @@ -20,7 +20,9 @@ const DiveLogImportDialog::CSVAppConfig DiveLogImportDialog::CSVApps[CSVAPPS] = ColumnNameProvider::ColumnNameProvider(QObject *parent) { - + columnNames << tr("Dive #") << tr("Date") << tr("Time") << tr("Duration") << tr("Location") << tr("GPS") << tr("Weight") << tr("Cyl size") << tr("Start Pressure") + << tr("End Press") << tr("Max depth") << tr("Mean depth") << tr("Buddy") << tr("Notes") << tr("Tags") << tr("Air temp") << tr("Water temp") + << tr("O₂") << tr("He"); } bool ColumnNameProvider::insertRows(int row, int count, const QModelIndex &parent) @@ -40,12 +42,19 @@ bool ColumnNameProvider::setData(const QModelIndex &index, const QVariant &value QVariant ColumnNameProvider::data(const QModelIndex &index, int role) const { + if (!index.isValid()) + return QVariant(); + + if (role != Qt::DisplayRole) + return QVariant(); + return QVariant(columnNames[index.row()]); } int ColumnNameProvider::rowCount(const QModelIndex &parent) const { - + Q_UNUSED(parent) + return columnNames.count(); } DiveLogImportDialog::DiveLogImportDialog(QStringList *fn, QWidget *parent) : QDialog(parent), -- cgit v1.2.3-70-g09d2