From 80b42bd28bc9d98dc9f645a4f6e56c224ee855b2 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Tue, 22 Sep 2015 16:36:17 -0300 Subject: Set the current dive site uid / text Start to make this thing usefull: Upon selecting the current index or writting something on the line edit, we need to set the dive site. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/locationinformation.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/qt-ui/locationinformation.cpp b/qt-ui/locationinformation.cpp index c446cada7..206b6eccf 100644 --- a/qt-ui/locationinformation.cpp +++ b/qt-ui/locationinformation.cpp @@ -357,6 +357,9 @@ void DiveLocationModel::resetModel() QVariant DiveLocationModel::data(const QModelIndex& index, int role) const { if(index.row() <= 1) { // two special cases. + if(index.column() == UUID) { + return RECENTLY_ADDED_DIVESITE; + } switch(role) { case Qt::DisplayRole : return new_ds_value[index.row()]; case Qt::ToolTipRole : return "Create a new dive site"; @@ -475,14 +478,17 @@ bool DiveLocationLineEdit::eventFilter(QObject *o, QEvent *e) void DiveLocationLineEdit::focusOutEvent(QFocusEvent* ev) { if (!view->isVisible()) { - qDebug() << "Focusing Out"; QLineEdit::focusOutEvent(ev); } } void DiveLocationLineEdit::itemActivated(const QModelIndex& index) { - qDebug() << "Activated" << index.data(); + QModelIndex uuidIndex = index.model()->index(index.row(), DiveLocationModel::UUID); + uint32_t uuid = uuidIndex.data().toInt(); + currType = uuid == 1 ? NEW_DIVE_SITE : EXISTING_DIVE_SITE; + currUuid = uuid; + setText(index.data().toString()); } void DiveLocationLineEdit::refreshDiveSiteCache() -- cgit v1.2.3-70-g09d2