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

View File

@ -31,6 +31,10 @@ void GameList::sortByName()
auto cmp = [](const Entry& a, const Entry& b) 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(); auto it1 = a._name.cbegin(), it2 = b._name.cbegin();
// Account for ending ']' character in directory entries // Account for ending ']' character in directory entries

View File

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