mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-24 23:53:54 -07:00
Moved get next set index code to own function
This commit is contained in:
parent
829f84fe50
commit
96fbad1f0c
2 changed files with 21 additions and 14 deletions
|
|
@ -714,9 +714,6 @@ void TabDeckEditor::actNewDeck()
|
||||||
|
|
||||||
void TabDeckEditor::actLoadDeck()
|
void TabDeckEditor::actLoadDeck()
|
||||||
{
|
{
|
||||||
if (!confirmClose())
|
|
||||||
return;
|
|
||||||
|
|
||||||
QFileDialog dialog(this, tr("Load deck"));
|
QFileDialog dialog(this, tr("Load deck"));
|
||||||
dialog.setDirectory(settingsCache->getDeckPath());
|
dialog.setDirectory(settingsCache->getDeckPath());
|
||||||
dialog.setNameFilters(DeckLoader::fileNameFilters);
|
dialog.setNameFilters(DeckLoader::fileNameFilters);
|
||||||
|
|
@ -891,25 +888,33 @@ void TabDeckEditor::actAddCustomSet()
|
||||||
if (!dialog.exec())
|
if (!dialog.exec())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
QDir dir(dataDir + "/customsets");
|
||||||
|
int nextPrefix = getNextCustomSetPrefix(dir);
|
||||||
|
|
||||||
QString fileName = dialog.selectedFiles().at(0);
|
QString fileName = dialog.selectedFiles().at(0);
|
||||||
QDir dir(dataDir.append("/customsets"));
|
|
||||||
QStringList files = dir.entryList();
|
|
||||||
int maxIndex = 0;
|
|
||||||
for (int i = 0; i < files.size(); ++i) {
|
|
||||||
int fileIndex = files.at(i).split(".").at(0).toInt();
|
|
||||||
if (fileIndex > maxIndex)
|
|
||||||
maxIndex = fileIndex;
|
|
||||||
}
|
|
||||||
maxIndex++;
|
|
||||||
bool res = QFile::copy(
|
bool res = QFile::copy(
|
||||||
fileName, dir.absolutePath() + "/" + (maxIndex > 9 ? "" : "0") +
|
fileName, dir.absolutePath() + "/" + (nextPrefix > 9 ? "" : "0") +
|
||||||
QString::number(maxIndex) + "." + QFileInfo(fileName).fileName()
|
QString::number(nextPrefix) + "." + QFileInfo(fileName).fileName()
|
||||||
);
|
);
|
||||||
|
|
||||||
DlgAddSetResult dlg(this, res);
|
DlgAddSetResult dlg(this, res);
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TabDeckEditor::getNextCustomSetPrefix(QDir dataDir) {
|
||||||
|
QStringList files = dataDir.entryList();
|
||||||
|
int maxIndex = 0;
|
||||||
|
|
||||||
|
QStringList::const_iterator filesIterator;
|
||||||
|
for (filesIterator = files.constBegin(); filesIterator != files.constEnd(); ++filesIterator) {
|
||||||
|
int fileIndex = (*filesIterator).split(".").at(0).toInt();
|
||||||
|
if (fileIndex > maxIndex)
|
||||||
|
maxIndex = fileIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
return maxIndex + 1;
|
||||||
|
}
|
||||||
|
|
||||||
void TabDeckEditor::actEditSets()
|
void TabDeckEditor::actEditSets()
|
||||||
{
|
{
|
||||||
WndSets *w = new WndSets;
|
WndSets *w = new WndSets;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "tab.h"
|
#include "tab.h"
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
|
#include <QDir>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include "keysignals.h"
|
#include "keysignals.h"
|
||||||
|
|
||||||
|
|
@ -95,6 +96,7 @@ private:
|
||||||
void offsetCountAtIndex(const QModelIndex &idx, int offset);
|
void offsetCountAtIndex(const QModelIndex &idx, int offset);
|
||||||
void decrementCardHelper(QString zoneName);
|
void decrementCardHelper(QString zoneName);
|
||||||
void recursiveExpand(const QModelIndex &index);
|
void recursiveExpand(const QModelIndex &index);
|
||||||
|
int getNextCustomSetPrefix(QDir dataDir);
|
||||||
|
|
||||||
CardDatabaseModel *databaseModel;
|
CardDatabaseModel *databaseModel;
|
||||||
CardDatabaseDisplayModel *databaseDisplayModel;
|
CardDatabaseDisplayModel *databaseDisplayModel;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue