diff options
Diffstat (limited to 'qt-ui/maintab.cpp')
-rw-r--r-- | qt-ui/maintab.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index dd6ce72b0..591f665d5 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -58,6 +58,24 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui.extraData->setModel(extraDataModel); closeMessage(); + QCompleter *completer = new QCompleter(); + completer->setModel(LocationInformationModel::instance()); + completer->setCompletionColumn(LocationInformationModel::NAME); + completer->setCompletionRole(Qt::DisplayRole); + completer->setCompletionMode(QCompleter::PopupCompletion); + completer->setCaseSensitivity(Qt::CaseInsensitive); + + QListView *completerListview = new QListView(); + completerListview->setItemDelegate(new LocationFilterDelegate()); + completer->setPopup(completerListview); + + QListView *completerListView2 = new QListView(); + completerListView2->setItemDelegate(new LocationFilterDelegate()); + completerListView2->setModel(LocationInformationModel::instance()); + completerListView2->setModelColumn(1); + completerListView2->show(); + + ui.location->setCompleter(completer); connect(ui.addDiveSite, SIGNAL(clicked()), this, SLOT(showDiveSiteSimpleEdit())); connect(ui.geocodeButton, SIGNAL(clicked()), this, SLOT(reverseGeocode())); @@ -101,11 +119,6 @@ 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))); - LocationCompletionModel *locationCompletion = new LocationCompletionModel(); - ui.location->setCompleter(new QCompleter(locationCompletion)); - ui.location->completer()->setCaseSensitivity(Qt::CaseInsensitive); - ui.location->completer()->setCompletionMode(QCompleter::PopupCompletion); - 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)); @@ -471,9 +484,6 @@ void MainTab::updateDiveInfo(bool clear) struct dive *prevd; char buf[1024]; - LocationCompletionModel *m = qobject_cast<LocationCompletionModel*>(ui.location->completer()->model()); - m->updateModel(); - process_selected_dives(); process_all_dives(&displayed_dive, &prevd); @@ -768,9 +778,9 @@ void MainTab::reload() { suitModel.updateModel(); buddyModel.updateModel(); - locationModel.updateModel(); diveMasterModel.updateModel(); tagModel.updateModel(); + LocationInformationModel::instance()->update(); } // tricky little macro to edit all the selected dives @@ -1382,8 +1392,6 @@ void MainTab::on_location_editingFinished() markChangedWidget(ui.location); LocationInformationModel::instance()->update(); - LocationCompletionModel *m = qobject_cast<LocationCompletionModel*>(ui.location->completer()->model()); - m->updateModel(); emit diveSiteChanged(uuid); return; } |