move a few small functions to actions
This commit is contained in:
@@ -980,7 +980,7 @@ bool MoveSortOrderUp::canBeRun() const
|
|||||||
|
|
||||||
void MoveSortOrderUp::Run()
|
void MoveSortOrderUp::Run()
|
||||||
{
|
{
|
||||||
myPlaylist->AdjustSortOrder(Playlist::mUp);
|
myPlaylist->moveSortOrderUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MoveSortOrderDown::canBeRun() const
|
bool MoveSortOrderDown::canBeRun() const
|
||||||
@@ -991,35 +991,55 @@ bool MoveSortOrderDown::canBeRun() const
|
|||||||
|
|
||||||
void MoveSortOrderDown::Run()
|
void MoveSortOrderDown::Run()
|
||||||
{
|
{
|
||||||
myPlaylist->AdjustSortOrder(Playlist::mDown);
|
myPlaylist->moveSortOrderDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MoveSelectedItemsUp::canBeRun() const
|
bool MoveSelectedItemsUp::canBeRun() const
|
||||||
{
|
{
|
||||||
return myScreen->ActiveWindow() == myPlaylist->Items
|
return ((myScreen->ActiveWindow() == myPlaylist->Items
|
||||||
|| myScreen->ActiveWindow() == myPlaylistEditor->Content;
|
&& !myPlaylist->Items->empty()
|
||||||
|
&& !myPlaylist->Items->isFiltered())
|
||||||
|
|| (myScreen->ActiveWindow() == myPlaylistEditor->Content
|
||||||
|
&& !myPlaylistEditor->Content->empty()
|
||||||
|
&& !myPlaylistEditor->Content->isFiltered()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveSelectedItemsUp::Run()
|
void MoveSelectedItemsUp::Run()
|
||||||
{
|
{
|
||||||
if (myScreen == myPlaylist)
|
if (myScreen == myPlaylist)
|
||||||
myPlaylist->MoveSelectedItems(Playlist::mUp);
|
{
|
||||||
|
moveSelectedItemsUp(*myPlaylist->Items, std::bind(&MPD::Connection::Move, _1, _2, _3));
|
||||||
|
}
|
||||||
else if (myScreen == myPlaylistEditor)
|
else if (myScreen == myPlaylistEditor)
|
||||||
myPlaylistEditor->MoveSelectedItems(Playlist::mUp);
|
{
|
||||||
|
assert(!myPlaylistEditor->Playlists->empty());
|
||||||
|
std::string playlist = myPlaylistEditor->Playlists->current().value();
|
||||||
|
moveSelectedItemsUp(*myPlaylistEditor->Content, std::bind(&MPD::Connection::PlaylistMove, _1, playlist, _2, _3));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MoveSelectedItemsDown::canBeRun() const
|
bool MoveSelectedItemsDown::canBeRun() const
|
||||||
{
|
{
|
||||||
return myScreen->ActiveWindow() == myPlaylist->Items
|
return ((myScreen->ActiveWindow() == myPlaylist->Items
|
||||||
|| myScreen->ActiveWindow() == myPlaylistEditor->Content;
|
&& !myPlaylist->Items->empty()
|
||||||
|
&& !myPlaylist->Items->isFiltered())
|
||||||
|
|| (myScreen->ActiveWindow() == myPlaylistEditor->Content
|
||||||
|
&& !myPlaylistEditor->Content->empty()
|
||||||
|
&& !myPlaylistEditor->Content->isFiltered()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveSelectedItemsDown::Run()
|
void MoveSelectedItemsDown::Run()
|
||||||
{
|
{
|
||||||
if (myScreen == myPlaylist)
|
if (myScreen == myPlaylist)
|
||||||
myPlaylist->MoveSelectedItems(Playlist::mDown);
|
{
|
||||||
|
moveSelectedItemsDown(*myPlaylist->Items, std::bind(&MPD::Connection::Move, _1, _2, _3));
|
||||||
|
}
|
||||||
else if (myScreen == myPlaylistEditor)
|
else if (myScreen == myPlaylistEditor)
|
||||||
myPlaylistEditor->MoveSelectedItems(Playlist::mDown);
|
{
|
||||||
|
assert(!myPlaylistEditor->Playlists->empty());
|
||||||
|
std::string playlist = myPlaylistEditor->Playlists->current().value();
|
||||||
|
moveSelectedItemsDown(*myPlaylistEditor->Content, std::bind(&MPD::Connection::PlaylistMove, _1, playlist, _2, _3));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MoveSelectedItemsTo::canBeRun() const
|
bool MoveSelectedItemsTo::canBeRun() const
|
||||||
|
|||||||
@@ -374,26 +374,6 @@ bool Playlist::isFiltered()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playlist::MoveSelectedItems(Movement where)
|
|
||||||
{
|
|
||||||
if (Items->empty() || isFiltered())
|
|
||||||
return;
|
|
||||||
|
|
||||||
switch (where)
|
|
||||||
{
|
|
||||||
case mUp:
|
|
||||||
{
|
|
||||||
moveSelectedItemsUp(*Items, std::bind(&MPD::Connection::Move, _1, _2, _3));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case mDown:
|
|
||||||
{
|
|
||||||
moveSelectedItemsDown(*Items, std::bind(&MPD::Connection::Move, _1, _2, _3));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Playlist::Sort()
|
void Playlist::Sort()
|
||||||
{
|
{
|
||||||
if (isFiltered())
|
if (isFiltered())
|
||||||
@@ -434,33 +414,6 @@ void Playlist::Reverse()
|
|||||||
ShowMessage("Playlist reversed");
|
ShowMessage("Playlist reversed");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playlist::AdjustSortOrder(Movement where)
|
|
||||||
{
|
|
||||||
switch (where)
|
|
||||||
{
|
|
||||||
case mUp:
|
|
||||||
{
|
|
||||||
size_t pos = SortDialog->choice();
|
|
||||||
if (pos > 0 && pos < SortOptions)
|
|
||||||
{
|
|
||||||
SortDialog->Swap(pos, pos-1);
|
|
||||||
SortDialog->scroll(NC::wUp);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case mDown:
|
|
||||||
{
|
|
||||||
size_t pos = SortDialog->choice();
|
|
||||||
if (pos < SortOptions-1)
|
|
||||||
{
|
|
||||||
SortDialog->Swap(pos, pos+1);
|
|
||||||
SortDialog->scroll(NC::wDown);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Playlist::EnableHighlighting()
|
void Playlist::EnableHighlighting()
|
||||||
{
|
{
|
||||||
Items->setHighlighting(1);
|
Items->setHighlighting(1);
|
||||||
@@ -620,6 +573,26 @@ bool Playlist::checkForSong(const MPD::Song &s)
|
|||||||
return itsSongHashes.find(s.getHash()) != itsSongHashes.end();
|
return itsSongHashes.find(s.getHash()) != itsSongHashes.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Playlist::moveSortOrderDown()
|
||||||
|
{
|
||||||
|
size_t pos = SortDialog->choice();
|
||||||
|
if (pos < SortOptions-1)
|
||||||
|
{
|
||||||
|
SortDialog->Swap(pos, pos+1);
|
||||||
|
SortDialog->scroll(NC::wDown);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Playlist::moveSortOrderUp()
|
||||||
|
{
|
||||||
|
size_t pos = SortDialog->choice();
|
||||||
|
if (pos > 0 && pos < SortOptions)
|
||||||
|
{
|
||||||
|
SortDialog->Swap(pos, pos-1);
|
||||||
|
SortDialog->scroll(NC::wUp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Playlist::registerHash(size_t hash)
|
void Playlist::registerHash(size_t hash)
|
||||||
{
|
{
|
||||||
itsSongHashes[hash] += 1;
|
itsSongHashes[hash] += 1;
|
||||||
|
|||||||
@@ -30,8 +30,6 @@
|
|||||||
class Playlist : public Screen<NC::Window>, public Filterable, public HasSongs, public Searchable
|
class Playlist : public Screen<NC::Window>, public Filterable, public HasSongs, public Searchable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Movement { mUp, mDown };
|
|
||||||
|
|
||||||
Playlist() : NowPlaying(-1), itsTotalLength(0), itsRemainingTime(0), itsScrollBegin(0) { }
|
Playlist() : NowPlaying(-1), itsTotalLength(0), itsRemainingTime(0), itsScrollBegin(0) { }
|
||||||
~Playlist() { }
|
~Playlist() { }
|
||||||
|
|
||||||
@@ -73,11 +71,8 @@ class Playlist : public Screen<NC::Window>, public Filterable, public HasSongs,
|
|||||||
bool isPlaying() { return NowPlaying >= 0 && !Items->empty(); }
|
bool isPlaying() { return NowPlaying >= 0 && !Items->empty(); }
|
||||||
const MPD::Song *NowPlayingSong();
|
const MPD::Song *NowPlayingSong();
|
||||||
|
|
||||||
void MoveSelectedItems(Movement where);
|
|
||||||
|
|
||||||
void Sort();
|
void Sort();
|
||||||
void Reverse();
|
void Reverse();
|
||||||
void AdjustSortOrder(Movement where);
|
|
||||||
bool SortingInProgress();
|
bool SortingInProgress();
|
||||||
|
|
||||||
void EnableHighlighting();
|
void EnableHighlighting();
|
||||||
@@ -92,6 +87,9 @@ class Playlist : public Screen<NC::Window>, public Filterable, public HasSongs,
|
|||||||
|
|
||||||
bool checkForSong(const MPD::Song &s);
|
bool checkForSong(const MPD::Song &s);
|
||||||
|
|
||||||
|
void moveSortOrderUp();
|
||||||
|
void moveSortOrderDown();
|
||||||
|
|
||||||
void registerHash(size_t hash);
|
void registerHash(size_t hash);
|
||||||
void unregisterHash(size_t hash);
|
void unregisterHash(size_t hash);
|
||||||
|
|
||||||
|
|||||||
@@ -208,26 +208,6 @@ void PlaylistEditor::Update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistEditor::MoveSelectedItems(Playlist::Movement where)
|
|
||||||
{
|
|
||||||
if (Content->empty() || isContentFiltered())
|
|
||||||
return;
|
|
||||||
|
|
||||||
switch (where)
|
|
||||||
{
|
|
||||||
case Playlist::mUp:
|
|
||||||
{
|
|
||||||
moveSelectedItemsUp(*Content, std::bind(&MPD::Connection::PlaylistMove, _1, Playlists->current().value(), _2, _3));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Playlist::mDown:
|
|
||||||
{
|
|
||||||
moveSelectedItemsDown(*Content, std::bind(&MPD::Connection::PlaylistMove, _1, Playlists->current().value(), _2, _3));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PlaylistEditor::isContentFiltered()
|
bool PlaylistEditor::isContentFiltered()
|
||||||
{
|
{
|
||||||
if (Content->isFiltered())
|
if (Content->isFiltered())
|
||||||
@@ -238,7 +218,6 @@ bool PlaylistEditor::isContentFiltered()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PlaylistEditor::isNextColumnAvailable()
|
bool PlaylistEditor::isNextColumnAvailable()
|
||||||
{
|
{
|
||||||
if (w == Playlists)
|
if (w == Playlists)
|
||||||
|
|||||||
@@ -21,7 +21,8 @@
|
|||||||
#ifndef _PLAYLIST_EDITOR_H
|
#ifndef _PLAYLIST_EDITOR_H
|
||||||
#define _PLAYLIST_EDITOR_H
|
#define _PLAYLIST_EDITOR_H
|
||||||
|
|
||||||
#include "playlist.h"
|
#include "interfaces.h"
|
||||||
|
#include "screen.h"
|
||||||
|
|
||||||
class PlaylistEditor : public Screen<NC::Window>, public Filterable, public HasSongs, public Searchable
|
class PlaylistEditor : public Screen<NC::Window>, public Filterable, public HasSongs, public Searchable
|
||||||
{
|
{
|
||||||
@@ -62,8 +63,6 @@ class PlaylistEditor : public Screen<NC::Window>, public Filterable, public HasS
|
|||||||
// private members
|
// private members
|
||||||
virtual void Locate(const std::string &);
|
virtual void Locate(const std::string &);
|
||||||
|
|
||||||
void MoveSelectedItems(Playlist::Movement where);
|
|
||||||
|
|
||||||
void requestPlaylistsUpdate() { playlistsUpdateRequested = true; }
|
void requestPlaylistsUpdate() { playlistsUpdateRequested = true; }
|
||||||
void requestContentsUpdate() { contentUpdateRequested = true; }
|
void requestContentsUpdate() { contentUpdateRequested = true; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user