This commit is contained in:
Andrzej Rybczak
2009-02-17 08:29:40 +01:00
parent 7c936d8eaf
commit 32bac776e7
11 changed files with 31 additions and 47 deletions

View File

@@ -134,7 +134,7 @@ void Browser::EnterPressed()
if (s->GetHash() == list[0]->GetHash()) if (s->GetHash() == list[0]->GetHash())
Mpd->PlayID(s->GetID()); Mpd->PlayID(s->GetID());
else else
ShowMessage("%s", message_part_of_songs_added); ShowMessage("%s", MPD::Message::PartOfSongsAdded);
} }
FreeSongList(list); FreeSongList(list);
break; break;
@@ -178,7 +178,7 @@ void Browser::SpacePressed()
ShowMessage("Added folder: %s", item.name.c_str()); ShowMessage("Added folder: %s", item.name.c_str());
Song &s = myPlaylist->Main()->at(myPlaylist->Main()->Size()-list.size()); Song &s = myPlaylist->Main()->at(myPlaylist->Main()->Size()-list.size());
if (s.GetHash() != list[0]->GetHash()) if (s.GetHash() != list[0]->GetHash())
ShowMessage("%s", message_part_of_songs_added); ShowMessage("%s", MPD::Message::PartOfSongsAdded);
} }
FreeSongList(list); FreeSongList(list);
break; break;
@@ -224,7 +224,7 @@ void Browser::SpacePressed()
ShowMessage("Loading playlist %s...", item.name.c_str()); ShowMessage("Loading playlist %s...", item.name.c_str());
Song &s = myPlaylist->Main()->at(myPlaylist->Main()->Size()-list.size()); Song &s = myPlaylist->Main()->at(myPlaylist->Main()->Size()-list.size());
if (s.GetHash() != list[0]->GetHash()) if (s.GetHash() != list[0]->GetHash())
ShowMessage("%s", message_part_of_songs_added); ShowMessage("%s", MPD::Message::PartOfSongsAdded);
} }
FreeSongList(list); FreeSongList(list);
break; break;

View File

@@ -247,14 +247,6 @@ bool Keypressed(int in, const int *key)
return in == key[0] || in == key[1]; return in == key[0] || in == key[1];
} }
bool SortSongsByTrack(Song *a, Song *b)
{
if (a->GetDisc() == b->GetDisc())
return StrToInt(a->GetTrack()) < StrToInt(b->GetTrack());
else
return StrToInt(a->GetDisc()) < StrToInt(b->GetDisc());
}
string FindSharedDir(const string &one, const string &two) string FindSharedDir(const string &one, const string &two)
{ {
if (one == two) if (one == two)

View File

@@ -37,8 +37,6 @@ class CaseInsensitiveSorting
bool operator()(const MPD::Item &, const MPD::Item &); bool operator()(const MPD::Item &, const MPD::Item &);
}; };
bool SortSongsByTrack(MPD::Song *, MPD::Song *);
void UpdateSongList(Menu<MPD::Song> *); void UpdateSongList(Menu<MPD::Song> *);
bool Keypressed(int, const int *); bool Keypressed(int, const int *);

View File

@@ -345,7 +345,7 @@ void MediaLibrary::AddToPlaylist(bool add_n_play)
Mpd->PlayID(s->GetID()); Mpd->PlayID(s->GetID());
} }
else else
ShowMessage("%s", message_part_of_songs_added); ShowMessage("%s", MPD::Message::PartOfSongsAdded);
} }
} }
else if (w == Albums) else if (w == Albums)
@@ -362,7 +362,7 @@ void MediaLibrary::AddToPlaylist(bool add_n_play)
Mpd->PlayID(s->GetID()); Mpd->PlayID(s->GetID());
} }
else else
ShowMessage("%s", message_part_of_songs_added); ShowMessage("%s", MPD::Message::PartOfSongsAdded);
} }
} }
else if (w == Songs) else if (w == Songs)
@@ -428,3 +428,11 @@ void MediaLibrary::AddToPlaylist(bool add_n_play)
} }
} }
bool MediaLibrary::SortSongsByTrack(Song *a, Song *b)
{
if (a->GetDisc() == b->GetDisc())
return StrToInt(a->GetTrack()) < StrToInt(b->GetTrack());
else
return StrToInt(a->GetDisc()) < StrToInt(b->GetDisc());
}

View File

@@ -57,6 +57,8 @@ class MediaLibrary : public Screen<Window>
protected: protected:
void AddToPlaylist(bool); void AddToPlaylist(bool);
static bool SortSongsByTrack(MPD::Song *, MPD::Song *);
static size_t itsLeftColWidth; static size_t itsLeftColWidth;
static size_t itsMiddleColWidth; static size_t itsMiddleColWidth;
static size_t itsMiddleColStartX; static size_t itsMiddleColStartX;

View File

@@ -25,7 +25,8 @@ using namespace MPD;
using std::string; using std::string;
const char *playlist_max_message = "playlist is at the max size"; const char *MPD::Message::PartOfSongsAdded = "Only part of requested songs' list added to playlist!";
const char *MPD::Message::FullPlaylist = "Playlist is full!";
Connection::Connection() : isConnected(0), Connection::Connection() : isConnected(0),
itsErrorCode(0), itsErrorCode(0),
@@ -486,7 +487,7 @@ int Connection::AddSong(const string &path)
} }
else else
if (itsErrorHandler) if (itsErrorHandler)
itsErrorHandler(this, MPD_ACK_ERROR_PLAYLIST_MAX, playlist_max_message, NULL); itsErrorHandler(this, MPD_ACK_ERROR_PLAYLIST_MAX, Message::FullPlaylist, NULL);
} }
return id; return id;
} }
@@ -627,7 +628,7 @@ bool Connection::CommitQueue()
mpd_finishCommand(itsConnection); mpd_finishCommand(itsConnection);
UpdateStatus(); UpdateStatus();
if (GetPlaylistLength() == itsMaxPlaylistLength && itsErrorHandler) if (GetPlaylistLength() == itsMaxPlaylistLength && itsErrorHandler)
itsErrorHandler(this, MPD_ACK_ERROR_PLAYLIST_MAX, playlist_max_message, NULL); itsErrorHandler(this, MPD_ACK_ERROR_PLAYLIST_MAX, Message::FullPlaylist, NULL);
retval = !itsQueue.empty(); retval = !itsQueue.empty();
} }
ClearQueue(); ClearQueue();

View File

@@ -28,6 +28,12 @@
namespace MPD namespace MPD
{ {
namespace Message
{
extern const char *PartOfSongsAdded;
extern const char *FullPlaylist;
}
enum QueueCommandType { qctAdd, qctAddToPlaylist, qctDelete, qctDeleteID, qctMove, qctPlaylistMove, qctDeleteFromPlaylist }; enum QueueCommandType { qctAdd, qctAddToPlaylist, qctDelete, qctDeleteID, qctMove, qctPlaylistMove, qctDeleteFromPlaylist };
enum ItemType { itDirectory, itSong, itPlaylist }; enum ItemType { itDirectory, itSong, itPlaylist };
enum PlayerState { psUnknown, psStop, psPlay, psPause }; enum PlayerState { psUnknown, psStop, psPlay, psPause };

View File

@@ -818,7 +818,7 @@ int main(int argc, char *argv[])
{ {
Song &s = myPlaylist->Main()->at(myPlaylist->Main()->Size()-list.size()); Song &s = myPlaylist->Main()->at(myPlaylist->Main()->Size()-list.size());
if (s.GetHash() != list[0]->GetHash()) if (s.GetHash() != list[0]->GetHash())
ShowMessage("%s", message_part_of_songs_added); ShowMessage("%s", MPD::Message::PartOfSongsAdded);
} }
} }
else else
@@ -1275,7 +1275,7 @@ int main(int argc, char *argv[])
ShowMessage("Selected items added!"); ShowMessage("Selected items added!");
Song &s = myPlaylist->Main()->at(myPlaylist->Main()->Size()-result.size()); Song &s = myPlaylist->Main()->at(myPlaylist->Main()->Size()-result.size());
if (s.GetHash() != result[0]->GetHash()) if (s.GetHash() != result[0]->GetHash())
ShowMessage("%s", message_part_of_songs_added); ShowMessage("%s", MPD::Message::PartOfSongsAdded);
} }
} }
else if (id == 1) else if (id == 1)

View File

@@ -24,7 +24,6 @@
#include "window.h" #include "window.h"
#include "menu.h" #include "menu.h"
#include "scrollpad.h" #include "scrollpad.h"
#include "misc.h"
#define CLEAR_FIND_HISTORY \ #define CLEAR_FIND_HISTORY \
do { \ do { \
@@ -34,33 +33,9 @@
typedef std::pair<std::string, std::string> string_pair; typedef std::pair<std::string, std::string> string_pair;
/*enum NcmpcppScreen
{
myHelp,
myPlaylist,
myBrowser,
# ifdef HAVE_TAGLIB_H
myTinyTagEditor,
# endif // HAVE_TAGLIB_H
myInfo,
mySearcher,
myLibrary,
myLyrics,
myPlaylistEditor,
# ifdef HAVE_TAGLIB_H
myTagEditor,
# endif // HAVE_TAGLIB_H
# ifdef ENABLE_CLOCK
myClock,
# endif // ENABLE_CLOCK
csOther
};*/
const int ncmpcpp_window_timeout = 500; const int ncmpcpp_window_timeout = 500;
const std::string home_folder = getenv("HOME") ? getenv("HOME") : ""; const std::string home_folder = getenv("HOME") ? getenv("HOME") : "";
const char * const message_part_of_songs_added = "Only part of requested songs' list added to playlist!";
#endif #endif

View File

@@ -204,7 +204,7 @@ void PlaylistEditor::AddToPlaylist(bool add_n_play)
Mpd->PlayID(s.GetID()); Mpd->PlayID(s.GetID());
} }
else else
ShowMessage("%s", message_part_of_songs_added); ShowMessage("%s", MPD::Message::PartOfSongsAdded);
} }
} }
else if (w == Content) else if (w == Content)

View File

@@ -21,11 +21,13 @@
#ifndef _SETTINGS_H #ifndef _SETTINGS_H
#define _SETTINGS_H #define _SETTINGS_H
#include <limits>
#include "libmpdclient.h" #include "libmpdclient.h"
#include "ncmpcpp.h" #include "ncmpcpp.h"
const std::string config_dir = home_folder + "/.ncmpcpp/"; const std::string config_dir = home_folder + "/.ncmpcpp/";
const int null_key = 0x0fffffff; const int null_key = std::numeric_limits<int>::max();
struct ncmpcpp_keys struct ncmpcpp_keys
{ {