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
748aac7e
Commit
748aac7e
authored
Mar 25, 2014
by
sylvanbasilisk
Browse files
whitespace modifications in preparation for merge
parent
378cc91c
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/carddatabasemodel.cpp
View file @
748aac7e
...
@@ -2,12 +2,12 @@
...
@@ -2,12 +2,12 @@
#include
"filtertree.h"
#include
"filtertree.h"
CardDatabaseModel
::
CardDatabaseModel
(
CardDatabase
*
_db
,
QObject
*
parent
)
CardDatabaseModel
::
CardDatabaseModel
(
CardDatabase
*
_db
,
QObject
*
parent
)
:
QAbstractListModel
(
parent
),
db
(
_db
)
:
QAbstractListModel
(
parent
),
db
(
_db
)
{
{
connect
(
db
,
SIGNAL
(
cardListChanged
()),
this
,
SLOT
(
updateCardList
()));
connect
(
db
,
SIGNAL
(
cardListChanged
()),
this
,
SLOT
(
updateCardList
()));
connect
(
db
,
SIGNAL
(
cardAdded
(
CardInfo
*
)),
this
,
SLOT
(
cardAdded
(
CardInfo
*
)));
connect
(
db
,
SIGNAL
(
cardAdded
(
CardInfo
*
)),
this
,
SLOT
(
cardAdded
(
CardInfo
*
)));
connect
(
db
,
SIGNAL
(
cardRemoved
(
CardInfo
*
)),
this
,
SLOT
(
cardRemoved
(
CardInfo
*
)));
connect
(
db
,
SIGNAL
(
cardRemoved
(
CardInfo
*
)),
this
,
SLOT
(
cardRemoved
(
CardInfo
*
)));
updateCardList
();
updateCardList
();
}
}
CardDatabaseModel
::~
CardDatabaseModel
()
CardDatabaseModel
::~
CardDatabaseModel
()
...
@@ -16,164 +16,164 @@ CardDatabaseModel::~CardDatabaseModel()
...
@@ -16,164 +16,164 @@ CardDatabaseModel::~CardDatabaseModel()
int
CardDatabaseModel
::
rowCount
(
const
QModelIndex
&
/*parent*/
)
const
int
CardDatabaseModel
::
rowCount
(
const
QModelIndex
&
/*parent*/
)
const
{
{
return
cardList
.
size
();
return
cardList
.
size
();
}
}
int
CardDatabaseModel
::
columnCount
(
const
QModelIndex
&
/*parent*/
)
const
int
CardDatabaseModel
::
columnCount
(
const
QModelIndex
&
/*parent*/
)
const
{
{
return
5
;
return
5
;
}
}
QVariant
CardDatabaseModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
QVariant
CardDatabaseModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
{
{
if
(
!
index
.
isValid
())
if
(
!
index
.
isValid
())
return
QVariant
();
return
QVariant
();
if
((
index
.
row
()
>=
cardList
.
size
())
||
(
index
.
column
()
>=
5
))
if
((
index
.
row
()
>=
cardList
.
size
())
||
(
index
.
column
()
>=
5
))
return
QVariant
();
return
QVariant
();
if
(
role
!=
Qt
::
DisplayRole
)
if
(
role
!=
Qt
::
DisplayRole
)
return
QVariant
();
return
QVariant
();
CardInfo
*
card
=
cardList
.
at
(
index
.
row
());
CardInfo
*
card
=
cardList
.
at
(
index
.
row
());
switch
(
index
.
column
()){
switch
(
index
.
column
()){
case
0
:
return
card
->
getName
();
case
0
:
return
card
->
getName
();
case
1
:
{
case
1
:
{
QStringList
setList
;
QStringList
setList
;
const
QList
<
CardSet
*>
&
sets
=
card
->
getSets
();
const
QList
<
CardSet
*>
&
sets
=
card
->
getSets
();
for
(
int
i
=
0
;
i
<
sets
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
sets
.
size
();
i
++
)
setList
<<
sets
[
i
]
->
getShortName
();
setList
<<
sets
[
i
]
->
getShortName
();
return
setList
.
join
(
", "
);
return
setList
.
join
(
", "
);
}
}
case
2
:
return
card
->
getManaCost
();
case
2
:
return
card
->
getManaCost
();
case
3
:
return
card
->
getCardType
();
case
3
:
return
card
->
getCardType
();
case
4
:
return
card
->
getPowTough
();
case
4
:
return
card
->
getPowTough
();
default:
return
QVariant
();
default:
return
QVariant
();
}
}
}
}
QVariant
CardDatabaseModel
::
headerData
(
int
section
,
Qt
::
Orientation
orientation
,
int
role
)
const
QVariant
CardDatabaseModel
::
headerData
(
int
section
,
Qt
::
Orientation
orientation
,
int
role
)
const
{
{
if
(
role
!=
Qt
::
DisplayRole
)
if
(
role
!=
Qt
::
DisplayRole
)
return
QVariant
();
return
QVariant
();
if
(
orientation
!=
Qt
::
Horizontal
)
if
(
orientation
!=
Qt
::
Horizontal
)
return
QVariant
();
return
QVariant
();
switch
(
section
)
{
switch
(
section
)
{
case
0
:
return
QString
(
tr
(
"Name"
));
case
0
:
return
QString
(
tr
(
"Name"
));
case
1
:
return
QString
(
tr
(
"Sets"
));
case
1
:
return
QString
(
tr
(
"Sets"
));
case
2
:
return
QString
(
tr
(
"Mana cost"
));
case
2
:
return
QString
(
tr
(
"Mana cost"
));
case
3
:
return
QString
(
tr
(
"Card type"
));
case
3
:
return
QString
(
tr
(
"Card type"
));
case
4
:
return
QString
(
tr
(
"P/T"
));
case
4
:
return
QString
(
tr
(
"P/T"
));
default:
return
QVariant
();
default:
return
QVariant
();
}
}
}
}
void
CardDatabaseModel
::
updateCardList
()
void
CardDatabaseModel
::
updateCardList
()
{
{
for
(
int
i
=
0
;
i
<
cardList
.
size
();
++
i
)
for
(
int
i
=
0
;
i
<
cardList
.
size
();
++
i
)
disconnect
(
cardList
[
i
],
0
,
this
,
0
);
disconnect
(
cardList
[
i
],
0
,
this
,
0
);
cardList
=
db
->
getCardList
();
cardList
=
db
->
getCardList
();
for
(
int
i
=
0
;
i
<
cardList
.
size
();
++
i
)
for
(
int
i
=
0
;
i
<
cardList
.
size
();
++
i
)
connect
(
cardList
[
i
],
SIGNAL
(
cardInfoChanged
(
CardInfo
*
)),
this
,
SLOT
(
cardInfoChanged
(
CardInfo
*
)));
connect
(
cardList
[
i
],
SIGNAL
(
cardInfoChanged
(
CardInfo
*
)),
this
,
SLOT
(
cardInfoChanged
(
CardInfo
*
)));
reset
();
reset
();
}
}
void
CardDatabaseModel
::
cardInfoChanged
(
CardInfo
*
card
)
void
CardDatabaseModel
::
cardInfoChanged
(
CardInfo
*
card
)
{
{
const
int
row
=
cardList
.
indexOf
(
card
);
const
int
row
=
cardList
.
indexOf
(
card
);
if
(
row
==
-
1
)
if
(
row
==
-
1
)
return
;
return
;
emit
dataChanged
(
index
(
row
,
0
),
index
(
row
,
4
));
emit
dataChanged
(
index
(
row
,
0
),
index
(
row
,
4
));
}
}
void
CardDatabaseModel
::
cardAdded
(
CardInfo
*
card
)
void
CardDatabaseModel
::
cardAdded
(
CardInfo
*
card
)
{
{
beginInsertRows
(
QModelIndex
(),
cardList
.
size
(),
cardList
.
size
());
beginInsertRows
(
QModelIndex
(),
cardList
.
size
(),
cardList
.
size
());
cardList
.
append
(
card
);
cardList
.
append
(
card
);
connect
(
card
,
SIGNAL
(
cardInfoChanged
(
CardInfo
*
)),
this
,
SLOT
(
cardInfoChanged
(
CardInfo
*
)));
connect
(
card
,
SIGNAL
(
cardInfoChanged
(
CardInfo
*
)),
this
,
SLOT
(
cardInfoChanged
(
CardInfo
*
)));
endInsertRows
();
endInsertRows
();
}
}
void
CardDatabaseModel
::
cardRemoved
(
CardInfo
*
card
)
void
CardDatabaseModel
::
cardRemoved
(
CardInfo
*
card
)
{
{
const
int
row
=
cardList
.
indexOf
(
card
);
const
int
row
=
cardList
.
indexOf
(
card
);
if
(
row
==
-
1
)
if
(
row
==
-
1
)
return
;
return
;
beginRemoveRows
(
QModelIndex
(),
row
,
row
);
beginRemoveRows
(
QModelIndex
(),
row
,
row
);
cardList
.
removeAt
(
row
);
cardList
.
removeAt
(
row
);
endRemoveRows
();
endRemoveRows
();
}
}
CardDatabaseDisplayModel
::
CardDatabaseDisplayModel
(
QObject
*
parent
)
CardDatabaseDisplayModel
::
CardDatabaseDisplayModel
(
QObject
*
parent
)
:
QSortFilterProxyModel
(
parent
),
:
QSortFilterProxyModel
(
parent
),
isToken
(
ShowAll
)
isToken
(
ShowAll
)
{
{
filterTree
=
NULL
;
filterTree
=
NULL
;
setFilterCaseSensitivity
(
Qt
::
CaseInsensitive
);
setFilterCaseSensitivity
(
Qt
::
CaseInsensitive
);
setSortCaseSensitivity
(
Qt
::
CaseInsensitive
);
setSortCaseSensitivity
(
Qt
::
CaseInsensitive
);
}
}
bool
CardDatabaseDisplayModel
::
filterAcceptsRow
(
int
sourceRow
,
const
QModelIndex
&
/*sourceParent*/
)
const
bool
CardDatabaseDisplayModel
::
filterAcceptsRow
(
int
sourceRow
,
const
QModelIndex
&
/*sourceParent*/
)
const
{
{
CardInfo
const
*
info
=
static_cast
<
CardDatabaseModel
*>
(
sourceModel
())
->
getCard
(
sourceRow
);
CardInfo
const
*
info
=
static_cast
<
CardDatabaseModel
*>
(
sourceModel
())
->
getCard
(
sourceRow
);
if
(((
isToken
==
ShowTrue
)
&&
!
info
->
getIsToken
())
||
((
isToken
==
ShowFalse
)
&&
info
->
getIsToken
()))
if
(((
isToken
==
ShowTrue
)
&&
!
info
->
getIsToken
())
||
((
isToken
==
ShowFalse
)
&&
info
->
getIsToken
()))
return
false
;
return
false
;
if
(
!
cardNameBeginning
.
isEmpty
())
if
(
!
cardNameBeginning
.
isEmpty
())
if
(
!
info
->
getName
().
startsWith
(
cardNameBeginning
,
Qt
::
CaseInsensitive
))
if
(
!
info
->
getName
().
startsWith
(
cardNameBeginning
,
Qt
::
CaseInsensitive
))
return
false
;
return
false
;
if
(
!
cardName
.
isEmpty
())
if
(
!
cardName
.
isEmpty
())
if
(
!
info
->
getName
().
contains
(
cardName
,
Qt
::
CaseInsensitive
))
if
(
!
info
->
getName
().
contains
(
cardName
,
Qt
::
CaseInsensitive
))
return
false
;
return
false
;
if
(
!
cardNameSet
.
isEmpty
())
if
(
!
cardNameSet
.
isEmpty
())
if
(
!
cardNameSet
.
contains
(
info
->
getName
()))
if
(
!
cardNameSet
.
contains
(
info
->
getName
()))
return
false
;
return
false
;
if
(
!
cardText
.
isEmpty
())
if
(
!
cardText
.
isEmpty
())
if
(
!
info
->
getText
().
contains
(
cardText
,
Qt
::
CaseInsensitive
))
if
(
!
info
->
getText
().
contains
(
cardText
,
Qt
::
CaseInsensitive
))
return
false
;
return
false
;
if
(
!
cardColors
.
isEmpty
())
if
(
!
cardColors
.
isEmpty
())
if
(
QSet
<
QString
>::
fromList
(
info
->
getColors
()).
intersect
(
cardColors
).
isEmpty
()
&&
!
(
info
->
getColors
().
isEmpty
()
&&
cardColors
.
contains
(
"X"
)))
if
(
QSet
<
QString
>::
fromList
(
info
->
getColors
()).
intersect
(
cardColors
).
isEmpty
()
&&
!
(
info
->
getColors
().
isEmpty
()
&&
cardColors
.
contains
(
"X"
)))
return
false
;
return
false
;
if
(
!
cardTypes
.
isEmpty
())
if
(
!
cardTypes
.
isEmpty
())
if
(
!
cardTypes
.
contains
(
info
->
getMainCardType
()))
if
(
!
cardTypes
.
contains
(
info
->
getMainCardType
()))
return
false
;
return
false
;
if
(
filterTree
!=
NULL
)
if
(
filterTree
!=
NULL
)
return
filterTree
->
acceptsCard
(
info
);
return
filterTree
->
acceptsCard
(
info
);
return
true
;
return
true
;
}
}
void
CardDatabaseDisplayModel
::
clearSearch
()
void
CardDatabaseDisplayModel
::
clearSearch
()
{
{
cardName
.
clear
();
cardName
.
clear
();
cardText
.
clear
();
cardText
.
clear
();
cardTypes
.
clear
();
cardTypes
.
clear
();
cardColors
.
clear
();
cardColors
.
clear
();
if
(
filterTree
!=
NULL
)
if
(
filterTree
!=
NULL
)
filterTree
->
clear
();
filterTree
->
clear
();
invalidateFilter
();
invalidateFilter
();
}
}
void
CardDatabaseDisplayModel
::
setFilterTree
(
FilterTree
*
filterTree
)
void
CardDatabaseDisplayModel
::
setFilterTree
(
FilterTree
*
filterTree
)
{
{
if
(
this
->
filterTree
!=
NULL
)
if
(
this
->
filterTree
!=
NULL
)
disconnect
(
this
->
filterTree
,
0
,
this
,
0
);
disconnect
(
this
->
filterTree
,
0
,
this
,
0
);
this
->
filterTree
=
filterTree
;
this
->
filterTree
=
filterTree
;
connect
(
this
->
filterTree
,
SIGNAL
(
changed
()),
this
,
SLOT
(
filterTreeChanged
()));
connect
(
this
->
filterTree
,
SIGNAL
(
changed
()),
this
,
SLOT
(
filterTreeChanged
()));
invalidate
();
invalidate
();
}
}
void
CardDatabaseDisplayModel
::
filterTreeChanged
()
void
CardDatabaseDisplayModel
::
filterTreeChanged
()
{
{
invalidate
();
invalidate
();
}
}
cockatrice/src/carddatabasemodel.h
View file @
748aac7e
...
@@ -10,50 +10,50 @@
...
@@ -10,50 +10,50 @@
class
FilterTree
;
class
FilterTree
;
class
CardDatabaseModel
:
public
QAbstractListModel
{
class
CardDatabaseModel
:
public
QAbstractListModel
{
Q_OBJECT
Q_OBJECT
public:
public:
CardDatabaseModel
(
CardDatabase
*
_db
,
QObject
*
parent
=
0
);
CardDatabaseModel
(
CardDatabase
*
_db
,
QObject
*
parent
=
0
);
~
CardDatabaseModel
();
~
CardDatabaseModel
();
int
rowCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
;
int
rowCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
;
int
columnCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
;
int
columnCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
;
QVariant
headerData
(
int
section
,
Qt
::
Orientation
orientation
,
int
role
=
Qt
::
DisplayRole
)
const
;
QVariant
headerData
(
int
section
,
Qt
::
Orientation
orientation
,
int
role
=
Qt
::
DisplayRole
)
const
;
CardDatabase
*
getDatabase
()
const
{
return
db
;
}
CardDatabase
*
getDatabase
()
const
{
return
db
;
}
CardInfo
*
getCard
(
int
index
)
const
{
return
cardList
[
index
];
}
CardInfo
*
getCard
(
int
index
)
const
{
return
cardList
[
index
];
}
private:
private:
QList
<
CardInfo
*>
cardList
;
QList
<
CardInfo
*>
cardList
;
CardDatabase
*
db
;
CardDatabase
*
db
;
private
slots
:
private
slots
:
void
updateCardList
();
void
updateCardList
();
void
cardAdded
(
CardInfo
*
card
);
void
cardAdded
(
CardInfo
*
card
);
void
cardRemoved
(
CardInfo
*
card
);
void
cardRemoved
(
CardInfo
*
card
);
void
cardInfoChanged
(
CardInfo
*
card
);
void
cardInfoChanged
(
CardInfo
*
card
);
};
};
class
CardDatabaseDisplayModel
:
public
QSortFilterProxyModel
{
class
CardDatabaseDisplayModel
:
public
QSortFilterProxyModel
{
Q_OBJECT
Q_OBJECT
public:
public:
enum
FilterBool
{
ShowTrue
,
ShowFalse
,
ShowAll
};
enum
FilterBool
{
ShowTrue
,
ShowFalse
,
ShowAll
};
private:
private:
FilterBool
isToken
;
FilterBool
isToken
;
QString
cardNameBeginning
,
cardName
,
cardText
;
QString
cardNameBeginning
,
cardName
,
cardText
;
QSet
<
QString
>
cardNameSet
,
cardTypes
,
cardColors
;
QSet
<
QString
>
cardNameSet
,
cardTypes
,
cardColors
;
FilterTree
*
filterTree
;
FilterTree
*
filterTree
;
public:
public:
CardDatabaseDisplayModel
(
QObject
*
parent
=
0
);
CardDatabaseDisplayModel
(
QObject
*
parent
=
0
);
void
setFilterTree
(
FilterTree
*
filterTree
);
void
setFilterTree
(
FilterTree
*
filterTree
);
void
setIsToken
(
FilterBool
_isToken
)
{
isToken
=
_isToken
;
invalidate
();
}
void
setIsToken
(
FilterBool
_isToken
)
{
isToken
=
_isToken
;
invalidate
();
}
void
setCardNameBeginning
(
const
QString
&
_beginning
)
{
cardNameBeginning
=
_beginning
;
invalidate
();
}
void
setCardNameBeginning
(
const
QString
&
_beginning
)
{
cardNameBeginning
=
_beginning
;
invalidate
();
}
void
setCardName
(
const
QString
&
_cardName
)
{
cardName
=
_cardName
;
invalidate
();
}
void
setCardName
(
const
QString
&
_cardName
)
{
cardName
=
_cardName
;
invalidate
();
}
void
setCardNameSet
(
const
QSet
<
QString
>
&
_cardNameSet
)
{
cardNameSet
=
_cardNameSet
;
invalidate
();
}
void
setCardNameSet
(
const
QSet
<
QString
>
&
_cardNameSet
)
{
cardNameSet
=
_cardNameSet
;
invalidate
();
}
void
setCardText
(
const
QString
&
_cardText
)
{
cardText
=
_cardText
;
invalidate
();
}
void
setCardText
(
const
QString
&
_cardText
)
{
cardText
=
_cardText
;
invalidate
();
}
void
setCardTypes
(
const
QSet
<
QString
>
&
_cardTypes
)
{
cardTypes
=
_cardTypes
;
invalidate
();
}
void
setCardTypes
(
const
QSet
<
QString
>
&
_cardTypes
)
{
cardTypes
=
_cardTypes
;
invalidate
();
}
void
setCardColors
(
const
QSet
<
QString
>
&
_cardColors
)
{
cardColors
=
_cardColors
;
invalidate
();
}
void
setCardColors
(
const
QSet
<
QString
>
&
_cardColors
)
{
cardColors
=
_cardColors
;
invalidate
();
}
void
clearSearch
();
void
clearSearch
();
protected:
protected:
bool
filterAcceptsRow
(
int
sourceRow
,
const
QModelIndex
&
sourceParent
)
const
;
bool
filterAcceptsRow
(
int
sourceRow
,
const
QModelIndex
&
sourceParent
)
const
;
private
slots
:
private
slots
:
void
filterTreeChanged
();
void
filterTreeChanged
();
};
};
#endif
#endif
cockatrice/src/decklistmodel.cpp
View file @
748aac7e
This diff is collapsed.
Click to expand it.
cockatrice/src/decklistmodel.h
View file @
748aac7e
...
@@ -13,63 +13,63 @@ class QTextCursor;
...
@@ -13,63 +13,63 @@ class QTextCursor;
class
DecklistModelCardNode
:
public
AbstractDecklistCardNode
{
class
DecklistModelCardNode
:
public
AbstractDecklistCardNode
{
private:
private:
DecklistCardNode
*
dataNode
;
DecklistCardNode
*
dataNode
;
public:
public:
DecklistModelCardNode
(
DecklistCardNode
*
_dataNode
,
InnerDecklistNode
*
_parent
)
:
AbstractDecklistCardNode
(
_parent
),
dataNode
(
_dataNode
)
{
}
DecklistModelCardNode
(
DecklistCardNode
*
_dataNode
,
InnerDecklistNode
*
_parent
)
:
AbstractDecklistCardNode
(
_parent
),
dataNode
(
_dataNode
)
{
}
int
getNumber
()
const
{
return
dataNode
->
getNumber
();
}
int
getNumber
()
const
{
return
dataNode
->
getNumber
();
}
void
setNumber
(
int
_number
)
{
dataNode
->
setNumber
(
_number
);
}
void
setNumber
(
int
_number
)
{
dataNode
->
setNumber
(
_number
);
}
float
getPrice
()
const
{
return
dataNode
->
getPrice
();
}
float
getPrice
()
const
{
return
dataNode
->
getPrice
();
}
void
setPrice
(
float
_price
)
{
dataNode
->
setPrice
(
_price
);
}
void
setPrice
(
float
_price
)
{
dataNode
->
setPrice
(
_price
);
}
QString
getName
()
const
{
return
dataNode
->
getName
();
}
QString
getName
()
const
{
return
dataNode
->
getName
();
}
void
setName
(
const
QString
&
_name
)
{
dataNode
->
setName
(
_name
);
}
void
setName
(
const
QString
&
_name
)
{
dataNode
->
setName
(
_name
);
}
DecklistCardNode
*
getDataNode
()
const
{
return
dataNode
;
}
DecklistCardNode
*
getDataNode
()
const
{
return
dataNode
;
}
};
};
class
DeckListModel
:
public
QAbstractItemModel
{
class
DeckListModel
:
public
QAbstractItemModel
{
Q_OBJECT
Q_OBJECT
private
slots
:
private
slots
:
void
rebuildTree
();
void
rebuildTree
();
public
slots
:
public
slots
:
void
printDeckList
(
QPrinter
*
printer
);
void
printDeckList
(
QPrinter
*
printer
);
signals:
signals:
void
deckHashChanged
();
void
deckHashChanged
();
public:
public:
DeckListModel
(
QObject
*
parent
=
0
);
DeckListModel
(
QObject
*
parent
=
0
);
~
DeckListModel
();
~
DeckListModel
();
int
rowCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
;
int
rowCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
;
int
columnCount
(
const
QModelIndex
&
/*parent*/
=
QModelIndex
())
const
;
int
columnCount
(
const
QModelIndex
&
/*parent*/
=
QModelIndex
())
const
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
;
QVariant
headerData
(
int
section
,
Qt
::
Orientation
orientation
,
int
role
=
Qt
::
DisplayRole
)
const
;
QVariant
headerData
(
int
section
,
Qt
::
Orientation
orientation
,
int
role
=
Qt
::
DisplayRole
)
const
;
QModelIndex
index
(
int
row
,
int
column
,
const
QModelIndex
&
parent
=
QModelIndex
())
const
;
QModelIndex
index
(
int
row
,
int
column
,
const
QModelIndex
&
parent
=
QModelIndex
())
const
;
QModelIndex
parent
(
const
QModelIndex
&
index
)
const
;
QModelIndex
parent
(
const
QModelIndex
&
index
)
const
;
Qt
::
ItemFlags
flags
(
const
QModelIndex
&
index
)
const
;
Qt
::
ItemFlags
flags
(
const
QModelIndex
&
index
)
const
;
bool
setData
(
const
QModelIndex
&
index
,
const
QVariant
&
value
,
int
role
);
bool
setData
(
const
QModelIndex
&
index
,
const
QVariant
&
value
,
int
role
);
bool
removeRows
(
int
row
,
int
count
,
const
QModelIndex
&
parent
=
QModelIndex
());
bool
removeRows
(
int
row
,
int
count
,
const
QModelIndex
&
parent
=
QModelIndex
());
QModelIndex
findCard
(
const
QString
&
cardName
,
const
QString
&
zoneName
)
const
;
QModelIndex
findCard
(
const
QString
&
cardName
,
const
QString
&
zoneName
)
const
;
QModelIndex
addCard
(
const
QString
&
cardName
,
const
QString
&
zoneName
);
QModelIndex
addCard
(
const
QString
&
cardName
,
const
QString
&
zoneName
);
void
sort
(
int
column
,
Qt
::
SortOrder
order
=
Qt
::
AscendingOrder
);
void
sort
(
int
column
,
Qt
::
SortOrder
order
=
Qt
::
AscendingOrder
);
void
cleanList
();
void
cleanList
();
DeckLoader
*
getDeckList
()
const
{
return
deckList
;
}
DeckLoader
*
getDeckList
()
const
{
return
deckList
;
}
void
setDeckList
(
DeckLoader
*
_deck
);
void
setDeckList
(
DeckLoader
*
_deck
);
void
pricesUpdated
(
InnerDecklistNode
*
node
=
0
);
void
pricesUpdated
(
InnerDecklistNode
*
node
=
0
);
private:
private:
DeckLoader
*
deckList
;
DeckLoader
*
deckList
;
InnerDecklistNode
*
root
;
InnerDecklistNode
*
root
;
InnerDecklistNode
*
createNodeIfNeeded
(
const
QString
&
name
,
InnerDecklistNode
*
parent
);
InnerDecklistNode
*
createNodeIfNeeded
(
const
QString
&
name
,
InnerDecklistNode
*
parent
);
QModelIndex
nodeToIndex
(
AbstractDecklistNode
*
node
)
const
;
QModelIndex
nodeToIndex
(
AbstractDecklistNode
*
node
)
const
;
DecklistModelCardNode
*
findCardNode
(
const
QString
&
cardName
,
const
QString
&
zoneName
)
const
;
DecklistModelCardNode
*
findCardNode
(
const
QString
&
cardName
,
const
QString
&
zoneName
)
const
;
void
emitRecursiveUpdates
(
const
QModelIndex
&
index
);
void
emitRecursiveUpdates
(
const
QModelIndex
&
index
);
void
sortHelper
(
InnerDecklistNode
*
node
,
Qt
::
SortOrder
order
);
void
sortHelper
(
InnerDecklistNode
*
node
,
Qt
::
SortOrder
order
);
void
printDeckListNode
(
QTextCursor
*
cursor
,
InnerDecklistNode
*
node
);
void
printDeckListNode
(
QTextCursor
*
cursor
,
InnerDecklistNode
*
node
);
template
<
typename
T
>
T
getNode
(
const
QModelIndex
&
index
)
const
template
<
typename
T
>
T
getNode
(
const
QModelIndex
&
index
)
const
{
{
if
(
!
index
.
isValid
())
if
(
!
index
.
isValid
())
return
dynamic_cast
<
T
>
(
root
);
return
dynamic_cast
<
T
>
(
root
);
return
dynamic_cast
<
T
>
(
static_cast
<
AbstractDecklistNode
*>
(
index
.
internalPointer
()));
return
dynamic_cast
<
T
>
(
static_cast
<
AbstractDecklistNode
*>
(
index
.
internalPointer
()));
}
}
};
};
#endif
#endif
cockatrice/src/tab_deck_editor.cpp
View file @
748aac7e
This diff is collapsed.
Click to expand it.
cockatrice/src/tab_deck_editor.h
View file @
748aac7e
...
@@ -20,98 +20,98 @@ class FilterTreeModel;
...
@@ -20,98 +20,98 @@ class FilterTreeModel;
class
CardInfo
;
class
CardInfo
;
class
SearchLineEdit
:
public
QLineEdit
{
class
SearchLineEdit
:
public
QLineEdit
{
private:
private:
QTreeView
*
treeView
;
QTreeView
*
treeView
;
protected:
protected:
void
keyPressEvent
(
QKeyEvent
*
event
);
void
keyPressEvent
(
QKeyEvent
*
event
);
public:
public:
SearchLineEdit
()
:
QLineEdit
(),
treeView
(
0
)
{
}
SearchLineEdit
()
:
QLineEdit
(),
treeView
(
0
)
{
}
void
setTreeView
(
QTreeView
*
_treeView
)
{
treeView
=
_treeView
;
}
void
setTreeView
(
QTreeView
*
_treeView
)
{
treeView
=
_treeView
;
}
};
};
class
TabDeckEditor
:
public
Tab
{
class
TabDeckEditor
:
public
Tab
{
Q_OBJECT
Q_OBJECT
private
slots
:
private
slots
:
void
updateName
(
const
QString
&
name
);
void
updateName
(
const
QString
&
name
);
void
updateComments
();
void
updateComments
();
void
updateHash
();
void
updateHash
();
void
updateCardInfoLeft
(
const
QModelIndex
&
current
,
const
QModelIndex
&
previous
);
void
updateCardInfoLeft
(
const
QModelIndex
&
current
,
const
QModelIndex
&
previous
);
void
updateCardInfoRight
(
const
QModelIndex
&
current
,
const
QModelIndex
&
previous
);
void
updateCardInfoRight
(
const
QModelIndex
&
current
,
const
QModelIndex
&
previous
);
void
updateSearch
(
const
QString
&
search
);
void
updateSearch
(
const
QString
&
search
);
void
actNewDeck
();
void
actNewDeck
();
void
actLoadDeck
();
void
actLoadDeck
();
bool
actSaveDeck
();
bool
actSaveDeck
();
bool
actSaveDeckAs
();
bool
actSaveDeckAs
();
void
actLoadDeckFromClipboard
();
void
actLoadDeckFromClipboard
();
void
actSaveDeckToClipboard
();
void
actSaveDeckToClipboard
();
void
actPrintDeck
();
void
actPrintDeck
();
void
actAnalyzeDeck
();
void
actAnalyzeDeck
();
void
actEditSets
();
void
actEditSets
();
void
actEditTokens
();
void
actEditTokens
();
void
actClearSearch
();
void
actClearSearch
();
void
actAddCard
();
void
actAddCard
();
void
actAddCardToSideboard
();
void
actAddCardToSideboard
();
void
actRemoveCard
();
void
actRemoveCard
();
void
actIncrement
();
void
actIncrement
();
void
actDecrement
();
void
actDecrement
();
void
actDecrementCard
();
void
actDecrementCard
();
void
actDecrementCardFromSideboard
();
void
actDecrementCardFromSideboard
();
void
actUpdatePrices
();
void
actUpdatePrices
();
void
finishedUpdatingPrices
();
void
finishedUpdatingPrices
();
void
saveDeckRemoteFinished
(
const
Response
&
r
);
void
saveDeckRemoteFinished
(
const
Response
&
r
);
void
filterViewCustomContextMenu
(
const
QPoint
&
point
);
void
filterViewCustomContextMenu
(
const
QPoint
&
point
);
void
filterRemove
(
QAction
*
action
);
void
filterRemove
(
QAction
*
action
);
private:
private:
CardInfo
*
currentCardInfo
()
const
;
CardInfo
*
currentCardInfo
()
const
;
void
addCardHelper
(
QString
zoneName
);
void
addCardHelper
(
QString
zoneName
);
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
);
bool
confirmClose
();
bool
confirmClose
();
CardDatabaseModel
*
databaseModel
;
CardDatabaseModel
*
databaseModel
;
CardDatabaseDisplayModel
*
databaseDisplayModel
;
CardDatabaseDisplayModel
*
databaseDisplayModel
;
DeckListModel
*
deckModel
;
DeckListModel
*
deckModel
;
QTreeView
*
databaseView
;
QTreeView
*
databaseView
;
KeySignals
dbViewKeySignals
;
KeySignals
dbViewKeySignals
;
QTreeView
*
deckView
;
QTreeView
*
deckView
;
KeySignals
deckViewKeySignals
;
KeySignals
deckViewKeySignals
;
CardFrame
*
cardInfo
;
CardFrame
*
cardInfo
;
QLabel
*
searchLabel
;
QLabel
*
searchLabel
;
SearchLineEdit
*
searchEdit
;
SearchLineEdit
*
searchEdit
;
KeySignals
searchKeySignals
;
KeySignals
searchKeySignals
;
QLabel
*
nameLabel
;
QLabel
*
nameLabel
;
QLineEdit
*
nameEdit
;
QLineEdit
*
nameEdit
;
QLabel
*
commentsLabel
;
QLabel
*
commentsLabel
;
QTextEdit
*
commentsEdit
;
QTextEdit
*
commentsEdit
;
QLabel
*
hashLabel1
;
QLabel
*
hashLabel1
;
QLabel
*
hashLabel
;
QLabel
*
hashLabel
;
FilterTreeModel
*
filterModel
;
FilterTreeModel
*
filterModel
;
QTreeView
*
filterView
;
QTreeView
*
filterView
;
QMenu
*
deckMenu
,
*
dbMenu
;
QMenu
*
deckMenu
,
*
dbMenu
;
QAction
*
aNewDeck
,
*
aLoadDeck
,
*
aSaveDeck
,
*
aSaveDeckAs
,
*
aLoadDeckFromClipboard
,
*
aSaveDeckToClipboard
,
*
aPrintDeck
,
*
aAnalyzeDeck
,
*
aClose
;
QAction
*
aNewDeck
,
*
aLoadDeck
,
*
aSaveDeck
,
*
aSaveDeckAs
,
*
aLoadDeckFromClipboard
,
*
aSaveDeckToClipboard
,
*
aPrintDeck
,
*
aAnalyzeDeck
,
*
aClose
;
QAction
*
aEditSets
,
*
aEditTokens
,
*
aClearSearch
,
*
aCardTextOnly
;
QAction
*
aEditSets
,
*
aEditTokens
,
*
aClearSearch
,
*
aCardTextOnly
;
QAction
*
aAddCard
,
*
aAddCardToSideboard
,
*
aRemoveCard
,
*
aIncrement
,
*
aDecrement
,
*
aUpdatePrices
;
QAction
*
aAddCard
,
*
aAddCardToSideboard
,
*
aRemoveCard
,
*
aIncrement
,
*
aDecrement
,
*
aUpdatePrices
;
bool
modified
;
bool
modified
;
public:
public:
TabDeckEditor
(
TabSupervisor
*
_tabSupervisor
,
QWidget
*
parent
=
0
);
TabDeckEditor
(
TabSupervisor
*
_tabSupervisor
,
QWidget
*
parent
=
0
);
~
TabDeckEditor
();
~
TabDeckEditor
();
void
retranslateUi
();
void
retranslateUi
();
QString
getTabText
()
const
;
QString
getTabText
()
const
;
void
setDeck
(
DeckLoader
*
_deckLoader
);
void
setDeck
(
DeckLoader
*
_deckLoader
);
void
setModified
(
bool
_windowModified
);
void
setModified
(
bool
_windowModified
);
public
slots
:
public
slots
:
void
closeRequest
();
void
closeRequest
();
signals:
signals:
void
deckEditorClosing
(
TabDeckEditor
*
tab
);
void
deckEditorClosing
(
TabDeckEditor
*
tab
);
};
};
#endif
#endif
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