handle colored empty tag marker

This commit is contained in:
Andrzej Rybczak
2008-12-11 18:29:56 +01:00
parent cfa8268f2d
commit da8feb885f
10 changed files with 151 additions and 175 deletions

View File

@@ -46,8 +46,6 @@ extern bool allow_statusbar_unlock;
extern bool search_case_sensitive; extern bool search_case_sensitive;
extern bool search_match_to_pattern; extern bool search_match_to_pattern;
extern string EMPTY_TAG;
const string term_type = getenv("TERM") ? getenv("TERM") : ""; const string term_type = getenv("TERM") ? getenv("TERM") : "";
bool ConnectToMPD() bool ConnectToMPD()
@@ -656,8 +654,16 @@ void DisplaySong(const Song &s, void *data, Menu<Song> *menu)
default: default:
break; break;
} }
if (get && (s.*get)() == EMPTY_TAG) if (get == &Song::GetLength)
break; {
if (!s.GetTotalLength())
break;
}
else if (get)
{
if ((s.*get)().empty())
break;
}
} }
} }
if (*it == '}') if (*it == '}')
@@ -675,6 +681,8 @@ void DisplaySong(const Song &s, void *data, Menu<Song> *menu)
{ {
for (; *it != '}'; it++) { } for (; *it != '}'; it++) { }
it++; it++;
if (it == song_template.end())
break;
if (*it == '{' || *it == '|') if (*it == '{' || *it == '|')
{ {
if (*it == '|') if (*it == '|')
@@ -817,8 +825,8 @@ void GetInfo(Song &s, Scrollpad &info)
# endif // HAVE_TAGLIB_H # endif // HAVE_TAGLIB_H
info << fmtBold << clWhite << "Filename: " << fmtBoldEnd << clGreen << s.GetName() << "\n" << clEnd; info << fmtBold << clWhite << "Filename: " << fmtBoldEnd << clGreen << s.GetName() << "\n" << clEnd;
info << fmtBold << "Directory: " << fmtBoldEnd << clGreen << s.GetDirectory() + "\n\n" << clEnd; info << fmtBold << "Directory: " << fmtBoldEnd << clGreen << ShowTagInInfoScreen(s.GetDirectory()) << "\n\n" << clEnd;
info << fmtBold << "Length: " << fmtBoldEnd << clGreen << s.GetLength() + "\n" << clEnd; info << fmtBold << "Length: " << fmtBoldEnd << clGreen << s.GetLength() << "\n" << clEnd;
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
if (!f.isNull()) if (!f.isNull())
{ {
@@ -826,17 +834,19 @@ void GetInfo(Song &s, Scrollpad &info)
info << fmtBold << "Sample rate: " << fmtBoldEnd << clGreen << f.audioProperties()->sampleRate() << " Hz\n" << clEnd; info << fmtBold << "Sample rate: " << fmtBoldEnd << clGreen << f.audioProperties()->sampleRate() << " Hz\n" << clEnd;
info << fmtBold << "Channels: " << fmtBoldEnd << clGreen << (f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") << "\n" << clDefault; info << fmtBold << "Channels: " << fmtBoldEnd << clGreen << (f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") << "\n" << clDefault;
} }
else
info << clDefault;
# endif // HAVE_TAGLIB_H # endif // HAVE_TAGLIB_H
info << fmtBold << "\nTitle: " << fmtBoldEnd << s.GetTitle(); info << fmtBold << "\nTitle: " << fmtBoldEnd << ShowTagInInfoScreen(s.GetTitle());
info << fmtBold << "\nArtist: " << fmtBoldEnd << s.GetArtist(); info << fmtBold << "\nArtist: " << fmtBoldEnd << ShowTagInInfoScreen(s.GetArtist());
info << fmtBold << "\nAlbum: " << fmtBoldEnd << s.GetAlbum(); info << fmtBold << "\nAlbum: " << fmtBoldEnd << ShowTagInInfoScreen(s.GetAlbum());
info << fmtBold << "\nYear: " << fmtBoldEnd << s.GetYear(); info << fmtBold << "\nYear: " << fmtBoldEnd << ShowTagInInfoScreen(s.GetYear());
info << fmtBold << "\nTrack: " << fmtBoldEnd << s.GetTrack(); info << fmtBold << "\nTrack: " << fmtBoldEnd << ShowTagInInfoScreen(s.GetTrack());
info << fmtBold << "\nGenre: " << fmtBoldEnd << s.GetGenre(); info << fmtBold << "\nGenre: " << fmtBoldEnd << ShowTagInInfoScreen(s.GetGenre());
info << fmtBold << "\nComposer: " << fmtBoldEnd << s.GetComposer(); info << fmtBold << "\nComposer: " << fmtBoldEnd << ShowTagInInfoScreen(s.GetComposer());
info << fmtBold << "\nPerformer: " << fmtBoldEnd << s.GetPerformer(); info << fmtBold << "\nPerformer: " << fmtBoldEnd << ShowTagInInfoScreen(s.GetPerformer());
info << fmtBold << "\nDisc: " << fmtBoldEnd << s.GetDisc(); info << fmtBold << "\nDisc: " << fmtBoldEnd << ShowTagInInfoScreen(s.GetDisc());
info << fmtBold << "\nComment: " << fmtBoldEnd << s.GetComment(); info << fmtBold << "\nComment: " << fmtBoldEnd << ShowTagInInfoScreen(s.GetComment());
} }
void ShowMessage(const char *format, ...) void ShowMessage(const char *format, ...)
@@ -868,3 +878,29 @@ Window &Statusbar()
wclrtoeol(wFooter->Raw()); wclrtoeol(wFooter->Raw());
return *wFooter; return *wFooter;
} }
const Buffer &ShowTag(const string &tag)
{
static Buffer result;
result.Clear();
if (tag.empty())
result << Config.empty_tags_color << Config.empty_tag << clEnd;
else
result << tag;
return result;
}
const basic_buffer<my_char_t> &ShowTagInInfoScreen(const string &tag)
{
# ifdef _UTF8
static WBuffer result;
result.Clear();
if (tag.empty())
result << Config.empty_tags_color << ToWString(Config.empty_tag) << clEnd;
else
result << TO_WSTRING(tag);
return result;
# else
return ShowTag(tag);
# endif
}

View File

@@ -67,5 +67,8 @@ void GetInfo(Song &, Scrollpad &);
void ShowMessage(const char *, ...); void ShowMessage(const char *, ...);
Window &Statusbar(); Window &Statusbar();
const Buffer &ShowTag(const string &);
const basic_buffer<my_char_t> &ShowTagInInfoScreen(const string &);
#endif #endif

View File

@@ -157,8 +157,6 @@ extern bool header_update_status;
extern bool search_case_sensitive; extern bool search_case_sensitive;
extern bool search_match_to_pattern; extern bool search_match_to_pattern;
extern string EMPTY_TAG;
extern string playlist_stats;
extern string volume_state; extern string volume_state;
extern const char *search_mode_normal; extern const char *search_mode_normal;
@@ -513,7 +511,7 @@ int main(int argc, char *argv[])
Mpd->AddSearch(Config.media_lib_primary_tag, mLibArtists->Current()); Mpd->AddSearch(Config.media_lib_primary_tag, mLibArtists->Current());
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, *it); Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, *it);
Mpd->CommitSearch(l); Mpd->CommitSearch(l);
if (!l.empty() && l[0]->GetAlbum() != EMPTY_TAG) if (!l.empty() && !l[0]->GetAlbum().empty())
maplist[l[0]->toString(Config.media_lib_album_format)] = *it; maplist[l[0]->toString(Config.media_lib_album_format)] = *it;
FreeSongList(l); FreeSongList(l);
} }
@@ -729,7 +727,7 @@ int main(int argc, char *argv[])
if (current_screen == csLyrics && reload_lyrics) if (current_screen == csLyrics && reload_lyrics)
{ {
const Song &s = mPlaylist->at(now_playing); const Song &s = mPlaylist->at(now_playing);
if (s.GetArtist() != EMPTY_TAG && s.GetTitle() != EMPTY_TAG) if (!s.GetArtist().empty() && !s.GetTitle().empty())
goto LOAD_LYRICS; goto LOAD_LYRICS;
else else
reload_lyrics = 0; reload_lyrics = 0;
@@ -1024,101 +1022,71 @@ int main(int argc, char *argv[])
case 1: case 1:
{ {
Statusbar() << fmtBold << "Title: " << fmtBoldEnd; Statusbar() << fmtBold << "Title: " << fmtBoldEnd;
if (s.GetTitle() == EMPTY_TAG) s.SetTitle(wFooter->GetString(s.GetTitle()));
s.SetTitle(wFooter->GetString()); mTagEditor->at(option) << fmtBold << "Title:" << fmtBoldEnd << ' ' << ShowTag(s.GetTitle());
else
s.SetTitle(wFooter->GetString(s.GetTitle()));
mTagEditor->at(option) << fmtBold << "Title:" << fmtBoldEnd << ' ' << s.GetTitle();
break; break;
} }
case 2: case 2:
{ {
Statusbar() << fmtBold << "Artist: " << fmtBoldEnd; Statusbar() << fmtBold << "Artist: " << fmtBoldEnd;
if (s.GetArtist() == EMPTY_TAG) s.SetArtist(wFooter->GetString(s.GetArtist()));
s.SetArtist(wFooter->GetString()); mTagEditor->at(option) << fmtBold << "Artist:" << fmtBoldEnd << ' ' << ShowTag(s.GetArtist());
else
s.SetArtist(wFooter->GetString(s.GetArtist()));
mTagEditor->at(option) << fmtBold << "Artist:" << fmtBoldEnd << ' ' << s.GetArtist();
break; break;
} }
case 3: case 3:
{ {
Statusbar() << fmtBold << "Album: " << fmtBoldEnd; Statusbar() << fmtBold << "Album: " << fmtBoldEnd;
if (s.GetAlbum() == EMPTY_TAG) s.SetAlbum(wFooter->GetString(s.GetAlbum()));
s.SetAlbum(wFooter->GetString()); mTagEditor->at(option) << fmtBold << "Album:" << fmtBoldEnd << ' ' << ShowTag(s.GetAlbum());
else
s.SetAlbum(wFooter->GetString(s.GetAlbum()));
mTagEditor->at(option) << fmtBold << "Album:" << fmtBoldEnd << ' ' << s.GetAlbum();
break; break;
} }
case 4: case 4:
{ {
Statusbar() << fmtBold << "Year: " << fmtBoldEnd; Statusbar() << fmtBold << "Year: " << fmtBoldEnd;
if (s.GetYear() == EMPTY_TAG) s.SetYear(wFooter->GetString(s.GetYear(), 4));
s.SetYear(wFooter->GetString(4)); mTagEditor->at(option) << fmtBold << "Year:" << fmtBoldEnd << ' ' << ShowTag(s.GetYear());
else
s.SetYear(wFooter->GetString(s.GetYear(), 4));
mTagEditor->at(option) << fmtBold << "Year:" << fmtBoldEnd << ' ' << s.GetYear();
break; break;
} }
case 5: case 5:
{ {
Statusbar() << fmtBold << "Track: " << fmtBoldEnd; Statusbar() << fmtBold << "Track: " << fmtBoldEnd;
if (s.GetTrack() == EMPTY_TAG) s.SetTrack(wFooter->GetString(s.GetTrack(), 3));
s.SetTrack(wFooter->GetString(3)); mTagEditor->at(option) << fmtBold << "Track:" << fmtBoldEnd << ' ' << ShowTag(s.GetTrack());
else
s.SetTrack(wFooter->GetString(s.GetTrack(), 3));
mTagEditor->at(option) << fmtBold << "Track:" << fmtBoldEnd << ' ' << s.GetTrack();
break; break;
} }
case 6: case 6:
{ {
Statusbar() << fmtBold << "Genre: " << fmtBoldEnd; Statusbar() << fmtBold << "Genre: " << fmtBoldEnd;
if (s.GetGenre() == EMPTY_TAG) s.SetGenre(wFooter->GetString(s.GetGenre()));
s.SetGenre(wFooter->GetString()); mTagEditor->at(option) << fmtBold << "Genre:" << fmtBoldEnd << ' ' << ShowTag(s.GetGenre());
else
s.SetGenre(wFooter->GetString(s.GetGenre()));
mTagEditor->at(option) << fmtBold << "Genre:" << fmtBoldEnd << ' ' << s.GetGenre();
break; break;
} }
case 7: case 7:
{ {
Statusbar() << fmtBold << "Composer: " << fmtBoldEnd; Statusbar() << fmtBold << "Composer: " << fmtBoldEnd;
if (s.GetComposer() == EMPTY_TAG) s.SetComposer(wFooter->GetString(s.GetComposer()));
s.SetComposer(wFooter->GetString()); mTagEditor->at(option) << fmtBold << "Composer:" << fmtBoldEnd << ' ' << ShowTag(s.GetComposer());
else
s.SetComposer(wFooter->GetString(s.GetComposer()));
mTagEditor->at(option) << fmtBold << "Composer:" << fmtBoldEnd << ' ' << s.GetComposer();
break; break;
} }
case 8: case 8:
{ {
Statusbar() << fmtBold << "Performer: " << fmtBoldEnd; Statusbar() << fmtBold << "Performer: " << fmtBoldEnd;
if (s.GetPerformer() == EMPTY_TAG) s.SetPerformer(wFooter->GetString(s.GetPerformer()));
s.SetPerformer(wFooter->GetString()); mTagEditor->at(option) << fmtBold << "Performer:" << fmtBoldEnd << ' ' << ShowTag(s.GetPerformer());
else
s.SetPerformer(wFooter->GetString(s.GetPerformer()));
mTagEditor->at(option) << fmtBold << "Performer:" << fmtBoldEnd << ' ' << s.GetPerformer();
break; break;
} }
case 9: case 9:
{ {
Statusbar() << fmtBold << "Disc: " << fmtBoldEnd; Statusbar() << fmtBold << "Disc: " << fmtBoldEnd;
if (s.GetDisc() == EMPTY_TAG) s.SetDisc(wFooter->GetString(s.GetDisc()));
s.SetDisc(wFooter->GetString()); mTagEditor->at(option) << fmtBold << "Disc:" << fmtBoldEnd << ' ' << ShowTag(s.GetDisc());
else
s.SetDisc(wFooter->GetString(s.GetDisc()));
mTagEditor->at(option) << fmtBold << "Disc:" << fmtBoldEnd << ' ' << s.GetDisc();
break; break;
} }
case 10: case 10:
{ {
Statusbar() << fmtBold << "Comment: " << fmtBoldEnd; Statusbar() << fmtBold << "Comment: " << fmtBoldEnd;
if (s.GetComment() == EMPTY_TAG) s.SetComment(wFooter->GetString(s.GetComment()));
s.SetComment(wFooter->GetString()); mTagEditor->at(option) << fmtBold << "Comment:" << fmtBoldEnd << ' ' << ShowTag(s.GetComment());
else
s.SetComment(wFooter->GetString(s.GetComment()));
mTagEditor->at(option) << fmtBold << "Comment:" << fmtBoldEnd << ' ' << s.GetComment();
break; break;
} }
case 12: case 12:
@@ -1198,81 +1166,57 @@ int main(int argc, char *argv[])
case 1: case 1:
{ {
Statusbar() << fmtBold << "Filename: " << fmtBoldEnd; Statusbar() << fmtBold << "Filename: " << fmtBoldEnd;
if (s.GetName() == EMPTY_TAG) s.SetFile(wFooter->GetString(s.GetFile()));
s.SetFile(wFooter->GetString()); *mSearcher->Current().first << fmtBold << "Filename:" << fmtBoldEnd << ' ' << ShowTag(s.GetFile());
else
s.SetFile(wFooter->GetString(s.GetFile()));
*mSearcher->Current().first << fmtBold << "Filename:" << fmtBoldEnd << ' ' << s.GetFile();
break; break;
} }
case 2: case 2:
{ {
Statusbar() << fmtBold << "Title: " << fmtBoldEnd; Statusbar() << fmtBold << "Title: " << fmtBoldEnd;
if (s.GetTitle() == EMPTY_TAG) s.SetTitle(wFooter->GetString(s.GetTitle()));
s.SetTitle(wFooter->GetString()); *mSearcher->Current().first << fmtBold << "Title:" << fmtBoldEnd << ' ' << ShowTag(s.GetTitle());
else
s.SetTitle(wFooter->GetString(s.GetTitle()));
*mSearcher->Current().first << fmtBold << "Title:" << fmtBoldEnd << ' ' << s.GetTitle();
break; break;
} }
case 3: case 3:
{ {
Statusbar() << fmtBold << "Artist: " << fmtBoldEnd; Statusbar() << fmtBold << "Artist: " << fmtBoldEnd;
if (s.GetArtist() == EMPTY_TAG) s.SetArtist(wFooter->GetString(s.GetArtist()));
s.SetArtist(wFooter->GetString()); *mSearcher->Current().first << fmtBold << "Artist:" << fmtBoldEnd << ' ' << ShowTag(s.GetArtist());
else
s.SetArtist(wFooter->GetString(s.GetArtist()));
*mSearcher->Current().first << fmtBold << "Artist:" << fmtBoldEnd << ' ' << s.GetArtist();
break; break;
} }
case 4: case 4:
{ {
Statusbar() << fmtBold << "Album: " << fmtBoldEnd; Statusbar() << fmtBold << "Album: " << fmtBoldEnd;
if (s.GetAlbum() == EMPTY_TAG) s.SetAlbum(wFooter->GetString(s.GetAlbum()));
s.SetAlbum(wFooter->GetString()); *mSearcher->Current().first << fmtBold << "Album:" << fmtBoldEnd << ' ' << ShowTag(s.GetAlbum());
else
s.SetAlbum(wFooter->GetString(s.GetAlbum()));
*mSearcher->Current().first << fmtBold << "Album:" << fmtBoldEnd << ' ' << s.GetAlbum();
break; break;
} }
case 5: case 5:
{ {
Statusbar() << fmtBold << "Year: " << fmtBoldEnd; Statusbar() << fmtBold << "Year: " << fmtBoldEnd;
if (s.GetYear() == EMPTY_TAG) s.SetYear(wFooter->GetString(s.GetYear(), 4));
s.SetYear(wFooter->GetString(4)); *mSearcher->Current().first << fmtBold << "Year:" << fmtBoldEnd << ' ' << ShowTag(s.GetYear());
else
s.SetYear(wFooter->GetString(s.GetYear(), 4));
*mSearcher->Current().first << fmtBold << "Year:" << fmtBoldEnd << ' ' << s.GetYear();
break; break;
} }
case 6: case 6:
{ {
Statusbar() << fmtBold << "Track: " << fmtBoldEnd; Statusbar() << fmtBold << "Track: " << fmtBoldEnd;
if (s.GetTrack() == EMPTY_TAG) s.SetTrack(wFooter->GetString(s.GetTrack(), 3));
s.SetTrack(wFooter->GetString(3)); *mSearcher->Current().first << fmtBold << "Track:" << fmtBoldEnd << ' ' << ShowTag(s.GetTrack());
else
s.SetTrack(wFooter->GetString(s.GetTrack(), 3));
*mSearcher->Current().first << fmtBold << "Track:" << fmtBoldEnd << ' ' << s.GetTrack();
break; break;
} }
case 7: case 7:
{ {
Statusbar() << fmtBold << "Genre: " << fmtBoldEnd; Statusbar() << fmtBold << "Genre: " << fmtBoldEnd;
if (s.GetGenre() == EMPTY_TAG) s.SetGenre(wFooter->GetString(s.GetGenre()));
s.SetGenre(wFooter->GetString()); *mSearcher->Current().first << fmtBold << "Genre:" << fmtBoldEnd << ' ' << ShowTag(s.GetGenre());
else
s.SetGenre(wFooter->GetString(s.GetGenre()));
*mSearcher->Current().first << fmtBold << "Genre:" << fmtBoldEnd << ' ' << s.GetGenre();
break; break;
} }
case 8: case 8:
{ {
Statusbar() << fmtBold << "Comment: " << fmtBoldEnd; Statusbar() << fmtBold << "Comment: " << fmtBoldEnd;
if (s.GetComment() == EMPTY_TAG) s.SetComment(wFooter->GetString(s.GetComment()));
s.SetComment(wFooter->GetString()); *mSearcher->Current().first << fmtBold << "Comment:" << fmtBoldEnd << ' ' << ShowTag(s.GetComment());
else
s.SetComment(wFooter->GetString(s.GetComment()));
*mSearcher->Current().first << fmtBold << "Comment:" << fmtBoldEnd << ' ' << s.GetComment();
break; break;
} }
case 10: case 10:
@@ -1719,9 +1663,7 @@ int main(int argc, char *argv[])
{ {
LockStatusbar(); LockStatusbar();
Statusbar() << fmtBold << mEditorTagTypes->Current() << fmtBoldEnd << ": "; Statusbar() << fmtBold << mEditorTagTypes->Current() << fmtBoldEnd << ": ";
mEditorTags->Current().GetEmptyFields(1);
string new_tag = wFooter->GetString((mEditorTags->Current().*get)()); string new_tag = wFooter->GetString((mEditorTags->Current().*get)());
mEditorTags->Current().GetEmptyFields(0);
UnlockStatusbar(); UnlockStatusbar();
for (SongList::iterator it = list.begin(); it != list.end(); it++) for (SongList::iterator it = list.begin(); it != list.end(); it++)
(**it.*set)(new_tag); (**it.*set)(new_tag);
@@ -1731,9 +1673,7 @@ int main(int argc, char *argv[])
{ {
LockStatusbar(); LockStatusbar();
Statusbar() << fmtBold << mEditorTagTypes->Current() << fmtBoldEnd << ": "; Statusbar() << fmtBold << mEditorTagTypes->Current() << fmtBoldEnd << ": ";
mEditorTags->Current().GetEmptyFields(1);
string new_tag = wFooter->GetString((mEditorTags->Current().*get)()); string new_tag = wFooter->GetString((mEditorTags->Current().*get)());
mEditorTags->Current().GetEmptyFields(0);
UnlockStatusbar(); UnlockStatusbar();
if (new_tag != (mEditorTags->Current().*get)()) if (new_tag != (mEditorTags->Current().*get)())
(mEditorTags->Current().*set)(new_tag); (mEditorTags->Current().*set)(new_tag);
@@ -2744,7 +2684,7 @@ int main(int argc, char *argv[])
break; break;
} }
if (s->GetDirectory() == EMPTY_TAG) // for streams if (s->GetDirectory().empty()) // for streams
continue; continue;
Config.local_browser = !s->IsFromDB(); Config.local_browser = !s->IsFromDB();
@@ -3305,7 +3245,7 @@ int main(int argc, char *argv[])
default: default:
break; break;
} }
if (*artist != EMPTY_TAG) if (!artist->empty())
{ {
wPrev = wCurrent; wPrev = wCurrent;
wCurrent = sInfo; wCurrent = sInfo;
@@ -3396,7 +3336,7 @@ int main(int argc, char *argv[])
default: default:
break; break;
} }
if (s->GetArtist() != EMPTY_TAG && s->GetTitle() != EMPTY_TAG) if (!s->GetArtist().empty() && !s->GetTitle().empty())
{ {
wPrev = wCurrent; wPrev = wCurrent;
prev_screen = current_screen; prev_screen = current_screen;

View File

@@ -88,14 +88,14 @@ void PrepareSearchEngine(Song &s)
catch (List::InvalidItem) { } catch (List::InvalidItem) { }
} }
*mSearcher->at(0).first << fmtBold << "Filename:" << fmtBoldEnd << ' ' << s.GetName(); *mSearcher->at(0).first << fmtBold << "Filename:" << fmtBoldEnd << ' ' << ShowTag(s.GetName());
*mSearcher->at(1).first << fmtBold << "Title:" << fmtBoldEnd << ' ' << s.GetTitle(); *mSearcher->at(1).first << fmtBold << "Title:" << fmtBoldEnd << ' ' << ShowTag(s.GetTitle());
*mSearcher->at(2).first << fmtBold << "Artist:" << fmtBoldEnd << ' ' << s.GetArtist(); *mSearcher->at(2).first << fmtBold << "Artist:" << fmtBoldEnd << ' ' << ShowTag(s.GetArtist());
*mSearcher->at(3).first << fmtBold << "Album:" << fmtBoldEnd << ' ' << s.GetAlbum(); *mSearcher->at(3).first << fmtBold << "Album:" << fmtBoldEnd << ' ' << ShowTag(s.GetAlbum());
*mSearcher->at(4).first << fmtBold << "Year:" << fmtBoldEnd << ' ' << s.GetYear(); *mSearcher->at(4).first << fmtBold << "Year:" << fmtBoldEnd << ' ' << ShowTag(s.GetYear());
*mSearcher->at(5).first << fmtBold << "Track:" << fmtBoldEnd << ' ' << s.GetTrack(); *mSearcher->at(5).first << fmtBold << "Track:" << fmtBoldEnd << ' ' << ShowTag(s.GetTrack());
*mSearcher->at(6).first << fmtBold << "Genre:" << fmtBoldEnd << ' ' << s.GetGenre(); *mSearcher->at(6).first << fmtBold << "Genre:" << fmtBoldEnd << ' ' << ShowTag(s.GetGenre());
*mSearcher->at(7).first << fmtBold << "Comment:" << fmtBoldEnd << ' ' << s.GetComment(); *mSearcher->at(7).first << fmtBold << "Comment:" << fmtBoldEnd << ' ' << ShowTag(s.GetComment());
*mSearcher->at(9).first << fmtBold << "Search in:" << fmtBoldEnd << ' ' << (Config.search_in_db ? "Database" : "Current playlist"); *mSearcher->at(9).first << fmtBold << "Search in:" << fmtBoldEnd << ' ' << (Config.search_in_db ? "Database" : "Current playlist");
*mSearcher->at(10).first << fmtBold << "Search mode:" << fmtBoldEnd << ' ' << (search_match_to_pattern ? search_mode_normal : search_mode_strict); *mSearcher->at(10).first << fmtBold << "Search mode:" << fmtBoldEnd << ' ' << (search_match_to_pattern ? search_mode_normal : search_mode_strict);
@@ -122,8 +122,6 @@ void Search(Song &s)
bool found = 1; bool found = 1;
s.GetEmptyFields(1);
if (!search_case_sensitive) if (!search_case_sensitive)
{ {
string t; string t;
@@ -234,6 +232,5 @@ void Search(Song &s)
} }
if (Config.search_in_db) // free song list only if it's database if (Config.search_in_db) // free song list only if it's database
FreeSongList(list); FreeSongList(list);
s.GetEmptyFields(0);
} }

View File

@@ -218,6 +218,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
void DefaultConfiguration(ncmpcpp_config &conf) void DefaultConfiguration(ncmpcpp_config &conf)
{ {
conf.mpd_host = "localhost"; conf.mpd_host = "localhost";
conf.empty_tag = "<empty>";
conf.song_list_format = "{%a - }{%t}|{$8%f$9}%r{$3(%l)$9}"; conf.song_list_format = "{%a - }{%t}|{$8%f$9}%r{$3(%l)$9}";
conf.song_columns_list_format = "(8)[green]{l} (25)[cyan]{a} (40){t} (30)[red]{b}"; conf.song_columns_list_format = "(8)[green]{l} (25)[cyan]{a} (40){t} (30)[red]{b}";
conf.song_status_format = "{(%l) }{%a - }{%t}|{%f}"; conf.song_status_format = "{(%l) }{%a - }{%t}|{%f}";

View File

@@ -96,6 +96,7 @@ struct ncmpcpp_config
{ {
string mpd_host; string mpd_host;
string mpd_music_dir; string mpd_music_dir;
string empty_tag;
string song_list_format; string song_list_format;
string song_columns_list_format; string song_columns_list_format;
string song_status_format; string song_status_format;

View File

@@ -21,16 +21,11 @@
#include "song.h" #include "song.h"
#include "settings.h" #include "settings.h"
extern ncmpcpp_config Config;
string EMPTY_TAG = "<empty>";
Song::Song(mpd_Song *s, bool copy_ptr) : itsSong(s), Song::Song(mpd_Song *s, bool copy_ptr) : itsSong(s),
itsSlash(string::npos), itsSlash(string::npos),
itsHash(0), itsHash(0),
copyPtr(copy_ptr), copyPtr(copy_ptr),
isStream(0), isStream(0)
itsGetEmptyFields(0)
{ {
size_t file_len = itsSong->file ? strlen(itsSong->file) : 0; size_t file_len = itsSong->file ? strlen(itsSong->file) : 0;
@@ -57,8 +52,7 @@ Song::Song(const Song &s) : itsSong(0),
itsSlash(s.itsSlash), itsSlash(s.itsSlash),
itsHash(s.itsHash), itsHash(s.itsHash),
copyPtr(s.copyPtr), copyPtr(s.copyPtr),
isStream(s.isStream), isStream(s.isStream)
itsGetEmptyFields(s.itsGetEmptyFields)
{ {
itsSong = s.copyPtr ? s.itsSong : mpd_songDup(s.itsSong); itsSong = s.copyPtr ? s.itsSong : mpd_songDup(s.itsSong);
} }
@@ -85,7 +79,6 @@ void Song::Clear()
itsSlash = 0; itsSlash = 0;
itsHash = 0; itsHash = 0;
copyPtr = 0; copyPtr = 0;
itsGetEmptyFields = 0;
} }
bool Song::Empty() const bool Song::Empty() const
@@ -101,67 +94,67 @@ bool Song::IsFromDB() const
string Song::GetFile() const string Song::GetFile() const
{ {
return !itsSong->file ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsSong->file; return !itsSong->file ? "" : itsSong->file;
} }
string Song::GetName() const string Song::GetName() const
{ {
return !itsSong->file ? (itsGetEmptyFields ? "" : EMPTY_TAG) : (itsSlash != string::npos && !isStream ? itsSong->file+itsSlash+1 : (isStream && itsSong->name ? itsSong->name : itsSong->file)); return !itsSong->file ? "" : (itsSlash != string::npos && !isStream ? itsSong->file+itsSlash+1 : (isStream && itsSong->name ? itsSong->name : itsSong->file));
} }
string Song::GetDirectory() const string Song::GetDirectory() const
{ {
return !itsSong->file || isStream ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsSlash != string::npos ? string(itsSong->file).substr(0, itsSlash) : "/"; return !itsSong->file || isStream ? "" : itsSlash != string::npos ? string(itsSong->file).substr(0, itsSlash) : "/";
} }
string Song::GetArtist() const string Song::GetArtist() const
{ {
return !itsSong->artist ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsSong->artist; return !itsSong->artist ? "" : itsSong->artist;
} }
string Song::GetTitle() const string Song::GetTitle() const
{ {
return !itsSong->title ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsSong->title; return !itsSong->title ? "" : itsSong->title;
} }
string Song::GetAlbum() const string Song::GetAlbum() const
{ {
return !itsSong->album ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsSong->album; return !itsSong->album ? "" : itsSong->album;
} }
string Song::GetTrack() const string Song::GetTrack() const
{ {
return !itsSong->track ? (itsGetEmptyFields ? "" : EMPTY_TAG) : (StrToInt(itsSong->track) < 10 && itsSong->track[0] != '0' ? "0"+string(itsSong->track) : itsSong->track); return !itsSong->track ? "" : (StrToInt(itsSong->track) < 10 && itsSong->track[0] != '0' ? "0"+string(itsSong->track) : itsSong->track);
} }
string Song::GetYear() const string Song::GetYear() const
{ {
return !itsSong->date ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsSong->date; return !itsSong->date ? "" : itsSong->date;
} }
string Song::GetGenre() const string Song::GetGenre() const
{ {
return !itsSong->genre ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsSong->genre; return !itsSong->genre ? "" : itsSong->genre;
} }
string Song::GetComposer() const string Song::GetComposer() const
{ {
return !itsSong->composer ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsSong->composer; return !itsSong->composer ? "" : itsSong->composer;
} }
string Song::GetPerformer() const string Song::GetPerformer() const
{ {
return !itsSong->performer ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsSong->performer; return !itsSong->performer ? "" : itsSong->performer;
} }
string Song::GetDisc() const string Song::GetDisc() const
{ {
return !itsSong->disc ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsSong->disc; return !itsSong->disc ? "" : itsSong->disc;
} }
string Song::GetComment() const string Song::GetComment() const
{ {
return !itsSong->comment ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsSong->comment; return !itsSong->comment ? "" : itsSong->comment;
} }
void Song::SetFile(const string &str) void Song::SetFile(const string &str)
@@ -320,8 +313,16 @@ string Song::toString(const std::string &format) const
default: default:
break; break;
} }
if (get && (this->*get)() == EMPTY_TAG) if (get == &Song::GetLength)
break; {
if (!GetTotalLength())
break;
}
else if (get)
{
if ((this->*get)().empty())
break;
}
} }
} }
if (*it == '}') if (*it == '}')
@@ -339,6 +340,8 @@ string Song::toString(const std::string &format) const
{ {
for (; *it != '}'; it++) { } for (; *it != '}'; it++) { }
it++; it++;
if (it == format.end())
break;
if (*it == '{' || *it == '|') if (*it == '{' || *it == '|')
{ {
if (*it == '|') if (*it == '|')
@@ -424,7 +427,6 @@ Song & Song::operator=(const Song &s)
itsHash = s.itsHash; itsHash = s.itsHash;
copyPtr = s.copyPtr; copyPtr = s.copyPtr;
isStream = s.isStream; isStream = s.isStream;
itsGetEmptyFields = s.itsGetEmptyFields;
return *this; return *this;
} }

View File

@@ -34,7 +34,7 @@ using std::string;
class Song class Song
{ {
public: public:
Song() : itsSlash(string::npos), itsHash(0), copyPtr(0), isStream(0), itsGetEmptyFields(0) { itsSong = mpd_newSong(); } Song() : itsSlash(string::npos), itsHash(0), copyPtr(0), isStream(0) { itsSong = mpd_newSong(); }
Song(mpd_Song *, bool = 0); Song(mpd_Song *, bool = 0);
Song(const Song &); Song(const Song &);
~Song(); ~Song();
@@ -48,13 +48,12 @@ class Song
string GetTrack() const; string GetTrack() const;
string GetYear() const; string GetYear() const;
string GetGenre() const; string GetGenre() const;
//string GetName() const { return itsName; }
string GetComposer() const; string GetComposer() const;
string GetPerformer() const; string GetPerformer() const;
string GetDisc() const; string GetDisc() const;
string GetComment() const; string GetComment() const;
string GetLength() const; string GetLength() const;
long long GetHash() const { return itsHash; } const long long &GetHash() const { return itsHash; }
int GetTotalLength() const { return itsSong->time < 0 ? 0 : itsSong->time; } int GetTotalLength() const { return itsSong->time < 0 ? 0 : itsSong->time; }
int GetPosition() const { return itsSong->pos; } int GetPosition() const { return itsSong->pos; }
int GetID() const { return itsSong->id; } int GetID() const { return itsSong->id; }
@@ -82,7 +81,7 @@ class Song
void NullMe() { itsSong = 0; } void NullMe() { itsSong = 0; }
void CopyPtr(bool copy) { copyPtr = copy; } void CopyPtr(bool copy) { copyPtr = copy; }
void GetEmptyFields(bool get) { itsGetEmptyFields = get; } //void GetEmptyFields(bool get) { itsGetEmptyFields = get; }
void Clear(); void Clear();
bool Empty() const; bool Empty() const;
bool IsFromDB() const; bool IsFromDB() const;
@@ -101,7 +100,7 @@ class Song
long long itsHash; long long itsHash;
bool copyPtr; bool copyPtr;
bool isStream; bool isStream;
bool itsGetEmptyFields; //bool itsGetEmptyFields;
}; };
#endif #endif

View File

@@ -67,7 +67,6 @@ int old_playing;
time_t time_of_statusbar_lock; time_t time_of_statusbar_lock;
//string playlist_stats;
string volume_state; string volume_state;
string switch_state; string switch_state;

View File

@@ -322,8 +322,10 @@ bool GetSongTags(Song &s)
mTagEditor->Reset(); mTagEditor->Reset();
mTagEditor->ResizeBuffer(23); mTagEditor->ResizeBuffer(23);
for (size_t i = 0; i < 7; i++) for (size_t i = 0; i < 7; i++)
mTagEditor->Static(i, 1); mTagEditor->Static(i, 1);
mTagEditor->IntoSeparator(7); mTagEditor->IntoSeparator(7);
mTagEditor->IntoSeparator(18); mTagEditor->IntoSeparator(18);
mTagEditor->IntoSeparator(20); mTagEditor->IntoSeparator(20);
@@ -335,22 +337,22 @@ bool GetSongTags(Song &s)
mTagEditor->Highlight(8); mTagEditor->Highlight(8);
mTagEditor->at(0) << fmtBold << clWhite << "Song name: " << fmtBoldEnd << clGreen << s.GetName() << clEnd; mTagEditor->at(0) << fmtBold << clWhite << "Song name: " << fmtBoldEnd << clGreen << s.GetName() << clEnd;
mTagEditor->at(1) << fmtBold << clWhite << "Location in DB: " << fmtBoldEnd << clGreen << s.GetDirectory() << clEnd; mTagEditor->at(1) << fmtBold << clWhite << "Location in DB: " << fmtBoldEnd << clGreen << ShowTag(s.GetDirectory()) << clEnd;
mTagEditor->at(3) << fmtBold << clWhite << "Length: " << fmtBoldEnd << clGreen << s.GetLength() << clEnd; mTagEditor->at(3) << fmtBold << clWhite << "Length: " << fmtBoldEnd << clGreen << s.GetLength() << clEnd;
mTagEditor->at(4) << fmtBold << clWhite << "Bitrate: " << fmtBoldEnd << clGreen << f.audioProperties()->bitrate() << " kbps" << clEnd; mTagEditor->at(4) << fmtBold << clWhite << "Bitrate: " << fmtBoldEnd << clGreen << f.audioProperties()->bitrate() << " kbps" << clEnd;
mTagEditor->at(5) << fmtBold << clWhite << "Sample rate: " << fmtBoldEnd << clGreen << f.audioProperties()->sampleRate() << " Hz" << clEnd; mTagEditor->at(5) << fmtBold << clWhite << "Sample rate: " << fmtBoldEnd << clGreen << f.audioProperties()->sampleRate() << " Hz" << clEnd;
mTagEditor->at(6) << fmtBold << clWhite << "Channels: " << fmtBoldEnd << clGreen << (f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") << clDefault; mTagEditor->at(6) << fmtBold << clWhite << "Channels: " << fmtBoldEnd << clGreen << (f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") << clDefault;
mTagEditor->at(8) << fmtBold << "Title:" << fmtBoldEnd << ' ' << s.GetTitle(); mTagEditor->at(8) << fmtBold << "Title:" << fmtBoldEnd << ' ' << ShowTag(s.GetTitle());
mTagEditor->at(9) << fmtBold << "Artist:" << fmtBoldEnd << ' ' << s.GetArtist(); mTagEditor->at(9) << fmtBold << "Artist:" << fmtBoldEnd << ' ' << ShowTag(s.GetArtist());
mTagEditor->at(10) << fmtBold << "Album:" << fmtBoldEnd << ' ' << s.GetAlbum(); mTagEditor->at(10) << fmtBold << "Album:" << fmtBoldEnd << ' ' << ShowTag(s.GetAlbum());
mTagEditor->at(11) << fmtBold << "Year:" << fmtBoldEnd << ' ' << s.GetYear(); mTagEditor->at(11) << fmtBold << "Year:" << fmtBoldEnd << ' ' << ShowTag(s.GetYear());
mTagEditor->at(12) << fmtBold << "Track:" << fmtBoldEnd << ' ' << s.GetTrack(); mTagEditor->at(12) << fmtBold << "Track:" << fmtBoldEnd << ' ' << ShowTag(s.GetTrack());
mTagEditor->at(13) << fmtBold << "Genre:" << fmtBoldEnd << ' ' <<s.GetGenre(); mTagEditor->at(13) << fmtBold << "Genre:" << fmtBoldEnd << ' ' << ShowTag(s.GetGenre());
mTagEditor->at(14) << fmtBold << "Composer:" << fmtBoldEnd << ' ' << s.GetComposer(); mTagEditor->at(14) << fmtBold << "Composer:" << fmtBoldEnd << ' ' << ShowTag(s.GetComposer());
mTagEditor->at(15) << fmtBold << "Performer:" << fmtBoldEnd << ' ' << s.GetPerformer(); mTagEditor->at(15) << fmtBold << "Performer:" << fmtBoldEnd << ' ' << ShowTag(s.GetPerformer());
mTagEditor->at(16) << fmtBold << "Disc:" << fmtBoldEnd << ' ' << s.GetDisc(); mTagEditor->at(16) << fmtBold << "Disc:" << fmtBoldEnd << ' ' << ShowTag(s.GetDisc());
mTagEditor->at(17) << fmtBold << "Comment:" << fmtBoldEnd << ' ' << s.GetComment(); mTagEditor->at(17) << fmtBold << "Comment:" << fmtBoldEnd << ' ' << ShowTag(s.GetComment());
mTagEditor->at(19) << fmtBold << "Filename:" << fmtBoldEnd << ' ' << s.GetName(); mTagEditor->at(19) << fmtBold << "Filename:" << fmtBoldEnd << ' ' << s.GetName();
@@ -370,7 +372,6 @@ bool WriteTags(Song &s)
FileRef f(path_to_file.c_str()); FileRef f(path_to_file.c_str());
if (!f.isNull()) if (!f.isNull())
{ {
s.GetEmptyFields(1);
f.tag()->setTitle(TO_WSTRING(s.GetTitle())); f.tag()->setTitle(TO_WSTRING(s.GetTitle()));
f.tag()->setArtist(TO_WSTRING(s.GetArtist())); f.tag()->setArtist(TO_WSTRING(s.GetArtist()));
f.tag()->setAlbum(TO_WSTRING(s.GetAlbum())); f.tag()->setAlbum(TO_WSTRING(s.GetAlbum()));
@@ -405,7 +406,6 @@ bool WriteTags(Song &s)
tag->addFrame(DiscFrame); tag->addFrame(DiscFrame);
file.save(); file.save();
} }
s.GetEmptyFields(0);
if (!s.GetNewName().empty()) if (!s.GetNewName().empty())
{ {
string old_name; string old_name;
@@ -505,7 +505,7 @@ void __deal_with_filenames(SongList &v)
*Legend << clGreen << " * " << clEnd << (*it)->GetName() << "\n"; *Legend << clGreen << " * " << clEnd << (*it)->GetName() << "\n";
Legend->Flush(); Legend->Flush();
Preview = static_cast<Scrollpad *>(Legend->EmptyClone()); Preview = Legend->EmptyClone();
Preview->SetTitle("Preview"); Preview->SetTitle("Preview");
Preview->SetTimeout(ncmpcpp_window_timeout); Preview->SetTimeout(ncmpcpp_window_timeout);
@@ -598,7 +598,6 @@ void __deal_with_filenames(SongList &v)
const string &file = s.GetName(); const string &file = s.GetName();
int last_dot = file.find_last_of("."); int last_dot = file.find_last_of(".");
string extension = file.substr(last_dot); string extension = file.substr(last_dot);
s.GetEmptyFields(1);
basic_buffer<my_char_t> new_file; basic_buffer<my_char_t> new_file;
new_file << TO_WSTRING(GenerateFilename(s, Config.pattern)); new_file << TO_WSTRING(GenerateFilename(s, Config.pattern));
if (new_file.Str().empty()) if (new_file.Str().empty())
@@ -615,7 +614,6 @@ void __deal_with_filenames(SongList &v)
if (!preview) if (!preview)
s.SetNewName(TO_STRING(new_file.Str()) + extension); s.SetNewName(TO_STRING(new_file.Str()) + extension);
*Preview << file << clGreen << " -> " << clEnd << new_file << extension << "\n\n"; *Preview << file << clGreen << " -> " << clEnd << new_file << extension << "\n\n";
s.GetEmptyFields(0);
} }
} }
if (!success) if (!success)