mirror of
https://github.com/transmission/transmission.git
synced 2026-05-08 09:39:08 +01:00
refactor: fix modernize-use-nodiscard warnings by adding [[nodiscard]] (#7351)
This commit is contained in:
@@ -119,17 +119,17 @@ struct BasicHandler : public Handler
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr auto key(size_t i) const
|
[[nodiscard]] constexpr auto key(size_t i) const
|
||||||
{
|
{
|
||||||
return keys_[i];
|
return keys_[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr auto depth() const
|
[[nodiscard]] constexpr auto depth() const
|
||||||
{
|
{
|
||||||
return depth_;
|
return depth_;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr auto currentKey() const
|
[[nodiscard]] constexpr auto currentKey() const
|
||||||
{
|
{
|
||||||
return key(depth());
|
return key(depth());
|
||||||
}
|
}
|
||||||
@@ -225,7 +225,7 @@ struct ParserStack
|
|||||||
return depth > 0 && stack[depth].parent_type == ParentType::Dict && (stack[depth].n_children_walked % 2) == 0;
|
return depth > 0 && stack[depth].parent_type == ParentType::Dict && (stack[depth].n_children_walked % 2) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr std::optional<ParentType> parentType() const
|
[[nodiscard]] constexpr std::optional<ParentType> parentType() const
|
||||||
{
|
{
|
||||||
if (depth == 0)
|
if (depth == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
+4
-4
@@ -40,9 +40,9 @@ public:
|
|||||||
|
|
||||||
int set(QString const&);
|
int set(QString const&);
|
||||||
|
|
||||||
QByteArray toBase64() const;
|
[[nodiscard]] QByteArray toBase64() const;
|
||||||
QString readableName() const;
|
[[nodiscard]] QString readableName() const;
|
||||||
QString readableShortName() const;
|
[[nodiscard]] QString readableShortName() const;
|
||||||
|
|
||||||
void disposeSourceFile() const;
|
void disposeSourceFile() const;
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ public:
|
|||||||
disposal_ = disposal;
|
disposal_ = disposal;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr auto& fileDisposal() const noexcept
|
[[nodiscard]] constexpr auto& fileDisposal() const noexcept
|
||||||
{
|
{
|
||||||
return disposal_;
|
return disposal_;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ class DBusInteropHelper
|
|||||||
public:
|
public:
|
||||||
DBusInteropHelper() = default;
|
DBusInteropHelper() = default;
|
||||||
|
|
||||||
bool isConnected() const;
|
[[nodiscard]] bool isConnected() const;
|
||||||
|
|
||||||
QVariant addMetainfo(QString const& metainfo) const;
|
[[nodiscard]] QVariant addMetainfo(QString const& metainfo) const;
|
||||||
|
|
||||||
static void registerObject(QObject* parent);
|
static void registerObject(QObject* parent);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,6 +22,6 @@ public:
|
|||||||
FileTreeDelegate& operator=(FileTreeDelegate const&) = delete;
|
FileTreeDelegate& operator=(FileTreeDelegate const&) = delete;
|
||||||
|
|
||||||
// QAbstractItemDelegate
|
// QAbstractItemDelegate
|
||||||
QSize sizeHint(QStyleOptionViewItem const&, QModelIndex const&) const override;
|
[[nodiscard]] QSize sizeHint(QStyleOptionViewItem const&, QModelIndex const&) const override;
|
||||||
void paint(QPainter*, QStyleOptionViewItem const&, QModelIndex const&) const override;
|
void paint(QPainter*, QStyleOptionViewItem const&, QModelIndex const&) const override;
|
||||||
};
|
};
|
||||||
|
|||||||
+11
-11
@@ -67,16 +67,16 @@ public:
|
|||||||
void setWanted(QModelIndexList const& indices, bool wanted);
|
void setWanted(QModelIndexList const& indices, bool wanted);
|
||||||
void setPriority(QModelIndexList const& indices, int priority);
|
void setPriority(QModelIndexList const& indices, int priority);
|
||||||
|
|
||||||
QModelIndex parent(QModelIndex const& child, int column) const;
|
[[nodiscard]] QModelIndex parent(QModelIndex const& child, int column) const;
|
||||||
|
|
||||||
// QAbstractItemModel
|
// QAbstractItemModel
|
||||||
QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const override;
|
[[nodiscard]] QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const override;
|
||||||
Qt::ItemFlags flags(QModelIndex const& index) const override;
|
[[nodiscard]] Qt::ItemFlags flags(QModelIndex const& index) const override;
|
||||||
QVariant headerData(int column, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
[[nodiscard]] QVariant headerData(int column, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||||
QModelIndex index(int row, int column, QModelIndex const& parent = {}) const override;
|
[[nodiscard]] QModelIndex index(int row, int column, QModelIndex const& parent = {}) const override;
|
||||||
QModelIndex parent(QModelIndex const& child) const override;
|
[[nodiscard]] QModelIndex parent(QModelIndex const& child) const override;
|
||||||
int rowCount(QModelIndex const& parent = {}) const override;
|
[[nodiscard]] int rowCount(QModelIndex const& parent = {}) const override;
|
||||||
int columnCount(QModelIndex const& parent = {}) const override;
|
[[nodiscard]] int columnCount(QModelIndex const& parent = {}) const override;
|
||||||
bool setData(QModelIndex const& index, QVariant const& value, int role = Qt::EditRole) override;
|
bool setData(QModelIndex const& index, QVariant const& value, int role = Qt::EditRole) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@@ -94,9 +94,9 @@ private:
|
|||||||
int last_column,
|
int last_column,
|
||||||
std::set<QModelIndex>* visited_parent_indices = nullptr);
|
std::set<QModelIndex>* visited_parent_indices = nullptr);
|
||||||
void emitSubtreeChanged(QModelIndex const&, int first_column, int last_column);
|
void emitSubtreeChanged(QModelIndex const&, int first_column, int last_column);
|
||||||
FileTreeItem* findItemForFileIndex(int file_index) const;
|
[[nodiscard]] FileTreeItem* findItemForFileIndex(int file_index) const;
|
||||||
FileTreeItem* itemFromIndex(QModelIndex const&) const;
|
[[nodiscard]] FileTreeItem* itemFromIndex(QModelIndex const&) const;
|
||||||
QModelIndexList getOrphanIndices(QModelIndexList const& indices) const;
|
[[nodiscard]] QModelIndexList getOrphanIndices(QModelIndexList const& indices) const;
|
||||||
|
|
||||||
std::map<int, FileTreeItem*> index_cache_;
|
std::map<int, FileTreeItem*> index_cache_;
|
||||||
std::unique_ptr<FileTreeItem> root_item_;
|
std::unique_ptr<FileTreeItem> root_item_;
|
||||||
|
|||||||
+1
-1
@@ -63,7 +63,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void initContextMenu();
|
void initContextMenu();
|
||||||
QModelIndexList selectedSourceRows(int column = 0) const;
|
[[nodiscard]] QModelIndexList selectedSourceRows(int column = 0) const;
|
||||||
|
|
||||||
static Qt::CheckState getCumulativeCheckState(QModelIndexList const& indices);
|
static Qt::CheckState getCumulativeCheckState(QModelIndexList const& indices);
|
||||||
|
|
||||||
|
|||||||
@@ -26,13 +26,13 @@ public:
|
|||||||
FilterBarComboBox& operator=(FilterBarComboBox const&) = delete;
|
FilterBarComboBox& operator=(FilterBarComboBox const&) = delete;
|
||||||
|
|
||||||
// QWidget
|
// QWidget
|
||||||
QSize minimumSizeHint() const override;
|
[[nodiscard]] QSize minimumSizeHint() const override;
|
||||||
QSize sizeHint() const override;
|
[[nodiscard]] QSize sizeHint() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// QWidget
|
// QWidget
|
||||||
void paintEvent(QPaintEvent* e) override;
|
void paintEvent(QPaintEvent* e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSize calculateSize(QSize const& text_size, QSize const& count_size) const;
|
[[nodiscard]] QSize calculateSize(QSize const& text_size, QSize const& count_size) const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
// QAbstractItemDelegate
|
// QAbstractItemDelegate
|
||||||
void paint(QPainter*, QStyleOptionViewItem const&, QModelIndex const&) const override;
|
void paint(QPainter*, QStyleOptionViewItem const&, QModelIndex const&) const override;
|
||||||
QSize sizeHint(QStyleOptionViewItem const&, QModelIndex const&) const override;
|
[[nodiscard]] QSize sizeHint(QStyleOptionViewItem const&, QModelIndex const&) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QComboBox* const combo_ = {};
|
QComboBox* const combo_ = {};
|
||||||
|
|||||||
+2
-2
@@ -30,7 +30,7 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int mode() const
|
[[nodiscard]] int mode() const
|
||||||
{
|
{
|
||||||
return mode_;
|
return mode_;
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ public:
|
|||||||
|
|
||||||
static bool test(Torrent const& tor, int mode);
|
static bool test(Torrent const& tor, int mode);
|
||||||
|
|
||||||
bool test(Torrent const& tor) const
|
[[nodiscard]] bool test(Torrent const& tor) const
|
||||||
{
|
{
|
||||||
return test(tor, mode());
|
return test(tor, mode());
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ public:
|
|||||||
IconToolButton& operator=(IconToolButton const&) = delete;
|
IconToolButton& operator=(IconToolButton const&) = delete;
|
||||||
|
|
||||||
// QWidget
|
// QWidget
|
||||||
QSize sizeHint() const override;
|
[[nodiscard]] QSize sizeHint() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// QWidget
|
// QWidget
|
||||||
|
|||||||
+2
-2
@@ -17,9 +17,9 @@ class QString;
|
|||||||
class InteropHelper
|
class InteropHelper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool isConnected() const;
|
[[nodiscard]] bool isConnected() const;
|
||||||
|
|
||||||
bool addMetainfo(QString const& metainfo) const;
|
[[nodiscard]] bool addMetainfo(QString const& metainfo) const;
|
||||||
|
|
||||||
static void initialize();
|
static void initialize();
|
||||||
static void registerObject(QObject* parent);
|
static void registerObject(QObject* parent);
|
||||||
|
|||||||
+2
-2
@@ -31,6 +31,6 @@ public:
|
|||||||
InteropObject(InteropObject const&) = delete;
|
InteropObject(InteropObject const&) = delete;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool PresentWindow() const;
|
[[nodiscard]] bool PresentWindow() const;
|
||||||
bool AddMetainfo(QString const& metainfo) const;
|
[[nodiscard]] bool AddMetainfo(QString const& metainfo) const;
|
||||||
};
|
};
|
||||||
|
|||||||
+3
-3
@@ -124,9 +124,9 @@ private slots:
|
|||||||
void trayActivated(QSystemTrayIcon::ActivationReason);
|
void trayActivated(QSystemTrayIcon::ActivationReason);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QIcon addEmblem(QIcon icon, QStringList const& emblem_names) const;
|
[[nodiscard]] QIcon addEmblem(QIcon icon, QStringList const& emblem_names) const;
|
||||||
|
|
||||||
torrent_ids_t getSelectedTorrents(bool with_metadata_only = false) const;
|
[[nodiscard]] torrent_ids_t getSelectedTorrents(bool with_metadata_only = false) const;
|
||||||
void updateNetworkIcon();
|
void updateNetworkIcon();
|
||||||
|
|
||||||
QMenu* createOptionsMenu();
|
QMenu* createOptionsMenu();
|
||||||
@@ -194,7 +194,7 @@ private:
|
|||||||
size_t peers_sending = 0;
|
size_t peers_sending = 0;
|
||||||
size_t peers_receiving = 0;
|
size_t peers_receiving = 0;
|
||||||
};
|
};
|
||||||
TransferStats getTransferStats() const;
|
[[nodiscard]] TransferStats getTransferStats() const;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@ private slots:
|
|||||||
void onPieceSizeUpdated(int);
|
void onPieceSizeUpdated(int);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString getSource() const;
|
[[nodiscard]] QString getSource() const;
|
||||||
void updatePiecesLabel();
|
void updatePiecesLabel();
|
||||||
Session& session_;
|
Session& session_;
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -36,7 +36,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// QWidget
|
// QWidget
|
||||||
QSize sizeHint() const override;
|
[[nodiscard]] QSize sizeHint() const override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void pathChanged(QString const& path);
|
void pathChanged(QString const& path);
|
||||||
@@ -52,8 +52,8 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void updateAppearance();
|
void updateAppearance();
|
||||||
|
|
||||||
bool isDirMode() const;
|
[[nodiscard]] bool isDirMode() const;
|
||||||
QString effectiveTitle() const;
|
[[nodiscard]] QString effectiveTitle() const;
|
||||||
|
|
||||||
QString name_filter_;
|
QString name_filter_;
|
||||||
QString path_;
|
QString path_;
|
||||||
|
|||||||
+1
-1
@@ -59,7 +59,7 @@ using PeerList = std::vector<Peer>;
|
|||||||
|
|
||||||
struct TrackerStat
|
struct TrackerStat
|
||||||
{
|
{
|
||||||
QPixmap getFavicon() const;
|
[[nodiscard]] QPixmap getFavicon() const;
|
||||||
|
|
||||||
bool has_announced;
|
bool has_announced;
|
||||||
bool has_scraped;
|
bool has_scraped;
|
||||||
|
|||||||
+2
-2
@@ -40,8 +40,8 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// QSortFilterProxyModel
|
// QSortFilterProxyModel
|
||||||
bool filterAcceptsRow(int, QModelIndex const&) const override;
|
[[nodiscard]] bool filterAcceptsRow(int, QModelIndex const&) const override;
|
||||||
bool lessThan(QModelIndex const&, QModelIndex const&) const override;
|
[[nodiscard]] bool lessThan(QModelIndex const&, QModelIndex const&) const override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onPrefChanged(int key);
|
void onPrefChanged(int key);
|
||||||
|
|||||||
@@ -29,13 +29,13 @@ public:
|
|||||||
void setShowMore(bool b);
|
void setShowMore(bool b);
|
||||||
|
|
||||||
// QAbstractItemDelegate
|
// QAbstractItemDelegate
|
||||||
QSize sizeHint(QStyleOptionViewItem const& option, QModelIndex const& index) const override;
|
[[nodiscard]] QSize sizeHint(QStyleOptionViewItem const& option, QModelIndex const& index) const override;
|
||||||
void paint(QPainter* painter, QStyleOptionViewItem const& option, QModelIndex const& index) const override;
|
void paint(QPainter* painter, QStyleOptionViewItem const& option, QModelIndex const& index) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString getText(TrackerInfo const&) const;
|
[[nodiscard]] QString getText(TrackerInfo const&) const;
|
||||||
|
|
||||||
QSize sizeHint(QStyleOptionViewItem const&, TrackerInfo const&) const;
|
[[nodiscard]] QSize sizeHint(QStyleOptionViewItem const&, TrackerInfo const&) const;
|
||||||
void drawTracker(QPainter*, QStyleOptionViewItem const&, TrackerInfo const&) const;
|
void drawTracker(QPainter*, QStyleOptionViewItem const&, TrackerInfo const&) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
+3
-3
@@ -39,11 +39,11 @@ public:
|
|||||||
TrackerModel& operator=(TrackerModel const&) = delete;
|
TrackerModel& operator=(TrackerModel const&) = delete;
|
||||||
|
|
||||||
void refresh(TorrentModel const&, torrent_ids_t const& ids);
|
void refresh(TorrentModel const&, torrent_ids_t const& ids);
|
||||||
int find(int torrent_id, QString const& url) const;
|
[[nodiscard]] int find(int torrent_id, QString const& url) const;
|
||||||
|
|
||||||
// QAbstractItemModel
|
// QAbstractItemModel
|
||||||
int rowCount(QModelIndex const& parent = QModelIndex{}) const override;
|
[[nodiscard]] int rowCount(QModelIndex const& parent = QModelIndex{}) const override;
|
||||||
QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const override;
|
[[nodiscard]] QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using rows_t = std::vector<TrackerInfo>;
|
using rows_t = std::vector<TrackerInfo>;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// QSortFilterProxyModel
|
// QSortFilterProxyModel
|
||||||
bool filterAcceptsRow(int source_row, QModelIndex const& source_parent) const override;
|
[[nodiscard]] bool filterAcceptsRow(int source_row, QModelIndex const& source_parent) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool show_backups_ = {};
|
bool show_backups_ = {};
|
||||||
|
|||||||
+1
-1
@@ -44,7 +44,7 @@ private:
|
|||||||
Error
|
Error
|
||||||
};
|
};
|
||||||
|
|
||||||
AddResult metainfoTest(QString const& filename) const;
|
[[nodiscard]] AddResult metainfoTest(QString const& filename) const;
|
||||||
|
|
||||||
TorrentModel const& model_;
|
TorrentModel const& model_;
|
||||||
|
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ public:
|
|||||||
rimraf(sandbox_dir_);
|
rimraf(sandbox_dir_);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string const& path() const
|
[[nodiscard]] constexpr std::string const& path() const
|
||||||
{
|
{
|
||||||
return sandbox_dir_;
|
return sandbox_dir_;
|
||||||
}
|
}
|
||||||
@@ -183,12 +183,12 @@ private:
|
|||||||
class SandboxedTest : public ::testing::Test
|
class SandboxedTest : public ::testing::Test
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
std::string sandboxDir() const
|
[[nodiscard]] std::string sandboxDir() const
|
||||||
{
|
{
|
||||||
return sandbox_.path();
|
return sandbox_.path();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto currentTestName() const
|
[[nodiscard]] auto currentTestName() const
|
||||||
{
|
{
|
||||||
auto const* i = ::testing::UnitTest::GetInstance()->current_test_info();
|
auto const* i = ::testing::UnitTest::GetInstance()->current_test_info();
|
||||||
auto child = std::string(i->test_suite_name());
|
auto child = std::string(i->test_suite_name());
|
||||||
|
|||||||
Reference in New Issue
Block a user