make 'go to containing dir' function work on all screens

This commit is contained in:
unK
2008-09-03 05:20:22 +02:00
parent 3bdac53feb
commit 0658eb1c7c
2 changed files with 42 additions and 7 deletions

View File

@@ -271,6 +271,7 @@ int main(int argc, char *argv[])
sHelp->Add(DisplayKeys(Key.PrevFoundPosition) + "Go to previous found position\n"); sHelp->Add(DisplayKeys(Key.PrevFoundPosition) + "Go to previous found position\n");
sHelp->Add(DisplayKeys(Key.NextFoundPosition) + "Go to next found position\n"); sHelp->Add(DisplayKeys(Key.NextFoundPosition) + "Go to next found position\n");
sHelp->Add(DisplayKeys(Key.ToggleFindMode) + "Toggle find mode (normal/wrapped)\n"); sHelp->Add(DisplayKeys(Key.ToggleFindMode) + "Toggle find mode (normal/wrapped)\n");
sHelp->Add(DisplayKeys(Key.GoToContainingDir) + "Go to directory containing current item\n");
sHelp->Add(DisplayKeys(Key.EditTags) + tag_screen_keydesc); sHelp->Add(DisplayKeys(Key.EditTags) + tag_screen_keydesc);
sHelp->Add(DisplayKeys(Key.GoToPosition) + "Go to chosen position in current song\n"); sHelp->Add(DisplayKeys(Key.GoToPosition) + "Go to chosen position in current song\n");
sHelp->Add(DisplayKeys(Key.Lyrics) + "Show/hide song's lyrics\n\n"); sHelp->Add(DisplayKeys(Key.Lyrics) + "Show/hide song's lyrics\n\n");
@@ -298,8 +299,7 @@ int main(int argc, char *argv[])
sHelp->Add(" [.b]Keys - Search engine\n -----------------------------------------[/b]\n"); sHelp->Add(" [.b]Keys - Search engine\n -----------------------------------------[/b]\n");
sHelp->Add(DisplayKeys(Key.Enter) + "Add item to playlist and play/change option\n"); sHelp->Add(DisplayKeys(Key.Enter) + "Add item to playlist and play/change option\n");
sHelp->Add(DisplayKeys(Key.Space) + "Add item to playlist\n"); sHelp->Add(DisplayKeys(Key.Space) + "Add item to playlist\n");
sHelp->Add(DisplayKeys(Key.StartSearching) + "Start searching immediately\n"); sHelp->Add(DisplayKeys(Key.StartSearching) + "Start searching immediately\n\n\n");
sHelp->Add(DisplayKeys(Key.GoToContainingDir) + "Go to directory containing found item\n\n\n");
sHelp->Add(" [.b]Keys - Media library\n -----------------------------------------[/b]\n"); sHelp->Add(" [.b]Keys - Media library\n -----------------------------------------[/b]\n");
sHelp->Add(DisplayKeys(&Key.VolumeDown[0], 1) + "Previous column\n"); sHelp->Add(DisplayKeys(&Key.VolumeDown[0], 1) + "Previous column\n");
@@ -1803,12 +1803,39 @@ int main(int argc, char *argv[])
} }
else if (Keypressed(input, Key.GoToContainingDir)) else if (Keypressed(input, Key.GoToContainingDir))
{ {
if (wCurrent == mSearcher && !vSearched.empty() && mSearcher->GetChoice() > search_engine_static_option) if ((wCurrent == mPlaylist && !mPlaylist->Empty())
|| (wCurrent == mSearcher && !vSearched.empty() && mSearcher->GetChoice() > search_engine_static_option)
|| (wCurrent == mLibSongs && !mLibSongs->Empty())
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty()))
{ {
GetDirectory(vSearched[mSearcher->GetRealChoice()-2]->GetDirectory()); int id = wCurrent->GetChoice()-1;
for (int i = 1; i < mBrowser->Size(); i++) Song *s;
switch (current_screen)
{ {
if (mSearcher->GetCurrentOption() == mBrowser->GetOption(i)) case csPlaylist:
s = &mPlaylist->at(id);
break;
case csSearcher:
s = vSearched[mSearcher->GetRealChoice()-2];
break;
case csLibrary:
s = &mLibSongs->at(id);
break;
case csPlaylistEditor:
s = &mPlaylistEditor->at(id);
break;
default:
break;
}
if (s->GetDirectory() == EMPTY_TAG) // for streams
continue;
string option = OmitBBCodes(DisplaySong(*s));
GetDirectory(s->GetDirectory());
for (int i = 1; i <= mBrowser->Size(); i++)
{
if (option == mBrowser->GetOption(i))
{ {
mBrowser->Highlight(i); mBrowser->Highlight(i);
break; break;

View File

@@ -57,7 +57,12 @@ Song::Song(mpd_Song *s) : itsHash(0),
s->comment ? itsComment = s->comment : itsComment = ""; s->comment ? itsComment = s->comment : itsComment = "";
int i = itsFile.find_last_of("/"); int i = itsFile.find_last_of("/");
if (i != string::npos)
if (itsFile.substr(0, 7) == "http://")
{
itsShortName = itsFile;
}
else if (i != string::npos)
{ {
itsDirectory = itsFile.substr(0, i); itsDirectory = itsFile.substr(0, i);
itsShortName = itsFile.substr(i+1); itsShortName = itsFile.substr(i+1);
@@ -81,6 +86,9 @@ string Song::GetLength() const
{ {
std::stringstream ss; std::stringstream ss;
if (!GetTotalLength())
return "unknown";
ss << itsMinutesLength << ":"; ss << itsMinutesLength << ":";
if (!itsSecondsLength) if (!itsSecondsLength)
{ {