mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 16:24:45 -07:00
[Fix-Warnings] Mark const getters as [[nodiscard]] (#6365)
Took 45 minutes Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
a1a3b02d3a
commit
9ece4bfd9b
58 changed files with 548 additions and 543 deletions
|
|
@ -42,19 +42,20 @@ public:
|
|||
*/
|
||||
GamesModel(const QMap<int, QString> &_rooms, const QMap<int, GameTypeMap> &_gameTypes, QObject *parent = nullptr);
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override
|
||||
[[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override
|
||||
{
|
||||
return parent.isValid() ? 0 : gameList.size();
|
||||
}
|
||||
|
||||
int columnCount(const QModelIndex & /*parent*/ = QModelIndex()) const override
|
||||
[[nodiscard]] int columnCount(const QModelIndex & /*parent*/ = QModelIndex()) const override
|
||||
{
|
||||
return NUM_COLS;
|
||||
}
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
[[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
[[nodiscard]] QVariant
|
||||
headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
|
||||
/**
|
||||
* @brief Formats the game creation time into a human-readable string.
|
||||
|
|
@ -148,71 +149,71 @@ public:
|
|||
explicit GamesProxyModel(QObject *parent = nullptr, const UserListProxy *_userListProxy = nullptr);
|
||||
|
||||
// Getters for filter parameters
|
||||
bool getHideBuddiesOnlyGames() const
|
||||
[[nodiscard]] bool getHideBuddiesOnlyGames() const
|
||||
{
|
||||
return hideBuddiesOnlyGames;
|
||||
}
|
||||
bool getHideIgnoredUserGames() const
|
||||
[[nodiscard]] bool getHideIgnoredUserGames() const
|
||||
{
|
||||
return hideIgnoredUserGames;
|
||||
}
|
||||
bool getHideFullGames() const
|
||||
[[nodiscard]] bool getHideFullGames() const
|
||||
{
|
||||
return hideFullGames;
|
||||
}
|
||||
bool getHideGamesThatStarted() const
|
||||
[[nodiscard]] bool getHideGamesThatStarted() const
|
||||
{
|
||||
return hideGamesThatStarted;
|
||||
}
|
||||
bool getHidePasswordProtectedGames() const
|
||||
[[nodiscard]] bool getHidePasswordProtectedGames() const
|
||||
{
|
||||
return hidePasswordProtectedGames;
|
||||
}
|
||||
bool getHideNotBuddyCreatedGames() const
|
||||
[[nodiscard]] bool getHideNotBuddyCreatedGames() const
|
||||
{
|
||||
return hideNotBuddyCreatedGames;
|
||||
}
|
||||
bool getHideOpenDecklistGames() const
|
||||
[[nodiscard]] bool getHideOpenDecklistGames() const
|
||||
{
|
||||
return hideOpenDecklistGames;
|
||||
}
|
||||
QString getGameNameFilter() const
|
||||
[[nodiscard]] QString getGameNameFilter() const
|
||||
{
|
||||
return gameNameFilter;
|
||||
}
|
||||
QStringList getCreatorNameFilters() const
|
||||
[[nodiscard]] QStringList getCreatorNameFilters() const
|
||||
{
|
||||
return creatorNameFilters;
|
||||
}
|
||||
QSet<int> getGameTypeFilter() const
|
||||
[[nodiscard]] QSet<int> getGameTypeFilter() const
|
||||
{
|
||||
return gameTypeFilter;
|
||||
}
|
||||
int getMaxPlayersFilterMin() const
|
||||
[[nodiscard]] int getMaxPlayersFilterMin() const
|
||||
{
|
||||
return maxPlayersFilterMin;
|
||||
}
|
||||
int getMaxPlayersFilterMax() const
|
||||
[[nodiscard]] int getMaxPlayersFilterMax() const
|
||||
{
|
||||
return maxPlayersFilterMax;
|
||||
}
|
||||
const QTime &getMaxGameAge() const
|
||||
[[nodiscard]] const QTime &getMaxGameAge() const
|
||||
{
|
||||
return maxGameAge;
|
||||
}
|
||||
bool getShowOnlyIfSpectatorsCanWatch() const
|
||||
[[nodiscard]] bool getShowOnlyIfSpectatorsCanWatch() const
|
||||
{
|
||||
return showOnlyIfSpectatorsCanWatch;
|
||||
}
|
||||
bool getShowSpectatorPasswordProtected() const
|
||||
[[nodiscard]] bool getShowSpectatorPasswordProtected() const
|
||||
{
|
||||
return showSpectatorPasswordProtected;
|
||||
}
|
||||
bool getShowOnlyIfSpectatorsCanChat() const
|
||||
[[nodiscard]] bool getShowOnlyIfSpectatorsCanChat() const
|
||||
{
|
||||
return showOnlyIfSpectatorsCanChat;
|
||||
}
|
||||
bool getShowOnlyIfSpectatorsCanSeeHands() const
|
||||
[[nodiscard]] bool getShowOnlyIfSpectatorsCanSeeHands() const
|
||||
{
|
||||
return showOnlyIfSpectatorsCanSeeHands;
|
||||
}
|
||||
|
|
@ -328,7 +329,7 @@ public:
|
|||
/**
|
||||
* @brief Returns the number of games filtered out by the current filter.
|
||||
*/
|
||||
int getNumFilteredGames() const;
|
||||
[[nodiscard]] int getNumFilteredGames() const;
|
||||
|
||||
/**
|
||||
* @brief Resets all filter parameters to default values.
|
||||
|
|
@ -338,7 +339,7 @@ public:
|
|||
/**
|
||||
* @brief Returns true if all filter parameters are set to their defaults.
|
||||
*/
|
||||
bool areFilterParametersSetToDefaults() const;
|
||||
[[nodiscard]] bool areFilterParametersSetToDefaults() const;
|
||||
|
||||
/**
|
||||
* @brief Loads filter parameters from persistent settings.
|
||||
|
|
@ -358,8 +359,8 @@ public:
|
|||
void refresh();
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
||||
bool filterAcceptsRow(int sourceRow) const;
|
||||
[[nodiscard]] bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
||||
[[nodiscard]] bool filterAcceptsRow(int sourceRow) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ public:
|
|||
{
|
||||
}
|
||||
virtual ~Node() = default;
|
||||
DirectoryNode *getParent() const
|
||||
[[nodiscard]] DirectoryNode *getParent() const
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
QString getName() const
|
||||
[[nodiscard]] QString getName() const
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
|
@ -49,9 +49,9 @@ public:
|
|||
explicit DirectoryNode(const QString &_name = QString(), DirectoryNode *_parent = nullptr);
|
||||
~DirectoryNode() override;
|
||||
void clearTree();
|
||||
QString getPath() const;
|
||||
[[nodiscard]] QString getPath() const;
|
||||
DirectoryNode *getNodeByPath(QStringList path);
|
||||
FileNode *getNodeById(int id) const;
|
||||
[[nodiscard]] FileNode *getNodeById(int id) const;
|
||||
};
|
||||
class FileNode : public Node
|
||||
{
|
||||
|
|
@ -64,17 +64,17 @@ public:
|
|||
: Node(_name, _parent), id(_id), uploadTime(_uploadTime)
|
||||
{
|
||||
}
|
||||
int getId() const
|
||||
[[nodiscard]] int getId() const
|
||||
{
|
||||
return id;
|
||||
}
|
||||
QDateTime getUploadTime() const
|
||||
[[nodiscard]] QDateTime getUploadTime() const
|
||||
{
|
||||
return uploadTime;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> T getNode(const QModelIndex &index) const
|
||||
template <typename T> [[nodiscard]] T getNode(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return dynamic_cast<T>(root);
|
||||
|
|
@ -96,15 +96,16 @@ private slots:
|
|||
public:
|
||||
explicit RemoteDeckList_TreeModel(AbstractClient *_client, QObject *parent = nullptr);
|
||||
~RemoteDeckList_TreeModel() override;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex & /*parent*/ = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
||||
QModelIndex parent(const QModelIndex &index) const override;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
[[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
[[nodiscard]] int columnCount(const QModelIndex & /*parent*/ = QModelIndex()) const override;
|
||||
[[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
|
||||
[[nodiscard]] QVariant
|
||||
headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
[[nodiscard]] QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
||||
[[nodiscard]] QModelIndex parent(const QModelIndex &index) const override;
|
||||
[[nodiscard]] Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
|
||||
DirectoryNode *getRoot() const
|
||||
[[nodiscard]] DirectoryNode *getRoot() const
|
||||
{
|
||||
return root;
|
||||
}
|
||||
|
|
@ -124,11 +125,11 @@ private:
|
|||
|
||||
public:
|
||||
explicit RemoteDeckList_TreeWidget(AbstractClient *_client, QWidget *parent = nullptr);
|
||||
RemoteDeckList_TreeModel::Node *getNode(const QModelIndex &ind) const;
|
||||
RemoteDeckList_TreeModel::Node *getCurrentItem() const;
|
||||
QList<RemoteDeckList_TreeModel::Node *> getCurrentSelection() const;
|
||||
RemoteDeckList_TreeModel::DirectoryNode *getNodeByPath(const QString &path) const;
|
||||
RemoteDeckList_TreeModel::FileNode *getNodeById(int id) const;
|
||||
[[nodiscard]] RemoteDeckList_TreeModel::Node *getNode(const QModelIndex &ind) const;
|
||||
[[nodiscard]] RemoteDeckList_TreeModel::Node *getCurrentItem() const;
|
||||
[[nodiscard]] QList<RemoteDeckList_TreeModel::Node *> getCurrentSelection() const;
|
||||
[[nodiscard]] RemoteDeckList_TreeModel::DirectoryNode *getNodeByPath(const QString &path) const;
|
||||
[[nodiscard]] RemoteDeckList_TreeModel::FileNode *getNodeById(int id) const;
|
||||
void addFileToTree(const ServerInfo_DeckStorage_TreeItem &file, RemoteDeckList_TreeModel::DirectoryNode *parent);
|
||||
void addFolderToTree(const ServerInfo_DeckStorage_TreeItem &folder,
|
||||
RemoteDeckList_TreeModel::DirectoryNode *parent);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ private:
|
|||
{
|
||||
}
|
||||
virtual ~Node() = default;
|
||||
QString getName() const
|
||||
[[nodiscard]] QString getName() const
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
|
@ -91,21 +91,22 @@ private slots:
|
|||
public:
|
||||
explicit RemoteReplayList_TreeModel(AbstractClient *_client, QObject *parent = nullptr);
|
||||
~RemoteReplayList_TreeModel() override;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex & /*parent*/ = QModelIndex()) const override
|
||||
[[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
[[nodiscard]] int columnCount(const QModelIndex & /*parent*/ = QModelIndex()) const override
|
||||
{
|
||||
return numberOfColumns;
|
||||
}
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
||||
QModelIndex parent(const QModelIndex &index) const override;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
[[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
|
||||
[[nodiscard]] QVariant
|
||||
headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
[[nodiscard]] QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
||||
[[nodiscard]] QModelIndex parent(const QModelIndex &index) const override;
|
||||
[[nodiscard]] Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
void clearTree();
|
||||
void refreshTree();
|
||||
ServerInfo_Replay const *getReplay(const QModelIndex &index) const;
|
||||
ServerInfo_ReplayMatch const *getReplayMatch(const QModelIndex &index) const;
|
||||
ServerInfo_ReplayMatch const *getEnclosingReplayMatch(const QModelIndex &index) const;
|
||||
[[nodiscard]] ServerInfo_Replay const *getReplay(const QModelIndex &index) const;
|
||||
[[nodiscard]] ServerInfo_ReplayMatch const *getReplayMatch(const QModelIndex &index) const;
|
||||
[[nodiscard]] ServerInfo_ReplayMatch const *getEnclosingReplayMatch(const QModelIndex &index) const;
|
||||
void addMatchInfo(const ServerInfo_ReplayMatch &matchInfo);
|
||||
void updateMatchInfo(int gameId, const ServerInfo_ReplayMatch &matchInfo);
|
||||
void removeMatchInfo(int gameId);
|
||||
|
|
@ -119,10 +120,10 @@ private:
|
|||
|
||||
public:
|
||||
explicit RemoteReplayList_TreeWidget(AbstractClient *_client, QWidget *parent = nullptr);
|
||||
ServerInfo_Replay const *getReplay(const QModelIndex &ind) const;
|
||||
ServerInfo_ReplayMatch const *getReplayMatch(const QModelIndex &ind) const;
|
||||
QList<ServerInfo_Replay const *> getSelectedReplays() const;
|
||||
QSet<ServerInfo_ReplayMatch const *> getSelectedReplayMatches() const;
|
||||
[[nodiscard]] ServerInfo_Replay const *getReplay(const QModelIndex &ind) const;
|
||||
[[nodiscard]] ServerInfo_ReplayMatch const *getReplayMatch(const QModelIndex &ind) const;
|
||||
[[nodiscard]] QList<ServerInfo_Replay const *> getSelectedReplays() const;
|
||||
[[nodiscard]] QSet<ServerInfo_ReplayMatch const *> getSelectedReplayMatches() const;
|
||||
void clearTree()
|
||||
{
|
||||
treeModel->clearTree();
|
||||
|
|
|
|||
|
|
@ -30,31 +30,31 @@ private:
|
|||
public:
|
||||
UserConnection_Information();
|
||||
UserConnection_Information(QString, QString, QString, QString, QString, bool, QString);
|
||||
QString getSaveName() const
|
||||
[[nodiscard]] QString getSaveName() const
|
||||
{
|
||||
return saveName;
|
||||
}
|
||||
QString getServer() const
|
||||
[[nodiscard]] QString getServer() const
|
||||
{
|
||||
return server;
|
||||
}
|
||||
QString getPort() const
|
||||
[[nodiscard]] QString getPort() const
|
||||
{
|
||||
return port;
|
||||
}
|
||||
QString getUsername() const
|
||||
[[nodiscard]] QString getUsername() const
|
||||
{
|
||||
return username;
|
||||
}
|
||||
QString getPassword() const
|
||||
[[nodiscard]] QString getPassword() const
|
||||
{
|
||||
return password;
|
||||
}
|
||||
bool getSavePassword() const
|
||||
[[nodiscard]] bool getSavePassword() const
|
||||
{
|
||||
return savePassword;
|
||||
}
|
||||
QString getSite() const
|
||||
[[nodiscard]] QString getSite() const
|
||||
{
|
||||
return site;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,11 +60,11 @@ public:
|
|||
return ignoredUsers;
|
||||
}
|
||||
|
||||
bool isOwnUserRegistered() const override;
|
||||
QString getOwnUsername() const override;
|
||||
bool isUserBuddy(const QString &userName) const override;
|
||||
bool isUserIgnored(const QString &userName) const override;
|
||||
const ServerInfo_User *getOnlineUser(const QString &userName) const override;
|
||||
[[nodiscard]] bool isOwnUserRegistered() const override;
|
||||
[[nodiscard]] QString getOwnUsername() const override;
|
||||
[[nodiscard]] bool isUserBuddy(const QString &userName) const override;
|
||||
[[nodiscard]] bool isUserIgnored(const QString &userName) const override;
|
||||
[[nodiscard]] const ServerInfo_User *getOnlineUser(const QString &userName) const override;
|
||||
|
||||
public slots:
|
||||
void handleConnect();
|
||||
|
|
|
|||
|
|
@ -45,13 +45,13 @@ private slots:
|
|||
|
||||
public:
|
||||
explicit BanDialog(const ServerInfo_User &info, QWidget *parent = nullptr);
|
||||
QString getBanName() const;
|
||||
QString getBanIP() const;
|
||||
QString getBanId() const;
|
||||
int getMinutes() const;
|
||||
QString getReason() const;
|
||||
QString getVisibleReason() const;
|
||||
int getDeleteMessages() const;
|
||||
[[nodiscard]] QString getBanName() const;
|
||||
[[nodiscard]] QString getBanIP() const;
|
||||
[[nodiscard]] QString getBanId() const;
|
||||
[[nodiscard]] int getMinutes() const;
|
||||
[[nodiscard]] QString getReason() const;
|
||||
[[nodiscard]] QString getVisibleReason() const;
|
||||
[[nodiscard]] int getDeleteMessages() const;
|
||||
};
|
||||
|
||||
class WarningDialog : public QDialog
|
||||
|
|
@ -68,10 +68,10 @@ private slots:
|
|||
|
||||
public:
|
||||
WarningDialog(const QString userName, const QString clientID, QWidget *parent = nullptr);
|
||||
QString getName() const;
|
||||
QString getWarnID() const;
|
||||
QString getReason() const;
|
||||
int getDeleteMessages() const;
|
||||
[[nodiscard]] QString getName() const;
|
||||
[[nodiscard]] QString getWarnID() const;
|
||||
[[nodiscard]] QString getReason() const;
|
||||
[[nodiscard]] int getDeleteMessages() const;
|
||||
void addWarningOption(const QString warning);
|
||||
};
|
||||
|
||||
|
|
@ -85,11 +85,11 @@ private:
|
|||
|
||||
public:
|
||||
explicit AdminNotesDialog(const QString &_userName, const QString &_notes, QWidget *_parent = nullptr);
|
||||
QString getName() const
|
||||
[[nodiscard]] QString getName() const
|
||||
{
|
||||
return userName;
|
||||
}
|
||||
QString getNotes() const;
|
||||
[[nodiscard]] QString getNotes() const;
|
||||
};
|
||||
|
||||
class UserListItemDelegate : public QStyledItemDelegate
|
||||
|
|
@ -159,7 +159,7 @@ public:
|
|||
void processUserInfo(const ServerInfo_User &user, bool online);
|
||||
bool deleteUser(const QString &userName);
|
||||
void setUserOnline(const QString &userName, bool online);
|
||||
const QMap<QString, UserListTWI *> &getUsers() const
|
||||
[[nodiscard]] const QMap<QString, UserListTWI *> &getUsers() const
|
||||
{
|
||||
return users;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue