fix c style casting (#2561)

This commit is contained in:
Zach H 2017-04-05 15:45:58 -04:00 committed by GitHub
parent ee154da598
commit 657e1ac9e6
8 changed files with 10 additions and 16 deletions

View file

@ -307,7 +307,7 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
QList<QGraphicsItem *> sel = scene()->selectedItems();
int j = 0;
for (int i = 0; i < sel.size(); i++) {
CardItem *c = (CardItem *) sel.at(i);
CardItem *c = static_cast<CardItem *>(sel.at(i));
if ((c == this) || (c->getZone() != zone))
continue;
++j;

View file

@ -184,7 +184,7 @@ void DlgUpdate::downloadSuccessful(QUrl filepath) {
//Try to open the installer. If it opens, quit Cockatrice
if (QDesktopServices::openUrl(filepath))
{
QMetaObject::invokeMethod((MainWindow*) parent(), "close", Qt::QueuedConnection);
QMetaObject::invokeMethod(static_cast<MainWindow *>(parent()), "close", Qt::QueuedConnection);
qDebug() << "Opened downloaded update file successfully - closing Cockatrice";
close();
} else {

View file

@ -25,9 +25,7 @@ int FilterTreeBranch<T>::childIndex(const FilterTreeNode *node) const
FilterTreeNode *unconst;
T downcasted;
/* to do the dynamic cast to T we will lose const'ness, but we can
* trust QList::indexOf */
unconst = (FilterTreeNode *) node;
unconst = const_cast<FilterTreeNode *>(node);
downcasted = dynamic_cast<T>(unconst);
if (downcasted == NULL)
return -1;

View file

@ -43,11 +43,11 @@ void HandZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone
int x = -1;
if (settingsCache->getHorizontalHand()) {
for (x = 0; x < cards.size(); x++)
if (point.x() < ((CardItem *) cards.at(x))->scenePos().x())
if (point.x() < static_cast<CardItem *>(cards.at(x))->scenePos().x())
break;
} else {
for (x = 0; x < cards.size(); x++)
if (point.y() < ((CardItem *) cards.at(x))->scenePos().y())
if (point.y() < static_cast<CardItem *>(cards.at(x))->scenePos().y())
break;
}
@ -112,7 +112,7 @@ void HandZone::reorganizeCards()
for (int i = 0; i < cardCount; i++) {
CardItem *c = cards.at(i);
qreal x = i % 2 ? x2 : x1;
qreal x = (i % 2) ? x2 : x1;
// If the total height of the cards is smaller than the available height,
// the cards do not need to overlap and are displayed in the center of the area.
if (cardHeight * cardCount > totalHeight)

View file

@ -84,7 +84,7 @@ void StackZone::reorganizeCards()
for (int i = 0; i < cardCount; i++) {
CardItem *c = cards.at(i);
qreal x = i % 2 ? x2 : x1;
qreal x = (i % 2) ? x2 : x1;
// If the total height of the cards is smaller than the available height,
// the cards do not need to overlap and are displayed in the center of the area.
if (cardHeight * cardCount > totalHeight)

View file

@ -47,13 +47,12 @@ void TappedOutInterface::queryFinished(QNetworkReply *reply)
QRegExp rx("<div class=\"alert alert-danger.*<ul>(.*)</ul>");
rx.setMinimal(true);
int found = rx.indexIn(data);
if(found >= 0)
if (found >= 0)
{
QString errors = rx.cap(1);
QRegExp rx2("<li>(.*)</li>");
rx2.setMinimal(true);
found = rx2.indexIn(errors);
int captures = rx2.captureCount();
for(int i = 1; i <= captures; i++)
{

View file

@ -288,11 +288,8 @@ UnZip::ErrorCode UnzipPrivate::parseLocalHeaderRecord(const QString& path, const
immediately following the compressed data."
*/
bool hasDataDescriptor = entry.hasDataDescriptor();
bool checkFailed = entry.compMethod != getUShort(uBuffer, UNZIP_LH_OFF_CMETHOD);
bool checkFailed = false;
if (!checkFailed)
checkFailed = entry.compMethod != getUShort(uBuffer, UNZIP_LH_OFF_CMETHOD);
if (!checkFailed)
checkFailed = entry.gpFlag[0] != uBuffer[UNZIP_LH_OFF_GPFLAG];
if (!checkFailed)

View file

@ -407,7 +407,7 @@ void IslInterface::processMessage(const IslMessage &item)
break;
}
case IslMessage::ROOM_EVENT: {
processRoomEvent(item.room_event()); break;
processRoomEvent(item.room_event());
break;
}
default: ;