Sayonara Player
Loading...
Searching...
No Matches
Utils.h
1/* Utils.h */
2/*
3 * Copyright (C) 2011-2024 Michael Lugmair
4 *
5 * This file is part of sayonara player
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef SAYONARA_PLAYER_UTILS_H
22#define SAYONARA_PLAYER_UTILS_H
23
24#include "Utils/typedefs.h"
25
26#include <QList>
27#include <QMap>
28#include <QString>
29#include <QSqlQuery>
30
31#include <utility>
32#include <vector>
33
34namespace Library
35{
36 class Filter;
37}
38
39namespace Util
40{
41 using Range = std::pair<int, int>;
42 using RangeList = std::vector<Range>;
43}
44
45namespace DB
46{
48 {
49 enum class ArtistIdField :
50 uint8_t
51 {
52 AlbumArtistId,
53 ArtistId
54 } key;
55 QString idField;
56 QString nameField;
57 };
58
60 {
61 QString sqlString;
62 QMap<QString, int> mapping;
63 };
64
65 RangeMapping convertRangesToMapping(const Util::RangeList& ranges, const QString& attribute,
66 const QString& sqlPlaceholderTemplate);
67
68 void bindMappingToQuery(QSqlQuery& query, const RangeMapping& rangeMapping, const QList<Id>& elements);
69
70 QString getFilterWhereStatement(const ::Library::Filter& filter, QString searchPlaceholder);
71}
72
73#endif //SAYONARA_PLAYER_UTILS_H
Definition Filter.h:34
Definition EngineUtils.h:33
Definition org_mpris_media_player2_adaptor.h:21
Helper functions.
Definition MetaTypeRegistry.h:25
Definition Utils.h:48
Definition Utils.h:60