Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
96fbad1f
Commit
96fbad1f
authored
Feb 09, 2016
by
Ira Aspen
Browse files
Moved get next set index code to own function
parent
829f84fe
Changes
2
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/tab_deck_editor.cpp
View file @
96fbad1f
...
...
@@ -714,9 +714,6 @@ void TabDeckEditor::actNewDeck()
void
TabDeckEditor
::
actLoadDeck
()
{
if
(
!
confirmClose
())
return
;
QFileDialog
dialog
(
this
,
tr
(
"Load deck"
));
dialog
.
setDirectory
(
settingsCache
->
getDeckPath
());
dialog
.
setNameFilters
(
DeckLoader
::
fileNameFilters
);
...
...
@@ -891,25 +888,33 @@ void TabDeckEditor::actAddCustomSet()
if
(
!
dialog
.
exec
())
return
;
QDir
dir
(
dataDir
+
"/customsets"
);
int
nextPrefix
=
getNextCustomSetPrefix
(
dir
);
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
(
fileName
,
dir
.
absolutePath
()
+
"/"
+
(
maxInde
x
>
9
?
""
:
"0"
)
+
QString
::
number
(
maxInde
x
)
+
"."
+
QFileInfo
(
fileName
).
fileName
()
fileName
,
dir
.
absolutePath
()
+
"/"
+
(
nextPrefi
x
>
9
?
""
:
"0"
)
+
QString
::
number
(
nextPrefi
x
)
+
"."
+
QFileInfo
(
fileName
).
fileName
()
);
DlgAddSetResult
dlg
(
this
,
res
);
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
()
{
WndSets
*
w
=
new
WndSets
;
...
...
cockatrice/src/tab_deck_editor.h
View file @
96fbad1f
...
...
@@ -3,6 +3,7 @@
#include
"tab.h"
#include
<QAbstractItemModel>
#include
<QDir>
#include
<QLineEdit>
#include
"keysignals.h"
...
...
@@ -95,6 +96,7 @@ private:
void
offsetCountAtIndex
(
const
QModelIndex
&
idx
,
int
offset
);
void
decrementCardHelper
(
QString
zoneName
);
void
recursiveExpand
(
const
QModelIndex
&
index
);
int
getNextCustomSetPrefix
(
QDir
dataDir
);
CardDatabaseModel
*
databaseModel
;
CardDatabaseDisplayModel
*
databaseDisplayModel
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment