fix searching in browser
it was taking whole path, take only top dir.
This commit is contained in:
@@ -459,8 +459,7 @@ void Display::Items(const MPD::Item &item, void *, Menu<MPD::Item> *menu)
|
|||||||
*menu << "[..]";
|
*menu << "[..]";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
size_t slash = item.name.rfind("/");
|
*menu << "[" << ExtractTopDirectory(item.name) << "]";
|
||||||
*menu << "[" << (slash != string::npos ? item.name.substr(slash+1) : item.name) << "]";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case MPD::itSong:
|
case MPD::itSong:
|
||||||
|
|||||||
@@ -41,12 +41,6 @@ namespace
|
|||||||
if (the_pos == 0 && the_pos != string::npos)
|
if (the_pos == 0 && the_pos != string::npos)
|
||||||
s = s.substr(4);
|
s = s.substr(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline string extract_top_directory(const string &s)
|
|
||||||
{
|
|
||||||
size_t slash = s.rfind("/");
|
|
||||||
return slash != string::npos ? s.substr(++slash) : s;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConnectToMPD()
|
bool ConnectToMPD()
|
||||||
@@ -207,7 +201,7 @@ bool CaseInsensitiveSorting::operator()(const Item &a, const Item &b)
|
|||||||
switch (a.type)
|
switch (a.type)
|
||||||
{
|
{
|
||||||
case itDirectory:
|
case itDirectory:
|
||||||
return operator()(extract_top_directory(a.name), extract_top_directory(b.name));
|
return operator()(ExtractTopDirectory(a.name), ExtractTopDirectory(b.name));
|
||||||
case itPlaylist:
|
case itPlaylist:
|
||||||
return operator()(a.name, b.name);
|
return operator()(a.name, b.name);
|
||||||
case itSong:
|
case itSong:
|
||||||
@@ -287,6 +281,12 @@ string GetLineValue(string &line, char a, char b, bool once)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ExtractTopDirectory(const std::string &s)
|
||||||
|
{
|
||||||
|
size_t slash = s.rfind("/");
|
||||||
|
return slash != string::npos ? s.substr(++slash) : s;
|
||||||
|
}
|
||||||
|
|
||||||
const Buffer &ShowTag(const string &tag)
|
const Buffer &ShowTag(const string &tag)
|
||||||
{
|
{
|
||||||
static Buffer result;
|
static Buffer result;
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ std::string FindSharedDir(const std::string &, const std::string &);
|
|||||||
|
|
||||||
std::string GetLineValue(std::string &, char = '"', char = '"', bool = 0);
|
std::string GetLineValue(std::string &, char = '"', char = '"', bool = 0);
|
||||||
|
|
||||||
|
std::string ExtractTopDirectory(const std::string &);
|
||||||
|
|
||||||
const Buffer &ShowTag(const std::string &);
|
const Buffer &ShowTag(const std::string &);
|
||||||
|
|
||||||
const std::basic_string<my_char_t> &Scroller(const std::string &, size_t, size_t &);
|
const std::basic_string<my_char_t> &Scroller(const std::string &, size_t, size_t &);
|
||||||
|
|||||||
@@ -1212,8 +1212,9 @@ int main(int argc, char *argv[])
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t dialog_width = COLS*0.8;
|
const size_t dialog_width = COLS*0.8;
|
||||||
size_t dialog_height = LINES*0.6;
|
const size_t dialog_height = LINES*0.6;
|
||||||
|
|
||||||
Menu<string> *mDialog = new Menu<string>((COLS-dialog_width)/2, (LINES-dialog_height)/2, dialog_width, dialog_height, "Add selected items to...", Config.main_color, Config.window_border);
|
Menu<string> *mDialog = new Menu<string>((COLS-dialog_width)/2, (LINES-dialog_height)/2, dialog_width, dialog_height, "Add selected items to...", Config.main_color, Config.window_border);
|
||||||
mDialog->SetTimeout(ncmpcpp_window_timeout);
|
mDialog->SetTimeout(ncmpcpp_window_timeout);
|
||||||
mDialog->SetItemDisplayer(Display::Generic);
|
mDialog->SetItemDisplayer(Display::Generic);
|
||||||
@@ -1397,7 +1398,7 @@ int main(int argc, char *argv[])
|
|||||||
switch (myBrowser->Main()->at(i).type)
|
switch (myBrowser->Main()->at(i).type)
|
||||||
{
|
{
|
||||||
case itDirectory:
|
case itDirectory:
|
||||||
name = myBrowser->Main()->at(i).name;
|
name = ExtractTopDirectory(myBrowser->Main()->at(i).name);
|
||||||
break;
|
break;
|
||||||
case itSong:
|
case itSong:
|
||||||
name = myBrowser->Main()->at(i).song->toString(Config.song_list_format);
|
name = myBrowser->Main()->at(i).song->toString(Config.song_list_format);
|
||||||
|
|||||||
@@ -409,7 +409,7 @@ void TagEditor::Update()
|
|||||||
if (Config.albums_in_tag_editor)
|
if (Config.albums_in_tag_editor)
|
||||||
{
|
{
|
||||||
std::map<string, string, CaseInsensitiveSorting> maplist;
|
std::map<string, string, CaseInsensitiveSorting> maplist;
|
||||||
*Albums << XY(0, 0) << "Fetching albums' list...";
|
*Albums << XY(0, 0) << "Fetching albums' list..." << wrefresh;
|
||||||
Mpd->GetAlbums("", list);
|
Mpd->GetAlbums("", list);
|
||||||
for (TagList::const_iterator it = list.begin(); it != list.end(); it++)
|
for (TagList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user