mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Sets window: implemented save and restore buttons
This commit is contained in:
parent
ac43fa23b9
commit
f48f386f35
4 changed files with 48 additions and 3 deletions
|
|
@ -90,6 +90,10 @@ bool SetsModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int r
|
|||
for (int i = 0; i < sets.size(); i++)
|
||||
sets[i]->setSortKey(i);
|
||||
|
||||
sets.sortByKey();
|
||||
|
||||
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -104,3 +108,17 @@ SetsProxyModel::SetsProxyModel(QObject *parent)
|
|||
setDynamicSortFilter(true);
|
||||
}
|
||||
|
||||
void SetsProxyModel::saveOrder()
|
||||
{
|
||||
int numRows = rowCount();
|
||||
SetsModel * model = (SetsModel*) sourceModel();
|
||||
for(int row = 0; row < numRows; ++row) {
|
||||
QModelIndex idx = index(row, 0);
|
||||
int oldRow = data(idx, Qt::DisplayRole).toInt();
|
||||
CardSet *temp = model->sets.at(oldRow);
|
||||
temp->setSortKey(row);
|
||||
}
|
||||
model->sets.sortByKey();
|
||||
|
||||
emit model->dataChanged(model->index(0, 0), model->index(model->rowCount() - 1, model->columnCount() - 1));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue