diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2015-06-25 14:24:22 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-06-26 18:49:46 -0700 |
commit | 8bd9fb161a8607683d94b7179f46888cb44be9f4 (patch) | |
tree | 131d869649dc332df3d6fede7dca8df1a58256c3 | |
parent | f763da66b3db17347954272b9f856df6f8b9888d (diff) | |
download | subsurface-8bd9fb161a8607683d94b7179f46888cb44be9f4.tar.gz |
Dive site rewrite: location edit on notes tab is again a LineEdit
Hopefully we now have the UI semantics figured out.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-ui/maintab.cpp | 43 | ||||
-rw-r--r-- | qt-ui/maintab.h | 2 | ||||
-rw-r--r-- | qt-ui/maintab.ui | 25 |
3 files changed, 38 insertions, 32 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index c6660fc6b..adc60aec0 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -99,7 +99,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), connect(ui.cylinders->view(), SIGNAL(clicked(QModelIndex)), this, SLOT(editCylinderWidget(QModelIndex))); connect(ui.weights->view(), SIGNAL(clicked(QModelIndex)), this, SLOT(editWeightWidget(QModelIndex))); - ui.location->setModel(LocationInformationModel::instance()); + ui.location->setCompleter(new QCompleter(LocationInformationModel::instance())); ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate(this)); ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::USE, new TankUseDelegate(this)); ui.weights->view()->setItemDelegateForColumn(WeightModel::TYPE, new WSInfoDelegate(this)); @@ -227,9 +227,9 @@ void MainTab::setCurrentLocationIndex() if (current_dive) { struct dive_site *ds = get_dive_site_by_uuid(current_dive->dive_site_uuid); if (ds) - ui.location->setCurrentText(ds->name); + ui.location->setText(ds->name); else - ui.location->setCurrentIndex(-1); + ui.location->clear(); } } @@ -430,9 +430,9 @@ bool MainTab::isEditing() void MainTab::showLocation() { if (get_dive_site_by_uuid(displayed_dive.dive_site_uuid)) - ui.location->setCurrentText(get_dive_location(&displayed_dive)); + ui.location->setText(get_dive_location(&displayed_dive)); else - ui.location->setCurrentIndex(-1); + ui.location->clear(); } void MainTab::updateDiveInfo(bool clear) @@ -457,7 +457,6 @@ void MainTab::updateDiveInfo(bool clear) process_selected_dives(); process_all_dives(&displayed_dive, &prevd); - ui.location->blockSignals(true); divePictureModel->updateDivePictures(); @@ -480,9 +479,9 @@ void MainTab::updateDiveInfo(bool clear) if (!clear) { struct dive_site *ds = get_dive_site_by_uuid(displayed_dive.dive_site_uuid); if (ds) - ui.location->setCurrentText(ds->name); + ui.location->setText(ds->name); else - ui.location->setCurrentIndex(-1); + ui.location->clear(); // Subsurface always uses "local time" as in "whatever was the local time at the location" // so all time stamps have no time zone information and are in UTC QDateTime localTime = QDateTime::fromTime_t(displayed_dive.when - gettimezoneoffset(displayed_dive.when)); @@ -513,7 +512,7 @@ void MainTab::updateDiveInfo(bool clear) ui.watertemp->setVisible(false); // rename the remaining fields and fill data from selected trip ui.LocationLabel->setText(tr("Trip location")); - ui.location->setCurrentText(currentTrip->location); + ui.location->setText(currentTrip->location); ui.NotesLabel->setText(tr("Trip notes")); ui.notes->setText(currentTrip->notes); clearEquipment(); @@ -700,8 +699,6 @@ void MainTab::updateDiveInfo(bool clear) else ui.cylinders->view()->hideColumn(CylindersModel::USE); - ui.location->blockSignals(false); - emit diveSiteChanged(displayed_dive.dive_site_uuid); } @@ -1269,22 +1266,38 @@ void MainTab::on_tagWidget_textChanged() markChangedWidget(ui.tagWidget); } -void MainTab::on_location_currentIndexChanged(int idx) +void MainTab::on_location_editingFinished() { if (editMode == IGNORE || acceptingEdit == true) return; if (currentTrip) { free(displayedTrip.location); - displayedTrip.location = strdup(qPrintable(ui.location->currentText())); + displayedTrip.location = strdup(qPrintable(ui.location->text())); + } + + QString currText = ui.location->text(); + QModelIndexList list = LocationInformationModel::instance()->match( + LocationInformationModel::instance()->index(0,0), + Qt::DisplayRole, + currText, + 1, + Qt::MatchExactly + ); + + if (list.isEmpty()) { + qDebug() << "TODO: add this string on the location management."; + return; } + int idx = list.first().row(); + if (!get_dive_site(idx)) return; if (current_dive) { struct dive_site *ds_from_dive = get_dive_site_by_uuid(displayed_dive.dive_site_uuid); - if(ds_from_dive && ui.location->currentText() == ds_from_dive->name) + if(ds_from_dive && ui.location->text() == ds_from_dive->name) return; ds_from_dive = get_dive_site(idx); displayed_dive.dive_site_uuid = ds_from_dive->uuid; @@ -1420,7 +1433,7 @@ void MainTab::showAndTriggerEditSelective(struct dive_components what) if (what.visibility) ui.visibility->setCurrentStars(displayed_dive.visibility); if (what.divesite) - ui.location->setCurrentText(get_dive_location(&displayed_dive)); + ui.location->setText(get_dive_location(&displayed_dive)); if (what.tags) { char buf[1024]; taglist_get_tagstring(displayed_dive.tag_list, buf, 1024); diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index 8b5880cb9..39350c956 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -65,7 +65,7 @@ slots: void updateDiveInfo(bool clear = false); void acceptChanges(); void rejectChanges(); - void on_location_currentIndexChanged(int idx); + void on_location_editingFinished(); void on_divemaster_textChanged(); void on_buddy_textChanged(); void on_suit_textChanged(const QString &text); diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui index d681fbdbb..c78ced6f3 100644 --- a/qt-ui/maintab.ui +++ b/qt-ui/maintab.ui @@ -55,8 +55,8 @@ <rect> <x>0</x> <y>0</y> - <width>445</width> - <height>760</height> + <width>449</width> + <height>751</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_3"> @@ -186,14 +186,7 @@ <number>2</number> </property> <item> - <widget class="QComboBox" name="location"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> + <widget class="QLineEdit" name="location"/> </item> <item> <widget class="QToolButton" name="addDiveSite"> @@ -539,8 +532,8 @@ <rect> <x>0</x> <y>0</y> - <width>445</width> - <height>754</height> + <width>100</width> + <height>30</height> </rect> </property> <layout class="QGridLayout" name="equipmentTabScrollAreaLayout"> @@ -634,8 +627,8 @@ <rect> <x>0</x> <y>0</y> - <width>445</width> - <height>754</height> + <width>389</width> + <height>430</height> </rect> </property> <layout class="QGridLayout" name="diveInfoScrollAreaLayout"> @@ -975,8 +968,8 @@ <rect> <x>0</x> <y>0</y> - <width>445</width> - <height>754</height> + <width>408</width> + <height>253</height> </rect> </property> <layout class="QHBoxLayout" name="horizontalLayout"> |