diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-10-05 10:12:12 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-10-16 14:26:37 -0700 |
commit | 4a50badb57efd7725fa540ea7bb13f1e334cb83c (patch) | |
tree | 9e3a9214f4d5510dca8e212bbaa2e7f6e7b3bf5e /qt-models | |
parent | fd8bd9d5c717799313c4decaa85796ba68449f8a (diff) | |
download | subsurface-4a50badb57efd7725fa540ea7bb13f1e334cb83c.tar.gz |
cleanup: use std::vector in struct device_table
Since we converted from QString to std::string, let's also use
std::vector instead of QVector. We don't need COW semantics
and all the rigmarole. Let's try to keep Qt data structures
out of the core.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/divecomputermodel.cpp | 8 | ||||
-rw-r--r-- | qt-models/divecomputermodel.h | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/qt-models/divecomputermodel.cpp b/qt-models/divecomputermodel.cpp index c675ad641..d0b9f7637 100644 --- a/qt-models/divecomputermodel.cpp +++ b/qt-models/divecomputermodel.cpp @@ -11,7 +11,7 @@ DiveComputerModel::DiveComputerModel(QObject *parent) : CleanerTableModel(parent QVariant DiveComputerModel::data(const QModelIndex &index, int role) const { - if (index.row() < 0 || index.row() >= dcs.size()) + if (index.row() < 0 || index.row() >= (int)dcs.size()) return QVariant(); const device &node = dcs[index.row()]; @@ -55,7 +55,7 @@ Qt::ItemFlags DiveComputerModel::flags(const QModelIndex &index) const bool DiveComputerModel::setData(const QModelIndex &index, const QVariant &value, int) { // We should test if the role == Qt::EditRole - if (index.row() < 0 || index.row() >= dcs.size()) + if (index.row() < 0 || index.row() >= (int)dcs.size()) return false; device &node = dcs[index.row()]; @@ -66,10 +66,10 @@ bool DiveComputerModel::setData(const QModelIndex &index, const QVariant &value, void DiveComputerModel::remove(const QModelIndex &index) { - if (index.row() < 0 || index.row() >= dcs.size()) + if (index.row() < 0 || index.row() >= (int)dcs.size()) return; beginRemoveRows(QModelIndex(), index.row(), index.row()); - dcs.remove(index.row()); + dcs.erase(dcs.begin() + index.row()); endRemoveRows(); } diff --git a/qt-models/divecomputermodel.h b/qt-models/divecomputermodel.h index d50e1cd96..b21eadcc9 100644 --- a/qt-models/divecomputermodel.h +++ b/qt-models/divecomputermodel.h @@ -27,7 +27,7 @@ slots: void remove(const QModelIndex &index); private: - QVector<device> dcs; + std::vector<device> dcs; }; class DiveComputerSortedModel : public QSortFilterProxyModel { |