Skip to content

Commit

Permalink
Code fascism.
Browse files Browse the repository at this point in the history
* Fix compiler warnings in non-3rd-party code.
* Add some missing const-references.
* Eliminate cases of "if(" "( ... )" and "for(".
  • Loading branch information
rryan committed Nov 18, 2014
1 parent c21f0c6 commit a74c65d
Show file tree
Hide file tree
Showing 138 changed files with 510 additions and 536 deletions.
4 changes: 2 additions & 2 deletions src/analyserbeats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ AnalyserBeats::AnalyserBeats(ConfigObject<ConfigValue>* pConfig)
m_iMaxBpm(9999) {
}

AnalyserBeats::~AnalyserBeats(){
AnalyserBeats::~AnalyserBeats() {
}

bool AnalyserBeats::initialise(TrackPointer tio, int sampleRate, int totalSamples) {
Expand Down Expand Up @@ -86,7 +86,7 @@ bool AnalyserBeats::initialise(TrackPointer tio, int sampleRate, int totalSample
bool bShouldAnalyze = !loadStored(tio);

if (bShouldAnalyze) {
m_pVamp = new VampAnalyser(m_pConfig);
m_pVamp = new VampAnalyser();
bShouldAnalyze = m_pVamp->Init(library, pluginID, m_iSampleRate, totalSamples,
m_bPreferencesFastAnalysis);
if (!bShouldAnalyze) {
Expand Down
4 changes: 2 additions & 2 deletions src/analyserkey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ AnalyserKey::AnalyserKey(ConfigObject<ConfigValue>* pConfig)
m_bPreferencesReanalyzeEnabled(false) {
}

AnalyserKey::~AnalyserKey(){
AnalyserKey::~AnalyserKey() {
delete m_pVamp;
}

Expand Down Expand Up @@ -56,7 +56,7 @@ bool AnalyserKey::initialise(TrackPointer tio, int sampleRate, int totalSamples)
bool bShouldAnalyze = !loadStored(tio);

if (bShouldAnalyze) {
m_pVamp = new VampAnalyser(m_pConfig);
m_pVamp = new VampAnalyser();
bShouldAnalyze = m_pVamp->Init(
library, m_pluginId, sampleRate, totalSamples,
m_bPreferencesFastAnalysisEnabled);
Expand Down
2 changes: 1 addition & 1 deletion src/analyserqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void AnalyserQueue::emitUpdateProgress(TrackPointer tio, int progress) {
// The following tries will success if the previous signal was processed in the GUI Thread
// This prevent the AnalysisQueue from filling up the GUI Thread event Queue
// 100 % is emitted in any case
if (progress < 1000 - FINALIZE_PERCENT && progress > 0 ) {
if (progress < 1000 - FINALIZE_PERCENT && progress > 0) {
// Signals during processing are not required in any case
if (!m_progressInfo.sema.tryAcquire()) {
return;
Expand Down
6 changes: 3 additions & 3 deletions src/analyserwaveform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ void AnalyserWaveform::resetFilters(TrackPointer tio, int sampleRate) {
}

void AnalyserWaveform::destroyFilters() {
for( int i = 0; i < FilterCount; i++) {
if( m_filter[i]) {
for (int i = 0; i < FilterCount; ++i) {
if (m_filter[i]) {
delete m_filter[i];
m_filter[i] = 0;
}
Expand All @@ -202,7 +202,7 @@ void AnalyserWaveform::process(const CSAMPLE* buffer, const int bufferLength) {
m_filter[High]->process(buffer, &m_buffers[High][0], bufferLength);


for( int i = 0; i < bufferLength; i+=2) {
for (int i = 0; i < bufferLength; i+=2) {
// Take max value, not average of data
CSAMPLE cover[2] = { fabs(buffer[i]), fabs(buffer[i+1]) };
CSAMPLE clow[2] = { fabs(m_buffers[ Low][i]), fabs(m_buffers[ Low][i+1]) };
Expand Down
22 changes: 11 additions & 11 deletions src/analyserwaveform.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class WaveformStride {
m_position = 0;
m_averagePosition = 0;
m_averageDivisor = 0;
for( int i = 0; i < ChannelCount; i++) {
for (int i = 0; i < ChannelCount; ++i) {
m_overallData[i] = 0.0f;
m_averageOverallData[i] = 0.0f;
for( int f = 0; f < FilterCount; f++) {
for (int f = 0; f < FilterCount; ++f) {
m_filteredData[i][f] = 0.0f;
m_averageFilteredData[i][f] = 0.0f;
}
Expand All @@ -52,18 +52,18 @@ class WaveformStride {
inline void reset() {
m_position = 0;
m_averageDivisor = 0;
for( int i = 0; i < ChannelCount; i++) {
for (int i = 0; i < ChannelCount; ++i) {
m_overallData[i] = 0.0f;
m_averageOverallData[i] = 0.0f;
for( int f = 0; f < FilterCount; f++) {
for (int f = 0; f < FilterCount; ++f) {
m_filteredData[i][f] = 0.0f;
m_averageFilteredData[i][f] = 0.0f;
}
}
}

inline void store(WaveformData* data) {
for( int i = 0; i < ChannelCount; i++) {
for (int i = 0; i < ChannelCount; ++i) {
WaveformData& datum = *(data + i);
datum.filtered.all = static_cast<unsigned char>(math_min(255.0,
m_postScaleConversion * scaleSignal(m_overallData[i]) + 0.5));
Expand All @@ -75,10 +75,10 @@ class WaveformStride {
m_postScaleConversion * scaleSignal(m_filteredData[i][High], High) + 0.5));
}
m_averageDivisor++;
for( int i = 0; i < ChannelCount; i++) {
for (int i = 0; i < ChannelCount; ++i) {
m_averageOverallData[i] += m_overallData[i];
m_overallData[i] = 0.0f;
for( int f = 0; f < FilterCount; f++) {
for (int f = 0; f < FilterCount; ++f) {
m_averageFilteredData[i][f] += m_filteredData[i][f];
m_filteredData[i][f] = 0.0f;
}
Expand All @@ -87,7 +87,7 @@ class WaveformStride {

inline void averageStore(WaveformData* data) {
if (m_averageDivisor) {
for( int i = 0; i < ChannelCount; i++) {
for (int i = 0; i < ChannelCount; ++i) {
WaveformData& datum = *(data + i);
datum.filtered.all = static_cast<unsigned char>(math_min(255.0,
m_postScaleConversion * scaleSignal(m_averageOverallData[i] / m_averageDivisor) + 0.5));
Expand All @@ -100,7 +100,7 @@ class WaveformStride {
}
} else {
// This is the case if The Overview Waveform has more samples than the detailed waveform
for( int i = 0; i < ChannelCount; i++) {
for (int i = 0; i < ChannelCount; ++i) {
WaveformData& datum = *(data + i);
datum.filtered.all = static_cast<unsigned char>(math_min(255.0,
m_postScaleConversion * scaleSignal(m_overallData[i]) + 0.5));
Expand All @@ -114,9 +114,9 @@ class WaveformStride {
}

m_averageDivisor = 0;
for( int i = 0; i < ChannelCount; i++) {
for (int i = 0; i < ChannelCount; ++i) {
m_averageOverallData[i] = 0.0f;
for( int f = 0; f < FilterCount; f++) {
for (int f = 0; f < FilterCount; ++f) {
m_averageFilteredData[i][f] = 0.0f;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/audiotagger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ bool AudioTagger::save() {
file = new TagLib::FLAC::File(fileBA.constData());

//If the flac has no ID3v2 tag, we create a new one and add the TBPM and TKEY frame
addID3v2Tag(((TagLib::FLAC::File*)file)->ID3v2Tag(true) );
addID3v2Tag(((TagLib::FLAC::File*)file)->ID3v2Tag(true));
//If the flac has no APE tag, we create a new one and add the TBPM and TKEY frame
addXiphComment(((TagLib::FLAC::File*) file)->xiphComment(true));

Expand Down
28 changes: 14 additions & 14 deletions src/audiotagger.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
class AudioTagger {
public:
AudioTagger(const QString& file, SecurityTokenPointer pToken);
virtual ~AudioTagger ( );

void setArtist (QString artist );
void setTitle (QString title );
void setAlbum (QString album );
void setAlbumArtist (QString albumArtist );
void setGenre (QString genre );
void setComposer (QString composer );
void setGrouping (QString grouping );
void setYear (QString year );
void setComment (QString comment );
void setKey (QString key );
void setBpm (QString bpm );
void setTracknumber (QString tracknumber );
virtual ~AudioTagger();

void setArtist(QString artist);
void setTitle(QString title);
void setAlbum(QString album);
void setAlbumArtist(QString albumArtist);
void setGenre(QString genre);
void setComposer(QString composer);
void setGrouping(QString grouping);
void setYear(QString year);
void setComment(QString comment);
void setKey(QString key);
void setBpm(QString bpm);
void setTracknumber(QString tracknumber);
bool save();

private:
Expand Down
6 changes: 3 additions & 3 deletions src/configobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ void ConfigValueKbd::valCopy(const ConfigValueKbd& v)
QTextStream(&value) << m_qKey.toString();
}

bool operator==(const ConfigValue & s1, const ConfigValue & s2)
bool operator==(const ConfigValue& s1, const ConfigValue& s2)
{
return (s1.value.toUpper() == s2.value.toUpper());
}

bool operator==(const ConfigValueKbd & s1, const ConfigValueKbd & s2)
bool operator==(const ConfigValueKbd& s1, const ConfigValueKbd& s2)
{
return (s1.value.toUpper() == s2.value.toUpper());
}
Expand Down Expand Up @@ -192,7 +192,7 @@ ConfigKey *ConfigObject<ValueType>::get(ValueType v)
while (iterator.hasNext())
{
it = iterator.next();
if (QString::compare(it->val->value, v.value, Qt::CaseInsensitive) == 0){
if (QString::compare(it->val->value, v.value, Qt::CaseInsensitive) == 0) {
//qDebug() << "ConfigObject #534: QString::compare match for " << it->key->group << it->key->item;
return it->key;
}
Expand Down
5 changes: 2 additions & 3 deletions src/controllers/controllerengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,9 +821,8 @@ QScriptValue ControllerEngine::connectControl(QString group, QString name,

ControllerEngineConnection conn = i.value();
return m_pEngine->newQObject(
new ControllerEngineConnectionScriptValue(conn),
QScriptEngine::ScriptOwnership
);
new ControllerEngineConnectionScriptValue(conn),
QScriptEngine::ScriptOwnership);
}
}
else if (callback.isFunction()) {
Expand Down
3 changes: 1 addition & 2 deletions src/controllers/controllerpresetinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ QHash<QString,QString> PresetInfo::parseOSCProduct(const QDomElement& element) c
return product;
}

PresetInfoEnumerator::PresetInfoEnumerator(ConfigObject<ConfigValue>* pConfig)
: m_pConfig(pConfig) {
PresetInfoEnumerator::PresetInfoEnumerator(ConfigObject<ConfigValue>* pConfig) {
controllerDirPaths.append(localPresetsPath(pConfig));
controllerDirPaths.append(resourcePresetsPath(pConfig));

Expand Down
1 change: 0 additions & 1 deletion src/controllers/controllerpresetinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class PresetInfoEnumerator {

private:
QList<QString> fileExtensions;
ConfigObject<ConfigValue>* m_pConfig;

// List of paths for controller presets
QList<QString> controllerDirPaths;
Expand Down
2 changes: 1 addition & 1 deletion src/controlobjectslave.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ControlObjectSlave : public QObject {
bool connectValueChanged(const QObject* receiver,
const char* method, Qt::ConnectionType type = Qt::AutoConnection);
bool connectValueChanged(
const char* method, Qt::ConnectionType type = Qt::AutoConnection );
const char* method, Qt::ConnectionType type = Qt::AutoConnection);

// Called from update();
inline void emitValueChanged() {
Expand Down
2 changes: 1 addition & 1 deletion src/controlobjectthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ControlObjectThread : public QObject {
bool connectValueChanged(const QObject* receiver,
const char* method, Qt::ConnectionType type = Qt::AutoConnection);
bool connectValueChanged(
const char* method, Qt::ConnectionType type = Qt::AutoConnection );
const char* method, Qt::ConnectionType type = Qt::AutoConnection);

QString name() const;
QString description() const;
Expand Down
44 changes: 19 additions & 25 deletions src/controlvaluedelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ QStringList ControlValueDelegate::m_flangerControlValues;
QStringList ControlValueDelegate::m_microphoneControlValues;


ControlValueDelegate::ControlValueDelegate(QObject *parent)
: QItemDelegate(parent)
{
if (m_channelControlValues.isEmpty()) //List is static/shared across all objects, so only fill once.
{
ControlValueDelegate::ControlValueDelegate(QObject* parent)
: QItemDelegate(parent) {
// List is static/shared across all objects, so only fill once.
if (m_channelControlValues.isEmpty()) {
m_channelControlValues.append("beatsync");
m_channelControlValues.append("cue_default");
m_channelControlValues.append("filterHigh");
Expand Down Expand Up @@ -170,9 +169,8 @@ ControlValueDelegate::ControlValueDelegate(QObject *parent)
}
}

void ControlValueDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
void ControlValueDelegate::paint(QPainter *painter, const QStyleOptionViewItem& option,
const QModelIndex& index) const {
if (index.data().canConvert<QString>()) {
QString value = index.data().value<QString>();

Expand All @@ -192,10 +190,9 @@ void ControlValueDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
}
}

QWidget *ControlValueDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &/* option */,
const QModelIndex &index ) const
{
QWidget* ControlValueDelegate::createEditor(QWidget* parent,
const QStyleOptionViewItem& /* option */,
const QModelIndex& index) const {
//TODO: Use index to grab the value of the ControlGroup column next to
// this item. We want to do this because some of the possible
// ControlValues only apply to Channel1/2, and not Master (for example).
Expand Down Expand Up @@ -238,18 +235,16 @@ QWidget *ControlValueDelegate::createEditor(QWidget *parent,
return editor;
}

void ControlValueDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
void ControlValueDelegate::setEditorData(QWidget* editor,
const QModelIndex& index) const {
QString value = index.model()->data(index, Qt::EditRole).toString();

QComboBox *comboBox = static_cast<QComboBox*>(editor);
comboBox->setCurrentIndex(comboBox->findText(value));
}

void ControlValueDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
void ControlValueDelegate::setModelData(QWidget* editor, QAbstractItemModel* model,
const QModelIndex& index) const {
QString midiType = 0;
QComboBox *comboBox = static_cast<QComboBox*>(editor);
//comboBox->interpretText();
Expand All @@ -260,10 +255,9 @@ void ControlValueDelegate::setModelData(QWidget *editor, QAbstractItemModel *mod
model->setData(index, text, Qt::EditRole);
}

void ControlValueDelegate::updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option,
const QModelIndex &/* index */) const
{
void ControlValueDelegate::updateEditorGeometry(QWidget* editor,
const QStyleOptionViewItem& option,
const QModelIndex& /* index */) const {
editor->setGeometry(option.rect);
}

Expand All @@ -273,9 +267,9 @@ void ControlValueDelegate::updateEditorGeometry(QWidget *editor,
@param controlGroup The group that has just been selected and should be verified against.
@param index The model index of the ControlValue.
*/
bool ControlValueDelegate::verifyControlValueValidity(QString controlGroup, QAbstractItemModel *model,
const QModelIndex& index)
{
bool ControlValueDelegate::verifyControlValueValidity(QString controlGroup,
QAbstractItemModel* model,
const QModelIndex& index) {
QString value = index.data().value<QString>();

if (controlGroup == CONTROLGROUP_CHANNEL1_STRING ||
Expand Down
Loading

0 comments on commit a74c65d

Please sign in to comment.