improvements for album tag editor
This commit is contained in:
@@ -51,6 +51,8 @@
|
|||||||
#
|
#
|
||||||
#key_playlist_editor = '6' 270
|
#key_playlist_editor = '6' 270
|
||||||
#
|
#
|
||||||
|
#key_album_tag_editor = '7' 271
|
||||||
|
#
|
||||||
#key_stop = 's'
|
#key_stop = 's'
|
||||||
#
|
#
|
||||||
#key_pause = 'P'
|
#key_pause = 'P'
|
||||||
|
|||||||
@@ -62,18 +62,22 @@
|
|||||||
#
|
#
|
||||||
#song_list_format = "{[.green](%l)[/green] }{%a - }{%t}|{[.white]%f[/white]}"
|
#song_list_format = "{[.green](%l)[/green] }{%a - }{%t}|{[.white]%f[/white]}"
|
||||||
#
|
#
|
||||||
#song_status_format = "{(%l) }{%a - }{%t}|{%f}"
|
|
||||||
#
|
|
||||||
#song_window_title_format = "{%a - }{%t}|{%f}"
|
|
||||||
#
|
|
||||||
#song_library_format = "{%n - }{%t}|{%f}"
|
#song_library_format = "{%n - }{%t}|{%f}"
|
||||||
#
|
#
|
||||||
|
#tag_editor_album_format = "{(%y) }%b"
|
||||||
|
#
|
||||||
#browser_playlist_prefix = "[.red]playlist[/red] "
|
#browser_playlist_prefix = "[.red]playlist[/red] "
|
||||||
#
|
#
|
||||||
#selected_item_prefix = "[.magenta]"
|
#selected_item_prefix = "[.magenta]"
|
||||||
#
|
#
|
||||||
#selected_item_suffix = "[/magenta]"
|
#selected_item_suffix = "[/magenta]"
|
||||||
#
|
#
|
||||||
|
## colors are not supported for below veriables
|
||||||
|
#
|
||||||
|
#song_status_format = "{(%l) }{%a - }{%t}|{%f}"
|
||||||
|
#
|
||||||
|
#song_window_title_format = "{%a - }{%t}|{%f}"
|
||||||
|
#
|
||||||
##### columns settings #####
|
##### columns settings #####
|
||||||
##
|
##
|
||||||
## syntax of song columns list format is "column column etc."
|
## syntax of song columns list format is "column column etc."
|
||||||
|
|||||||
@@ -59,6 +59,38 @@ extern string UNKNOWN_ARTIST;
|
|||||||
extern string UNKNOWN_TITLE;
|
extern string UNKNOWN_TITLE;
|
||||||
extern string UNKNOWN_ALBUM;
|
extern string UNKNOWN_ALBUM;
|
||||||
|
|
||||||
|
bool CaseInsensitiveSorting::operator()(string a, string b)
|
||||||
|
{
|
||||||
|
//a = Window::OmitBBCodes(a);
|
||||||
|
//b = Window::OmitBBCodes(b);
|
||||||
|
transform(a.begin(), a.end(), a.begin(), tolower);
|
||||||
|
transform(b.begin(), b.end(), b.begin(), tolower);
|
||||||
|
return a < b;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CaseInsensitiveSorting::operator()(Song *sa, Song *sb)
|
||||||
|
{
|
||||||
|
string a = sa->GetShortFilename();
|
||||||
|
string b = sb->GetShortFilename();
|
||||||
|
transform(a.begin(), a.end(), a.begin(), tolower);
|
||||||
|
transform(b.begin(), b.end(), b.begin(), tolower);
|
||||||
|
return a < b;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CaseInsensitiveSorting::operator()(const Item &a, const Item &b)
|
||||||
|
{
|
||||||
|
if (a.type == b.type)
|
||||||
|
{
|
||||||
|
string sa = a.type == itSong ? a.song->GetShortFilename() : a.name;
|
||||||
|
string sb = b.type == itSong ? b.song->GetShortFilename() : b.name;
|
||||||
|
transform(sa.begin(), sa.end(), sa.begin(), tolower);
|
||||||
|
transform(sb.begin(), sb.end(), sb.begin(), tolower);
|
||||||
|
return sa < sb;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return a.type < b.type;
|
||||||
|
}
|
||||||
|
|
||||||
void UpdateItemList(Menu<Item> *menu)
|
void UpdateItemList(Menu<Item> *menu)
|
||||||
{
|
{
|
||||||
bool bold = 0;
|
bool bold = 0;
|
||||||
@@ -981,20 +1013,6 @@ bool GetSongInfo(Song &s)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SortDirectory(const Item &a, const Item &b)
|
|
||||||
{
|
|
||||||
if (a.type == b.type)
|
|
||||||
{
|
|
||||||
string sa = a.type == itSong ? a.song->GetShortFilename() : a.name;
|
|
||||||
string sb = b.type == itSong ? b.song->GetShortFilename() : b.name;
|
|
||||||
transform(sa.begin(), sa.end(), sa.begin(), tolower);
|
|
||||||
transform(sb.begin(), sb.end(), sb.begin(), tolower);
|
|
||||||
return sa < sb;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return a.type < b.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GetDirectory(string dir, string subdir)
|
void GetDirectory(string dir, string subdir)
|
||||||
{
|
{
|
||||||
int highlightme = -1;
|
int highlightme = -1;
|
||||||
@@ -1016,7 +1034,7 @@ void GetDirectory(string dir, string subdir)
|
|||||||
|
|
||||||
ItemList list;
|
ItemList list;
|
||||||
Mpd->GetDirectory(dir, list);
|
Mpd->GetDirectory(dir, list);
|
||||||
sort(list.begin(), list.end(), SortDirectory);
|
sort(list.begin(), list.end(), CaseInsensitiveSorting());
|
||||||
|
|
||||||
for (ItemList::iterator it = list.begin(); it != list.end(); it++)
|
for (ItemList::iterator it = list.begin(); it != list.end(); it++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,15 +30,12 @@
|
|||||||
|
|
||||||
extern ncmpcpp_config Config;
|
extern ncmpcpp_config Config;
|
||||||
|
|
||||||
class CaseInsensitiveComparison
|
class CaseInsensitiveSorting
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool operator()(string a, string b)
|
bool operator()(string, string);
|
||||||
{
|
bool operator()(Song *, Song *);
|
||||||
transform(a.begin(), a.end(), a.begin(), tolower);
|
bool operator()(const Item &, const Item &);
|
||||||
transform(b.begin(), b.end(), b.begin(), tolower);
|
|
||||||
return a < b;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void UpdateItemList(Menu<Item> *);
|
void UpdateItemList(Menu<Item> *);
|
||||||
@@ -59,7 +56,6 @@ string DisplayColumns(string);
|
|||||||
string DisplaySongInColumns(const Song &, void *);
|
string DisplaySongInColumns(const Song &, void *);
|
||||||
string DisplaySong(const Song &, void * = &Config.song_list_format);
|
string DisplaySong(const Song &, void * = &Config.song_list_format);
|
||||||
void ShowMessage(const string &, int = Config.message_delay_time);
|
void ShowMessage(const string &, int = Config.message_delay_time);
|
||||||
bool SortDirectory(const Item &a, const Item &b);
|
|
||||||
void GetDirectory(string, string = "/");
|
void GetDirectory(string, string = "/");
|
||||||
#ifdef HAVE_TAGLIB_H
|
#ifdef HAVE_TAGLIB_H
|
||||||
bool WriteTags(Song &);
|
bool WriteTags(Song &);
|
||||||
|
|||||||
@@ -74,8 +74,8 @@ ncmpcpp_config Config;
|
|||||||
ncmpcpp_keys Key;
|
ncmpcpp_keys Key;
|
||||||
|
|
||||||
SongList vSearched;
|
SongList vSearched;
|
||||||
std::map<string, string, CaseInsensitiveComparison> vLibAlbums;
|
std::map<string, string, CaseInsensitiveSorting> vLibAlbums;
|
||||||
std::map<string, string, CaseInsensitiveComparison> vEditorAlbums;
|
std::map<string, string, CaseInsensitiveSorting> vEditorAlbums;
|
||||||
|
|
||||||
vector<int> vFoundPositions;
|
vector<int> vFoundPositions;
|
||||||
int found_pos = 0;
|
int found_pos = 0;
|
||||||
@@ -504,7 +504,7 @@ int main(int argc, char *argv[])
|
|||||||
mLibAlbums->Clear(0);
|
mLibAlbums->Clear(0);
|
||||||
mLibSongs->Clear(0);
|
mLibSongs->Clear(0);
|
||||||
Mpd->GetArtists(list);
|
Mpd->GetArtists(list);
|
||||||
sort(list.begin(), list.end(), CaseInsensitiveComparison());
|
sort(list.begin(), list.end(), CaseInsensitiveSorting());
|
||||||
for (TagList::const_iterator it = list.begin(); it != list.end(); it++)
|
for (TagList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||||
mLibArtists->AddOption(*it);
|
mLibArtists->AddOption(*it);
|
||||||
mLibArtists->Window::Clear();
|
mLibArtists->Window::Clear();
|
||||||
@@ -673,17 +673,7 @@ int main(int argc, char *argv[])
|
|||||||
Mpd->StartSearch(1);
|
Mpd->StartSearch(1);
|
||||||
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, *it);
|
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, *it);
|
||||||
Mpd->CommitSearch(l);
|
Mpd->CommitSearch(l);
|
||||||
for (SongList::const_iterator j = l.begin(); j != l.end(); j++)
|
vEditorAlbums[DisplaySong(*l[0], &Config.tag_editor_album_format)] = *it;
|
||||||
{
|
|
||||||
if ((*j)->GetYear() != EMPTY_TAG)
|
|
||||||
{
|
|
||||||
vEditorAlbums["(" + (*j)->GetYear() + ") " + *it] = *it;
|
|
||||||
written = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!written)
|
|
||||||
vEditorAlbums[*it] = *it;
|
|
||||||
FreeSongList(l);
|
FreeSongList(l);
|
||||||
}
|
}
|
||||||
for (std::map<string, string>::const_iterator it = vEditorAlbums.begin(); it != vEditorAlbums.end(); it++)
|
for (std::map<string, string>::const_iterator it = vEditorAlbums.begin(); it != vEditorAlbums.end(); it++)
|
||||||
@@ -699,6 +689,7 @@ int main(int argc, char *argv[])
|
|||||||
Mpd->StartSearch(1);
|
Mpd->StartSearch(1);
|
||||||
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, vEditorAlbums[mEditorAlbums->GetOption()]);
|
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, vEditorAlbums[mEditorAlbums->GetOption()]);
|
||||||
Mpd->CommitSearch(list);
|
Mpd->CommitSearch(list);
|
||||||
|
sort(list.begin(), list.end(), CaseInsensitiveSorting());
|
||||||
for (SongList::iterator it = list.begin(); it != list.end(); it++)
|
for (SongList::iterator it = list.begin(); it != list.end(); it++)
|
||||||
mEditorTags->AddOption(**it);
|
mEditorTags->AddOption(**it);
|
||||||
FreeSongList(list);
|
FreeSongList(list);
|
||||||
@@ -1330,7 +1321,8 @@ int main(int argc, char *argv[])
|
|||||||
case csAlbumEditor:
|
case csAlbumEditor:
|
||||||
{
|
{
|
||||||
void (Song::*set)(const string &) = 0;
|
void (Song::*set)(const string &) = 0;
|
||||||
switch (mEditorTagTypes->GetRealChoice())
|
int id = mEditorTagTypes->GetRealChoice();
|
||||||
|
switch (id)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
set = &Song::SetTitle;
|
set = &Song::SetTitle;
|
||||||
@@ -1346,6 +1338,29 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
set = &Song::SetTrack;
|
set = &Song::SetTrack;
|
||||||
|
if (wCurrent == mEditorTagTypes)
|
||||||
|
{
|
||||||
|
LOCK_STATUSBAR;
|
||||||
|
wFooter->WriteXY(0, Config.statusbar_visibility, "Number tracks? [y/n] ", 1);
|
||||||
|
curs_set(1);
|
||||||
|
int in = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
TraceMpdStatus();
|
||||||
|
wFooter->ReadKey(in);
|
||||||
|
}
|
||||||
|
while (in != 'y' && in != 'n');
|
||||||
|
if (in == 'y')
|
||||||
|
{
|
||||||
|
for (int i = 0; i < mEditorTags->Size(); i++)
|
||||||
|
mEditorTags->at(i).SetTrack(i+1);
|
||||||
|
ShowMessage("Tracks numbered!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ShowMessage("Aborted!");
|
||||||
|
curs_set(0);
|
||||||
|
UNLOCK_STATUSBAR;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
set = &Song::SetGenre;
|
set = &Song::SetGenre;
|
||||||
@@ -1354,9 +1369,11 @@ int main(int argc, char *argv[])
|
|||||||
set = &Song::SetComment;
|
set = &Song::SetComment;
|
||||||
break;
|
break;
|
||||||
case 8: // reset
|
case 8: // reset
|
||||||
|
{
|
||||||
mEditorTags->Clear(0);
|
mEditorTags->Clear(0);
|
||||||
ShowMessage("Changes reset");
|
ShowMessage("Changes reset");
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
case 9: // save
|
case 9: // save
|
||||||
{
|
{
|
||||||
bool success = 1;
|
bool success = 1;
|
||||||
@@ -1387,7 +1404,7 @@ int main(int argc, char *argv[])
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (wCurrent == mEditorTagTypes && set != NULL)
|
if (wCurrent == mEditorTagTypes && id != 0 && id != 4 && set != NULL)
|
||||||
{
|
{
|
||||||
LOCK_STATUSBAR;
|
LOCK_STATUSBAR;
|
||||||
wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]" + mEditorTagTypes->GetOption() + "[/b]: ", 1);
|
wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]" + mEditorTagTypes->GetOption() + "[/b]: ", 1);
|
||||||
@@ -1395,9 +1412,8 @@ int main(int argc, char *argv[])
|
|||||||
string new_tag = wFooter->GetString(mEditorTags->GetOption());
|
string new_tag = wFooter->GetString(mEditorTags->GetOption());
|
||||||
mEditorTags->at(mEditorTags->GetChoice()).GetEmptyFields(0);
|
mEditorTags->at(mEditorTags->GetChoice()).GetEmptyFields(0);
|
||||||
UNLOCK_STATUSBAR;
|
UNLOCK_STATUSBAR;
|
||||||
if (!new_tag.empty())
|
for (int i = 0; i < mEditorTags->Size(); i++)
|
||||||
for (int i = 0; i < mEditorTags->Size(); i++)
|
(mEditorTags->at(i).*set)(new_tag);
|
||||||
(mEditorTags->at(i).*set)(new_tag);
|
|
||||||
}
|
}
|
||||||
else if (wCurrent == mEditorTags && set != NULL)
|
else if (wCurrent == mEditorTags && set != NULL)
|
||||||
{
|
{
|
||||||
@@ -2801,6 +2817,7 @@ int main(int argc, char *argv[])
|
|||||||
mEditorTagTypes->AddSeparator();
|
mEditorTagTypes->AddSeparator();
|
||||||
mEditorTagTypes->AddOption("Reset");
|
mEditorTagTypes->AddOption("Reset");
|
||||||
mEditorTagTypes->AddOption("Save");
|
mEditorTagTypes->AddOption("Save");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wCurrent = mEditorAlbums;
|
wCurrent = mEditorAlbums;
|
||||||
|
|||||||
@@ -152,6 +152,7 @@ void DefaultConfiguration(ncmpcpp_config &conf)
|
|||||||
conf.song_status_format = "{(%l) }{%a - }{%t}|{%f}";
|
conf.song_status_format = "{(%l) }{%a - }{%t}|{%f}";
|
||||||
conf.song_window_title_format = "{%a - }{%t}|{%f}";
|
conf.song_window_title_format = "{%a - }{%t}|{%f}";
|
||||||
conf.song_library_format = "{%n - }{%t}|{%f}";
|
conf.song_library_format = "{%n - }{%t}|{%f}";
|
||||||
|
conf.tag_editor_album_format = "{(%y) }%b";
|
||||||
conf.browser_playlist_prefix = "[.red](playlist)[/red] ";
|
conf.browser_playlist_prefix = "[.red](playlist)[/red] ";
|
||||||
conf.selected_item_prefix = "[.magenta]";
|
conf.selected_item_prefix = "[.magenta]";
|
||||||
conf.selected_item_suffix = "[/magenta]";
|
conf.selected_item_suffix = "[/magenta]";
|
||||||
@@ -324,6 +325,8 @@ void ReadKeys(ncmpcpp_keys &keys)
|
|||||||
GetKeys(*it, keys.MediaLibrary);
|
GetKeys(*it, keys.MediaLibrary);
|
||||||
else if (it->find("key_playlist_editor ") != string::npos)
|
else if (it->find("key_playlist_editor ") != string::npos)
|
||||||
GetKeys(*it, keys.PlaylistEditor);
|
GetKeys(*it, keys.PlaylistEditor);
|
||||||
|
else if (it->find("key_album_tag_editor ") != string::npos)
|
||||||
|
GetKeys(*it, keys.AlbumEditor);
|
||||||
else if (it->find("key_stop ") != string::npos)
|
else if (it->find("key_stop ") != string::npos)
|
||||||
GetKeys(*it, keys.Stop);
|
GetKeys(*it, keys.Stop);
|
||||||
else if (it->find("key_pause ") != string::npos)
|
else if (it->find("key_pause ") != string::npos)
|
||||||
@@ -469,6 +472,11 @@ void ReadConfiguration(ncmpcpp_config &conf)
|
|||||||
if (!v.empty())
|
if (!v.empty())
|
||||||
conf.song_library_format = v;
|
conf.song_library_format = v;
|
||||||
}
|
}
|
||||||
|
else if (it->find("tag_editor_album_format") != string::npos)
|
||||||
|
{
|
||||||
|
if (!v.empty())
|
||||||
|
conf.tag_editor_album_format = v;
|
||||||
|
}
|
||||||
else if (it->find("browser_playlist_prefix") != string::npos)
|
else if (it->find("browser_playlist_prefix") != string::npos)
|
||||||
{
|
{
|
||||||
if (!v.empty())
|
if (!v.empty())
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ struct ncmpcpp_config
|
|||||||
string song_status_format;
|
string song_status_format;
|
||||||
string song_window_title_format;
|
string song_window_title_format;
|
||||||
string song_library_format;
|
string song_library_format;
|
||||||
|
string tag_editor_album_format;
|
||||||
string browser_playlist_prefix;
|
string browser_playlist_prefix;
|
||||||
|
|
||||||
string selected_item_prefix;
|
string selected_item_prefix;
|
||||||
|
|||||||
@@ -68,7 +68,9 @@ class Song
|
|||||||
void SetTitle(const string &str) { itsTitle = str; }
|
void SetTitle(const string &str) { itsTitle = str; }
|
||||||
void SetAlbum(const string &str) { itsAlbum = str; }
|
void SetAlbum(const string &str) { itsAlbum = str; }
|
||||||
void SetTrack(const string &str) { itsTrack = str.empty() ? "" : IntoStr(StrToInt(str)); }
|
void SetTrack(const string &str) { itsTrack = str.empty() ? "" : IntoStr(StrToInt(str)); }
|
||||||
|
void SetTrack(int track) { itsTrack = IntoStr(track); }
|
||||||
void SetYear(const string &str) { itsYear = str.empty() ? "" : IntoStr(StrToInt(str)); }
|
void SetYear(const string &str) { itsYear = str.empty() ? "" : IntoStr(StrToInt(str)); }
|
||||||
|
void SetYear(int year) { itsYear = IntoStr(year); }
|
||||||
void SetGenre(const string &str) { itsGenre = str; }
|
void SetGenre(const string &str) { itsGenre = str; }
|
||||||
void SetComment(const string &str) { itsComment = str; }
|
void SetComment(const string &str) { itsComment = str; }
|
||||||
void SetPosition(int pos) { itsPosition = pos; }
|
void SetPosition(int pos) { itsPosition = pos; }
|
||||||
|
|||||||
@@ -433,6 +433,9 @@ string Window::GetString(const string &base, unsigned int length) const
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
mvwprintw(itsWindow, y, minx, "%ls",tmp.c_str());
|
||||||
|
wclrtoeol(itsWindow);
|
||||||
|
|
||||||
if (itsGetStringHelper)
|
if (itsGetStringHelper)
|
||||||
itsGetStringHelper();
|
itsGetStringHelper();
|
||||||
wmove(itsWindow,y,x);
|
wmove(itsWindow,y,x);
|
||||||
@@ -465,7 +468,7 @@ string Window::GetString(const string &base, unsigned int length) const
|
|||||||
if ((maxx-x) < 1) break;
|
if ((maxx-x) < 1) break;
|
||||||
tmp.erase(tmp.end()-(maxx-x));
|
tmp.erase(tmp.end()-(maxx-x));
|
||||||
wmove(itsWindow,y,x); // for backspace
|
wmove(itsWindow,y,x); // for backspace
|
||||||
wdelch(itsWindow);
|
//wdelch(itsWindow);
|
||||||
maxx--;
|
maxx--;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -494,7 +497,7 @@ string Window::GetString(const string &base, unsigned int length) const
|
|||||||
else
|
else
|
||||||
tmp.insert(tmp.end()-(maxx-x),wc_in);
|
tmp.insert(tmp.end()-(maxx-x),wc_in);
|
||||||
|
|
||||||
winsstr(itsWindow, tmp_in.c_str());
|
//winsstr(itsWindow, tmp_in.c_str());
|
||||||
tmp_in.clear();
|
tmp_in.clear();
|
||||||
|
|
||||||
x++;
|
x++;
|
||||||
|
|||||||
Reference in New Issue
Block a user