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
68c0932a
Commit
68c0932a
authored
Jun 22, 2014
by
Daenyth
Browse files
Don't have decklist sort behavior rely on column order
parent
e99c1bbe
Changes
3
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/decklistmodel.cpp
View file @
68c0932a
...
@@ -315,7 +315,7 @@ void DeckListModel::sortHelper(InnerDecklistNode *node, Qt::SortOrder order)
...
@@ -315,7 +315,7 @@ void DeckListModel::sortHelper(InnerDecklistNode *node, Qt::SortOrder order)
}
}
}
}
changePersistentIndexList
(
from
,
to
);
changePersistentIndexList
(
from
,
to
);
// Recursion
// Recursion
for
(
int
i
=
node
->
size
()
-
1
;
i
>=
0
;
--
i
)
{
for
(
int
i
=
node
->
size
()
-
1
;
i
>=
0
;
--
i
)
{
InnerDecklistNode
*
subNode
=
dynamic_cast
<
InnerDecklistNode
*>
(
node
->
at
(
i
));
InnerDecklistNode
*
subNode
=
dynamic_cast
<
InnerDecklistNode
*>
(
node
->
at
(
i
));
...
@@ -330,7 +330,18 @@ void DeckListModel::sort(int column, Qt::SortOrder order)
...
@@ -330,7 +330,18 @@ void DeckListModel::sort(int column, Qt::SortOrder order)
lastKnownOrder
=
order
;
lastKnownOrder
=
order
;
emit
layoutAboutToBeChanged
();
emit
layoutAboutToBeChanged
();
root
->
setSortMethod
(
column
);
DeckSortMethod
sortMethod
;
switch
(
column
)
{
case
0
:
sortMethod
=
ByNumber
;
break
;
case
1
:
sortMethod
=
ByName
;
break
;
case
2
:
sortMethod
=
ByPrice
;
}
root
->
setSortMethod
(
sortMethod
);
sortHelper
(
root
,
order
);
sortHelper
(
root
,
order
);
emit
layoutChanged
();
emit
layoutChanged
();
}
}
...
...
common/decklist.cpp
View file @
68c0932a
...
@@ -104,7 +104,7 @@ QString InnerDecklistNode::visibleNameFromName(const QString &_name)
...
@@ -104,7 +104,7 @@ QString InnerDecklistNode::visibleNameFromName(const QString &_name)
return
_name
;
return
_name
;
}
}
void
InnerDecklistNode
::
setSortMethod
(
int
method
)
void
InnerDecklistNode
::
setSortMethod
(
DeckSortMethod
method
)
{
{
sortMethod
=
method
;
sortMethod
=
method
;
for
(
int
i
=
0
;
i
<
size
();
i
++
)
for
(
int
i
=
0
;
i
<
size
();
i
++
)
...
@@ -218,11 +218,11 @@ bool InnerDecklistNode::comparePrice(AbstractDecklistNode *other) const
...
@@ -218,11 +218,11 @@ bool InnerDecklistNode::comparePrice(AbstractDecklistNode *other) const
bool
AbstractDecklistCardNode
::
compare
(
AbstractDecklistNode
*
other
)
const
bool
AbstractDecklistCardNode
::
compare
(
AbstractDecklistNode
*
other
)
const
{
{
switch
(
sortMethod
)
{
switch
(
sortMethod
)
{
case
0
:
case
ByNumber
:
return
compareNumber
(
other
);
return
compareNumber
(
other
);
case
1
:
case
ByName
:
return
compareName
(
other
);
return
compareName
(
other
);
case
2
:
case
ByPrice
:
return
compareTotalPrice
(
other
);
return
compareTotalPrice
(
other
);
}
}
}
}
...
...
common/decklist.h
View file @
68c0932a
...
@@ -29,26 +29,28 @@ public:
...
@@ -29,26 +29,28 @@ public:
SideboardPlan
(
const
QString
&
_name
=
QString
(),
const
QList
<
MoveCard_ToZone
>
&
_moveList
=
QList
<
MoveCard_ToZone
>
());
SideboardPlan
(
const
QString
&
_name
=
QString
(),
const
QList
<
MoveCard_ToZone
>
&
_moveList
=
QList
<
MoveCard_ToZone
>
());
bool
readElement
(
QXmlStreamReader
*
xml
);
bool
readElement
(
QXmlStreamReader
*
xml
);
void
write
(
QXmlStreamWriter
*
xml
);
void
write
(
QXmlStreamWriter
*
xml
);
QString
getName
()
const
{
return
name
;
}
QString
getName
()
const
{
return
name
;
}
const
QList
<
MoveCard_ToZone
>
&
getMoveList
()
const
{
return
moveList
;
}
const
QList
<
MoveCard_ToZone
>
&
getMoveList
()
const
{
return
moveList
;
}
void
setMoveList
(
const
QList
<
MoveCard_ToZone
>
&
_moveList
);
void
setMoveList
(
const
QList
<
MoveCard_ToZone
>
&
_moveList
);
};
};
enum
DeckSortMethod
{
ByNumber
,
ByName
,
ByPrice
};
class
AbstractDecklistNode
{
class
AbstractDecklistNode
{
protected:
protected:
InnerDecklistNode
*
parent
;
InnerDecklistNode
*
parent
;
int
sortMethod
;
DeckSortMethod
sortMethod
;
public:
public:
AbstractDecklistNode
(
InnerDecklistNode
*
_parent
=
0
);
AbstractDecklistNode
(
InnerDecklistNode
*
_parent
=
0
);
virtual
~
AbstractDecklistNode
()
{
}
virtual
~
AbstractDecklistNode
()
{
}
virtual
void
setSortMethod
(
int
method
)
{
sortMethod
=
method
;
}
virtual
void
setSortMethod
(
DeckSortMethod
method
)
{
sortMethod
=
method
;
}
virtual
QString
getName
()
const
=
0
;
virtual
QString
getName
()
const
=
0
;
InnerDecklistNode
*
getParent
()
const
{
return
parent
;
}
InnerDecklistNode
*
getParent
()
const
{
return
parent
;
}
int
depth
()
const
;
int
depth
()
const
;
virtual
int
height
()
const
=
0
;
virtual
int
height
()
const
=
0
;
virtual
bool
compare
(
AbstractDecklistNode
*
other
)
const
=
0
;
virtual
bool
compare
(
AbstractDecklistNode
*
other
)
const
=
0
;
virtual
bool
readElement
(
QXmlStreamReader
*
xml
)
=
0
;
virtual
bool
readElement
(
QXmlStreamReader
*
xml
)
=
0
;
virtual
void
writeElement
(
QXmlStreamWriter
*
xml
)
=
0
;
virtual
void
writeElement
(
QXmlStreamWriter
*
xml
)
=
0
;
};
};
...
@@ -61,7 +63,7 @@ public:
...
@@ -61,7 +63,7 @@ public:
InnerDecklistNode
(
const
QString
&
_name
=
QString
(),
InnerDecklistNode
*
_parent
=
0
)
:
AbstractDecklistNode
(
_parent
),
name
(
_name
)
{
}
InnerDecklistNode
(
const
QString
&
_name
=
QString
(),
InnerDecklistNode
*
_parent
=
0
)
:
AbstractDecklistNode
(
_parent
),
name
(
_name
)
{
}
InnerDecklistNode
(
InnerDecklistNode
*
other
,
InnerDecklistNode
*
_parent
=
0
);
InnerDecklistNode
(
InnerDecklistNode
*
other
,
InnerDecklistNode
*
_parent
=
0
);
virtual
~
InnerDecklistNode
();
virtual
~
InnerDecklistNode
();
void
setSortMethod
(
int
method
);
void
setSortMethod
(
DeckSortMethod
method
);
QString
getName
()
const
{
return
name
;
}
QString
getName
()
const
{
return
name
;
}
void
setName
(
const
QString
&
_name
)
{
name
=
_name
;
}
void
setName
(
const
QString
&
_name
)
{
name
=
_name
;
}
static
QString
visibleNameFromName
(
const
QString
&
_name
);
static
QString
visibleNameFromName
(
const
QString
&
_name
);
...
@@ -76,7 +78,7 @@ public:
...
@@ -76,7 +78,7 @@ public:
bool
compareName
(
AbstractDecklistNode
*
other
)
const
;
bool
compareName
(
AbstractDecklistNode
*
other
)
const
;
bool
comparePrice
(
AbstractDecklistNode
*
other
)
const
;
bool
comparePrice
(
AbstractDecklistNode
*
other
)
const
;
QVector
<
QPair
<
int
,
int
>
>
sort
(
Qt
::
SortOrder
order
=
Qt
::
AscendingOrder
);
QVector
<
QPair
<
int
,
int
>
>
sort
(
Qt
::
SortOrder
order
=
Qt
::
AscendingOrder
);
bool
readElement
(
QXmlStreamReader
*
xml
);
bool
readElement
(
QXmlStreamReader
*
xml
);
void
writeElement
(
QXmlStreamWriter
*
xml
);
void
writeElement
(
QXmlStreamWriter
*
xml
);
};
};
...
@@ -96,7 +98,7 @@ public:
...
@@ -96,7 +98,7 @@ public:
bool
compareNumber
(
AbstractDecklistNode
*
other
)
const
;
bool
compareNumber
(
AbstractDecklistNode
*
other
)
const
;
bool
compareName
(
AbstractDecklistNode
*
other
)
const
;
bool
compareName
(
AbstractDecklistNode
*
other
)
const
;
bool
compareTotalPrice
(
AbstractDecklistNode
*
other
)
const
;
bool
compareTotalPrice
(
AbstractDecklistNode
*
other
)
const
;
bool
readElement
(
QXmlStreamReader
*
xml
);
bool
readElement
(
QXmlStreamReader
*
xml
);
void
writeElement
(
QXmlStreamWriter
*
xml
);
void
writeElement
(
QXmlStreamWriter
*
xml
);
};
};
...
...
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