mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add the setColumnValues() method
This method populates the model with a few lines of the CSV data to help the user to define what each column is. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
79e81d70ec
commit
58e21a6160
2 changed files with 26 additions and 4 deletions
|
@ -161,17 +161,39 @@ QVariant ColumnNameResult::data(const QModelIndex &index, int role) const
|
|||
|
||||
int ColumnNameResult::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
|
||||
Q_UNUSED(parent);
|
||||
return columnValues.count() + 1; // +1 == the header.
|
||||
}
|
||||
|
||||
int ColumnNameResult::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
|
||||
Q_UNUSED(parent);
|
||||
return columnNames.count();
|
||||
}
|
||||
|
||||
void ColumnNameResult::setColumnValues(QList<QStringList> columns)
|
||||
{
|
||||
if (rowCount() != 1) {
|
||||
beginRemoveRows(QModelIndex(), 1, rowCount()-1);
|
||||
columnValues.clear();
|
||||
endRemoveRows();
|
||||
}
|
||||
if (columnCount() != 0) {
|
||||
beginRemoveColumns(QModelIndex(), 0, columnCount()-1);
|
||||
columnNames.clear();
|
||||
endRemoveColumns();
|
||||
}
|
||||
|
||||
QStringList first = columns.first();
|
||||
beginInsertColumns(QModelIndex(), 0, first.count()-1);
|
||||
for(int i = 0; i < first.count(); i++){
|
||||
columnNames.append(QString());
|
||||
}
|
||||
endInsertColumns();
|
||||
|
||||
beginInsertRows(QModelIndex(), 0, columns.count()-1);
|
||||
columnValues = columns;
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
DiveLogImportDialog::DiveLogImportDialog(QStringList fn, QWidget *parent) : QDialog(parent),
|
||||
|
|
|
@ -34,8 +34,8 @@ 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;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
void setColumnValues(QList<QStringList> columns);
|
||||
private:
|
||||
QList<QStringList> columnValues;
|
||||
|
|
Loading…
Add table
Reference in a new issue