Mantid
Loading...
Searching...
No Matches
TrackedAction.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
9#include <QCoreApplication>
10
11namespace MantidQt {
12namespace MantidWidgets {
13
17TrackedAction::TrackedAction(QObject *parent) : QAction(parent), m_isTracking(true), m_trackingName() {
19}
20
25TrackedAction::TrackedAction(const QString &text, QObject *parent)
26 : QAction(text, parent), m_isTracking(true), m_trackingName() {
28}
29
35TrackedAction::TrackedAction(const QIcon &icon, const QString &text, QObject *parent)
36 : QAction(icon, text, parent), m_isTracking(true), m_trackingName() {
38}
39
43void TrackedAction::setTrackingName(const std::vector<std::string> &name) { m_trackingName = name; }
44
50std::vector<std::string> TrackedAction::getTrackingName() const {
51 if (m_trackingName.empty()) {
53 }
54 return m_trackingName;
55}
56
60void TrackedAction::setIsTracking(const bool enableTracking) { m_isTracking = enableTracking; }
61
66
69void TrackedAction::setupTracking() { connect(this, SIGNAL(triggered(bool)), this, SLOT(trackActivation(bool))); }
70
74std::vector<std::string> TrackedAction::generateTrackingName() const {
75 return {QCoreApplication::applicationName().toStdString(), QAction::text().remove("&").remove(" ").toStdString()};
76}
77
81void TrackedAction::trackActivation(const bool checked) {
82 UNUSED_ARG(checked);
83 if (m_isTracking) {
84 // do tracking
86 }
87}
88
92void TrackedAction::registerUsage(const std::vector<std::string> &name) {
94}
95
96} // namespace MantidWidgets
97} // namespace MantidQt
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
Definition: System.h:64
void setupTracking()
Sets up tracking for the class.
TrackedAction(QObject *parent)
Constructor.
std::vector< std::string > m_trackingName
Definition: TrackedAction.h:39
void trackActivation(const bool checked)
Registers the feature usage if usage is enabled.
void setIsTracking(const bool enableTracking)
Sets whether this action is tracking usage.
virtual std::vector< std::string > generateTrackingName() const
Creates a tracking name from the action text.
void setTrackingName(const std::vector< std::string > &name)
Sets the tracking name for this action.
std::vector< std::string > getTrackingName() const
Gets the tracking name for this action If the tacking name is not set a default name will be generate...
virtual void registerUsage(const std::vector< std::string > &name)
Registers the feature usage with the usage service.
bool getIsTracking() const
Gets whether this action is tracking usage.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...