summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Rybczak <electricityispower@gmail.com>2008-12-11 18:29:56 +0100
committerAndrzej Rybczak <electricityispower@gmail.com>2008-12-11 18:29:56 +0100
commitda8feb885f4e279e788749a2b4682679b2a9382c (patch)
treecc5b8de68bac9aecb745ef8ba53c1cfcd1d304ec
parentcfa8268f2dc6a14ea3a2700fd556fdb1e294e9ce (diff)
handle colored empty tag marker
-rw-r--r--src/helpers.cpp68
-rw-r--r--src/helpers.h3
-rw-r--r--src/ncmpcpp.cpp142
-rw-r--r--src/search_engine.cpp19
-rw-r--r--src/settings.cpp1
-rw-r--r--src/settings.h1
-rw-r--r--src/song.cpp52
-rw-r--r--src/song.h9
-rw-r--r--src/status_checker.cpp1
-rw-r--r--src/tag_editor.cpp30
10 files changed, 151 insertions, 175 deletions
diff --git a/src/helpers.cpp b/src/helpers.cpp
index f4f19a17..9226dcc0 100644
--- a/src/helpers.cpp
+++ b/src/helpers.cpp
@@ -46,8 +46,6 @@ extern bool allow_statusbar_unlock;
extern bool search_case_sensitive;
extern bool search_match_to_pattern;
-extern string EMPTY_TAG;
-
const string term_type = getenv("TERM") ? getenv("TERM") : "";
bool ConnectToMPD()
@@ -656,8 +654,16 @@ void DisplaySong(const Song &s, void *data, Menu<Song> *menu)
default:
break;
}
- if (get && (s.*get)() == EMPTY_TAG)
- break;
+ if (get == &Song::GetLength)
+ {
+ if (!s.GetTotalLength())
+ break;
+ }
+ else if (get)
+ {
+ if ((s.*get)().empty())
+ break;
+ }
}
}
if (*it == '}')
@@ -675,6 +681,8 @@ void DisplaySong(const Song &s, void *data, Menu<Song> *menu)
{
for (; *it != '}'; it++) { }
it++;
+ if (it == song_template.end())
+ break;
if (*it == '{' || *it == '|')
{
if (*it == '|')
@@ -817,8 +825,8 @@ void GetInfo(Song &s, Scrollpad &info)
# endif // HAVE_TAGLIB_H
info << fmtBold << clWhite << "Filename: " << fmtBoldEnd << clGreen << s.GetName() << "\n" << clEnd;
- info << fmtBold << "Directory: " << fmtBoldEnd << clGreen << s.GetDirectory() + "\n\n" << clEnd;
- info << fmtBold << "Length: " << fmtBoldEnd << clGreen << s.GetLength() + "\n" << clEnd;
+ info << fmtBold << "Directory: " << fmtBoldEnd << clGreen << ShowTagInInfoScreen(s.GetDirectory()) << "\n\n" << clEnd;
+ info << fmtBold << "Length: " << fmtBoldEnd << clGreen << s.GetLength() << "\n" << clEnd;
# ifdef HAVE_TAGLIB_H
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 << "Channels: " << fmtBoldEnd << clGreen << (f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") << "\n" << clDefault;
}
+ else
+ info << clDefault;
# endif // HAVE_TAGLIB_H
- info << fmtBold << "\nTitle: " << fmtBoldEnd << s.GetTitle();
- info << fmtBold << "\nArtist: " << fmtBoldEnd << s.GetArtist();
- info << fmtBold << "\nAlbum: " << fmtBoldEnd << s.GetAlbum();
- info << fmtBold << "\nYear: " << fmtBoldEnd << s.GetYear();
- info << fmtBold << "\nTrack: " << fmtBoldEnd << s.GetTrack();
- info << fmtBold << "\nGenre: " << fmtBoldEnd << s.GetGenre();
- info << fmtBold << "\nComposer: " << fmtBoldEnd << s.GetComposer();
- info << fmtBold << "\nPerformer: " << fmtBoldEnd << s.GetPerformer();
- info << fmtBold << "\nDisc: " << fmtBoldEnd << s.GetDisc();
- info << fmtBold << "\nComment: " << fmtBoldEnd << s.GetComment();
+ info << fmtBold << "\nTitle: " << fmtBoldEnd << ShowTagInInfoScreen(s.GetTitle());
+ info << fmtBold << "\nArtist: " << fmtBoldEnd << ShowTagInInfoScreen(s.GetArtist());
+ info << fmtBold << "\nAlbum: " << fmtBoldEnd << ShowTagInInfoScreen(s.GetAlbum());
+ info << fmtBold << "\nYear: " << fmtBoldEnd << ShowTagInInfoScreen(s.GetYear());
+ info << fmtBold << "\nTrack: " << fmtBoldEnd << ShowTagInInfoScreen(s.GetTrack());
+ info << fmtBold << "\nGenre: " << fmtBoldEnd << ShowTagInInfoScreen(s.GetGenre());
+ info << fmtBold << "\nComposer: " << fmtBoldEnd << ShowTagInInfoScreen(s.GetComposer());
+ info << fmtBold << "\nPerformer: " << fmtBoldEnd << ShowTagInInfoScreen(s.GetPerformer());
+ info << fmtBold << "\nDisc: " << fmtBoldEnd << ShowTagInInfoScreen(s.GetDisc());
+ info << fmtBold << "\nComment: " << fmtBoldEnd << ShowTagInInfoScreen(s.GetComment());
}
void ShowMessage(const char *format, ...)
@@ -868,3 +878,29 @@ Window &Statusbar()
wclrtoeol(wFooter->Raw());
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
+}
diff --git a/src/helpers.h b/src/helpers.h
index a5b219e4..21211c7c 100644
--- a/src/helpers.h
+++ b/src/helpers.h
@@ -67,5 +67,8 @@ void GetInfo(Song &, Scrollpad &);
void ShowMessage(const char *, ...);
Window &Statusbar();
+const Buffer &ShowTag(const string &);
+const basic_buffer<my_char_t> &ShowTagInInfoScreen(const string &);
+
#endif
diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp
index e8e114bd..c7f299dc 100644
--- a/src/ncmpcpp.cpp
+++ b/src/ncmpcpp.cpp
@@ -157,8 +157,6 @@ extern bool header_update_status;
extern bool search_case_sensitive;
extern bool search_match_to_pattern;
-extern string EMPTY_TAG;
-extern string playlist_stats;
extern string volume_state;
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(MPD_TAG_ITEM_ALBUM, *it);
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;
FreeSongList(l);
}
@@ -729,7 +727,7 @@ int main(int argc, char *argv[])
if (current_screen == csLyrics && reload_lyrics)
{
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;
else
reload_lyrics = 0;
@@ -1024,101 +1022,71 @@ int main(int argc, char *argv[])
case 1:
{
Statusbar() << fmtBold << "Title: " << fmtBoldEnd;
- if (s.GetTitle() == EMPTY_TAG)
- s.SetTitle(wFooter->GetString());
- else
- s.SetTitle(wFooter->GetString(s.GetTitle()));
- mTagEditor->at(option) << fmtBold << "Title:" << fmtBoldEnd << ' ' << s.GetTitle();
+ s.SetTitle(wFooter->GetString(s.GetTitle()));
+ mTagEditor->at(option) << fmtBold << "Title:" << fmtBoldEnd << ' ' << ShowTag(s.GetTitle());
break;
}
case 2:
{
Statusbar() << fmtBold << "Artist: " << fmtBoldEnd;
- if (s.GetArtist() == EMPTY_TAG)
- s.SetArtist(wFooter->GetString());
- else
- s.SetArtist(wFooter->GetString(s.GetArtist()));
- mTagEditor->at(option) << fmtBold << "Artist:" << fmtBoldEnd << ' ' << s.GetArtist();
+ s.SetArtist(wFooter->GetString(s.GetArtist()));
+ mTagEditor->at(option) << fmtBold << "Artist:" << fmtBoldEnd << ' ' << ShowTag(s.GetArtist());
break;
}
case 3:
{
Statusbar() << fmtBold << "Album: " << fmtBoldEnd;
- if (s.GetAlbum() == EMPTY_TAG)
- s.SetAlbum(wFooter->GetString());
- else
- s.SetAlbum(wFooter->GetString(s.GetAlbum()));
- mTagEditor->at(option) << fmtBold << "Album:" << fmtBoldEnd << ' ' << s.GetAlbum();
+ s.SetAlbum(wFooter->GetString(s.GetAlbum()));
+ mTagEditor->at(option) << fmtBold << "Album:" << fmtBoldEnd << ' ' << ShowTag(s.GetAlbum());
break;
}
case 4:
{
Statusbar() << fmtBold << "Year: " << fmtBoldEnd;
- if (s.GetYear() == EMPTY_TAG)
- s.SetYear(wFooter->GetString(4));
- else
- s.SetYear(wFooter->GetString(s.GetYear(), 4));
- mTagEditor->at(option) << fmtBold << "Year:" << fmtBoldEnd << ' ' << s.GetYear();
+ s.SetYear(wFooter->GetString(s.GetYear(), 4));
+ mTagEditor->at(option) << fmtBold << "Year:" << fmtBoldEnd << ' ' << ShowTag(s.GetYear());
break;
}
case 5:
{
Statusbar() << fmtBold << "Track: " << fmtBoldEnd;
- if (s.GetTrack() == EMPTY_TAG)
- s.SetTrack(wFooter->GetString(3));
- else
- s.SetTrack(wFooter->GetString(s.GetTrack(), 3));
- mTagEditor->at(option) << fmtBold << "Track:" << fmtBoldEnd << ' ' << s.GetTrack();
+ s.SetTrack(wFooter->GetString(s.GetTrack(), 3));
+ mTagEditor->at(option) << fmtBold << "Track:" << fmtBoldEnd << ' ' << ShowTag(s.GetTrack());
break;
}
case 6:
{
Statusbar() << fmtBold << "Genre: " << fmtBoldEnd;
- if (s.GetGenre() == EMPTY_TAG)
- s.SetGenre(wFooter->GetString());
- else
- s.SetGenre(wFooter->GetString(s.GetGenre()));
- mTagEditor->at(option) << fmtBold << "Genre:" << fmtBoldEnd << ' ' << s.GetGenre();
+ s.SetGenre(wFooter->GetString(s.GetGenre()));
+ mTagEditor->at(option) << fmtBold << "Genre:" << fmtBoldEnd << ' ' << ShowTag(s.GetGenre());
break;
}
case 7:
{
Statusbar() << fmtBold << "Composer: " << fmtBoldEnd;
- if (s.GetComposer() == EMPTY_TAG)
- s.SetComposer(wFooter->GetString());
- else
- s.SetComposer(wFooter->GetString(s.GetComposer()));
- mTagEditor->at(option) << fmtBold << "Composer:" << fmtBoldEnd << ' ' << s.GetComposer();
+ s.SetComposer(wFooter->GetString(s.GetComposer()));
+ mTagEditor->at(option) << fmtBold << "Composer:" << fmtBoldEnd << ' ' << ShowTag(s.GetComposer());
break;
}
case 8:
{
Statusbar() << fmtBold << "Performer: " << fmtBoldEnd;
- if (s.GetPerformer() == EMPTY_TAG)
- s.SetPerformer(wFooter->GetString());
- else
- s.SetPerformer(wFooter->GetString(s.GetPerformer()));
- mTagEditor->at(option) << fmtBold << "Performer:" << fmtBoldEnd << ' ' << s.GetPerformer();
+ s.SetPerformer(wFooter->GetString(s.GetPerformer()));
+ mTagEditor->at(option) << fmtBold << "Performer:" << fmtBoldEnd << ' ' << ShowTag(s.GetPerformer());
break;
}
case 9:
{
Statusbar() << fmtBold << "Disc: " << fmtBoldEnd;
- if (s.GetDisc() == EMPTY_TAG)
- s.SetDisc(wFooter->GetString());
- else
- s.SetDisc(wFooter->GetString(s.GetDisc()));
- mTagEditor->at(option) << fmtBold << "Disc:" << fmtBoldEnd << ' ' << s.GetDisc();
+ s.SetDisc(wFooter->GetString(s.GetDisc()));
+ mTagEditor->at(option) << fmtBold << "Disc:" << fmtBoldEnd << ' ' << ShowTag(s.GetDisc());
break;
}
case 10:
{
Statusbar() << fmtBold << "Comment: " << fmtBoldEnd;
- if (s.GetComment() == EMPTY_TAG)
- s.SetComment(wFooter->GetString());
- else
- s.SetComment(wFooter->GetString(s.GetComment()));
- mTagEditor->at(option) << fmtBold << "Comment:" << fmtBoldEnd << ' ' << s.GetComment();
+ s.SetComment(wFooter->GetString(s.GetComment()));
+ mTagEditor->at(option) << fmtBold << "Comment:" << fmtBoldEnd << ' ' << ShowTag(s.GetComment());
break;
}
case 12:
@@ -1198,81 +1166,57 @@ int main(int argc, char *argv[])
case 1:
{
Statusbar() << fmtBold << "Filename: " << fmtBoldEnd;
- if (s.GetName() == EMPTY_TAG)
- s.SetFile(wFooter->GetString());
- else
- s.SetFile(wFooter->GetString(s.GetFile()));
- *mSearcher->Current().first << fmtBold << "Filename:" << fmtBoldEnd << ' ' << s.GetFile();
+ s.SetFile(wFooter->GetString(s.GetFile()));
+ *mSearcher->Current().first << fmtBold << "Filename:" << fmtBoldEnd << ' ' << ShowTag(s.GetFile());
break;
}
case 2:
{
Statusbar() << fmtBold << "Title: " << fmtBoldEnd;
- if (s.GetTitle() == EMPTY_TAG)
- s.SetTitle(wFooter->GetString());
- else
- s.SetTitle(wFooter->GetString(s.GetTitle()));
- *mSearcher->Current().first << fmtBold << "Title:" << fmtBoldEnd << ' ' << s.GetTitle();
+ s.SetTitle(wFooter->GetString(s.GetTitle()));
+ *mSearcher->Current().first << fmtBold << "Title:" << fmtBoldEnd << ' ' << ShowTag(s.GetTitle());
break;
}
case 3:
{
Statusbar() << fmtBold << "Artist: " << fmtBoldEnd;
- if (s.GetArtist() == EMPTY_TAG)
- s.SetArtist(wFooter->GetString());
- else
- s.SetArtist(wFooter->GetString(s.GetArtist()));
- *mSearcher->Current().first << fmtBold << "Artist:" << fmtBoldEnd << ' ' << s.GetArtist();
+ s.SetArtist(wFooter->GetString(s.GetArtist()));
+ *mSearcher->Current().first << fmtBold << "Artist:" << fmtBoldEnd << ' ' << ShowTag(s.GetArtist());
break;
}
case 4:
{
Statusbar() << fmtBold << "Album: " << fmtBoldEnd;
- if (s.GetAlbum() == EMPTY_TAG)
- s.SetAlbum(wFooter->GetString());
- else
- s.SetAlbum(wFooter->GetString(s.GetAlbum()));
- *mSearcher->Current().first << fmtBold << "Album:" << fmtBoldEnd << ' ' << s.GetAlbum();
+ s.SetAlbum(wFooter->GetString(s.GetAlbum()));
+ *mSearcher->Current().first << fmtBold << "Album:" << fmtBoldEnd << ' ' << ShowTag(s.GetAlbum());
break;
}
case 5:
{
Statusbar() << fmtBold << "Year: " << fmtBoldEnd;
- if (s.GetYear() == EMPTY_TAG)
- s.SetYear(wFooter->GetString(4));
- else
- s.SetYear(wFooter->GetString(s.GetYear(), 4));
- *mSearcher->Current().first << fmtBold << "Year:" << fmtBoldEnd << ' ' << s.GetYear();
+ s.SetYear(wFooter->GetString(s.GetYear(), 4));
+ *mSearcher->Current().first << fmtBold << "Year:" << fmtBoldEnd << ' ' << ShowTag(s.GetYear());
break;
}
case 6:
{
Statusbar() << fmtBold << "Track: " << fmtBoldEnd;
- if (s.GetTrack() == EMPTY_TAG)
- s.SetTrack(wFooter->GetString(3));
- else
- s.SetTrack(wFooter->GetString(s.GetTrack(), 3));
- *mSearcher->Current().first << fmtBold << "Track:" << fmtBoldEnd << ' ' << s.GetTrack();
+ s.SetTrack(wFooter->GetString(s.GetTrack(), 3));
+ *mSearcher->Current().first << fmtBold << "Track:" << fmtBoldEnd << ' ' << ShowTag(s.GetTrack());
break;
}
case 7:
{
Statusbar() << fmtBold << "Genre: " << fmtBoldEnd;
- if (s.GetGenre() == EMPTY_TAG)
- s.SetGenre(wFooter->GetString());
- else
- s.SetGenre(wFooter->GetString(s.GetGenre()));
- *mSearcher->Current().first << fmtBold << "Genre:" << fmtBoldEnd << ' ' << s.GetGenre();
+ s.SetGenre(wFooter->GetString(s.GetGenre()));
+ *mSearcher->Current().first << fmtBold << "Genre:" << fmtBoldEnd << ' ' << ShowTag(s.GetGenre());
break;
}
case 8:
{
Statusbar() << fmtBold << "Comment: " << fmtBoldEnd;
- if (s.GetComment() == EMPTY_TAG)
- s.SetComment(wFooter->GetString());
- else
- s.SetComment(wFooter->GetString(s.GetComment()));
- *mSearcher->Current().first << fmtBold << "Comment:" << fmtBoldEnd << ' ' << s.GetComment();
+ s.SetComment(wFooter->GetString(s.GetComment()));
+ *mSearcher->Current().first << fmtBold << "Comment:" << fmtBoldEnd << ' ' << ShowTag(s.GetComment());
break;
}
case 10:
@@ -1719,9 +1663,7 @@ int main(int argc, char *argv[])
{
LockStatusbar();
Statusbar() << fmtBold << mEditorTagTypes->Current() << fmtBoldEnd << ": ";
- mEditorTags->Current().GetEmptyFields(1);
string new_tag = wFooter->GetString((mEditorTags->Current().*get)());
- mEditorTags->Current().GetEmptyFields(0);
UnlockStatusbar();
for (SongList::iterator it = list.begin(); it != list.end(); it++)
(**it.*set)(new_tag);
@@ -1731,9 +1673,7 @@ int main(int argc, char *argv[])
{
LockStatusbar();
Statusbar() << fmtBold << mEditorTagTypes->Current() << fmtBoldEnd << ": ";
- mEditorTags->Current().GetEmptyFields(1);
string new_tag = wFooter->GetString((mEditorTags->Current().*get)());
- mEditorTags->Current().GetEmptyFields(0);
UnlockStatusbar();
if (new_tag != (mEditorTags->Current().*get)())
(mEditorTags->Current().*set)(new_tag);
@@ -2744,7 +2684,7 @@ int main(int argc, char *argv[])
break;
}
- if (s->GetDirectory() == EMPTY_TAG) // for streams
+ if (s->GetDirectory().empty()) // for streams
continue;
Config.local_browser = !s->IsFromDB();
@@ -3305,7 +3245,7 @@ int main(int argc, char *argv[])
default:
break;
}
- if (*artist != EMPTY_TAG)
+ if (!artist->empty())
{
wPrev = wCurrent;
wCurrent = sInfo;
@@ -3396,7 +3336,7 @@ int main(int argc, char *argv[])
default:
break;
}
- if (s->GetArtist() != EMPTY_TAG && s->GetTitle() != EMPTY_TAG)
+ if (!s->GetArtist().empty() && !s->GetTitle().empty())
{
wPrev = wCurrent;
prev_screen = current_screen;
diff --git a/src/search_engine.cpp b/src/search_engine.cpp
index 3fcddd66..21a39804 100644
--- a/src/search_engine.cpp
+++ b/src/search_engine.cpp
@@ -88,14 +88,14 @@ void PrepareSearchEngine(Song &s)
catch (List::InvalidItem) { }
}
- *mSearcher->at(0).first << fmtBold << "Filename:" << fmtBoldEnd << ' ' << s.GetName();
- *mSearcher->at(1).first << fmtBold << "Title:" << fmtBoldEnd << ' ' << s.GetTitle();
- *mSearcher->at(2).first << fmtBold << "Artist:" << fmtBoldEnd << ' ' << s.GetArtist();
- *mSearcher->at(3).first << fmtBold << "Album:" << fmtBoldEnd << ' ' << s.GetAlbum();
- *mSearcher->at(4).first << fmtBold << "Year:" << fmtBoldEnd << ' ' << s.GetYear();
- *mSearcher->at(5).first << fmtBold << "Track:" << fmtBoldEnd << ' ' << s.GetTrack();
- *mSearcher->at(6).first << fmtBold << "Genre:" << fmtBoldEnd << ' ' << s.GetGenre();
- *mSearcher->at(7).first << fmtBold << "Comment:" << fmtBoldEnd << ' ' << s.GetComment();
+ *mSearcher->at(0).first << fmtBold << "Filename:" << fmtBoldEnd << ' ' << ShowTag(s.GetName());
+ *mSearcher->at(1).first << fmtBold << "Title:" << fmtBoldEnd << ' ' << ShowTag(s.GetTitle());
+ *mSearcher->at(2).first << fmtBold << "Artist:" << fmtBoldEnd << ' ' << ShowTag(s.GetArtist());
+ *mSearcher->at(3).first << fmtBold << "Album:" << fmtBoldEnd << ' ' << ShowTag(s.GetAlbum());
+ *mSearcher->at(4).first << fmtBold << "Year:" << fmtBoldEnd << ' ' << ShowTag(s.GetYear());
+ *mSearcher->at(5).first << fmtBold << "Track:" << fmtBoldEnd << ' ' << ShowTag(s.GetTrack());
+ *mSearcher->at(6).first << fmtBold << "Genre:" << fmtBoldEnd << ' ' << ShowTag(s.GetGenre());
+ *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(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;
- s.GetEmptyFields(1);
-
if (!search_case_sensitive)
{
string t;
@@ -234,6 +232,5 @@ void Search(Song &s)
}
if (Config.search_in_db) // free song list only if it's database
FreeSongList(list);
- s.GetEmptyFields(0);
}
diff --git a/src/settings.cpp b/src/settings.cpp
index 51d56f55..22145786 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -218,6 +218,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
void DefaultConfiguration(ncmpcpp_config &conf)
{
conf.mpd_host = "localhost";
+ conf.empty_tag = "<empty>";
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_status_format = "{(%l) }{%a - }{%t}|{%f}";
diff --git a/src/settings.h b/src/settings.h
index ac409a02..f7388866 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -96,6 +96,7 @@ struct ncmpcpp_config
{
string mpd_host;
string mpd_music_dir;
+ string empty_tag;
string song_list_format;
string song_columns_list_format;
string song_status_format;
diff --git a/src/song.cpp b/src/song.cpp
index 5c62b3cb..b01eb10b 100644
--- a/src/song.cpp
+++ b/src/song.cpp
@@ -21,16 +21,11 @@
#include "song.h"
#include "settings.h"
-extern ncmpcpp_config Config;
-
-string EMPTY_TAG = "<empty>";
-
Song::Song(mpd_Song *s, bool copy_ptr) : itsSong(s),
itsSlash(string::npos),
itsHash(0),
copyPtr(copy_ptr),
- isStream(0),
- itsGetEmptyFields(0)
+ isStream(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),
itsHash(s.itsHash),
copyPtr(s.copyPtr),
- isStream(s.isStream),
- itsGetEmptyFields(s.itsGetEmptyFields)
+ isStream(s.isStream)
{
itsSong = s.copyPtr ? s.itsSong : mpd_songDup(s.itsSong);
}
@@ -85,7 +79,6 @@ void Song::Clear()
itsSlash = 0;
itsHash = 0;
copyPtr = 0;
- itsGetEmptyFields = 0;
}
bool Song::Empty() const
@@ -101,67 +94,67 @@ bool Song::IsFromDB() const
string Song::GetFile() const
{
- return !itsSong->file ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsSong->file;
+ return !itsSong->file ? "" : itsSong->file;
}
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
{
- 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
{
- return !itsSong->artist ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsSong->artist;
+ return !itsSong->artist ? "" : itsSong->artist;
}
string Song::GetTitle() const
{
- return !itsSong->title ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsSong->title;
+ return !itsSong->title ? "" : itsSong->title;
}
string Song::GetAlbum() const
{
- return !itsSong->album ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsSong->album;
+ return !itsSong->album ? "" : itsSong->album;
}
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
{
- return !itsSong->date ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsSong->date;
+ return !itsSong->date ? "" : itsSong->date;
}
string Song::GetGenre() const
{
- return !itsSong->genre ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsSong->genre;
+ return !itsSong->genre ? "" : itsSong->genre;
}
string Song::GetComposer() const
{
- return !itsSong->composer ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsSong->composer;
+ return !itsSong->composer ? "" : itsSong->composer;
}
string Song::GetPerformer() const
{
- return !itsSong->performer ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsSong->performer;
+ return !itsSong->performer ? "" : itsSong->performer;
}
string Song::GetDisc() const
{
- return !itsSong->disc ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsSong->disc;
+ return !itsSong->disc ? "" : itsSong->disc;
}
string Song::GetComment() const
{
- return !itsSong->comment ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsSong->comment;
+ return !itsSong->comment ? "" : itsSong->comment;
}
void Song::SetFile(const string &str)
@@ -320,8 +313,16 @@ string Song::toString(const std::string &format) const
default:
break;
}
- if (get && (this->*get)() == EMPTY_TAG)
- break;
+ if (get == &Song::GetLength)
+ {
+ if (!GetTotalLength())
+ break;
+ }
+ else if (get)
+ {
+ if ((this->*get)().empty())
+ break;
+ }
}
}
if (*it == '}')
@@ -339,6 +340,8 @@ string Song::toString(const std::string &format) const
{
for (; *it != '}'; it++) { }
it++;
+ if (it == format.end())
+ break;
if (*it == '{' || *it == '|')
{
if (*it == '|')
@@ -424,7 +427,6 @@ Song & Song::operator=(const Song &s)
itsHash = s.itsHash;
copyPtr = s.copyPtr;
isStream = s.isStream;
- itsGetEmptyFields = s.itsGetEmptyFields;
return *this;
}
diff --git a/src/song.h b/src/song.h
index ac675bd4..d5d63b3a 100644
--- a/src/song.h
+++ b/src/song.h
@@ -34,7 +34,7 @@ using std::string;
class Song
{
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(const Song &);
~Song();
@@ -48,13 +48,12 @@ class Song
string GetTrack() const;
string GetYear() const;
string GetGenre() const;
- //string GetName() const { return itsName; }
string GetComposer() const;
string GetPerformer() const;
string GetDisc() const;
string GetComment() 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 GetPosition() const { return itsSong->pos; }
int GetID() const { return itsSong->id; }
@@ -82,7 +81,7 @@ class Song
void NullMe() { itsSong = 0; }
void CopyPtr(bool copy) { copyPtr = copy; }
- void GetEmptyFields(bool get) { itsGetEmptyFields = get; }
+ //void GetEmptyFields(bool get) { itsGetEmptyFields = get; }
void Clear();
bool Empty() const;
bool IsFromDB() const;
@@ -101,7 +100,7 @@ class Song
long long itsHash;
bool copyPtr;
bool isStream;
- bool itsGetEmptyFields;
+ //bool itsGetEmptyFields;
};
#endif
diff --git a/src/status_checker.cpp b/src/status_checker.cpp
index 6f63fb02..791e14b7 100644
--- a/src/status_checker.cpp
+++ b/src/status_checker.cpp
@@ -67,7 +67,6 @@ int old_playing;
time_t time_of_statusbar_lock;
-//string playlist_stats;
string volume_state;
string switch_state;
diff --git a/src/tag_editor.cpp b/src/tag_editor.cpp
index a8855caf..507d0824 100644
--- a/src/tag_editor.cpp
+++ b/src/tag_editor.cpp
@@ -322,8 +322,10 @@ bool GetSongTags(Song &s)
mTagEditor->Reset();
mTagEditor->ResizeBuffer(23);
+
for (size_t i = 0; i < 7; i++)
mTagEditor->Static(i, 1);
+
mTagEditor->IntoSeparator(7);
mTagEditor->IntoSeparator(18);
mTagEditor->IntoSeparator(20);
@@ -335,22 +337,22 @@ bool GetSongTags(Song &s)
mTagEditor->Highlight(8);
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(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(6) << fmtBold << clWhite << "Channels: " << fmtBoldEnd << clGreen << (f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") << clDefault;
- mTagEditor->at(8) << fmtBold << "Title:" << fmtBoldEnd << ' ' << s.GetTitle();
- mTagEditor->at(9) << fmtBold << "Artist:" << fmtBoldEnd << ' ' << s.GetArtist();
- mTagEditor->at(10) << fmtBold << "Album:" << fmtBoldEnd << ' ' << s.GetAlbum();
- mTagEditor->at(11) << fmtBold << "Year:" << fmtBoldEnd << ' ' << s.GetYear();
- mTagEditor->at(12) << fmtBold << "Track:" << fmtBoldEnd << ' ' << s.GetTrack();
- mTagEditor->at(13) << fmtBold << "Genre:" << fmtBoldEnd << ' ' <<s.GetGenre();
- mTagEditor->at(14) << fmtBold << "Composer:" << fmtBoldEnd << ' ' << s.GetComposer();
- mTagEditor->at(15) << fmtBold << "Performer:" << fmtBoldEnd << ' ' << s.GetPerformer();
- mTagEditor->at(16) << fmtBold << "Disc:" << fmtBoldEnd << ' ' << s.GetDisc();
- mTagEditor->at(17) << fmtBold << "Comment:" << fmtBoldEnd << ' ' << s.GetComment();
+ mTagEditor->at(8) << fmtBold << "Title:" << fmtBoldEnd << ' ' << ShowTag(s.GetTitle());
+ mTagEditor->at(9) << fmtBold << "Artist:" << fmtBoldEnd << ' ' << ShowTag(s.GetArtist());
+ mTagEditor->at(10) << fmtBold << "Album:" << fmtBoldEnd << ' ' << ShowTag(s.GetAlbum());
+ mTagEditor->at(11) << fmtBold << "Year:" << fmtBoldEnd << ' ' << ShowTag(s.GetYear());
+ mTagEditor->at(12) << fmtBold << "Track:" << fmtBoldEnd << ' ' << ShowTag(s.GetTrack());
+ mTagEditor->at(13) << fmtBold << "Genre:" << fmtBoldEnd << ' ' << ShowTag(s.GetGenre());
+ mTagEditor->at(14) << fmtBold << "Composer:" << fmtBoldEnd << ' ' << ShowTag(s.GetComposer());
+ mTagEditor->at(15) << fmtBold << "Performer:" << fmtBoldEnd << ' ' << ShowTag(s.GetPerformer());
+ mTagEditor->at(16) << fmtBold << "Disc:" << fmtBoldEnd << ' ' << ShowTag(s.GetDisc());
+ mTagEditor->at(17) << fmtBold << "Comment:" << fmtBoldEnd << ' ' << ShowTag(s.GetComment());
mTagEditor->at(19) << fmtBold << "Filename:" << fmtBoldEnd << ' ' << s.GetName();
@@ -370,7 +372,6 @@ bool WriteTags(Song &s)
FileRef f(path_to_file.c_str());
if (!f.isNull())
{
- s.GetEmptyFields(1);
f.tag()->setTitle(TO_WSTRING(s.GetTitle()));
f.tag()->setArtist(TO_WSTRING(s.GetArtist()));
f.tag()->setAlbum(TO_WSTRING(s.GetAlbum()));
@@ -405,7 +406,6 @@ bool WriteTags(Song &s)
tag->addFrame(DiscFrame);
file.save();
}
- s.GetEmptyFields(0);
if (!s.GetNewName().empty())
{
string old_name;
@@ -505,7 +505,7 @@ void __deal_with_filenames(SongList &v)
*Legend << clGreen << " * " << clEnd << (*it)->GetName() << "\n";
Legend->Flush();
- Preview = static_cast<Scrollpad *>(Legend->EmptyClone());
+ Preview = Legend->EmptyClone();
Preview->SetTitle("Preview");
Preview->SetTimeout(ncmpcpp_window_timeout);
@@ -598,7 +598,6 @@ void __deal_with_filenames(SongList &v)
const string &file = s.GetName();
int last_dot = file.find_last_of(".");
string extension = file.substr(last_dot);
- s.GetEmptyFields(1);
basic_buffer<my_char_t> new_file;
new_file << TO_WSTRING(GenerateFilename(s, Config.pattern));
if (new_file.Str().empty())
@@ -615,7 +614,6 @@ void __deal_with_filenames(SongList &v)
if (!preview)
s.SetNewName(TO_STRING(new_file.Str()) + extension);
*Preview << file << clGreen << " -> " << clEnd << new_file << extension << "\n\n";
- s.GetEmptyFields(0);
}
}
if (!success)