Cleanup: Address clang-tidy warnings in UI views

Unused header warning and `modernize-use-override` warnings.

I would like to selectively disable warnings about redundant `virtual` and
`override` keywords, since both together are useful (`override` enables
important compiler warnings that can avoid bugs, `virtual` helps quickly
identifying API functions available for overriding). But this doesn't
seem to be possible, only all of `modernize-use-override` can be
disabled, so simply keep the `virtual` but comment it out.
This commit is contained in:
Julian Eisel
2023-07-26 15:08:21 +02:00
parent 5846b9164a
commit add3ec71d2
2 changed files with 12 additions and 14 deletions

View File

@@ -44,7 +44,7 @@ class AbstractGridViewItem : public AbstractViewItem {
uiButViewItem *view_item_but_ = nullptr;
public:
virtual ~AbstractGridViewItem() = default;
/* virtual */ ~AbstractGridViewItem() override = default;
virtual void build_grid_tile(uiLayout &layout) const = 0;
@@ -54,7 +54,7 @@ class AbstractGridViewItem : public AbstractViewItem {
AbstractGridViewItem(StringRef identifier);
/** See AbstractViewItem::matches(). */
virtual bool matches(const AbstractViewItem &other) const override;
/* virtual */ bool matches(const AbstractViewItem &other) const override;
/** Called when the item's state changes from inactive to active. */
virtual void on_activate();
@@ -64,7 +64,7 @@ class AbstractGridViewItem : public AbstractViewItem {
*/
virtual std::optional<bool> should_be_active() const;
virtual std::unique_ptr<DropTargetInterface> create_item_drop_target() final;
/* virtual */ std::unique_ptr<DropTargetInterface> create_item_drop_target() final;
virtual std::unique_ptr<GridViewItemDropTarget> create_drop_target();
/**
@@ -111,7 +111,7 @@ class AbstractGridView : public AbstractView {
public:
AbstractGridView();
virtual ~AbstractGridView() = default;
/* virtual */ ~AbstractGridView() override = default;
using ItemIterFn = FunctionRef<void(AbstractGridViewItem &)>;
void foreach_item(ItemIterFn iter_fn) const;

View File

@@ -15,8 +15,6 @@
#include <memory>
#include <string>
#include "DNA_defs.h"
#include "BLI_function_ref.hh"
#include "BLI_math_vector_types.hh"
#include "BLI_vector.hh"
@@ -119,7 +117,7 @@ class AbstractTreeView : public AbstractView, public TreeViewItemContainer {
friend class TreeViewItemDropTarget;
public:
virtual ~AbstractTreeView() = default;
/* virtual */ ~AbstractTreeView() override = default;
void draw_overlays(const ARegion &region) const override;
@@ -186,11 +184,11 @@ class AbstractTreeViewItem : public AbstractViewItem, public TreeViewItemContain
std::string label_{};
public:
virtual ~AbstractTreeViewItem() = default;
/* virtual */ ~AbstractTreeViewItem() override = default;
virtual void build_row(uiLayout &row) = 0;
virtual std::unique_ptr<DropTargetInterface> create_item_drop_target() final;
std::unique_ptr<DropTargetInterface> create_item_drop_target() final;
virtual std::unique_ptr<TreeViewItemDropTarget> create_drop_target();
AbstractTreeView &get_tree_view() const;
@@ -222,9 +220,9 @@ class AbstractTreeViewItem : public AbstractViewItem, public TreeViewItemContain
virtual std::optional<bool> should_be_active() const;
/** See AbstractViewItem::get_rename_string(). */
virtual StringRef get_rename_string() const override;
/* virtual */ StringRef get_rename_string() const override;
/** See AbstractViewItem::rename(). */
virtual bool rename(StringRefNull new_name) override;
/* virtual */ bool rename(StringRefNull new_name) override;
/**
* Return whether the item can be collapsed. Used to disable collapsing for items with children.
@@ -233,10 +231,10 @@ class AbstractTreeViewItem : public AbstractViewItem, public TreeViewItemContain
virtual bool supports_collapsing() const;
/** See #AbstractViewItem::matches(). */
virtual bool matches(const AbstractViewItem &other) const override;
/* virtual */ bool matches(const AbstractViewItem &other) const override;
/** See #AbstractViewItem::update_from_old(). */
virtual void update_from_old(const AbstractViewItem &old) override;
/* virtual */ void update_from_old(const AbstractViewItem &old) override;
/**
* Compare this item to \a other to check if they represent the same data.
@@ -354,7 +352,7 @@ class TreeViewItemDropTarget : public DropTargetInterface {
TreeViewItemDropTarget(AbstractTreeView &view, DropBehavior behavior = DropBehavior::Insert);
std::optional<DropLocation> choose_drop_location(const ARegion &region,
const wmEvent &event) const;
const wmEvent &event) const override;
/** Request the view the item is registered for as type #ViewType. Throws a `std::bad_cast`
* exception if the view is not of the requested type. */