diff --git a/libcockatrice_interfaces/libcockatrice/interfaces/interface_card_set_priority_controller.h b/libcockatrice_interfaces/libcockatrice/interfaces/interface_card_set_priority_controller.h index 46a5897f7..b8fbbc74a 100644 --- a/libcockatrice_interfaces/libcockatrice/interfaces/interface_card_set_priority_controller.h +++ b/libcockatrice_interfaces/libcockatrice/interfaces/interface_card_set_priority_controller.h @@ -12,9 +12,9 @@ public: virtual void setEnabled(QString shortName, bool enabled) = 0; virtual void setIsKnown(QString shortName, bool isknown) = 0; - virtual unsigned int getSortKey(QString shortName) = 0; - virtual bool isEnabled(QString shortName) = 0; - virtual bool isKnown(QString shortName) = 0; + virtual unsigned int getSortKey(QString shortName) const = 0; + virtual bool isEnabled(QString shortName) const = 0; + virtual bool isKnown(QString shortName) const = 0; }; #endif // COCKATRICE_INTERFACE_CARD_SET_PRIORITY_CONTROLLER_H diff --git a/libcockatrice_interfaces/libcockatrice/interfaces/noop_card_set_priority_controller.h b/libcockatrice_interfaces/libcockatrice/interfaces/noop_card_set_priority_controller.h index 949ab5a91..e5027648c 100644 --- a/libcockatrice_interfaces/libcockatrice/interfaces/noop_card_set_priority_controller.h +++ b/libcockatrice_interfaces/libcockatrice/interfaces/noop_card_set_priority_controller.h @@ -16,15 +16,15 @@ public: { } - unsigned int getSortKey(QString /* shortName */) override + unsigned int getSortKey(QString /* shortName */) const override { return 0; } - bool isEnabled(QString /* shortName */) override + bool isEnabled(QString /* shortName */) const override { return true; } - bool isKnown(QString /* shortName */) override + bool isKnown(QString /* shortName */) const override { return true; } diff --git a/libcockatrice_settings/libcockatrice/settings/card_database_settings.cpp b/libcockatrice_settings/libcockatrice/settings/card_database_settings.cpp index 79738f1cd..26a91a4dd 100644 --- a/libcockatrice_settings/libcockatrice/settings/card_database_settings.cpp +++ b/libcockatrice_settings/libcockatrice/settings/card_database_settings.cpp @@ -20,17 +20,17 @@ void CardDatabaseSettings::setIsKnown(QString shortName, bool isknown) setValue(isknown, "isknown", "sets", std::move(shortName)); } -unsigned int CardDatabaseSettings::getSortKey(QString shortName) +unsigned int CardDatabaseSettings::getSortKey(QString shortName) const { return getValue("sortkey", "sets", std::move(shortName)).toUInt(); } -bool CardDatabaseSettings::isEnabled(QString shortName) +bool CardDatabaseSettings::isEnabled(QString shortName) const { return getValue("enabled", "sets", std::move(shortName)).toBool(); } -bool CardDatabaseSettings::isKnown(QString shortName) +bool CardDatabaseSettings::isKnown(QString shortName) const { return getValue("isknown", "sets", std::move(shortName)).toBool(); } diff --git a/libcockatrice_settings/libcockatrice/settings/card_database_settings.h b/libcockatrice_settings/libcockatrice/settings/card_database_settings.h index 9a176a99b..bb946ea80 100644 --- a/libcockatrice_settings/libcockatrice/settings/card_database_settings.h +++ b/libcockatrice_settings/libcockatrice/settings/card_database_settings.h @@ -22,9 +22,9 @@ public: void setEnabled(QString shortName, bool enabled) override; void setIsKnown(QString shortName, bool isknown) override; - unsigned int getSortKey(QString shortName) override; - bool isEnabled(QString shortName) override; - bool isKnown(QString shortName) override; + unsigned int getSortKey(QString shortName) const override; + bool isEnabled(QString shortName) const override; + bool isKnown(QString shortName) const override; private: explicit CardDatabaseSettings(const QString &settingPath, QObject *parent = nullptr); diff --git a/libcockatrice_settings/libcockatrice/settings/card_override_settings.cpp b/libcockatrice_settings/libcockatrice/settings/card_override_settings.cpp index 894358be6..a61a4693b 100644 --- a/libcockatrice_settings/libcockatrice/settings/card_override_settings.cpp +++ b/libcockatrice_settings/libcockatrice/settings/card_override_settings.cpp @@ -15,7 +15,7 @@ void CardOverrideSettings::deleteCardPreferenceOverride(const QString &cardName) deleteValue(cardName); } -QString CardOverrideSettings::getCardPreferenceOverride(const QString &cardName) +QString CardOverrideSettings::getCardPreferenceOverride(const QString &cardName) const { return getValue(cardName).toString(); } \ No newline at end of file diff --git a/libcockatrice_settings/libcockatrice/settings/card_override_settings.h b/libcockatrice_settings/libcockatrice/settings/card_override_settings.h index d5ee0287b..3d9db4e65 100644 --- a/libcockatrice_settings/libcockatrice/settings/card_override_settings.h +++ b/libcockatrice_settings/libcockatrice/settings/card_override_settings.h @@ -22,7 +22,7 @@ public: void deleteCardPreferenceOverride(const QString &cardName); - QString getCardPreferenceOverride(const QString &cardName); + QString getCardPreferenceOverride(const QString &cardName) const; private: explicit CardOverrideSettings(const QString &settingPath, QObject *parent = nullptr); diff --git a/libcockatrice_settings/libcockatrice/settings/debug_settings.cpp b/libcockatrice_settings/libcockatrice/settings/debug_settings.cpp index 084696dc1..5bf6eca30 100644 --- a/libcockatrice_settings/libcockatrice/settings/debug_settings.cpp +++ b/libcockatrice_settings/libcockatrice/settings/debug_settings.cpp @@ -11,22 +11,22 @@ DebugSettings::DebugSettings(const QString &settingPath, QObject *parent) } } -bool DebugSettings::getShowCardId() +bool DebugSettings::getShowCardId() const { return getValue("showCardId").toBool(); } -bool DebugSettings::getLocalGameOnStartup() +bool DebugSettings::getLocalGameOnStartup() const { return getValue("onStartup", "localgame").toBool(); } -int DebugSettings::getLocalGamePlayerCount() +int DebugSettings::getLocalGamePlayerCount() const { return getValue("playerCount", "localgame").toInt(); } -QString DebugSettings::getDeckPathForPlayer(const QString &playerName) +QString DebugSettings::getDeckPathForPlayer(const QString &playerName) const { return getValue(playerName, "localgame", "deck").toString(); } \ No newline at end of file diff --git a/libcockatrice_settings/libcockatrice/settings/debug_settings.h b/libcockatrice_settings/libcockatrice/settings/debug_settings.h index 2087b16b3..30cdd5fa5 100644 --- a/libcockatrice_settings/libcockatrice/settings/debug_settings.h +++ b/libcockatrice_settings/libcockatrice/settings/debug_settings.h @@ -17,12 +17,12 @@ class DebugSettings : public SettingsManager DebugSettings(const DebugSettings & /*other*/); public: - bool getShowCardId(); + bool getShowCardId() const; - bool getLocalGameOnStartup(); - int getLocalGamePlayerCount(); + bool getLocalGameOnStartup() const; + int getLocalGamePlayerCount() const; - QString getDeckPathForPlayer(const QString &playerName); + QString getDeckPathForPlayer(const QString &playerName) const; }; #endif // DEBUG_SETTINGS_H diff --git a/libcockatrice_settings/libcockatrice/settings/download_settings.cpp b/libcockatrice_settings/libcockatrice/settings/download_settings.cpp index ad4b81ec5..66525a598 100644 --- a/libcockatrice_settings/libcockatrice/settings/download_settings.cpp +++ b/libcockatrice_settings/libcockatrice/settings/download_settings.cpp @@ -18,7 +18,7 @@ void DownloadSettings::setDownloadUrls(const QStringList &downloadURLs) setValue(QVariant::fromValue(downloadURLs), "urls"); } -QStringList DownloadSettings::getAllURLs() +QStringList DownloadSettings::getAllURLs() const { return getValue("urls").toStringList(); } diff --git a/libcockatrice_settings/libcockatrice/settings/download_settings.h b/libcockatrice_settings/libcockatrice/settings/download_settings.h index ed3634ea1..b7442301e 100644 --- a/libcockatrice_settings/libcockatrice/settings/download_settings.h +++ b/libcockatrice_settings/libcockatrice/settings/download_settings.h @@ -19,7 +19,7 @@ class DownloadSettings : public SettingsManager public: explicit DownloadSettings(const QString &, QObject *); - QStringList getAllURLs(); + QStringList getAllURLs() const; void setDownloadUrls(const QStringList &downloadURLs); void resetToDefaultURLs(); }; diff --git a/libcockatrice_settings/libcockatrice/settings/game_filters_settings.cpp b/libcockatrice_settings/libcockatrice/settings/game_filters_settings.cpp index e5db3010d..4f5bf52ee 100644 --- a/libcockatrice_settings/libcockatrice/settings/game_filters_settings.cpp +++ b/libcockatrice_settings/libcockatrice/settings/game_filters_settings.cpp @@ -8,11 +8,11 @@ GameFiltersSettings::GameFiltersSettings(const QString &settingPath, QObject *pa { } -/* +/** * The game type might contain special characters, so to use it in * QSettings we just hash it. */ -QString GameFiltersSettings::hashGameType(const QString &gameType) const +static QString hashGameType(const QString &gameType) { return QCryptographicHash::hash(gameType.toUtf8(), QCryptographicHash::Md5).toHex(); } @@ -22,7 +22,7 @@ void GameFiltersSettings::setHideBuddiesOnlyGames(bool hide) setValue(hide, "hide_buddies_only_games"); } -bool GameFiltersSettings::isHideBuddiesOnlyGames() +bool GameFiltersSettings::isHideBuddiesOnlyGames() const { QVariant previous = getValue("hide_buddies_only_games"); return previous == QVariant() ? false : previous.toBool(); @@ -33,7 +33,7 @@ void GameFiltersSettings::setHideFullGames(bool hide) setValue(hide, "hide_full_games"); } -bool GameFiltersSettings::isHideFullGames() +bool GameFiltersSettings::isHideFullGames() const { QVariant previous = getValue("hide_full_games"); return previous == QVariant() ? false : previous.toBool(); @@ -44,7 +44,7 @@ void GameFiltersSettings::setHideGamesThatStarted(bool hide) setValue(hide, "hide_games_that_started"); } -bool GameFiltersSettings::isHideGamesThatStarted() +bool GameFiltersSettings::isHideGamesThatStarted() const { QVariant previous = getValue("hide_games_that_started"); return previous == QVariant() ? false : previous.toBool(); @@ -55,7 +55,7 @@ void GameFiltersSettings::setHidePasswordProtectedGames(bool hide) setValue(hide, "hide_password_protected_games"); } -bool GameFiltersSettings::isHidePasswordProtectedGames() +bool GameFiltersSettings::isHidePasswordProtectedGames() const { QVariant previous = getValue("hide_password_protected_games"); return previous == QVariant() ? false : previous.toBool(); @@ -66,7 +66,7 @@ void GameFiltersSettings::setHideIgnoredUserGames(bool hide) setValue(hide, "hide_ignored_user_games"); } -bool GameFiltersSettings::isHideIgnoredUserGames() +bool GameFiltersSettings::isHideIgnoredUserGames() const { QVariant previous = getValue("hide_ignored_user_games"); return previous == QVariant() ? true : previous.toBool(); @@ -77,7 +77,7 @@ void GameFiltersSettings::setHideNotBuddyCreatedGames(bool hide) setValue(hide, "hide_not_buddy_created_games"); } -bool GameFiltersSettings::isHideNotBuddyCreatedGames() +bool GameFiltersSettings::isHideNotBuddyCreatedGames() const { QVariant previous = getValue("hide_not_buddy_created_games"); return previous == QVariant() ? false : previous.toBool(); @@ -88,7 +88,7 @@ void GameFiltersSettings::setHideOpenDecklistGames(bool hide) setValue(hide, "hide_open_decklist_games"); } -bool GameFiltersSettings::isHideOpenDecklistGames() +bool GameFiltersSettings::isHideOpenDecklistGames() const { QVariant previous = getValue("hide_open_decklist_games"); return previous == QVariant() ? false : previous.toBool(); @@ -99,7 +99,7 @@ void GameFiltersSettings::setGameNameFilter(QString gameName) setValue(gameName, "game_name_filter"); } -QString GameFiltersSettings::getGameNameFilter() +QString GameFiltersSettings::getGameNameFilter() const { return getValue("game_name_filter").toString(); } @@ -109,7 +109,7 @@ void GameFiltersSettings::setCreatorNameFilters(QStringList creatorName) setValue(creatorName, "creator_name_filter"); } -QStringList GameFiltersSettings::getCreatorNameFilters() +QStringList GameFiltersSettings::getCreatorNameFilters() const { return getValue("creator_name_filter").toStringList(); } @@ -119,7 +119,7 @@ void GameFiltersSettings::setMinPlayers(int min) setValue(min, "min_players"); } -int GameFiltersSettings::getMinPlayers() +int GameFiltersSettings::getMinPlayers() const { QVariant previous = getValue("min_players"); return previous == QVariant() ? 1 : previous.toInt(); @@ -130,7 +130,7 @@ void GameFiltersSettings::setMaxPlayers(int max) setValue(max, "max_players"); } -int GameFiltersSettings::getMaxPlayers() +int GameFiltersSettings::getMaxPlayers() const { QVariant previous = getValue("max_players"); return previous == QVariant() ? 99 : previous.toInt(); @@ -141,7 +141,7 @@ void GameFiltersSettings::setMaxGameAge(const QTime &maxGameAge) setValue(maxGameAge, "max_game_age_time"); } -QTime GameFiltersSettings::getMaxGameAge() +QTime GameFiltersSettings::getMaxGameAge() const { QVariant previous = getValue("max_game_age_time"); return previous.toTime(); @@ -157,7 +157,7 @@ void GameFiltersSettings::setGameHashedTypeEnabled(QString gametypeHASHED, bool setValue(enabled, gametypeHASHED); } -bool GameFiltersSettings::isGameTypeEnabled(QString gametype) +bool GameFiltersSettings::isGameTypeEnabled(QString gametype) const { QVariant previous = getValue("game_type/" + hashGameType(gametype)); return previous == QVariant() ? false : previous.toBool(); @@ -168,7 +168,7 @@ void GameFiltersSettings::setShowOnlyIfSpectatorsCanWatch(bool show) setValue(show, "show_only_if_spectators_can_watch"); } -bool GameFiltersSettings::isShowOnlyIfSpectatorsCanWatch() +bool GameFiltersSettings::isShowOnlyIfSpectatorsCanWatch() const { QVariant previous = getValue("show_only_if_spectators_can_watch"); return previous == QVariant() ? false : previous.toBool(); @@ -179,7 +179,7 @@ void GameFiltersSettings::setShowSpectatorPasswordProtected(bool show) setValue(show, "show_spectator_password_protected"); } -bool GameFiltersSettings::isShowSpectatorPasswordProtected() +bool GameFiltersSettings::isShowSpectatorPasswordProtected() const { QVariant previous = getValue("show_spectator_password_protected"); return previous == QVariant() ? false : previous.toBool(); @@ -190,7 +190,7 @@ void GameFiltersSettings::setShowOnlyIfSpectatorsCanChat(bool show) setValue(show, "show_only_if_spectators_can_chat"); } -bool GameFiltersSettings::isShowOnlyIfSpectatorsCanChat() +bool GameFiltersSettings::isShowOnlyIfSpectatorsCanChat() const { QVariant previous = getValue("show_only_if_spectators_can_chat"); return previous == QVariant() ? false : previous.toBool(); @@ -201,7 +201,7 @@ void GameFiltersSettings::setShowOnlyIfSpectatorsCanSeeHands(bool show) setValue(show, "show_only_if_spectators_can_see_hands"); } -bool GameFiltersSettings::isShowOnlyIfSpectatorsCanSeeHands() +bool GameFiltersSettings::isShowOnlyIfSpectatorsCanSeeHands() const { QVariant previous = getValue("show_only_if_spectators_can_see_hands"); return previous == QVariant() ? false : previous.toBool(); diff --git a/libcockatrice_settings/libcockatrice/settings/game_filters_settings.h b/libcockatrice_settings/libcockatrice/settings/game_filters_settings.h index 45e9b7441..c0e60551a 100644 --- a/libcockatrice_settings/libcockatrice/settings/game_filters_settings.h +++ b/libcockatrice_settings/libcockatrice/settings/game_filters_settings.h @@ -16,23 +16,23 @@ class GameFiltersSettings : public SettingsManager friend class SettingsCache; public: - bool isHideBuddiesOnlyGames(); - bool isHideFullGames(); - bool isHideGamesThatStarted(); - bool isHidePasswordProtectedGames(); - bool isHideIgnoredUserGames(); - bool isHideNotBuddyCreatedGames(); - bool isHideOpenDecklistGames(); - QString getGameNameFilter(); - QStringList getCreatorNameFilters(); - int getMinPlayers(); - int getMaxPlayers(); - QTime getMaxGameAge(); - bool isGameTypeEnabled(QString gametype); - bool isShowOnlyIfSpectatorsCanWatch(); - bool isShowSpectatorPasswordProtected(); - bool isShowOnlyIfSpectatorsCanChat(); - bool isShowOnlyIfSpectatorsCanSeeHands(); + bool isHideBuddiesOnlyGames() const; + bool isHideFullGames() const; + bool isHideGamesThatStarted() const; + bool isHidePasswordProtectedGames() const; + bool isHideIgnoredUserGames() const; + bool isHideNotBuddyCreatedGames() const; + bool isHideOpenDecklistGames() const; + QString getGameNameFilter() const; + QStringList getCreatorNameFilters() const; + int getMinPlayers() const; + int getMaxPlayers() const; + QTime getMaxGameAge() const; + bool isGameTypeEnabled(QString gametype) const; + bool isShowOnlyIfSpectatorsCanWatch() const; + bool isShowSpectatorPasswordProtected() const; + bool isShowOnlyIfSpectatorsCanChat() const; + bool isShowOnlyIfSpectatorsCanSeeHands() const; void setHideBuddiesOnlyGames(bool hide); void setHideIgnoredUserGames(bool hide); @@ -56,8 +56,6 @@ public: private: explicit GameFiltersSettings(const QString &settingPath, QObject *parent = nullptr); GameFiltersSettings(const GameFiltersSettings & /*other*/); - - [[nodiscard]] QString hashGameType(const QString &gameType) const; }; #endif // GAMEFILTERSSETTINGS_H diff --git a/libcockatrice_settings/libcockatrice/settings/layouts_settings.cpp b/libcockatrice_settings/libcockatrice/settings/layouts_settings.cpp index f7704cbc7..e914dc2d8 100644 --- a/libcockatrice_settings/libcockatrice/settings/layouts_settings.cpp +++ b/libcockatrice_settings/libcockatrice/settings/layouts_settings.cpp @@ -23,12 +23,12 @@ void LayoutsSettings::setMainWindowGeometry(const QByteArray &value) setValue(value, GEOMETRY_PROP, GROUP_MAIN_WINDOW); } -QByteArray LayoutsSettings::getMainWindowGeometry() +QByteArray LayoutsSettings::getMainWindowGeometry() const { return getValue(GEOMETRY_PROP, GROUP_MAIN_WINDOW).toByteArray(); } -QByteArray LayoutsSettings::getDeckEditorLayoutState() +QByteArray LayoutsSettings::getDeckEditorLayoutState() const { return getValue(STATE_PROP, GROUP_DECK_EDITOR).toByteArray(); } @@ -38,7 +38,7 @@ void LayoutsSettings::setDeckEditorLayoutState(const QByteArray &value) setValue(value, STATE_PROP, GROUP_DECK_EDITOR); } -QByteArray LayoutsSettings::getDeckEditorGeometry() +QByteArray LayoutsSettings::getDeckEditorGeometry() const { return getValue(GEOMETRY_PROP, GROUP_DECK_EDITOR).toByteArray(); } @@ -48,7 +48,7 @@ void LayoutsSettings::setDeckEditorGeometry(const QByteArray &value) setValue(value, GEOMETRY_PROP, GROUP_DECK_EDITOR); } -QByteArray LayoutsSettings::getVisualDeckEditorLayoutState() +QByteArray LayoutsSettings::getVisualDeckEditorLayoutState() const { return getValue(STATE_PROP, GROUP_VISUAL_DECK_EDITOR).toByteArray(); } @@ -58,7 +58,7 @@ void LayoutsSettings::setVisualDeckEditorLayoutState(const QByteArray &value) setValue(value, STATE_PROP, GROUP_VISUAL_DECK_EDITOR); } -QByteArray LayoutsSettings::getVisualDeckEditorGeometry() +QByteArray LayoutsSettings::getVisualDeckEditorGeometry() const { return getValue(GEOMETRY_PROP, GROUP_VISUAL_DECK_EDITOR).toByteArray(); } @@ -68,7 +68,7 @@ void LayoutsSettings::setVisualDeckEditorGeometry(const QByteArray &value) setValue(value, GEOMETRY_PROP, GROUP_VISUAL_DECK_EDITOR); } -QByteArray LayoutsSettings::getDeckEditorDbHeaderState() +QByteArray LayoutsSettings::getDeckEditorDbHeaderState() const { return getValue(STATE_PROP, GROUP_DECK_EDITOR_DB, "header").toByteArray(); } @@ -78,7 +78,7 @@ void LayoutsSettings::setDeckEditorDbHeaderState(const QByteArray &value) setValue(value, STATE_PROP, GROUP_DECK_EDITOR_DB, "header"); } -QByteArray LayoutsSettings::getSetsDialogHeaderState() +QByteArray LayoutsSettings::getSetsDialogHeaderState() const { return getValue(STATE_PROP, GROUP_SETS_DIALOG, "header").toByteArray(); } @@ -93,7 +93,7 @@ void LayoutsSettings::setSetsDialogGeometry(const QByteArray &value) setValue(value, GEOMETRY_PROP, GROUP_SETS_DIALOG); } -QByteArray LayoutsSettings::getSetsDialogGeometry() +QByteArray LayoutsSettings::getSetsDialogGeometry() const { return getValue(GEOMETRY_PROP, GROUP_SETS_DIALOG).toByteArray(); } @@ -103,7 +103,7 @@ void LayoutsSettings::setTokenDialogGeometry(const QByteArray &value) setValue(value, GEOMETRY_PROP, GROUP_TOKEN_DIALOG); } -QByteArray LayoutsSettings::getTokenDialogGeometry() +QByteArray LayoutsSettings::getTokenDialogGeometry() const { return getValue(GEOMETRY_PROP, GROUP_TOKEN_DIALOG).toByteArray(); } @@ -118,12 +118,12 @@ void LayoutsSettings::setGamePlayAreaState(const QByteArray &value) setValue(value, STATE_PROP, GROUP_GAME_PLAY_AREA); } -QByteArray LayoutsSettings::getGamePlayAreaLayoutState() +QByteArray LayoutsSettings::getGamePlayAreaLayoutState() const { return getValue(STATE_PROP, GROUP_GAME_PLAY_AREA).toByteArray(); } -QByteArray LayoutsSettings::getGamePlayAreaGeometry() +QByteArray LayoutsSettings::getGamePlayAreaGeometry() const { return getValue(GEOMETRY_PROP, GROUP_GAME_PLAY_AREA).toByteArray(); } @@ -138,12 +138,12 @@ void LayoutsSettings::setReplayPlayAreaState(const QByteArray &value) setValue(value, STATE_PROP, GROUP_REPLAY_PLAY_AREA); } -QByteArray LayoutsSettings::getReplayPlayAreaLayoutState() +QByteArray LayoutsSettings::getReplayPlayAreaLayoutState() const { return getValue(STATE_PROP, GROUP_REPLAY_PLAY_AREA).toByteArray(); } -QByteArray LayoutsSettings::getReplayPlayAreaGeometry() +QByteArray LayoutsSettings::getReplayPlayAreaGeometry() const { return getValue(GEOMETRY_PROP, GROUP_REPLAY_PLAY_AREA).toByteArray(); } diff --git a/libcockatrice_settings/libcockatrice/settings/layouts_settings.h b/libcockatrice_settings/libcockatrice/settings/layouts_settings.h index cab9a456e..5353ce15a 100644 --- a/libcockatrice_settings/libcockatrice/settings/layouts_settings.h +++ b/libcockatrice_settings/libcockatrice/settings/layouts_settings.h @@ -36,24 +36,24 @@ public: void setReplayPlayAreaGeometry(const QByteArray &value); void setReplayPlayAreaState(const QByteArray &value); - QByteArray getMainWindowGeometry(); + QByteArray getMainWindowGeometry() const; - QByteArray getDeckEditorLayoutState(); - QByteArray getDeckEditorGeometry(); + QByteArray getDeckEditorLayoutState() const; + QByteArray getDeckEditorGeometry() const; - QByteArray getVisualDeckEditorLayoutState(); - QByteArray getVisualDeckEditorGeometry(); + QByteArray getVisualDeckEditorLayoutState() const; + QByteArray getVisualDeckEditorGeometry() const; - QByteArray getDeckEditorDbHeaderState(); - QByteArray getSetsDialogHeaderState(); - QByteArray getSetsDialogGeometry(); - QByteArray getTokenDialogGeometry(); + QByteArray getDeckEditorDbHeaderState() const; + QByteArray getSetsDialogHeaderState() const; + QByteArray getSetsDialogGeometry() const; + QByteArray getTokenDialogGeometry() const; - QByteArray getGamePlayAreaLayoutState(); - QByteArray getGamePlayAreaGeometry(); + QByteArray getGamePlayAreaLayoutState() const; + QByteArray getGamePlayAreaGeometry() const; - QByteArray getReplayPlayAreaLayoutState(); - QByteArray getReplayPlayAreaGeometry(); + QByteArray getReplayPlayAreaLayoutState() const; + QByteArray getReplayPlayAreaGeometry() const; signals: public slots: diff --git a/libcockatrice_settings/libcockatrice/settings/message_settings.cpp b/libcockatrice_settings/libcockatrice/settings/message_settings.cpp index 761c94484..50da39df6 100644 --- a/libcockatrice_settings/libcockatrice/settings/message_settings.cpp +++ b/libcockatrice_settings/libcockatrice/settings/message_settings.cpp @@ -5,12 +5,12 @@ MessageSettings::MessageSettings(const QString &settingPath, QObject *parent) { } -QString MessageSettings::getMessageAt(int index) +QString MessageSettings::getMessageAt(int index) const { return getValue(QString("msg%1").arg(index)).toString(); } -int MessageSettings::getCount() +int MessageSettings::getCount() const { return getValue("count").toInt(); } diff --git a/libcockatrice_settings/libcockatrice/settings/message_settings.h b/libcockatrice_settings/libcockatrice/settings/message_settings.h index 265c455e1..ec70027af 100644 --- a/libcockatrice_settings/libcockatrice/settings/message_settings.h +++ b/libcockatrice_settings/libcockatrice/settings/message_settings.h @@ -15,8 +15,8 @@ class MessageSettings : public SettingsManager friend class SettingsCache; public: - int getCount(); - QString getMessageAt(int index); + int getCount() const; + QString getMessageAt(int index) const; void setCount(int count); void setMessageAt(int index, QString message); diff --git a/libcockatrice_settings/libcockatrice/settings/recents_settings.cpp b/libcockatrice_settings/libcockatrice/settings/recents_settings.cpp index e64dd7494..76bc4069e 100644 --- a/libcockatrice_settings/libcockatrice/settings/recents_settings.cpp +++ b/libcockatrice_settings/libcockatrice/settings/recents_settings.cpp @@ -7,7 +7,7 @@ RecentsSettings::RecentsSettings(const QString &settingPath, QObject *parent) { } -QStringList RecentsSettings::getRecentlyOpenedDeckPaths() +QStringList RecentsSettings::getRecentlyOpenedDeckPaths() const { return getValue("deckpaths").toStringList(); } @@ -31,7 +31,7 @@ void RecentsSettings::updateRecentlyOpenedDeckPaths(const QString &deckPath) emit recentlyOpenedDeckPathsChanged(); } -QString RecentsSettings::getLatestDeckDirPath() +QString RecentsSettings::getLatestDeckDirPath() const { return getValue("latestDeckDir", "dirs").toString(); } diff --git a/libcockatrice_settings/libcockatrice/settings/recents_settings.h b/libcockatrice_settings/libcockatrice/settings/recents_settings.h index 23c8f1a9f..3aebff334 100644 --- a/libcockatrice_settings/libcockatrice/settings/recents_settings.h +++ b/libcockatrice_settings/libcockatrice/settings/recents_settings.h @@ -18,11 +18,11 @@ class RecentsSettings : public SettingsManager RecentsSettings(const RecentsSettings & /*other*/); public: - QStringList getRecentlyOpenedDeckPaths(); + QStringList getRecentlyOpenedDeckPaths() const; void clearRecentlyOpenedDeckPaths(); void updateRecentlyOpenedDeckPaths(const QString &deckPath); - QString getLatestDeckDirPath(); + QString getLatestDeckDirPath() const; void setLatestDeckDirPath(const QString &dirPath); signals: diff --git a/libcockatrice_settings/libcockatrice/settings/servers_settings.cpp b/libcockatrice_settings/libcockatrice/settings/servers_settings.cpp index 5f69f47c9..0140182be 100644 --- a/libcockatrice_settings/libcockatrice/settings/servers_settings.cpp +++ b/libcockatrice_settings/libcockatrice/settings/servers_settings.cpp @@ -13,7 +13,7 @@ void ServersSettings::setPreviousHostLogin(int previous) setValue(previous, "previoushostlogin"); } -int ServersSettings::getPreviousHostLogin() +int ServersSettings::getPreviousHostLogin() const { QVariant previous = getValue("previoushostlogin"); return previous == QVariant() ? 1 : previous.toInt(); @@ -24,7 +24,7 @@ void ServersSettings::setPreviousHostList(QStringList list) setValue(list, "previoushosts"); } -QStringList ServersSettings::getPreviousHostList() +QStringList ServersSettings::getPreviousHostList() const { return getValue("previoushosts").toStringList(); } @@ -48,13 +48,13 @@ QString ServersSettings::getSite(QString defaultSite) return site == QVariant() ? std::move(defaultSite) : site.toString(); } -QString ServersSettings::getPrevioushostName() +QString ServersSettings::getPrevioushostName() const { QVariant value = getValue("previoushostName"); return value == QVariant() ? "Rooster Ranges" : value.toString(); } -int ServersSettings::getPrevioushostindex(const QString &saveName) +int ServersSettings::getPrevioushostindex(const QString &saveName) const { int size = getValue("totalServers", "server", "server_details").toInt(); @@ -65,14 +65,14 @@ int ServersSettings::getPrevioushostindex(const QString &saveName) return -1; } -QString ServersSettings::getHostname(QString defaultHost) +QString ServersSettings::getHostname(QString defaultHost) const { int index = getPrevioushostindex(getPrevioushostName()); QVariant hostname = getValue(QString("server%1").arg(index), "server", "server_details"); return hostname == QVariant() ? std::move(defaultHost) : hostname.toString(); } -QString ServersSettings::getPort(QString defaultPort) +QString ServersSettings::getPort(QString defaultPort) const { int index = getPrevioushostindex(getPrevioushostName()); QVariant port = getValue(QString("port%1").arg(index), "server", "server_details"); @@ -80,7 +80,7 @@ QString ServersSettings::getPort(QString defaultPort) return port == QVariant() ? std::move(defaultPort) : port.toString(); } -QString ServersSettings::getPlayerName(QString defaultName) +QString ServersSettings::getPlayerName(QString defaultName) const { int index = getPrevioushostindex(getPrevioushostName()); QVariant name = getValue(QString("username%1").arg(index), "server", "server_details"); @@ -98,7 +98,7 @@ QString ServersSettings::getPassword() return QString(); } -bool ServersSettings::getSavePassword() +bool ServersSettings::getSavePassword() const { int index = getPrevioushostindex(getPrevioushostName()); bool save = getValue(QString("savePassword%1").arg(index), "server", "server_details").toBool(); @@ -110,7 +110,7 @@ void ServersSettings::setAutoConnect(int autoconnect) setValue(autoconnect, "auto_connect"); } -int ServersSettings::getAutoConnect() +int ServersSettings::getAutoConnect() const { QVariant autoconnect = getValue("auto_connect"); return autoconnect == QVariant() ? 0 : autoconnect.toInt(); @@ -121,7 +121,7 @@ void ServersSettings::setFPHostName(QString hostname) setValue(hostname, "fphostname"); } -QString ServersSettings::getFPHostname(QString defaultHost) +QString ServersSettings::getFPHostname(QString defaultHost) const { QVariant hostname = getValue("fphostname"); return hostname == QVariant() ? std::move(defaultHost) : hostname.toString(); @@ -132,7 +132,7 @@ void ServersSettings::setFPPort(QString port) setValue(port, "fpport"); } -QString ServersSettings::getFPPort(QString defaultPort) +QString ServersSettings::getFPPort(QString defaultPort) const { QVariant port = getValue("fpport"); return port == QVariant() ? std::move(defaultPort) : port.toString(); @@ -143,7 +143,7 @@ void ServersSettings::setFPPlayerName(QString playerName) setValue(playerName, "fpplayername"); } -QString ServersSettings::getFPPlayerName(QString defaultName) +QString ServersSettings::getFPPlayerName(QString defaultName) const { QVariant name = getValue("fpplayername"); return name == QVariant() ? std::move(defaultName) : name.toString(); @@ -154,7 +154,7 @@ void ServersSettings::setClearDebugLogStatus(bool abIsChecked) setValue(abIsChecked, "save_debug_log"); } -bool ServersSettings::getClearDebugLogStatus(bool abDefaultValue) +bool ServersSettings::getClearDebugLogStatus(bool abDefaultValue) const { QVariant cbFlushLog = getValue("save_debug_log"); return cbFlushLog == QVariant() ? abDefaultValue : cbFlushLog.toBool(); diff --git a/libcockatrice_settings/libcockatrice/settings/servers_settings.h b/libcockatrice_settings/libcockatrice/settings/servers_settings.h index 4d92c4647..22603a356 100644 --- a/libcockatrice_settings/libcockatrice/settings/servers_settings.h +++ b/libcockatrice_settings/libcockatrice/settings/servers_settings.h @@ -22,21 +22,21 @@ class ServersSettings : public SettingsManager friend class SettingsCache; public: - int getPreviousHostLogin(); - int getPrevioushostindex(const QString &); - QStringList getPreviousHostList(); - QString getPrevioushostName(); - QString getHostname(QString defaultHost = SERVERSETTINGS_DEFAULT_HOST); - QString getPort(QString defaultPort = SERVERSETTINGS_DEFAULT_PORT); - QString getPlayerName(QString defaultName = ""); - QString getFPHostname(QString defaultHost = SERVERSETTINGS_DEFAULT_HOST); - QString getFPPort(QString defaultPort = SERVERSETTINGS_DEFAULT_PORT); - QString getFPPlayerName(QString defaultName = ""); + int getPreviousHostLogin() const; + int getPrevioushostindex(const QString &) const; + QStringList getPreviousHostList() const; + QString getPrevioushostName() const; + QString getHostname(QString defaultHost = SERVERSETTINGS_DEFAULT_HOST) const; + QString getPort(QString defaultPort = SERVERSETTINGS_DEFAULT_PORT) const; + QString getPlayerName(QString defaultName = "") const; + QString getFPHostname(QString defaultHost = SERVERSETTINGS_DEFAULT_HOST) const; + QString getFPPort(QString defaultPort = SERVERSETTINGS_DEFAULT_PORT) const; + QString getFPPlayerName(QString defaultName = "") const; QString getPassword(); QString getSaveName(QString defaultname = ""); QString getSite(QString defaultName = ""); - bool getSavePassword(); - int getAutoConnect(); + bool getSavePassword() const; + int getAutoConnect() const; void setPreviousHostLogin(int previous); void setPrevioushostName(const QString &); @@ -67,7 +67,7 @@ public: QString port = QString(), QString site = QString()); void setClearDebugLogStatus(bool abIsChecked); - bool getClearDebugLogStatus(bool abDefaultValue); + bool getClearDebugLogStatus(bool abDefaultValue) const; private: explicit ServersSettings(const QString &settingPath, QObject *parent = nullptr); diff --git a/libcockatrice_settings/libcockatrice/settings/settings_manager.cpp b/libcockatrice_settings/libcockatrice/settings/settings_manager.cpp index 3f3deb638..2d4f1c441 100644 --- a/libcockatrice_settings/libcockatrice/settings/settings_manager.cpp +++ b/libcockatrice_settings/libcockatrice/settings/settings_manager.cpp @@ -108,7 +108,7 @@ void SettingsManager::deleteValue(const QString &name, const QString &group, con } } -QVariant SettingsManager::getValue(const QString &name) +QVariant SettingsManager::getValue(const QString &name) const { auto settings = getSettings(); @@ -133,7 +133,7 @@ QVariant SettingsManager::getValue(const QString &name) return value; } -QVariant SettingsManager::getValue(const QString &name, const QString &group, const QString &subGroup) +QVariant SettingsManager::getValue(const QString &name, const QString &group, const QString &subGroup) const { auto settings = getSettings(); diff --git a/libcockatrice_settings/libcockatrice/settings/settings_manager.h b/libcockatrice_settings/libcockatrice/settings/settings_manager.h index 18abb8dbf..ad828f089 100644 --- a/libcockatrice_settings/libcockatrice/settings/settings_manager.h +++ b/libcockatrice_settings/libcockatrice/settings/settings_manager.h @@ -19,8 +19,8 @@ public: const QString &defaultGroup = QString(), const QString &defaultSubGroup = QString(), QObject *parent = nullptr); - QVariant getValue(const QString &name); - QVariant getValue(const QString &name, const QString &group, const QString &subGroup = QString()); + QVariant getValue(const QString &name) const; + QVariant getValue(const QString &name, const QString &group, const QString &subGroup = QString()) const; void sync(); protected: