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
401b34d2
Commit
401b34d2
authored
Feb 18, 2014
by
Buce
Browse files
Clean up DecklistModel::addCard()
Split common functionality out of the if-else block.
parent
875df014
Changes
1
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/decklistmodel.cpp
View file @
401b34d2
...
...
@@ -244,24 +244,20 @@ QModelIndex DeckListModel::addCard(const QString &cardName, const QString &zoneN
QString
cardType
=
info
->
getMainCardType
();
InnerDecklistNode
*
cardTypeNode
=
createNodeIfNeeded
(
cardType
,
zoneNode
);
QModelIndex
parentIndex
=
nodeToIndex
(
cardTypeNode
);
DecklistModelCardNode
*
cardNode
=
dynamic_cast
<
DecklistModelCardNode
*>
(
cardTypeNode
->
findChild
(
cardName
));
if
(
!
cardNode
)
{
DecklistCardNode
*
decklistCard
=
deckList
->
addCard
(
cardName
,
zoneName
);
QModelIndex
parentIndex
=
nodeToIndex
(
cardTypeNode
);
beginInsertRows
(
parentIndex
,
cardTypeNode
->
size
(),
cardTypeNode
->
size
());
cardNode
=
new
DecklistModelCardNode
(
decklistCard
,
cardTypeNode
);
endInsertRows
();
sort
(
lastKnownColumn
,
lastKnownOrder
);
emitRecursiveUpdates
(
parentIndex
);
return
nodeToIndex
(
cardNode
);
}
else
{
cardNode
->
setNumber
(
cardNode
->
getNumber
()
+
1
);
QModelIndex
parentIndex
=
nodeToIndex
(
cardTypeNode
);
sort
(
lastKnownColumn
,
lastKnownOrder
);
emitRecursiveUpdates
(
parentIndex
);
deckList
->
updateDeckHash
();
return
nodeToIndex
(
cardNode
);
}
sort
(
lastKnownColumn
,
lastKnownOrder
);
emitRecursiveUpdates
(
parentIndex
);
return
nodeToIndex
(
cardNode
);
}
QModelIndex
DeckListModel
::
nodeToIndex
(
AbstractDecklistNode
*
node
)
const
...
...
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