Skip to content

Commit

Permalink
Merge pull request Aloshi#802 from cmitu/view-bulk-remove-2
Browse files Browse the repository at this point in the history
ViewController: improves bulk removal of entries
  • Loading branch information
pjft authored Aug 26, 2022
2 parents 48b2db5 + 48ef225 commit b5e1950
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 12 deletions.
9 changes: 5 additions & 4 deletions es-app/src/CollectionSystemManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ void CollectionSystemManager::updateCollectionSystem(FileData* file, CollectionS
// found and we are removing
if (name == "favorites" && file->metadata.get("favorite") == "false") {
// need to check if still marked as favorite, if not remove
ViewController::get()->getGameListView(curSys).get()->remove(collectionEntry, false);
ViewController::get()->getGameListView(curSys).get()->remove(collectionEntry, false, true);
}
else
{
Expand Down Expand Up @@ -298,8 +298,9 @@ void CollectionSystemManager::trimCollectionCount(FileData* rootFolder, int limi
while ((int)rootFolder->getChildrenListToDisplay().size() > limit)
{
CollectionFileData* gameToRemove = (CollectionFileData*)rootFolder->getChildrenListToDisplay().back();
ViewController::get()->getGameListView(curSys).get()->remove(gameToRemove, false);
ViewController::get()->getGameListView(curSys).get()->remove(gameToRemove, false, false);
}
ViewController::get()->onFileChanged(rootFolder, FILE_REMOVED);
}

// deletes all collection files from collection systems related to the source file
Expand All @@ -323,7 +324,7 @@ void CollectionSystemManager::deleteCollectionFiles(FileData* file)
sysDataIt->second.needsSave = true;
FileData* collectionEntry = children.at(key);
SystemData* systemViewToUpdate = getSystemToView(sysDataIt->second.system);
ViewController::get()->getGameListView(systemViewToUpdate).get()->remove(collectionEntry, false);
ViewController::get()->getGameListView(systemViewToUpdate).get()->remove(collectionEntry, false, true);
}
}
}
Expand Down Expand Up @@ -495,7 +496,7 @@ bool CollectionSystemManager::toggleGameInCollection(FileData* file, int pressco
{
systemViewToUpdate->getIndex()->removeFromIndex(collectionEntry);
}
ViewController::get()->getGameListView(systemViewToUpdate).get()->remove(collectionEntry, false);
ViewController::get()->getGameListView(systemViewToUpdate).get()->remove(collectionEntry, false, true);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion es-app/src/guis/GuiGamelistOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void GuiGamelistOptions::openMetaDataEd()
{
deleteBtnFunc = [this, file] {
CollectionSystemManager::get()->deleteCollectionFiles(file);
ViewController::get()->getGameListView(file->getSystem()).get()->remove(file, true);
ViewController::get()->getGameListView(file->getSystem()).get()->remove(file, true, true);
};
}

Expand Down
5 changes: 3 additions & 2 deletions es-app/src/views/gamelist/BasicGameListView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void BasicGameListView::launch(FileData* game)
ViewController::get()->launch(game);
}

void BasicGameListView::remove(FileData *game, bool deleteFile)
void BasicGameListView::remove(FileData *game, bool deleteFile, bool refreshView)
{
if (deleteFile)
{
Expand Down Expand Up @@ -184,7 +184,8 @@ void BasicGameListView::remove(FileData *game, bool deleteFile)
addPlaceholder();
}
delete game; // remove before repopulating (removes from parent)
onFileChanged(parent, FILE_REMOVED); // update the view, with game removed
if(refreshView)
onFileChanged(parent, FILE_REMOVED); // update the view, with game removed
}

std::vector<HelpPrompt> BasicGameListView::getHelpPrompts()
Expand Down
2 changes: 1 addition & 1 deletion es-app/src/views/gamelist/BasicGameListView.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class BasicGameListView : public ISimpleGameListView
virtual std::string getQuickSystemSelectRightButton() override;
virtual std::string getQuickSystemSelectLeftButton() override;
virtual void populateList(const std::vector<FileData*>& files) override;
virtual void remove(FileData* game, bool deleteFile) override;
virtual void remove(FileData* game, bool deleteFile, bool refreshView=true) override;
virtual void addPlaceholder();

TextListComponent<FileData*> mList;
Expand Down
6 changes: 4 additions & 2 deletions es-app/src/views/gamelist/GridGameListView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ void GridGameListView::launch(FileData* game)

}

void GridGameListView::remove(FileData *game, bool deleteFile)
void GridGameListView::remove(FileData *game, bool deleteFile, bool refreshView)
{
if (deleteFile)
Utils::FileSystem::removeFile(game->getPath()); // actually delete the file on the filesystem
Expand All @@ -437,7 +437,9 @@ void GridGameListView::remove(FileData *game, bool deleteFile)
addPlaceholder();
}
delete game; // remove before repopulating (removes from parent)
onFileChanged(parent, FILE_REMOVED); // update the view, with game removed

if(refreshView)
onFileChanged(parent, FILE_REMOVED); // update the view, with game removed
}

std::vector<TextComponent*> GridGameListView::getMDLabels()
Expand Down
2 changes: 1 addition & 1 deletion es-app/src/views/gamelist/GridGameListView.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class GridGameListView : public ISimpleGameListView
virtual std::string getQuickSystemSelectRightButton() override;
virtual std::string getQuickSystemSelectLeftButton() override;
virtual void populateList(const std::vector<FileData*>& files) override;
virtual void remove(FileData* game, bool deleteFile) override;
virtual void remove(FileData* game, bool deleteFile, bool refreshView=true) override;
virtual void addPlaceholder();

ImageGridComponent<FileData*> mGrid;
Expand Down
2 changes: 1 addition & 1 deletion es-app/src/views/gamelist/IGameListView.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class IGameListView : public GuiComponent
virtual void setCursor(FileData*) = 0;

virtual bool input(InputConfig* config, Input input) override;
virtual void remove(FileData* game, bool deleteFile) = 0;
virtual void remove(FileData* game, bool deleteFile, bool refreshView=true) = 0;

virtual const char* getName() const = 0;
virtual void launch(FileData* game) = 0;
Expand Down

0 comments on commit b5e1950

Please sign in to comment.