diff options
-rw-r--r-- | qt-ui/completionmodels.cpp | 15 | ||||
-rw-r--r-- | qt-ui/completionmodels.h | 5 | ||||
-rw-r--r-- | qt-ui/maintab.cpp | 20 | ||||
-rw-r--r-- | qt-ui/maintab.h | 7 |
4 files changed, 17 insertions, 30 deletions
diff --git a/qt-ui/completionmodels.cpp b/qt-ui/completionmodels.cpp index 8ccab3f2f..b0a5db2d3 100644 --- a/qt-ui/completionmodels.cpp +++ b/qt-ui/completionmodels.cpp @@ -2,21 +2,6 @@ #include "dive.h" #include "mainwindow.h" -#define CREATE_SINGLETON(X) \ -X* X::instance() \ -{ \ - static QScopedPointer<X> self(new X()); \ - return self.data(); \ -} - -CREATE_SINGLETON(BuddyCompletionModel); -CREATE_SINGLETON(DiveMasterCompletionModel); -CREATE_SINGLETON(LocationCompletionModel); -CREATE_SINGLETON(SuitCompletionModel); -CREATE_SINGLETON(TagCompletionModel); - -#undef CREATE_SINGLETON - #define CREATE_UPDATE_METHOD(Class, diveStructMember) \ void Class::updateModel() \ { \ diff --git a/qt-ui/completionmodels.h b/qt-ui/completionmodels.h index 146186531..2ac9f17a1 100644 --- a/qt-ui/completionmodels.h +++ b/qt-ui/completionmodels.h @@ -6,35 +6,30 @@ class BuddyCompletionModel : public QStringListModel { Q_OBJECT public: - static BuddyCompletionModel* instance(); void updateModel(); }; class DiveMasterCompletionModel : public QStringListModel { Q_OBJECT public: - static DiveMasterCompletionModel* instance(); void updateModel(); }; class LocationCompletionModel : public QStringListModel { Q_OBJECT public: - static LocationCompletionModel* instance(); void updateModel(); }; class SuitCompletionModel : public QStringListModel { Q_OBJECT public: - static SuitCompletionModel* instance(); void updateModel(); }; class TagCompletionModel : public QStringListModel { Q_OBJECT public: - static TagCompletionModel* instance(); void updateModel(); }; diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 0aa683dcb..bdaddb827 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -89,11 +89,11 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui.weights->view()->setItemDelegateForColumn(WeightModel::TYPE, new WSInfoDelegate(this)); // disabled as this column is pointless outside the disabled planner // ui.cylinders->view()->setColumnHidden(CylindersModel::DEPTH, true); - completers.buddy = new QCompleter(BuddyCompletionModel::instance(), ui.buddy); - completers.divemaster = new QCompleter(DiveMasterCompletionModel::instance(), ui.divemaster); - completers.location = new QCompleter(LocationCompletionModel::instance(), ui.location); - completers.suit = new QCompleter(SuitCompletionModel::instance(), ui.suit); - completers.tags = new QCompleter(TagCompletionModel::instance(), ui.tagWidget); + completers.buddy = new QCompleter(&buddyModel, ui.buddy); + completers.divemaster = new QCompleter(&diveMasterModel, ui.divemaster); + completers.location = new QCompleter(&locationModel, ui.location); + completers.suit = new QCompleter(&suitModel, ui.suit); + completers.tags = new QCompleter(&tagModel, ui.tagWidget); completers.buddy->setCaseSensitivity(Qt::CaseInsensitive); completers.divemaster->setCaseSensitivity(Qt::CaseInsensitive); completers.location->setCaseSensitivity(Qt::CaseInsensitive); @@ -563,11 +563,11 @@ void MainTab::addWeight_clicked() void MainTab::reload() { - SuitCompletionModel::instance()->updateModel(); - BuddyCompletionModel::instance()->updateModel(); - LocationCompletionModel::instance()->updateModel(); - DiveMasterCompletionModel::instance()->updateModel(); - TagCompletionModel::instance()->updateModel(); + suitModel.updateModel(); + buddyModel.updateModel(); + locationModel.updateModel(); + diveMasterModel.updateModel(); + tagModel.updateModel(); } void MainTab::acceptChanges() diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index c5afd2f55..1edeebab6 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -13,6 +13,7 @@ #include "models.h" #include "ui_maintab.h" +#include "completionmodels.h" class QCompleter; struct dive; @@ -94,6 +95,12 @@ private: QMap<dive*, NotesBackup> notesBackup; EditMode editMode; + BuddyCompletionModel buddyModel; + DiveMasterCompletionModel diveMasterModel; + LocationCompletionModel locationModel; + SuitCompletionModel suitModel; + TagCompletionModel tagModel; + /* since the multi-edition of the equipment is fairly more * complex than a single item, because it involves a Qt * Model to edit things, we are copying the first selected |