Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
e6a974a9
Commit
e6a974a9
authored
Sep 02, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/Selection: add `sort` and `window`
Remove them as parameters from `db_selection_print()`.
parent
9894967f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
34 deletions
+33
-34
DatabaseCommands.cxx
src/command/DatabaseCommands.cxx
+5
-4
DatabasePrint.cxx
src/db/DatabasePrint.cxx
+9
-16
DatabasePrint.hxx
src/db/DatabasePrint.hxx
+1
-12
Selection.cxx
src/db/Selection.cxx
+1
-1
Selection.hxx
src/db/Selection.hxx
+17
-1
No files found.
src/command/DatabaseCommands.cxx
View file @
e6a974a9
...
...
@@ -107,12 +107,13 @@ handle_match(Client &client, Request args, Response &r, bool fold_case)
}
filter
.
Optimize
();
const
DatabaseSelection
selection
(
""
,
true
,
&
filter
);
DatabaseSelection
selection
(
""
,
true
,
&
filter
);
selection
.
window
=
window
;
selection
.
sort
=
sort
;
selection
.
descending
=
descending
;
db_selection_print
(
r
,
client
.
GetPartition
(),
selection
,
true
,
false
,
sort
,
descending
,
window
);
selection
,
true
,
false
);
return
CommandResult
::
OK
;
}
...
...
src/db/DatabasePrint.cxx
View file @
e6a974a9
/*
* Copyright 2003-201
7
The Music Player Daemon Project
* Copyright 2003-201
8
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -179,9 +179,7 @@ CompareTags(TagType type, bool descending, const Tag &a, const Tag &b) noexcept
void
db_selection_print
(
Response
&
r
,
Partition
&
partition
,
const
DatabaseSelection
&
selection
,
bool
full
,
bool
base
,
TagType
sort
,
bool
descending
,
RangeArg
window
)
bool
full
,
bool
base
)
{
const
Database
&
db
=
partition
.
GetDatabaseOrThrow
();
...
...
@@ -197,9 +195,11 @@ db_selection_print(Response &r, Partition &partition,
std
::
ref
(
r
),
base
,
_1
,
_2
)
:
VisitPlaylist
();
if
(
sort
==
TAG_NUM_OF_ITEM_TYPES
)
{
const
auto
window
=
selection
.
window
;
if
(
selection
.
sort
==
TAG_NUM_OF_ITEM_TYPES
)
{
unsigned
i
=
0
;
if
(
!
window
.
IsAll
())
if
(
!
selection
.
window
.
IsAll
())
s
=
[
s
,
window
,
&
i
](
const
LightSong
&
song
){
if
(
window
.
Contains
(
i
++
))
s
(
song
);
...
...
@@ -223,6 +223,9 @@ db_selection_print(Response &r, Partition &partition,
db
.
Visit
(
selection
,
d
,
collect_songs
,
p
);
}
const
auto
sort
=
selection
.
sort
;
const
auto
descending
=
selection
.
descending
;
if
(
sort
==
TagType
(
SORT_TAG_LAST_MODIFIED
))
std
::
stable_sort
(
songs
.
begin
(),
songs
.
end
(),
[
descending
](
const
DetachedSong
&
a
,
const
DetachedSong
&
b
){
...
...
@@ -254,16 +257,6 @@ db_selection_print(Response &r, Partition &partition,
}
}
void
db_selection_print
(
Response
&
r
,
Partition
&
partition
,
const
DatabaseSelection
&
selection
,
bool
full
,
bool
base
)
{
db_selection_print
(
r
,
partition
,
selection
,
full
,
base
,
TAG_NUM_OF_ITEM_TYPES
,
false
,
RangeArg
::
All
());
}
static
void
PrintSongURIVisitor
(
Response
&
r
,
const
LightSong
&
song
)
noexcept
{
...
...
src/db/DatabasePrint.hxx
View file @
e6a974a9
/*
* Copyright 2003-201
7
The Music Player Daemon Project
* Copyright 2003-201
8
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -39,17 +39,6 @@ db_selection_print(Response &r, Partition &partition,
const
DatabaseSelection
&
selection
,
bool
full
,
bool
base
);
/**
* @param sort the sort tag; TAG_NUM_OF_ITEM_TYPES means don't sort;
* LOCATE_TAG_MODIFIED_SINCE means sort by file modification time
*/
void
db_selection_print
(
Response
&
r
,
Partition
&
partition
,
const
DatabaseSelection
&
selection
,
bool
full
,
bool
base
,
TagType
sort
,
bool
descending
,
RangeArg
window
);
void
PrintSongUris
(
Response
&
r
,
Partition
&
partition
,
const
SongFilter
*
filter
);
...
...
src/db/Selection.cxx
View file @
e6a974a9
/*
* Copyright 2003-201
7
The Music Player Daemon Project
* Copyright 2003-201
8
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
src/db/Selection.hxx
View file @
e6a974a9
/*
* Copyright 2003-201
7
The Music Player Daemon Project
* Copyright 2003-201
8
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -20,6 +20,8 @@
#ifndef MPD_DATABASE_SELECTION_HXX
#define MPD_DATABASE_SELECTION_HXX
#include "protocol/RangeArg.hxx"
#include "tag/Type.h"
#include "util/Compiler.h"
#include <string>
...
...
@@ -36,6 +38,20 @@ struct DatabaseSelection {
const
SongFilter
*
filter
;
RangeArg
window
=
RangeArg
::
All
();
/**
* Sort the result by the given tag. #TAG_NUM_OF_ITEM_TYPES
* means don't sort. #SORT_TAG_LAST_MODIFIED sorts by
* "Last-Modified" (not technically a tag).
*/
TagType
sort
=
TAG_NUM_OF_ITEM_TYPES
;
/**
* If #sort is set, this flag can reverse the sort order.
*/
bool
descending
=
false
;
/**
* Recursively search all sub directories?
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment