mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 00:24:47 -07:00
Avoid repeating type by using auto. (#6321)
Took 19 minutes Took 22 seconds Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
28dfd62163
commit
5df00de246
32 changed files with 116 additions and 117 deletions
|
|
@ -28,7 +28,7 @@ enum GameListColumn
|
|||
|
||||
const int DEFAULT_MAX_PLAYERS_MIN = 1;
|
||||
const int DEFAULT_MAX_PLAYERS_MAX = 99;
|
||||
constexpr QTime DEFAULT_MAX_GAME_AGE = QTime();
|
||||
constexpr auto DEFAULT_MAX_GAME_AGE = QTime();
|
||||
|
||||
const QString GamesModel::getGameCreatedString(const int secs)
|
||||
{
|
||||
|
|
@ -333,7 +333,7 @@ void GamesProxyModel::setGameFilters(bool _hideBuddiesOnlyGames,
|
|||
|
||||
int GamesProxyModel::getNumFilteredGames() const
|
||||
{
|
||||
GamesModel *model = qobject_cast<GamesModel *>(sourceModel());
|
||||
auto *model = qobject_cast<GamesModel *>(sourceModel());
|
||||
if (!model)
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ int RemoteReplayList_TreeModel::rowCount(const QModelIndex &parent) const
|
|||
if (!parent.isValid())
|
||||
return replayMatches.size();
|
||||
|
||||
MatchNode *matchNode = dynamic_cast<MatchNode *>(static_cast<Node *>(parent.internalPointer()));
|
||||
auto *matchNode = dynamic_cast<MatchNode *>(static_cast<Node *>(parent.internalPointer()));
|
||||
if (matchNode)
|
||||
return matchNode->size();
|
||||
else
|
||||
|
|
@ -62,7 +62,7 @@ QVariant RemoteReplayList_TreeModel::data(const QModelIndex &index, int role) co
|
|||
if (index.column() >= numberOfColumns)
|
||||
return QVariant();
|
||||
|
||||
ReplayNode *replayNode = dynamic_cast<ReplayNode *>(static_cast<Node *>(index.internalPointer()));
|
||||
auto *replayNode = dynamic_cast<ReplayNode *>(static_cast<Node *>(index.internalPointer()));
|
||||
if (replayNode) {
|
||||
const ServerInfo_Replay &replayInfo = replayNode->getReplayInfo();
|
||||
switch (role) {
|
||||
|
|
@ -84,7 +84,7 @@ QVariant RemoteReplayList_TreeModel::data(const QModelIndex &index, int role) co
|
|||
return index.column() == 0 ? fileIcon : QVariant();
|
||||
}
|
||||
} else {
|
||||
MatchNode *matchNode = dynamic_cast<MatchNode *>(static_cast<Node *>(index.internalPointer()));
|
||||
auto *matchNode = dynamic_cast<MatchNode *>(static_cast<Node *>(index.internalPointer()));
|
||||
const ServerInfo_ReplayMatch &matchInfo = matchNode->getMatchInfo();
|
||||
switch (role) {
|
||||
case Qt::TextAlignmentRole:
|
||||
|
|
@ -170,7 +170,7 @@ QModelIndex RemoteReplayList_TreeModel::index(int row, int column, const QModelI
|
|||
if (!hasIndex(row, column, parent))
|
||||
return QModelIndex();
|
||||
|
||||
MatchNode *matchNode = dynamic_cast<MatchNode *>(static_cast<Node *>(parent.internalPointer()));
|
||||
auto *matchNode = dynamic_cast<MatchNode *>(static_cast<Node *>(parent.internalPointer()));
|
||||
if (matchNode) {
|
||||
if (row >= matchNode->size())
|
||||
return QModelIndex();
|
||||
|
|
@ -188,7 +188,7 @@ QModelIndex RemoteReplayList_TreeModel::parent(const QModelIndex &ind) const
|
|||
if (matchNode)
|
||||
return QModelIndex();
|
||||
else {
|
||||
ReplayNode *replayNode = dynamic_cast<ReplayNode *>(static_cast<Node *>(ind.internalPointer()));
|
||||
auto *replayNode = dynamic_cast<ReplayNode *>(static_cast<Node *>(ind.internalPointer()));
|
||||
return createIndex(replayNode->getParent()->indexOf(replayNode), 0, replayNode->getParent());
|
||||
}
|
||||
}
|
||||
|
|
@ -206,7 +206,7 @@ ServerInfo_Replay const *RemoteReplayList_TreeModel::getReplay(const QModelIndex
|
|||
if (!index.isValid())
|
||||
return 0;
|
||||
|
||||
ReplayNode *node = dynamic_cast<ReplayNode *>(static_cast<Node *>(index.internalPointer()));
|
||||
auto *node = dynamic_cast<ReplayNode *>(static_cast<Node *>(index.internalPointer()));
|
||||
if (!node)
|
||||
return 0;
|
||||
return &node->getReplayInfo();
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ void UserContextMenu::gamesOfUserReceived(const Response &resp, const CommandCon
|
|||
gameTypeMap.insert(roomInfo.room_id(), tempMap);
|
||||
}
|
||||
|
||||
GameSelector *selector = new GameSelector(client, tabSupervisor, nullptr, roomMap, gameTypeMap, false, false);
|
||||
auto *selector = new GameSelector(client, tabSupervisor, nullptr, roomMap, gameTypeMap, false, false);
|
||||
selector->setParent(static_cast<QWidget *>(parent()), Qt::Window);
|
||||
const int gameListSize = response.game_list_size();
|
||||
for (int i = 0; i < gameListSize; ++i) {
|
||||
|
|
@ -128,7 +128,7 @@ void UserContextMenu::banUser_processUserInfoResponse(const Response &r)
|
|||
const Response_GetUserInfo &response = r.GetExtension(Response_GetUserInfo::ext);
|
||||
|
||||
// The dialog needs to be non-modal in order to not block the event queue of the client.
|
||||
BanDialog *dlg = new BanDialog(response.user_info(), static_cast<QWidget *>(parent()));
|
||||
auto *dlg = new BanDialog(response.user_info(), static_cast<QWidget *>(parent()));
|
||||
connect(dlg, &QDialog::accepted, this, &UserContextMenu::banUser_dialogFinished);
|
||||
dlg->show();
|
||||
}
|
||||
|
|
@ -141,7 +141,7 @@ void UserContextMenu::warnUser_processGetWarningsListResponse(const Response &r)
|
|||
QString clientid = QString::fromStdString(response.user_clientid()).simplified();
|
||||
|
||||
// The dialog needs to be non-modal in order to not block the event queue of the client.
|
||||
WarningDialog *dlg = new WarningDialog(user, clientid, static_cast<QWidget *>(parent()));
|
||||
auto *dlg = new WarningDialog(user, clientid, static_cast<QWidget *>(parent()));
|
||||
connect(dlg, &QDialog::accepted, this, &UserContextMenu::warnUser_dialogFinished);
|
||||
|
||||
if (response.warning_size() > 0) {
|
||||
|
|
@ -171,7 +171,7 @@ void UserContextMenu::banUserHistory_processResponse(const Response &resp)
|
|||
if (resp.response_code() == Response::RespOk) {
|
||||
|
||||
if (response.ban_list_size() > 0) {
|
||||
QTableWidget *table = new QTableWidget();
|
||||
auto *table = new QTableWidget();
|
||||
table->setWindowTitle(tr("Ban History"));
|
||||
table->setRowCount(response.ban_list_size());
|
||||
table->setColumnCount(5);
|
||||
|
|
@ -209,7 +209,7 @@ void UserContextMenu::warnUserHistory_processResponse(const Response &resp)
|
|||
if (resp.response_code() == Response::RespOk) {
|
||||
|
||||
if (response.warn_list_size() > 0) {
|
||||
QTableWidget *table = new QTableWidget();
|
||||
auto *table = new QTableWidget();
|
||||
table->setWindowTitle(tr("Warning History"));
|
||||
table->setRowCount(response.warn_list_size());
|
||||
table->setColumnCount(4);
|
||||
|
|
@ -278,7 +278,7 @@ void UserContextMenu::adjustMod_processUserResponse(const Response &resp, const
|
|||
|
||||
void UserContextMenu::banUser_dialogFinished()
|
||||
{
|
||||
BanDialog *dlg = static_cast<BanDialog *>(sender());
|
||||
auto *dlg = static_cast<BanDialog *>(sender());
|
||||
|
||||
Command_BanFromServer cmd;
|
||||
cmd.set_user_name(dlg->getBanName().toStdString());
|
||||
|
|
@ -297,7 +297,7 @@ void UserContextMenu::banUser_dialogFinished()
|
|||
|
||||
void UserContextMenu::warnUser_dialogFinished()
|
||||
{
|
||||
WarningDialog *dlg = static_cast<WarningDialog *>(sender());
|
||||
auto *dlg = static_cast<WarningDialog *>(sender());
|
||||
|
||||
if (dlg->getName().isEmpty() || userListProxy->getOwnUsername().simplified().isEmpty())
|
||||
return;
|
||||
|
|
@ -433,7 +433,7 @@ void UserContextMenu::showContextMenu(const QPoint &pos,
|
|||
QAction *actionClicked = menu->exec(pos);
|
||||
if (actionClicked == nullptr) {
|
||||
} else if (actionClicked == aDetails) {
|
||||
UserInfoBox *infoWidget =
|
||||
auto *infoWidget =
|
||||
new UserInfoBox(client, false, static_cast<QWidget *>(parent()),
|
||||
Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
|
||||
infoWidget->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue