Clang-format (#3028)

* 1/3 Add .clang-format file and travis compilation check

* 2/3 Run clang-format

* 3/3 Fix compilation problems due to include reordering

* 3bis/3 AfterControlStatement: false
This commit is contained in:
ctrlaltca 2018-01-27 10:41:32 +01:00 committed by GitHub
parent 8dbdd24c8e
commit b29bd9e070
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
272 changed files with 13378 additions and 9535 deletions

View file

@ -1,13 +1,13 @@
#include "remotereplaylist_treewidget.h"
#include "abstractclient.h"
#include <QFileIconProvider>
#include <QHeaderView>
#include <QSortFilterProxyModel>
#include "remotereplaylist_treewidget.h"
#include "abstractclient.h"
#include "pending_command.h"
#include "pb/command_replay_list.pb.h"
#include "pb/response_replay_list.pb.h"
#include "pb/serverinfo_replay.pb.h"
#include "pending_command.h"
const int RemoteReplayList_TreeModel::numberOfColumns = 6;
@ -49,7 +49,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()));
if (matchNode)
return matchNode->size();
@ -63,7 +63,7 @@ QVariant RemoteReplayList_TreeModel::data(const QModelIndex &index, int role) co
return QVariant();
if (index.column() >= numberOfColumns)
return QVariant();
ReplayNode *replayNode = dynamic_cast<ReplayNode *>(static_cast<Node *>(index.internalPointer()));
if (replayNode) {
const ServerInfo_Replay &replayInfo = replayNode->getReplayInfo();
@ -72,10 +72,14 @@ QVariant RemoteReplayList_TreeModel::data(const QModelIndex &index, int role) co
return index.column() == 0 ? Qt::AlignRight : Qt::AlignLeft;
case Qt::DisplayRole: {
switch (index.column()) {
case 0: return replayInfo.replay_id();
case 1: return QString::fromStdString(replayInfo.replay_name());
case 5: return replayInfo.duration();
default: return QVariant();
case 0:
return replayInfo.replay_id();
case 1:
return QString::fromStdString(replayInfo.replay_name());
case 5:
return replayInfo.duration();
default:
return QVariant();
}
}
case Qt::DecorationRole:
@ -85,34 +89,42 @@ QVariant RemoteReplayList_TreeModel::data(const QModelIndex &index, int role) co
MatchNode *matchNode = dynamic_cast<MatchNode *>(static_cast<Node *>(index.internalPointer()));
const ServerInfo_ReplayMatch &matchInfo = matchNode->getMatchInfo();
switch (role) {
case Qt::TextAlignmentRole:
switch (index.column()) {
case 0:
case 5:
return Qt::AlignRight;
default:
return Qt::AlignLeft;
}
case Qt::TextAlignmentRole:
switch (index.column()) {
case 0:
case 5:
return Qt::AlignRight;
default:
return Qt::AlignLeft;
}
case Qt::DisplayRole: {
switch (index.column()) {
case 0: return matchInfo.game_id();
case 1: return QString::fromStdString(matchInfo.game_name());
case 0:
return matchInfo.game_id();
case 1:
return QString::fromStdString(matchInfo.game_name());
case 2: {
QStringList playerList;
for (int i = 0; i < matchInfo.player_names_size(); ++i)
playerList.append(QString::fromStdString(matchInfo.player_names(i)));
return playerList.join(", ");
}
case 4: return QDateTime::fromTime_t(matchInfo.time_started());
case 5: return matchInfo.length();
default: return QVariant();
case 4:
return QDateTime::fromTime_t(matchInfo.time_started());
case 5:
return matchInfo.length();
default:
return QVariant();
}
}
case Qt::DecorationRole:
switch (index.column()) {
case 0: return dirIcon;
case 3: return matchInfo.do_not_hide() ? lockIcon : QVariant();
default: return QVariant();
case 0:
return dirIcon;
case 3:
return matchInfo.do_not_hide() ? lockIcon : QVariant();
default:
return QVariant();
}
}
}
@ -134,16 +146,24 @@ QVariant RemoteReplayList_TreeModel::headerData(int section, Qt::Orientation ori
}
case Qt::DisplayRole: {
switch (section) {
case 0: return tr("ID");
case 1: return tr("Name");
case 2: return tr("Players");
case 3: return tr("Keep");
case 4: return tr("Time started");
case 5: return tr("Duration (sec)");
default: return QVariant();
case 0:
return tr("ID");
case 1:
return tr("Name");
case 2:
return tr("Players");
case 3:
return tr("Keep");
case 4:
return tr("Time started");
case 5:
return tr("Duration (sec)");
default:
return QVariant();
}
}
default: return QVariant();
default:
return QVariant();
}
}
@ -151,16 +171,16 @@ 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()));
if (matchNode) {
if (row >= matchNode->size())
return QModelIndex();
return createIndex(row, column, (void *) matchNode->at(row));
return createIndex(row, column, (void *)matchNode->at(row));
} else {
if (row >= replayMatches.size())
return QModelIndex();
return createIndex(row, column, (void *) replayMatches[row]);
return createIndex(row, column, (void *)replayMatches[row]);
}
}
@ -183,22 +203,22 @@ Qt::ItemFlags RemoteReplayList_TreeModel::flags(const QModelIndex &index) const
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
ServerInfo_Replay const* RemoteReplayList_TreeModel::getReplay(const QModelIndex &index) const
ServerInfo_Replay const *RemoteReplayList_TreeModel::getReplay(const QModelIndex &index) const
{
if (!index.isValid())
return 0;
ReplayNode *node = dynamic_cast<ReplayNode *>(static_cast<Node *>(index.internalPointer()));
if (!node)
return 0;
return &node->getReplayInfo();
}
ServerInfo_ReplayMatch const* RemoteReplayList_TreeModel::getReplayMatch(const QModelIndex &index) const
ServerInfo_ReplayMatch const *RemoteReplayList_TreeModel::getReplayMatch(const QModelIndex &index) const
{
if (!index.isValid())
return 0;
MatchNode *node = dynamic_cast<MatchNode *>(static_cast<Node *>(index.internalPointer()));
if (!node) {
ReplayNode *node = dynamic_cast<ReplayNode *>(static_cast<Node *>(index.internalPointer()));
@ -219,8 +239,9 @@ void RemoteReplayList_TreeModel::clearTree()
void RemoteReplayList_TreeModel::refreshTree()
{
PendingCommand *pend = client->prepareSessionCommand(Command_ReplayList());
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(replayListFinished(const Response &)));
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this,
SLOT(replayListFinished(const Response &)));
client->sendCommand(pend);
}
@ -229,7 +250,7 @@ void RemoteReplayList_TreeModel::addMatchInfo(const ServerInfo_ReplayMatch &matc
beginInsertRows(QModelIndex(), replayMatches.size(), replayMatches.size());
replayMatches.append(new MatchNode(matchInfo));
endInsertRows();
emit treeRefreshed();
}
@ -238,7 +259,8 @@ void RemoteReplayList_TreeModel::updateMatchInfo(int gameId, const ServerInfo_Re
for (int i = 0; i < replayMatches.size(); ++i)
if (replayMatches[i]->getMatchInfo().game_id() == gameId) {
replayMatches[i]->updateMatchInfo(matchInfo);
emit dataChanged(createIndex(i, 0, (void *) replayMatches[i]), createIndex(i, numberOfColumns - 1, (void *) replayMatches[i]));
emit dataChanged(createIndex(i, 0, (void *)replayMatches[i]),
createIndex(i, numberOfColumns - 1, (void *)replayMatches[i]));
break;
}
}
@ -257,19 +279,18 @@ void RemoteReplayList_TreeModel::removeMatchInfo(int gameId)
void RemoteReplayList_TreeModel::replayListFinished(const Response &r)
{
const Response_ReplayList &resp = r.GetExtension(Response_ReplayList::ext);
beginResetModel();
clearTree();
for (int i = 0; i < resp.match_list_size(); ++i)
replayMatches.append(new MatchNode(resp.match_list(i)));
endResetModel();
emit treeRefreshed();
}
RemoteReplayList_TreeWidget::RemoteReplayList_TreeWidget(AbstractClient *_client, QWidget *parent)
: QTreeView(parent)
RemoteReplayList_TreeWidget::RemoteReplayList_TreeWidget(AbstractClient *_client, QWidget *parent) : QTreeView(parent)
{
treeModel = new RemoteReplayList_TreeModel(_client, this);
proxyModel = new QSortFilterProxyModel(this);