Add init function to qmlmanager

In order to get autocomplete to work on manual dive add
we apparently need a separate init function.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Joakim Bygdell 2016-05-20 18:48:35 +02:00 committed by Dirk Hohndel
parent 6be5aba799
commit 80274b0968
2 changed files with 58 additions and 0 deletions

View file

@ -1337,3 +1337,54 @@ void QMLManager::quit()
saveChangesCloud(false);
QApplication::quit();
}
QStringList QMLManager::suitInit() const
{
QStringList suits;
struct dive *d;
int i = 0;
for_each_dive (i, d) {
QString temp = d->suit;
if (!temp.isEmpty())
suits << d->suit;
}
suits.removeDuplicates();
suits.sort();
return suits;
}
QStringList QMLManager::buddyInit() const
{
QStringList buddies;
struct dive *d;
int i = 0;
for_each_dive (i, d) {
QString temp = d->buddy;
if (!temp.isEmpty() && !temp.contains(",")){
buddies << d->buddy;
}
else if (!temp.isEmpty()){
QRegExp sep("(,\\s)");
QStringList tempList = temp.split(sep);
buddies << tempList;
}
}
buddies.removeDuplicates();
buddies.sort();
return buddies;
}
QStringList QMLManager::divemasterInit() const
{
QStringList divemasters;
struct dive *d;
int i = 0;
for_each_dive (i, d) {
QString temp = d->divemaster;
if (!temp.isEmpty())
divemasters << d->divemaster;
}
divemasters.removeDuplicates();
divemasters.sort();
return divemasters;
}

View file

@ -29,6 +29,9 @@ class QMLManager : public QObject {
Q_PROPERTY(bool syncToCloud READ syncToCloud WRITE setSyncToCloud NOTIFY syncToCloudChanged)
Q_PROPERTY(int updateSelectedDive READ updateSelectedDive WRITE setUpdateSelectedDive NOTIFY updateSelectedDiveChanged)
Q_PROPERTY(int selectedDiveTimestamp READ selectedDiveTimestamp WRITE setSelectedDiveTimestamp NOTIFY selectedDiveTimestampChanged)
Q_PROPERTY(QStringList suitInit READ suitInit CONSTANT)
Q_PROPERTY(QStringList buddyInit READ buddyInit CONSTANT)
Q_PROPERTY(QStringList divemasterInit READ divemasterInit CONSTANT)
public:
QMLManager();
@ -97,6 +100,10 @@ public:
typedef void (QMLManager::*execute_function_type)();
DiveListSortModel *dlSortModel;
QStringList suitInit() const;
QStringList buddyInit() const;
QStringList divemasterInit() const;
public slots:
void applicationStateChanged(Qt::ApplicationState state);
void savePreferences();