filter chars unallowed in filename / more actions for songs in tag editor

This commit is contained in:
unK
2008-09-14 14:55:08 +02:00
parent 03eb5f31f9
commit 9ae8249b73
3 changed files with 59 additions and 9 deletions

View File

@@ -42,12 +42,14 @@
mvvline(main_start_y, middle_col_startx-1, 0, main_height); \
mPlaylistEditor->Display(redraw_screen)
#define REFRESH_ALBUM_EDITOR_SCREEN \
#ifdef HAVE_TAGLIB_H
# define REFRESH_TAG_EDITOR_SCREEN \
mEditorLeftCol->Display(redraw_screen); \
mvvline(main_start_y, middle_col_startx-1, 0, main_height); \
mEditorTagTypes->Display(redraw_screen); \
mvvline(main_start_y, right_col_startx-1, 0, main_height); \
mEditorTags->Display(redraw_screen)
#endif // HAVE_TAGLIB_H
ncmpcpp_config Config;
ncmpcpp_keys Key;
@@ -836,7 +838,7 @@ int main(int argc, char *argv[])
}
else if (current_screen == csTagEditor)
{
REFRESH_ALBUM_EDITOR_SCREEN;
REFRESH_TAG_EDITOR_SCREEN;
}
else
# endif // HAVE_TAGLIB_H
@@ -1027,6 +1029,10 @@ int main(int argc, char *argv[])
{
REFRESH_PLAYLIST_EDITOR_SCREEN;
}
else if (current_screen == csTagEditor)
{
REFRESH_TAG_EDITOR_SCREEN;
}
break;
}
}
@@ -1393,7 +1399,7 @@ int main(int argc, char *argv[])
__deal_with_filenames(list);
current_screen = csTagEditor;
redraw_screen = 1;
REFRESH_ALBUM_EDITOR_SCREEN;
REFRESH_TAG_EDITOR_SCREEN;
}
else if (wCurrent == mEditorTags)
{
@@ -2236,7 +2242,8 @@ int main(int argc, char *argv[])
|| (wCurrent == mBrowser && mBrowser->Current().type == itSong)
|| (wCurrent == mSearcher && mSearcher->Current().first == ".")
|| (wCurrent == mLibSongs && !mLibSongs->Empty())
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty()))
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty())
|| (wCurrent == mEditorTags && !mEditorTags->Empty()))
{
int id = wCurrent->GetChoice();
switch (current_screen)
@@ -2256,6 +2263,9 @@ int main(int argc, char *argv[])
case csPlaylistEditor:
edited_song = mPlaylistEditor->at(id);
break;
case csTagEditor:
edited_song = mEditorTags->at(id);
break;
default:
break;
}
@@ -2310,7 +2320,8 @@ int main(int argc, char *argv[])
if ((wCurrent == mPlaylist && !mPlaylist->Empty())
|| (wCurrent == mSearcher && mSearcher->Current().first == ".")
|| (wCurrent == mLibSongs && !mLibSongs->Empty())
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty()))
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty())
|| (wCurrent == mEditorTags && !mEditorTags->Empty()))
{
int id = wCurrent->GetChoice();
Song *s;
@@ -2328,6 +2339,9 @@ int main(int argc, char *argv[])
case csPlaylistEditor:
s = &mPlaylistEditor->at(id);
break;
case csTagEditor:
s = &mEditorTags->at(id);
break;
default:
break;
}
@@ -2720,13 +2734,20 @@ int main(int argc, char *argv[])
{
REFRESH_PLAYLIST_EDITOR_SCREEN;
}
# ifdef HAVE_TAGLIB_H
else if (current_screen == csTagEditor)
{
REFRESH_TAG_EDITOR_SCREEN;
}
# endif // HAVE_TAGLIB_H
}
else if (
(wCurrent == mPlaylist && !mPlaylist->Empty())
|| (wCurrent == mBrowser && mBrowser->Current().type == itSong)
|| (wCurrent == mSearcher && mSearcher->Current().first == ".")
|| (wCurrent == mLibSongs && !mLibSongs->Empty())
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty()))
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty())
|| (wCurrent == mEditorTags && !mEditorTags->Empty()))
{
Song *s;
int id = wCurrent->GetChoice();
@@ -2747,6 +2768,9 @@ int main(int argc, char *argv[])
case csPlaylistEditor:
s = &mPlaylistEditor->at(id);
break;
case csTagEditor:
s = &mEditorTags->at(id);
break;
default:
break;
}
@@ -2777,13 +2801,20 @@ int main(int argc, char *argv[])
{
REFRESH_PLAYLIST_EDITOR_SCREEN;
}
# ifdef HAVE_TAGLIB_H
else if (current_screen == csTagEditor)
{
REFRESH_TAG_EDITOR_SCREEN;
}
# endif // HAVE_TAGLIB_H
}
else if (
(wCurrent == mPlaylist && !mPlaylist->Empty())
|| (wCurrent == mBrowser && mBrowser->Current().type == itSong)
|| (wCurrent == mSearcher && mSearcher->Current().first == ".")
|| (wCurrent == mLibSongs && !mLibSongs->Empty())
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty()))
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty())
|| (wCurrent == mEditorTags && !mEditorTags->Empty()))
{
Song *s;
int id = wCurrent->GetChoice();
@@ -2804,6 +2835,9 @@ int main(int argc, char *argv[])
case csPlaylistEditor:
s = &mPlaylistEditor->at(id);
break;
case csTagEditor:
s = &mEditorTags->at(id);
break;
default:
break;
}
@@ -2954,7 +2988,7 @@ int main(int argc, char *argv[])
redraw_screen = 1;
redraw_header = 1;
REFRESH_ALBUM_EDITOR_SCREEN;
REFRESH_TAG_EDITOR_SCREEN;
if (mEditorTagTypes->Empty())
{

View File

@@ -177,6 +177,21 @@ SongSetFunction IntoSetFunction(char c)
}
}
string GenerateFilename(const Song &s, string &pattern)
{
const string unallowed_chars = "\"*/:<>?\\|";
string result = Window::OmitBBCodes(DisplaySong(s, &pattern));
for (string::const_iterator it = unallowed_chars.begin(); it != unallowed_chars.end(); it++)
{
for (int i = 0; i < result.length(); i++)
{
if (result[i] == *it)
result.erase(result.begin()+i);
}
}
return result;
}
string ParseFilename(Song &s, string mask, bool preview)
{
std::stringstream result;
@@ -376,7 +391,7 @@ void __deal_with_filenames(SongList &v)
int last_dot = file.find_last_of(".");
string extension = file.substr(last_dot);
s.GetEmptyFields(1);
string new_file = Window::OmitBBCodes(DisplaySong(s, &pattern));
string new_file = GenerateFilename(s, pattern);
if (new_file.empty())
{
if (preview)

View File

@@ -41,6 +41,7 @@ string DisplayTag(const Song &, void *, const Menu<Song> *);
bool GetSongTags(Song &);
bool WriteTags(Song &);
string GenerateFilename(const Song &, string &);
string ParseFilename(Song &, string, bool);
void __deal_with_filenames(SongList &);