mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
cleanup: remove macros from qt-models/completionmodels.cpp
There were macros to auto-generate functions to reload the models. One was only used once and therefore is pointless. The other can be replaced by a function with a pointer-to-member-variable argument. While doing this, adapt the coding style. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
10bedf02d0
commit
67d956b44c
1 changed files with 36 additions and 37 deletions
|
@ -5,51 +5,50 @@
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QString>
|
#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); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||||
#define SKIP_EMPTY Qt::SkipEmptyParts
|
#define SKIP_EMPTY Qt::SkipEmptyParts
|
||||||
#else
|
#else
|
||||||
#define SKIP_EMPTY QString::SkipEmptyParts
|
#define SKIP_EMPTY QString::SkipEmptyParts
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CREATE_CSV_UPDATE_METHOD(Class, diveStructMember) \
|
static QStringList getCSVList(char *dive::*item)
|
||||||
void Class::updateModel() \
|
{
|
||||||
{ \
|
QSet<QString> set;
|
||||||
QSet<QString> set; \
|
struct dive *dive;
|
||||||
struct dive *dive; \
|
int i = 0;
|
||||||
int i = 0; \
|
for_each_dive (i, dive) {
|
||||||
for_each_dive (i, dive) \
|
QString str(dive->*item);
|
||||||
{ \
|
for (const QString &value: str.split(",", SKIP_EMPTY))
|
||||||
QString buddy(dive->diveStructMember); \
|
set.insert(value.trimmed());
|
||||||
foreach (const QString &value, buddy.split(",", SKIP_EMPTY)) \
|
|
||||||
{ \
|
|
||||||
set.insert(value.trimmed()); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
QStringList setList = set.values(); \
|
|
||||||
std::sort(setList.begin(), setList.end()); \
|
|
||||||
setStringList(setList); \
|
|
||||||
}
|
}
|
||||||
|
QStringList setList = set.values();
|
||||||
|
std::sort(setList.begin(), setList.end());
|
||||||
|
return setList;
|
||||||
|
}
|
||||||
|
|
||||||
CREATE_CSV_UPDATE_METHOD(BuddyCompletionModel, buddy);
|
void BuddyCompletionModel::updateModel()
|
||||||
CREATE_CSV_UPDATE_METHOD(DiveMasterCompletionModel, divemaster);
|
{
|
||||||
CREATE_UPDATE_METHOD(SuitCompletionModel, suit);
|
setStringList(getCSVList(&dive::buddy));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DiveMasterCompletionModel::updateModel()
|
||||||
|
{
|
||||||
|
setStringList(getCSVList(&dive::divemaster));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SuitCompletionModel::updateModel()
|
||||||
|
{
|
||||||
|
QStringList list;
|
||||||
|
struct dive *dive;
|
||||||
|
int i = 0;
|
||||||
|
for_each_dive (i, dive) {
|
||||||
|
QString suit(dive->suit);
|
||||||
|
if (!list.contains(suit))
|
||||||
|
list.append(suit);
|
||||||
|
}
|
||||||
|
std::sort(list.begin(), list.end());
|
||||||
|
setStringList(list);
|
||||||
|
}
|
||||||
|
|
||||||
void TagCompletionModel::updateModel()
|
void TagCompletionModel::updateModel()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue