/
sort.h
138 lines (114 loc) · 3.98 KB
/
sort.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
Arbitrary Sorting Filter(s)
Copyright (C) 2004 Robert Lipe, robertlipe+source@gpsbabel.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SORT_H_INCLUDED_
#define SORT_H_INCLUDED_
#include <QString> // for QString
#include <QVector> // for QVector
#include "defs.h" // for arglist_t, ARGTYPE_BOOL, ARG_NOMINMAX, Waypoint
#include "filter.h" // for Filter
#if FILTERS_ENABLED
class SortFilter:public Filter
{
public:
/* Member Functions */
QVector<arglist_t>* get_args() override
{
return &args;
}
void init() override;
void process() override;
private:
/* Types */
enum class SortModeWpt {
none,
description,
gcid,
shortname,
time
};
enum class SortModeRteHd {
none,
description,
name,
number
};
/* Member Functions */
static bool sort_comp_wpt_by_description(const Waypoint* a, const Waypoint* b);
static bool sort_comp_wpt_by_gcid(const Waypoint* a, const Waypoint* b);
static bool sort_comp_wpt_by_shortname(const Waypoint* a, const Waypoint* b);
static bool sort_comp_wpt_by_time(const Waypoint* a, const Waypoint* b);
static bool sort_comp_rh_by_description(const route_head* a, const route_head* b);
static bool sort_comp_rh_by_name(const route_head* a, const route_head* b);
static bool sort_comp_rh_by_number(const route_head* a, const route_head* b);
/* Data Members */
SortModeWpt wpt_sort_mode{SortModeWpt::none}; /* How are we sorting these? */
SortModeRteHd rte_sort_mode{SortModeRteHd::none}; /* How are we sorting these? */
SortModeRteHd trk_sort_mode{SortModeRteHd::none}; /* How are we sorting these? */
char* opt_sm_gcid{};
char* opt_sm_shortname{};
char* opt_sm_description{};
char* opt_sm_time{};
char* opt_sm_rtenum{};
char* opt_sm_rtename{};
char* opt_sm_rtedesc{};
char* opt_sm_trknum{};
char* opt_sm_trkname{};
char* opt_sm_trkdesc{};
QVector<arglist_t> args = {
{
"description", &opt_sm_description, "Sort waypoints by description",
nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
},
{
"gcid", &opt_sm_gcid, "Sort waypoints by numeric geocache ID",
nullptr, ARGTYPE_BEGIN_EXCL | ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
},
{
"shortname", &opt_sm_shortname, "Sort waypoints by short name",
nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
},
{
"time", &opt_sm_time, "Sort waypoints by time",
nullptr, ARGTYPE_END_EXCL | ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
},
{
"rtedesc", &opt_sm_rtedesc, "Sort routes by description",
nullptr, ARGTYPE_END_EXCL | ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
},
{
"rtename", &opt_sm_rtename, "Sort routes by name",
nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
},
{
"rtenum", &opt_sm_rtenum, "Sort routes by number",
nullptr, ARGTYPE_BEGIN_EXCL | ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
},
{
"trkdesc", &opt_sm_trkdesc, "Sort tracks by description",
nullptr, ARGTYPE_END_EXCL | ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
},
{
"trkname", &opt_sm_trkname, "Sort tracks by name",
nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
},
{
"trknum", &opt_sm_trknum, "Sort tracks by number",
nullptr, ARGTYPE_BEGIN_EXCL | ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
},
};
};
#endif // FILTERS_ENABLED
#endif // SORT_H_INCLUDED_