2013-08-13 13:30:22 +00:00
|
|
|
#include "completionmodels.h"
|
|
|
|
#include "dive.h"
|
2013-11-30 17:18:04 +00:00
|
|
|
#include "mainwindow.h"
|
2013-08-13 13:30:22 +00:00
|
|
|
|
|
|
|
#define CREATE_UPDATE_METHOD(Class, diveStructMember) \
|
|
|
|
void Class::updateModel() \
|
|
|
|
{ \
|
|
|
|
QStringList list; \
|
|
|
|
struct dive* dive; \
|
|
|
|
int i = 0; \
|
2014-01-16 04:50:56 +00:00
|
|
|
for_each_dive(i, dive) { \
|
2013-08-13 13:30:22 +00:00
|
|
|
QString buddy(dive->diveStructMember); \
|
2014-01-16 04:50:56 +00:00
|
|
|
if (!list.contains(buddy)) { \
|
2013-08-13 13:30:22 +00:00
|
|
|
list.append(buddy); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
setStringList(list); \
|
|
|
|
}
|
|
|
|
|
2014-01-19 17:27:49 +00:00
|
|
|
#define CREATE_CSV_UPDATE_METHOD(Class, diveStructMember) \
|
|
|
|
void Class::updateModel() \
|
|
|
|
{ \
|
|
|
|
QSet<QString> set; \
|
|
|
|
struct dive* dive; \
|
|
|
|
int i = 0; \
|
|
|
|
for_each_dive(i, dive) { \
|
|
|
|
QString buddy(dive->diveStructMember); \
|
|
|
|
foreach (const QString &value, buddy.split(",", QString::SkipEmptyParts)) { \
|
|
|
|
set.insert(value.trimmed()); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
setStringList(set.toList()); \
|
2014-01-15 20:35:13 +00:00
|
|
|
}
|
|
|
|
|
2014-01-19 17:27:49 +00:00
|
|
|
CREATE_CSV_UPDATE_METHOD(BuddyCompletionModel, buddy);
|
|
|
|
CREATE_CSV_UPDATE_METHOD(DiveMasterCompletionModel, divemaster);
|
2013-08-13 13:30:22 +00:00
|
|
|
CREATE_UPDATE_METHOD(LocationCompletionModel, location);
|
|
|
|
CREATE_UPDATE_METHOD(SuitCompletionModel, suit);
|
|
|
|
|
2013-11-02 01:20:02 +00:00
|
|
|
void TagCompletionModel::updateModel()
|
|
|
|
{
|
2014-01-16 04:50:56 +00:00
|
|
|
if (g_tag_list == NULL)
|
2013-11-02 01:20:02 +00:00
|
|
|
return;
|
|
|
|
QStringList list;
|
|
|
|
struct tag_entry *current_tag_entry = g_tag_list->next;
|
|
|
|
while (current_tag_entry != NULL) {
|
|
|
|
list.append(QString(current_tag_entry->tag->name));
|
|
|
|
current_tag_entry = current_tag_entry->next;
|
|
|
|
}
|
|
|
|
setStringList(list);
|
|
|
|
}
|