diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-10-09 09:07:04 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-10-09 21:00:44 -0700 |
commit | 50e42bffa16728f1b663e37a76db6293cc00b122 (patch) | |
tree | e9774bce51aaa8e2e083b7995fdd35483ba566ea /qt-models | |
parent | 65ca3444f5429c5189e53c3a83d799e7b37b38aa (diff) | |
download | subsurface-50e42bffa16728f1b663e37a76db6293cc00b122.tar.gz |
Dive sites: don't add dummy entries to LocationInformationModel
The LocationInformationModel added two dummy sites to the front
of the list (add new dive site). This was never used - desktop
uses its own model, mobile only extracts the list of dive site
names with a custom function. Remove this functionality.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/divelocationmodel.cpp | 58 | ||||
-rw-r--r-- | qt-models/divelocationmodel.h | 2 |
2 files changed, 4 insertions, 56 deletions
diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp index 33a508bfd..ffe5e501f 100644 --- a/qt-models/divelocationmodel.cpp +++ b/qt-models/divelocationmodel.cpp @@ -19,8 +19,7 @@ LocationInformationModel *LocationInformationModel::instance() } LocationInformationModel::LocationInformationModel(QObject *obj) : QAbstractTableModel(obj), - internalRowCount(0), - textField(NULL) + internalRowCount(0) { } @@ -31,19 +30,7 @@ int LocationInformationModel::columnCount(const QModelIndex&) const int LocationInformationModel::rowCount(const QModelIndex&) const { - return internalRowCount + 2; -} - -static struct dive_site *get_dive_site_name_start_which_str(const QString& str) { - struct dive_site *ds; - int i; - for_each_dive_site(i,ds) { - QString dsName(ds->name); - if (dsName.startsWith(str)) { - return ds; - } - } - return NULL; + return internalRowCount; } QVariant LocationInformationModel::data(const QModelIndex &index, int role) const @@ -51,39 +38,7 @@ QVariant LocationInformationModel::data(const QModelIndex &index, int role) cons if (!index.isValid()) return QVariant(); - // Special case to handle the 'create dive site' with name. - if (index.row() < 2) { - if (index.column() == UUID) - return RECENTLY_ADDED_DIVESITE; - switch(role) { - case Qt::DisplayRole : { - if (index.row() == 1) { - struct dive_site *ds = get_dive_site_name_start_which_str(textField->text()); - if(ds) - return ds->name; - } - return textField->text(); - } - case Qt::ToolTipRole : { - return QString(tr("Create dive site with this name")); - } - case Qt::EditRole : { - if (index.row() == 1) { - struct dive_site *ds = get_dive_site_name_start_which_str(textField->text()); - if (!ds) - return INVALID_DIVE_SITE_NAME; - if (QString(ds->name) == textField->text()) - return INVALID_DIVE_SITE_NAME; - - } - return textField->text(); - } - case Qt::DecorationRole : return QIcon(":list-add-icon"); - } - } - - // The dive sites are -2 because of the first two items. - struct dive_site *ds = get_dive_site(index.row() - 2); + struct dive_site *ds = get_dive_site(index.row()); if (!ds) return QVariant(); @@ -116,11 +71,6 @@ QVariant LocationInformationModel::data(const QModelIndex &index, int role) cons return QVariant(); } -void LocationInformationModel::setFirstRowTextField(QLineEdit *t) -{ - textField = t; -} - void LocationInformationModel::update() { beginResetModel(); @@ -142,7 +92,7 @@ bool LocationInformationModel::removeRows(int row, int, const QModelIndex&) if(row >= rowCount()) return false; - beginRemoveRows(QModelIndex(), row + 2, row + 2); + beginRemoveRows(QModelIndex(), row, row); struct dive_site *ds = get_dive_site(row); if (ds) delete_dive_site(ds->uuid); diff --git a/qt-models/divelocationmodel.h b/qt-models/divelocationmodel.h index 2abd894ea..debbdf871 100644 --- a/qt-models/divelocationmodel.h +++ b/qt-models/divelocationmodel.h @@ -25,7 +25,6 @@ public: int rowCount(const QModelIndex &parent = QModelIndex()) const; QVariant data(const QModelIndex &index = QModelIndex(), int role = Qt::DisplayRole) const; bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex()); - void setFirstRowTextField(QLineEdit *textField); public slots: void update(); @@ -33,7 +32,6 @@ public slots: private: int internalRowCount; QStringList locationNames; - QLineEdit *textField; }; class GeoReferencingOptionsModel : public QStringListModel { |