mirror of
https://github.com/transmission/transmission
synced 2025-03-12 23:23:54 +00:00
refactor: fix modernize-use-nodiscard warnings by adding [[nodiscard]] (#7351)
This commit is contained in:
parent
de782e4315
commit
cbd65ae8b1
22 changed files with 55 additions and 55 deletions
|
@ -119,17 +119,17 @@ struct BasicHandler : public Handler
|
|||
return true;
|
||||
}
|
||||
|
||||
constexpr auto key(size_t i) const
|
||||
[[nodiscard]] constexpr auto key(size_t i) const
|
||||
{
|
||||
return keys_[i];
|
||||
}
|
||||
|
||||
constexpr auto depth() const
|
||||
[[nodiscard]] constexpr auto depth() const
|
||||
{
|
||||
return depth_;
|
||||
}
|
||||
|
||||
constexpr auto currentKey() const
|
||||
[[nodiscard]] constexpr auto currentKey() const
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
constexpr std::optional<ParentType> parentType() const
|
||||
[[nodiscard]] constexpr std::optional<ParentType> parentType() const
|
||||
{
|
||||
if (depth == 0)
|
||||
{
|
||||
|
|
|
@ -40,9 +40,9 @@ public:
|
|||
|
||||
int set(QString const&);
|
||||
|
||||
QByteArray toBase64() const;
|
||||
QString readableName() const;
|
||||
QString readableShortName() const;
|
||||
[[nodiscard]] QByteArray toBase64() const;
|
||||
[[nodiscard]] QString readableName() const;
|
||||
[[nodiscard]] QString readableShortName() const;
|
||||
|
||||
void disposeSourceFile() const;
|
||||
|
||||
|
@ -51,7 +51,7 @@ public:
|
|||
disposal_ = disposal;
|
||||
}
|
||||
|
||||
constexpr auto& fileDisposal() const noexcept
|
||||
[[nodiscard]] constexpr auto& fileDisposal() const noexcept
|
||||
{
|
||||
return disposal_;
|
||||
}
|
||||
|
|
|
@ -14,9 +14,9 @@ class DBusInteropHelper
|
|||
public:
|
||||
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);
|
||||
};
|
||||
|
|
|
@ -22,6 +22,6 @@ public:
|
|||
FileTreeDelegate& operator=(FileTreeDelegate const&) = delete;
|
||||
|
||||
// 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;
|
||||
};
|
||||
|
|
|
@ -67,16 +67,16 @@ public:
|
|||
void setWanted(QModelIndexList const& indices, bool wanted);
|
||||
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
|
||||
QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const override;
|
||||
Qt::ItemFlags flags(QModelIndex const& index) const override;
|
||||
QVariant headerData(int column, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
QModelIndex index(int row, int column, QModelIndex const& parent = {}) const override;
|
||||
QModelIndex parent(QModelIndex const& child) const override;
|
||||
int rowCount(QModelIndex const& parent = {}) const override;
|
||||
int columnCount(QModelIndex const& parent = {}) const override;
|
||||
[[nodiscard]] QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const override;
|
||||
[[nodiscard]] Qt::ItemFlags flags(QModelIndex const& index) const override;
|
||||
[[nodiscard]] QVariant headerData(int column, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
[[nodiscard]] QModelIndex index(int row, int column, QModelIndex const& parent = {}) const override;
|
||||
[[nodiscard]] QModelIndex parent(QModelIndex const& child) const override;
|
||||
[[nodiscard]] int rowCount(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;
|
||||
|
||||
signals:
|
||||
|
@ -94,9 +94,9 @@ private:
|
|||
int last_column,
|
||||
std::set<QModelIndex>* visited_parent_indices = nullptr);
|
||||
void emitSubtreeChanged(QModelIndex const&, int first_column, int last_column);
|
||||
FileTreeItem* findItemForFileIndex(int file_index) const;
|
||||
FileTreeItem* itemFromIndex(QModelIndex const&) const;
|
||||
QModelIndexList getOrphanIndices(QModelIndexList const& indices) const;
|
||||
[[nodiscard]] FileTreeItem* findItemForFileIndex(int file_index) const;
|
||||
[[nodiscard]] FileTreeItem* itemFromIndex(QModelIndex const&) const;
|
||||
[[nodiscard]] QModelIndexList getOrphanIndices(QModelIndexList const& indices) const;
|
||||
|
||||
std::map<int, FileTreeItem*> index_cache_;
|
||||
std::unique_ptr<FileTreeItem> root_item_;
|
||||
|
|
|
@ -63,7 +63,7 @@ private slots:
|
|||
|
||||
private:
|
||||
void initContextMenu();
|
||||
QModelIndexList selectedSourceRows(int column = 0) const;
|
||||
[[nodiscard]] QModelIndexList selectedSourceRows(int column = 0) const;
|
||||
|
||||
static Qt::CheckState getCumulativeCheckState(QModelIndexList const& indices);
|
||||
|
||||
|
|
|
@ -26,13 +26,13 @@ public:
|
|||
FilterBarComboBox& operator=(FilterBarComboBox const&) = delete;
|
||||
|
||||
// QWidget
|
||||
QSize minimumSizeHint() const override;
|
||||
QSize sizeHint() const override;
|
||||
[[nodiscard]] QSize minimumSizeHint() const override;
|
||||
[[nodiscard]] QSize sizeHint() const override;
|
||||
|
||||
protected:
|
||||
// QWidget
|
||||
void paintEvent(QPaintEvent* e) override;
|
||||
|
||||
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:
|
||||
// QAbstractItemDelegate
|
||||
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:
|
||||
QComboBox* const combo_ = {};
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
int mode() const
|
||||
[[nodiscard]] int mode() const
|
||||
{
|
||||
return mode_;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public:
|
|||
|
||||
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());
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
IconToolButton& operator=(IconToolButton const&) = delete;
|
||||
|
||||
// QWidget
|
||||
QSize sizeHint() const override;
|
||||
[[nodiscard]] QSize sizeHint() const override;
|
||||
|
||||
protected:
|
||||
// QWidget
|
||||
|
|
|
@ -17,9 +17,9 @@ class QString;
|
|||
class InteropHelper
|
||||
{
|
||||
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 registerObject(QObject* parent);
|
||||
|
|
|
@ -31,6 +31,6 @@ public:
|
|||
InteropObject(InteropObject const&) = delete;
|
||||
|
||||
public slots:
|
||||
bool PresentWindow() const;
|
||||
bool AddMetainfo(QString const& metainfo) const;
|
||||
[[nodiscard]] bool PresentWindow() const;
|
||||
[[nodiscard]] bool AddMetainfo(QString const& metainfo) const;
|
||||
};
|
||||
|
|
|
@ -124,9 +124,9 @@ private slots:
|
|||
void trayActivated(QSystemTrayIcon::ActivationReason);
|
||||
|
||||
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();
|
||||
|
||||
QMenu* createOptionsMenu();
|
||||
|
@ -194,7 +194,7 @@ private:
|
|||
size_t peers_sending = 0;
|
||||
size_t peers_receiving = 0;
|
||||
};
|
||||
TransferStats getTransferStats() const;
|
||||
[[nodiscard]] TransferStats getTransferStats() const;
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@ private slots:
|
|||
void onPieceSizeUpdated(int);
|
||||
|
||||
private:
|
||||
QString getSource() const;
|
||||
[[nodiscard]] QString getSource() const;
|
||||
void updatePiecesLabel();
|
||||
Session& session_;
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
}
|
||||
|
||||
// QWidget
|
||||
QSize sizeHint() const override;
|
||||
[[nodiscard]] QSize sizeHint() const override;
|
||||
|
||||
signals:
|
||||
void pathChanged(QString const& path);
|
||||
|
@ -52,8 +52,8 @@ private slots:
|
|||
private:
|
||||
void updateAppearance();
|
||||
|
||||
bool isDirMode() const;
|
||||
QString effectiveTitle() const;
|
||||
[[nodiscard]] bool isDirMode() const;
|
||||
[[nodiscard]] QString effectiveTitle() const;
|
||||
|
||||
QString name_filter_;
|
||||
QString path_;
|
||||
|
|
|
@ -59,7 +59,7 @@ using PeerList = std::vector<Peer>;
|
|||
|
||||
struct TrackerStat
|
||||
{
|
||||
QPixmap getFavicon() const;
|
||||
[[nodiscard]] QPixmap getFavicon() const;
|
||||
|
||||
bool has_announced;
|
||||
bool has_scraped;
|
||||
|
|
|
@ -40,8 +40,8 @@ public:
|
|||
|
||||
protected:
|
||||
// QSortFilterProxyModel
|
||||
bool filterAcceptsRow(int, QModelIndex const&) const override;
|
||||
bool lessThan(QModelIndex const&, QModelIndex const&) const override;
|
||||
[[nodiscard]] bool filterAcceptsRow(int, QModelIndex const&) const override;
|
||||
[[nodiscard]] bool lessThan(QModelIndex const&, QModelIndex const&) const override;
|
||||
|
||||
private slots:
|
||||
void onPrefChanged(int key);
|
||||
|
|
|
@ -29,13 +29,13 @@ public:
|
|||
void setShowMore(bool b);
|
||||
|
||||
// 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;
|
||||
|
||||
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;
|
||||
|
||||
private:
|
||||
|
|
|
@ -39,11 +39,11 @@ public:
|
|||
TrackerModel& operator=(TrackerModel const&) = delete;
|
||||
|
||||
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
|
||||
int rowCount(QModelIndex const& parent = QModelIndex{}) const override;
|
||||
QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const override;
|
||||
[[nodiscard]] int rowCount(QModelIndex const& parent = QModelIndex{}) const override;
|
||||
[[nodiscard]] QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
private:
|
||||
using rows_t = std::vector<TrackerInfo>;
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
|
||||
protected:
|
||||
// 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:
|
||||
bool show_backups_ = {};
|
||||
|
|
|
@ -44,7 +44,7 @@ private:
|
|||
Error
|
||||
};
|
||||
|
||||
AddResult metainfoTest(QString const& filename) const;
|
||||
[[nodiscard]] AddResult metainfoTest(QString const& filename) const;
|
||||
|
||||
TorrentModel const& model_;
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ public:
|
|||
rimraf(sandbox_dir_);
|
||||
}
|
||||
|
||||
std::string const& path() const
|
||||
[[nodiscard]] constexpr std::string const& path() const
|
||||
{
|
||||
return sandbox_dir_;
|
||||
}
|
||||
|
@ -183,12 +183,12 @@ private:
|
|||
class SandboxedTest : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
std::string sandboxDir() const
|
||||
[[nodiscard]] std::string sandboxDir() const
|
||||
{
|
||||
return sandbox_.path();
|
||||
}
|
||||
|
||||
auto currentTestName() const
|
||||
[[nodiscard]] auto currentTestName() const
|
||||
{
|
||||
auto const* i = ::testing::UnitTest::GetInstance()->current_test_info();
|
||||
auto child = std::string(i->test_suite_name());
|
||||
|
|
Loading…
Add table
Reference in a new issue