Skip to content

Commit

Permalink
clang-tidy pass
Browse files Browse the repository at this point in the history
 - ensure signature coherence
 - cleanup spacing / naming
 - avoid implicit pointer -> bool conversions
  • Loading branch information
crep4ever committed Jul 18, 2017
1 parent 271f192 commit 8dd9f60
Show file tree
Hide file tree
Showing 35 changed files with 435 additions and 395 deletions.
22 changes: 14 additions & 8 deletions src/benchmark-dialog.cc
Expand Up @@ -41,8 +41,7 @@
#include "progress-bar.hh"
#include "benchmark-task.hh"

CBenchmarkDialog::CBenchmarkDialog(QWidget *p_parent)
: QDialog(p_parent)
CBenchmarkDialog::CBenchmarkDialog(QWidget *p_parent) : QDialog(p_parent)
, m_parent(qobject_cast<CMainWindow*>(p_parent))
, m_tabs(new QTabWidget)
, m_progressBar(new CProgressBar)
Expand Down Expand Up @@ -185,8 +184,11 @@ void CBenchmarkDialog::writeSettings()

CMainWindow* CBenchmarkDialog::parent() const
{
if (!m_parent)
qWarning() << "CBenchmarkDialog::parent invalid parent";
if (m_parent == nullptr)
{
qWarning() << "CBenchmarkDialog::parent invalid parent";
}

return m_parent;
}

Expand Down Expand Up @@ -221,7 +223,7 @@ void CBenchmarkDialog::run()
model());

connect(&task, SIGNAL(resultReady(const BenchmarkResult &)),
this, SLOT(handleResult(const BenchmarkResult &)));
this, SLOT(processResult(const BenchmarkResult &)));

connect(m_progressBar, SIGNAL(canceled()),
&task, SLOT(cancel()));
Expand All @@ -236,7 +238,7 @@ void CBenchmarkDialog::run()
}


void CBenchmarkDialog::handleResult(const BenchmarkResult & p_result)
void CBenchmarkDialog::processResult(const BenchmarkResult & p_result)
{
m_progressBar->setValue(++m_progress);

Expand Down Expand Up @@ -286,7 +288,9 @@ int CBenchmarkDialog::countOperations() const
foreach (QCheckBox *checkBox, m_operations)
{
if (checkBox->isChecked())
++count;
{
++count;
}
}

return count;
Expand Down Expand Up @@ -348,7 +352,9 @@ void CBenchmarkDialog::save()
tr("Data files (*.txt *.html)"));
QFileInfo fi(filename);
if (filename.isEmpty())
return;
{
return;
}

m_savePath = fi.absolutePath();
QFile file(filename);
Expand Down
4 changes: 2 additions & 2 deletions src/benchmark-dialog.hh
Expand Up @@ -45,7 +45,7 @@ class CBenchmarkDialog : public QDialog

public:
/// Constructor.
CBenchmarkDialog(QWidget *parent = 0);
CBenchmarkDialog(QWidget *p_parent = 0);

/// Destructor.
virtual ~CBenchmarkDialog();
Expand All @@ -56,7 +56,7 @@ public:
public slots:

void run();
void handleResult(const BenchmarkResult & p_res);
void processResult(const BenchmarkResult & p_result);

void cancel();
void save();
Expand Down
25 changes: 17 additions & 8 deletions src/benchmark-task.cc
Expand Up @@ -25,11 +25,11 @@
#include "matrix-model.hh"
#include "elapsed-timer.hh"

BenchmarkTask::BenchmarkTask(const QString & p_name,
const int p_iterations,
BenchmarkTask::BenchmarkTask(const QString & p_operationName,
const int p_nbIterations,
CMatrixModel* p_model) : QObject()
, m_name(p_name)
, m_iterations(p_iterations)
, m_name(p_operationName)
, m_iterations(p_nbIterations)
, m_model(p_model)
, m_cancelRequested(false)
{
Expand All @@ -41,8 +41,10 @@ BenchmarkTask::~BenchmarkTask()

void BenchmarkTask::execute()
{
if (!m_model)
return;
if (m_model == nullptr)
{
return;
}

m_cancelRequested = false;

Expand Down Expand Up @@ -157,8 +159,15 @@ void BenchmarkTask::execute()
m_model->setData(backup->data());
delete backup;

if (ns < min) min = ns;
if (ns > max) max = ns;
if (ns < min)
{
min = ns;
}

if (ns > max)
{
max = ns;
}
sum += ns;
}

Expand Down
2 changes: 1 addition & 1 deletion src/double-spinbox.hh
Expand Up @@ -31,7 +31,7 @@ class CDoubleSpinBox : public QDoubleSpinBox

public:
/// Constructor.
CDoubleSpinBox(QWidget *parent = 0);
CDoubleSpinBox(QWidget *p_parent = 0);

/// Destructor.
~CDoubleSpinBox();
Expand Down
45 changes: 27 additions & 18 deletions src/file-chooser.cc
Expand Up @@ -66,72 +66,81 @@ void CFileChooser::browse()
{
QString selection;
if (options() & QFileDialog::ShowDirsOnly)
selection = QFileDialog::getExistingDirectory(0, caption(), directory());
{
selection = QFileDialog::getExistingDirectory(0, caption(), directory());
}
else
selection = QFileDialog::getOpenFileName(0, caption(), directory(), filter(), 0, options());
{
selection = QFileDialog::getOpenFileName(0, caption(), directory(), filter(), 0, options());
}

if (!selection.isEmpty())
setPath(selection);
{
setPath(selection);
}
}

QFileDialog::Options CFileChooser::options() const
const QFileDialog::Options & CFileChooser::options() const
{
return m_options;
}

void CFileChooser::setOptions(const QFileDialog::Options &p_opts)
void CFileChooser::setOptions(const QFileDialog::Options & p_options)
{
m_options = p_opts;
m_options = p_options;
}

QString CFileChooser::filter() const
const QString & CFileChooser::filter() const
{
return m_filter;
}

void CFileChooser::setFilter(const QString &p_filter)
void CFileChooser::setFilter(const QString & p_filter)
{
m_filter = p_filter;
}

QString CFileChooser::caption() const
const QString & CFileChooser::caption() const
{
return m_caption;
}

void CFileChooser::setCaption(const QString &p_caption)
void CFileChooser::setCaption(const QString & p_caption)
{
m_caption = p_caption;
}

QString CFileChooser::directory() const
const QString & CFileChooser::directory() const
{
return m_directory;
}

void CFileChooser::setDirectory(const QString &p_directory)
void CFileChooser::setDirectory(const QString & p_directory)
{
m_directory = p_directory;
}

void CFileChooser::setDirectory(const QDir &p_directory)
void CFileChooser::setDirectory(const QDir & p_directory)
{
m_directory = p_directory.absolutePath();
}


QString CFileChooser::path() const
const QString & CFileChooser::path() const
{
return m_path;
}

void CFileChooser::setPath(const QString &p_path)
void CFileChooser::setPath(const QString & p_path)
{
if (QString::compare(m_path, p_path, Qt::CaseSensitive) == 0)
return;
{
return;
}

if (m_lineEdit->text() != p_path)
m_lineEdit->setText(p_path);
{
m_lineEdit->setText(p_path);
}

m_path = p_path;

Expand Down
26 changes: 13 additions & 13 deletions src/file-chooser.hh
Expand Up @@ -44,7 +44,7 @@ class CFileChooser : public QWidget

public:
/// Constructor.
CFileChooser(QWidget *parent=0);
CFileChooser(QWidget *p_parent = 0);

/// Destructor.
~CFileChooser();
Expand All @@ -53,75 +53,75 @@ public:
Returns the options of the QFileDialog .
\sa setOptions
*/
QFileDialog::Options options() const;
const QFileDialog::Options & options() const;

/*!
Sets the options of the QFileDialog .
\sa options
*/
void setOptions(const QFileDialog::Options &options);
void setOptions(const QFileDialog::Options & p_options);

/*!
Returns the filter of the QFileDialog.
\sa setFilter
*/
QString filter() const;
const QString & filter() const;

/*!
Sets the filter of the QFileDialog.
\sa filter
*/
void setFilter(const QString &filter);
void setFilter(const QString & p_filter);

/*!
Returns the caption of the QFileDialog.
\sa setCaption
*/
QString caption() const;
const QString & caption() const;

/*!
Sets the caption of the QFileDialog.
\sa caption
*/
void setCaption(const QString &caption);
void setCaption(const QString & p_caption);

/*!
Returns the base directory from which the QFileDialog is opened.
\sa setDirectory
*/
QString directory() const;
const QString & directory() const;

/*!
Sets the base directory from which the QFileDialog is opened.
\sa directory
*/
void setDirectory(const QString &directory);
void setDirectory(const QString & p_directory);

/*!
Sets the base directory from which the QFileDialog is opened.
\sa directory
*/
void setDirectory(const QDir &directory);
void setDirectory(const QDir & p_directory);

/*!
Returns the path from the QLineEdit.
\sa setPath
*/
QString path() const;
const QString & path() const;

public slots:
/*!
Sets the path for the QLineEdit.
\sa path
*/
void setPath(const QString &path);
void setPath(const QString & p_path);

signals:
/*!
This signal is emitted when the path is changed in the QLineEdit.
\sa path, setPath
*/
void pathChanged(const QString &path);
void pathChanged(const QString & p_path);

private slots:
void browse();
Expand Down
11 changes: 6 additions & 5 deletions src/histogram-widget.cc
Expand Up @@ -49,14 +49,14 @@ CHistogramWidget::~CHistogramWidget()
{
}

void CHistogramWidget::setImage(QImage *image)
void CHistogramWidget::setImage(QImage *p_image)
{
QImage copy = image->convertToFormat(QImage::Format_ARGB32);
QImage copy = p_image->convertToFormat(QImage::Format_ARGB32);
QVector<uint> redValues(256, 0), greenValues(256, 0), blueValues(256, 0);
for (int j = 0; j < image->height(); ++j)
for (int j = 0; j < p_image->height(); ++j)
{
QRgb *row = reinterpret_cast<QRgb *>(copy.scanLine(j));
for (int i = 0; i < image->width(); ++i)
for (int i = 0; i < p_image->width(); ++i)
{
++redValues[qRed(row[i])];
++greenValues[qGreen(row[i])];
Expand All @@ -74,8 +74,9 @@ QSize CHistogramWidget::sizeHint() const
return QSize(500, 300);
}

void CHistogramWidget::paintEvent(QPaintEvent* /*event*/)
void CHistogramWidget::paintEvent(QPaintEvent *p_event)
{
Q_UNUSED(p_event);
QColor backgroundColor = palette().dark().color();
backgroundColor.setAlpha(150);
QPainter customPainter(this);
Expand Down
6 changes: 3 additions & 3 deletions src/histogram-widget.hh
Expand Up @@ -39,16 +39,16 @@ class CHistogramWidget : public QWidget

public:
/// Constructor.
CHistogramWidget(QWidget *parent = 0);
CHistogramWidget(QWidget *p_parent = 0);

/// Destructor.
virtual ~CHistogramWidget();

void setImage(QImage *image);
void setImage(QImage *p_image);

protected:
virtual QSize sizeHint() const;
void paintEvent(QPaintEvent* event);
void paintEvent(QPaintEvent *p_event);

private:
CHistogram *m_redHistogram;
Expand Down

0 comments on commit 8dd9f60

Please sign in to comment.