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
7a7b686e
Commit
7a7b686e
authored
Feb 28, 2011
by
Max-Wilhelm Bruker
Browse files
fixed crash that occurs when reloading the card database while deck editor or game is running
parent
b0656ffc
Changes
8
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/abstractcarditem.cpp
View file @
7a7b686e
...
...
@@ -13,14 +13,15 @@
#include
<QTimer>
AbstractCardItem
::
AbstractCardItem
(
const
QString
&
_name
,
Player
*
_owner
,
QGraphicsItem
*
parent
)
:
ArrowTarget
(
_owner
,
parent
),
info
(
db
->
getCard
(
_name
)),
infoWidget
(
0
),
name
(
_name
),
tapped
(
false
),
tapAngle
(
0
),
isHovered
(
false
),
realZValue
(
0
)
:
ArrowTarget
(
_owner
,
parent
),
infoWidget
(
0
),
name
(
_name
),
tapped
(
false
),
tapAngle
(
0
),
isHovered
(
false
),
realZValue
(
0
)
{
setCursor
(
Qt
::
OpenHandCursor
);
setFlag
(
ItemIsSelectable
);
setCacheMode
(
DeviceCoordinateCache
);
connect
(
info
,
SIGNAL
(
pixmapUpdat
ed
()),
this
,
SLOT
(
pixmap
Updated
()));
connect
(
db
,
SIGNAL
(
cardListChang
ed
()),
this
,
SLOT
(
cardInfo
Updated
()));
connect
(
settingsCache
,
SIGNAL
(
displayCardNamesChanged
()),
this
,
SLOT
(
callUpdate
()));
cardInfoUpdated
();
animationTimer
=
new
QTimer
(
this
);
animationTimer
->
setSingleShot
(
false
);
...
...
@@ -42,6 +43,12 @@ void AbstractCardItem::pixmapUpdated()
update
();
}
void
AbstractCardItem
::
cardInfoUpdated
()
{
info
=
db
->
getCard
(
name
);
connect
(
info
,
SIGNAL
(
pixmapUpdated
()),
this
,
SLOT
(
pixmapUpdated
()));
}
void
AbstractCardItem
::
setRealZValue
(
qreal
_zValue
)
{
realZValue
=
_zValue
;
...
...
cockatrice/src/abstractcarditem.h
View file @
7a7b686e
...
...
@@ -27,6 +27,7 @@ private:
private
slots
:
void
animationEvent
();
void
pixmapUpdated
();
void
cardInfoUpdated
();
void
callUpdate
()
{
update
();
}
signals:
void
hovered
(
AbstractCardItem
*
card
);
...
...
cockatrice/src/carddatabase.cpp
View file @
7a7b686e
...
...
@@ -659,6 +659,8 @@ bool CardDatabase::loadCardDatabase(const QString &path)
allSets
.
sortByKey
();
for
(
int
i
=
0
;
i
<
allSets
.
size
();
++
i
)
allSets
[
i
]
->
setSortKey
(
i
);
emit
cardListChanged
();
}
return
loadSuccess
;
...
...
cockatrice/src/carddatabase.h
View file @
7a7b686e
...
...
@@ -201,6 +201,8 @@ private slots:
void
imageLoaded
(
CardInfo
*
card
,
QImage
image
);
void
picDownloadChanged
();
void
picsPathChanged
();
signals:
void
cardListChanged
();
};
#endif
cockatrice/src/carddatabasemodel.cpp
View file @
7a7b686e
...
...
@@ -3,6 +3,7 @@
CardDatabaseModel
::
CardDatabaseModel
(
CardDatabase
*
_db
,
QObject
*
parent
)
:
QAbstractListModel
(
parent
),
db
(
_db
)
{
connect
(
db
,
SIGNAL
(
cardListChanged
()),
this
,
SLOT
(
updateCardList
()));
cardList
=
db
->
getCardList
();
}
...
...
@@ -63,6 +64,12 @@ QVariant CardDatabaseModel::headerData(int section, Qt::Orientation orientation,
}
}
void
CardDatabaseModel
::
updateCardList
()
{
cardList
=
db
->
getCardList
();
reset
();
}
CardDatabaseDisplayModel
::
CardDatabaseDisplayModel
(
QObject
*
parent
)
:
QSortFilterProxyModel
(
parent
)
{
...
...
cockatrice/src/carddatabasemodel.h
View file @
7a7b686e
...
...
@@ -20,6 +20,8 @@ public:
private:
QList
<
CardInfo
*>
cardList
;
CardDatabase
*
db
;
private
slots
:
void
updateCardList
();
};
class
CardDatabaseDisplayModel
:
public
QSortFilterProxyModel
{
...
...
cockatrice/src/cardinfowidget.cpp
View file @
7a7b686e
...
...
@@ -115,6 +115,7 @@ void CardInfoWidget::setCard(CardInfo *card)
disconnect
(
info
,
0
,
this
,
0
);
info
=
card
;
connect
(
info
,
SIGNAL
(
pixmapUpdated
()),
this
,
SLOT
(
updatePixmap
()));
connect
(
info
,
SIGNAL
(
destroyed
()),
this
,
SLOT
(
clear
()));
updatePixmap
();
nameLabel2
->
setText
(
card
->
getName
());
...
...
@@ -134,6 +135,11 @@ void CardInfoWidget::setCard(AbstractCardItem *card)
setCard
(
card
->
getInfo
());
}
void
CardInfoWidget
::
clear
()
{
setCard
(
db
->
getCard
());
}
void
CardInfoWidget
::
updatePixmap
()
{
QPixmap
*
resizedPixmap
=
info
->
getPixmap
(
QSize
(
pixmapWidth
,
pixmapWidth
*
aspectRatio
));
...
...
cockatrice/src/cardinfowidget.h
View file @
7a7b686e
...
...
@@ -39,6 +39,7 @@ public slots:
void
setCard
(
const
QString
&
cardName
);
void
setCard
(
AbstractCardItem
*
card
);
private
slots
:
void
clear
();
void
updatePixmap
();
void
minimizeClicked
();
signals:
...
...
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