Skip to content

Commit

Permalink
Gui: [skip ci] fix some clang-tidy warnings:
Browse files Browse the repository at this point in the history
* cppcoreguidelines-special-member-functions
* cppcoreguidelines-explicit-virtual-functions
* readability-inconsistent-declaration-parameter-name
  • Loading branch information
wwmayer committed Nov 13, 2022
1 parent 951ea0a commit bbb3697
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 43 deletions.
31 changes: 19 additions & 12 deletions src/Gui/Action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,20 +217,20 @@ void Action::setToolTip(const QString & text, const QString & title)
_pcCmd));
}

QString Action::cleanTitle(const QString & text)
QString Action::cleanTitle(const QString & title)
{
QString title(text);
QString text(title);
// Deal with QAction title mnemonic
static QRegularExpression re(QStringLiteral("&(.)"));
title.replace(re, QStringLiteral("\\1"));
text.replace(re, QStringLiteral("\\1"));

// Probably not a good idea to trim ending punctuation
#if 0
// Trim line ending punctuation
static QRegularExpression rePunct(QStringLiteral("[[:punct:]]+$"));
title.replace(rePunct, QString());
text.replace(rePunct, QString());
#endif
return title;
return text;
}

QString Action::commandToolTip(const Command *cmd, bool richFormat)
Expand Down Expand Up @@ -286,8 +286,8 @@ QString Action::commandMenuText(const Command *cmd)
QString Action::createToolTip(QString helpText,
const QString & title,
const QFont &font,
const QString &sc,
const Command *pcCmd)
const QString &shortCut,
const Command *command)
{
QString text = cleanTitle(title);

Expand All @@ -302,7 +302,7 @@ QString Action::createToolTip(QString helpText,
// a rich text tooltip but the width is too short. We can escape the auto
// wrappin using <p style='white-space:pre'>.

QString shortcut = sc;
QString shortcut = shortCut;
if (shortcut.size() && helpText.endsWith(shortcut))
helpText.resize(helpText.size() - shortcut.size());
if (shortcut.size())
Expand All @@ -313,10 +313,10 @@ QString Action::createToolTip(QString helpText,
text.toHtmlEscaped(), shortcut.toHtmlEscaped());

QString cmdName;
if (pcCmd && pcCmd->getName()) {
cmdName = QString::fromLatin1(pcCmd->getName());
if (auto groupcmd = dynamic_cast<const GroupCommand*>(pcCmd)) {
if (auto act = pcCmd->getAction()) {
if (command && command->getName()) {
cmdName = QString::fromLatin1(command->getName());
if (auto groupcmd = dynamic_cast<const GroupCommand*>(command)) {
if (auto act = command->getAction()) {
int idx = act->property("defaultAction").toInt();
auto cmd = groupcmd->getCommand(idx);
if (cmd && cmd->getName()) {
Expand Down Expand Up @@ -571,6 +571,8 @@ class WorkbenchActionEvent : public QEvent
{ return act; }
private:
QAction* act;

Q_DISABLE_COPY(WorkbenchActionEvent)
};
}

Expand Down Expand Up @@ -862,6 +864,11 @@ void WorkbenchGroup::slotRemoveWorkbench(const char* name)
class RecentFilesAction::Private: public ParameterGrp::ObserverType
{
public:
Private(const Private&) = delete;
Private(Private&&) = delete;
void operator= (const Private&) = delete;
void operator= (Private&&) = delete;

Private(RecentFilesAction *master, const char *path):master(master)
{
handle = App::GetApplication().GetParameterGroupByPath(path);
Expand Down
86 changes: 55 additions & 31 deletions src/Gui/Action.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class GuiExport Action : public QObject
explicit Action (Command* pcCmd, QObject * parent = nullptr);
/// Action takes ownership of the 'action' object.
Action (Command* pcCmd, QAction* action, QObject * parent);
virtual ~Action();
~Action() override;

virtual void addTo (QWidget * widget);
virtual void setEnabled(bool);
Expand Down Expand Up @@ -80,8 +80,8 @@ class GuiExport Action : public QObject
static QString createToolTip(QString helpText,
const QString &title,
const QFont &font,
const QString &shortcut,
const Command *cmd = nullptr);
const QString &shortCut,
const Command *command = nullptr);

/** Obtain tool tip of a given command
* @param cmd: input command
Expand Down Expand Up @@ -113,6 +113,9 @@ public Q_SLOTS:
QString _tooltip;
QString _title;
QMetaObject::Connection _connection;

private:
Q_DISABLE_COPY(Action)
};

// --------------------------------------------------------------------
Expand All @@ -130,14 +133,14 @@ class GuiExport ActionGroup : public Action

public:
explicit ActionGroup (Command* pcCmd, QObject * parent = nullptr);
virtual ~ActionGroup();
~ActionGroup() override;

void addTo (QWidget * widget);
void setEnabled (bool);
void addTo (QWidget * widget) override;
void setEnabled (bool) override;
void setDisabled (bool);
void setExclusive (bool);
bool isExclusive() const;
void setVisible (bool);
void setVisible (bool) override;
void setIsMode(bool check) { _isMode = check; }

void setDropDownMenu(bool check) { _dropDown = check; }
Expand All @@ -148,8 +151,8 @@ class GuiExport ActionGroup : public Action
void setCheckedAction(int);

public Q_SLOTS:
void onActivated ();
void onToggled(bool);
void onActivated () override;
void onToggled(bool) override;
void onActivated (QAction*);
void onHovered (QAction*);

Expand All @@ -159,6 +162,9 @@ public Q_SLOTS:
bool _external;
bool _toggle;
bool _isMode;

private:
Q_DISABLE_COPY(ActionGroup)
};

// --------------------------------------------------------------------
Expand All @@ -170,8 +176,8 @@ class GuiExport WorkbenchComboBox : public QComboBox

public:
explicit WorkbenchComboBox(WorkbenchGroup* wb, QWidget* parent=nullptr);
virtual ~WorkbenchComboBox();
void showPopup();
~WorkbenchComboBox() override;
void showPopup() override;

public Q_SLOTS:
void onActivated(int);
Expand All @@ -181,10 +187,12 @@ protected Q_SLOTS:
void onWorkbenchActivated(const QString&);

protected:
void actionEvent (QActionEvent*);
void actionEvent (QActionEvent*) override;

private:
WorkbenchGroup* group;

Q_DISABLE_COPY(WorkbenchComboBox)
};

/**
Expand All @@ -202,19 +210,21 @@ class GuiExport WorkbenchGroup : public ActionGroup
* when it gets activated.
*/
WorkbenchGroup (Command* pcCmd, QObject * parent);
virtual ~WorkbenchGroup();
void addTo (QWidget * widget);
~WorkbenchGroup() override;
void addTo (QWidget * widget) override;
void refreshWorkbenchList();

void slotActivateWorkbench(const char*);
void slotAddWorkbench(const char*);
void slotRemoveWorkbench(const char*);

protected:
void customEvent(QEvent* event);
void customEvent(QEvent* event) override;

private:
void setWorkbenchData(int index, const QString& wb);

Q_DISABLE_COPY(WorkbenchGroup)
};

// --------------------------------------------------------------------
Expand All @@ -229,7 +239,7 @@ class GuiExport RecentFilesAction : public ActionGroup

public:
explicit RecentFilesAction (Command* pcCmd, QObject * parent = nullptr);
virtual ~RecentFilesAction();
~RecentFilesAction() override;

void appendFile(const QString&);
void activateFile(int);
Expand All @@ -248,6 +258,8 @@ class GuiExport RecentFilesAction : public ActionGroup
class Private;
friend class Private;
std::unique_ptr<Private> _pimpl;

Q_DISABLE_COPY(RecentFilesAction)
};

// --------------------------------------------------------------------
Expand All @@ -262,7 +274,7 @@ class GuiExport RecentMacrosAction : public ActionGroup

public:
explicit RecentMacrosAction (Command* pcCmd, QObject * parent = nullptr);
virtual ~RecentMacrosAction();
~RecentMacrosAction() override;

void appendFile(const QString&);
void activateFile(int);
Expand All @@ -279,6 +291,8 @@ class GuiExport RecentMacrosAction : public ActionGroup
int maximumItems; /**< Number of maximum items */
std::string shortcut_modifiers; /**< default = "Ctrl+Shift+" */
int shortcut_count; /**< Number of dynamic shortcuts to create -- default = 3*/

Q_DISABLE_COPY(RecentMacrosAction)
};


Expand All @@ -295,16 +309,18 @@ class GuiExport UndoAction : public Action

public:
explicit UndoAction (Command* pcCmd,QObject * parent = nullptr);
~UndoAction();
void addTo (QWidget * widget);
void setEnabled(bool);
void setVisible(bool);
~UndoAction() override;
void addTo (QWidget * widget) override;
void setEnabled(bool) override;
void setVisible(bool) override;

private Q_SLOTS:
void actionChanged();

private:
QAction* _toolAction;

Q_DISABLE_COPY(UndoAction)
};

// --------------------------------------------------------------------
Expand All @@ -320,16 +336,18 @@ class GuiExport RedoAction : public Action

public:
explicit RedoAction (Command* pcCmd,QObject * parent = nullptr);
~RedoAction();
void addTo ( QWidget * widget );
void setEnabled(bool);
void setVisible(bool);
~RedoAction() override;
void addTo ( QWidget * widget ) override;
void setEnabled(bool) override;
void setVisible(bool) override;

private Q_SLOTS:
void actionChanged();

private:
QAction* _toolAction;

Q_DISABLE_COPY(RedoAction)
};

// --------------------------------------------------------------------
Expand All @@ -344,11 +362,13 @@ class GuiExport DockWidgetAction : public Action

public:
explicit DockWidgetAction (Command* pcCmd, QObject * parent = nullptr);
virtual ~DockWidgetAction();
void addTo (QWidget * widget);
~DockWidgetAction() override;
void addTo (QWidget * widget) override;

private:
QMenu* _menu;

Q_DISABLE_COPY(DockWidgetAction)
};

// --------------------------------------------------------------------
Expand All @@ -363,11 +383,13 @@ class GuiExport ToolBarAction : public Action

public:
explicit ToolBarAction (Command* pcCmd, QObject * parent = nullptr);
virtual ~ToolBarAction();
void addTo (QWidget * widget);
~ToolBarAction() override;
void addTo (QWidget * widget) override;

private:
QMenu* _menu;

Q_DISABLE_COPY(ToolBarAction)
};

// --------------------------------------------------------------------
Expand All @@ -381,11 +403,13 @@ class GuiExport WindowAction : public ActionGroup

public:
explicit WindowAction (Command* pcCmd, QObject * parent = nullptr);
virtual ~WindowAction();
void addTo (QWidget * widget);
~WindowAction() override;
void addTo (QWidget * widget) override;

private:
QMenu* _menu;

Q_DISABLE_COPY(WindowAction)
};

} // namespace Gui
Expand Down

0 comments on commit bbb3697

Please sign in to comment.