mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 13:10:19 +00:00
7be962bfc2
Having subsurface-core as a directory name really messes with autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an autocomplete conflict and also was inconsistent with the desktop-widget name for the directory containing the "other" UI. And while cleaning up the resulting change in the path name for include files, I decided to clean up those even more to make them consistent overall. This could have been handled in more commits, but since this requires a make clean before the build, it seemed more sensible to do it all in one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
57 lines
2.7 KiB
C++
57 lines
2.7 KiB
C++
#include "qt-models/completionmodels.h"
|
|
#include "core/dive.h"
|
|
#include <QSet>
|
|
#include <QString>
|
|
|
|
#define CREATE_UPDATE_METHOD(Class, diveStructMember) \
|
|
void Class::updateModel() \
|
|
{ \
|
|
QStringList list; \
|
|
struct dive *dive; \
|
|
int i = 0; \
|
|
for_each_dive (i, dive) \
|
|
{ \
|
|
QString buddy(dive->diveStructMember); \
|
|
if (!list.contains(buddy)) { \
|
|
list.append(buddy); \
|
|
} \
|
|
} \
|
|
std::sort(list.begin(), list.end()); \
|
|
setStringList(list); \
|
|
}
|
|
|
|
#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()); \
|
|
} \
|
|
} \
|
|
QStringList setList = set.toList(); \
|
|
std::sort(setList.begin(), setList.end()); \
|
|
setStringList(setList); \
|
|
}
|
|
|
|
CREATE_CSV_UPDATE_METHOD(BuddyCompletionModel, buddy);
|
|
CREATE_CSV_UPDATE_METHOD(DiveMasterCompletionModel, divemaster);
|
|
CREATE_UPDATE_METHOD(SuitCompletionModel, suit);
|
|
|
|
void TagCompletionModel::updateModel()
|
|
{
|
|
if (g_tag_list == NULL)
|
|
return;
|
|
QStringList list;
|
|
struct tag_entry *current_tag_entry = g_tag_list;
|
|
while (current_tag_entry != NULL) {
|
|
list.append(QString(current_tag_entry->tag->name));
|
|
current_tag_entry = current_tag_entry->next;
|
|
}
|
|
setStringList(list);
|
|
}
|