mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-06 13:33:55 -07:00
Add batch write function
Took 24 minutes Took 5 seconds Took 26 seconds
This commit is contained in:
parent
21d8e6b9ad
commit
8f9dad8966
9 changed files with 61 additions and 7 deletions
|
|
@ -228,16 +228,19 @@ void SetsModel::sort(int column, Qt::SortOrder order)
|
|||
|
||||
void SetsModel::save(CardDatabase *db)
|
||||
{
|
||||
// order
|
||||
for (int i = 0; i < sets.size(); i++)
|
||||
sets[i]->setSortKey(static_cast<unsigned int>(i + 1));
|
||||
QVector<ICardSetPriorityController::SetSaveData> saveData;
|
||||
saveData.reserve(sets.size());
|
||||
|
||||
// enabled sets
|
||||
for (const CardSetPtr &set : sets)
|
||||
set->setEnabled(enabledSets.contains(set));
|
||||
for (int i = 0; i < sets.size(); ++i) {
|
||||
const unsigned int sortKey = static_cast<unsigned int>(i + 1);
|
||||
const bool enabled = enabledSets.contains(sets[i]);
|
||||
sets[i]->setSortKeyInMemory(sortKey);
|
||||
sets[i]->setEnabledInMemory(enabled);
|
||||
saveData.append({sets[i]->getShortName(), sortKey, enabled});
|
||||
}
|
||||
|
||||
db->getPriorityController()->saveSets(saveData);
|
||||
sets.sortByKey();
|
||||
|
||||
db->notifyEnabledSetsChanged();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue