diff options
-rw-r--r-- | core/divesite.h | 2 | ||||
-rw-r--r-- | qt-models/divelocationmodel.cpp | 58 | ||||
-rw-r--r-- | qt-models/divelocationmodel.h | 2 |
3 files changed, 4 insertions, 58 deletions
diff --git a/core/divesite.h b/core/divesite.h index 9f6b8f527..5b6943c73 100644 --- a/core/divesite.h +++ b/core/divesite.h @@ -73,8 +73,6 @@ unsigned int get_distance(degrees_t lat1, degrees_t lon1, degrees_t lat2, degree uint32_t find_or_create_dive_site_with_name(const char *name, timestamp_t divetime); void merge_dive_sites(uint32_t ref, uint32_t *uuids, int count); -#define INVALID_DIVE_SITE_NAME "development use only - not a valid dive site name" - #ifdef __cplusplus } QString constructLocationTags(struct dive_site *ds, bool for_maintab); 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 { |