removed leading space from directories, as this will make navigation slightly faster

see #160
This commit is contained in:
thrust26 2017-12-01 12:06:35 +01:00
parent bd52880a46
commit 823debcc04
3 changed files with 10 additions and 6 deletions

View File

@ -53,7 +53,7 @@ void FileListWidget::setLocation(const FilesystemNode& node, string select)
// Add '[..]' to indicate previous folder
if(_node.hasParent())
_gameList.appendGame(" [..]", _node.getParent().getPath(), "", true);
_gameList.appendGame("[..]", _node.getParent().getPath(), "", true);
// Now add the directory entries
for(const auto& file: content)
@ -61,7 +61,7 @@ void FileListWidget::setLocation(const FilesystemNode& node, string select)
string name = file.getName();
bool isDir = file.isDirectory();
if(isDir)
name = " [" + name + "]";
name = "[" + name + "]";
else if(!BSPF::endsWithIgnoreCase(name, _extension))
continue;
@ -109,7 +109,7 @@ void FileListWidget::handleCommand(CommandSender* sender, int cmd, int data, int
if(_gameList.isDir(data))
{
cmd = ItemChanged;
if(_gameList.name(data) == " [..]")
if(_gameList.name(data) == "[..]")
selectParent();
else
setLocation(FilesystemNode(_gameList.path(data)));

View File

@ -31,6 +31,10 @@ void GameList::sortByName()
auto cmp = [](const Entry& a, const Entry& b)
{
// directories always first
if(a._isdir != b._isdir)
return a._isdir;
auto it1 = a._name.cbegin(), it2 = b._name.cbegin();
// Account for ending ']' character in directory entries

View File

@ -294,14 +294,14 @@ void LauncherDialog::loadDirListing()
// Add '[..]' to indicate previous folder
if(myCurrentNode.hasParent())
myGameList->appendGame(" [..]", "", "", true);
myGameList->appendGame("[..]", "", "", true);
// Now add the directory entries
bool domatch = myPattern && myPattern->getText() != "";
for(const auto& f: files)
{
bool isDir = f.isDirectory();
const string& name = isDir ? (" [" + f.getName() + "]") : f.getName();
const string& name = isDir ? ("[" + f.getName() + "]") : f.getName();
// Honour the filtering settings
// Showing only certain ROM extensions is determined by the extension
@ -461,7 +461,7 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
if(romnode.isDirectory())
{
string dirname = "";
if(myGameList->name(item) == " [..]")
if(myGameList->name(item) == "[..]")
{
myCurrentNode = myCurrentNode.getParent();
if(!myNodeNames.empty())