diff --git a/lib/jkqtplotter/jkqtpdatastorage.cpp b/lib/jkqtplotter/jkqtpdatastorage.cpp index 1552b03056..1a20e0646d 100644 --- a/lib/jkqtplotter/jkqtpdatastorage.cpp +++ b/lib/jkqtplotter/jkqtpdatastorage.cpp @@ -315,6 +315,12 @@ JKQTPDatastore::~JKQTPDatastore() { clear(); } +//////////////////////////////////////////////////////////////////////////////////////////////// +bool JKQTPDatastore::hasColumn(size_t i) const +{ + return columns.find(i)!=columns.end(); +} + //////////////////////////////////////////////////////////////////////////////////////////////// JKQTPDatastore::ColumnIterator JKQTPDatastore::begin() { @@ -1159,6 +1165,17 @@ QList > JKQTPDatastore::getData(QStringList *columnNames, const return res; } +//////////////////////////////////////////////////////////////////////////////////////////////// +QVector JKQTPDatastore::getData(size_t column, QString *columnName) const +{ + QVector res; + if (hasColumn(column)) { + if (columnName) *columnName=columns.value(column).getName(); + columns.value(column).copyData(res); + } + return res; +} + //////////////////////////////////////////////////////////////////////////////////////////////// void JKQTPDatastore::saveDIF(const QString& filename, const QSet& userColumns, const QString& floatformat) const { diff --git a/lib/jkqtplotter/jkqtpdatastorage.h b/lib/jkqtplotter/jkqtpdatastorage.h index 28442c4527..5fad0fa6c1 100644 --- a/lib/jkqtplotter/jkqtpdatastorage.h +++ b/lib/jkqtplotter/jkqtpdatastorage.h @@ -387,6 +387,9 @@ class JKQTP_LIB_EXPORT JKQTPDatastore{ /** \brief class destructor, destroys all subordered JKQTPDatastoreItem objects */ ~JKQTPDatastore(); + /** \brief determines whether a column with the given ID exists */ + bool hasColumn(size_t i) const; + /** \brief returns an iterator to the first data entry in the \a i -th column in the JKQTPDatastore \see JKQTPColumn::iterator */ JKQTPColumnIterator begin(int i); /** \brief returns an iterator behind the last data entry data in the \a i -th column in the JKQTPDatastore \see JKQTPColumn::iterator */ @@ -1326,6 +1329,13 @@ class JKQTP_LIB_EXPORT JKQTPDatastore{ */ QList > getData(QStringList* columnNames=nullptr, const QSet& userColumns=QSet()) const; + /** \brief return contents of a given column as QVector + * + * \param column column to copy + * \param columnName if \c !=nullptr this will afterwards conatin the column title + */ + QVector getData(size_t column, QString* columnName=nullptr) const; + /** \brief save contents of datastore as DIF file (data interchange format) * * \param filename the file to create