diff options
author | RJ Skerry-Ryan <rryan@mixxx.org> | 2018-10-25 22:39:12 -0700 |
---|---|---|
committer | RJ Skerry-Ryan <rryan@mixxx.org> | 2018-10-26 00:14:38 -0700 |
commit | 10ec4cb3d6c5d6a3d7727ef74a16c7c3526ed30f (patch) | |
tree | 033cc4304a434c024d3ffde5450ac0d51908ee26 /src/controllers | |
parent | 398b533a847db24ddb6f3d30e1d2964f62308cbf (diff) |
Fix some issues identified by clazy.
Diffstat (limited to 'src/controllers')
-rw-r--r-- | src/controllers/controllerengine.cpp | 10 | ||||
-rw-r--r-- | src/controllers/controlpickermenu.cpp | 6 | ||||
-rw-r--r-- | src/controllers/keyboard/keyboardeventfilter.cpp | 5 | ||||
-rw-r--r-- | src/controllers/learningutils.cpp | 22 | ||||
-rw-r--r-- | src/controllers/midi/midicontroller.cpp | 13 | ||||
-rw-r--r-- | src/controllers/midi/midicontrollerpresetfilehandler.cpp | 8 |
6 files changed, 27 insertions, 37 deletions
diff --git a/src/controllers/controllerengine.cpp b/src/controllers/controllerengine.cpp index b9c069a53d..0aa1d102a5 100644 --- a/src/controllers/controllerengine.cpp +++ b/src/controllers/controllerengine.cpp @@ -113,10 +113,8 @@ QScriptValue ControllerEngine::wrapFunctionCode(const QString& codeSnippet, int numberOfArgs) { QScriptValue wrappedFunction; - QHash<QString, QScriptValue>::const_iterator i = - m_scriptWrappedFunctionCache.find(codeSnippet); - - if (i != m_scriptWrappedFunctionCache.end()) { + auto i = m_scriptWrappedFunctionCache.constFind(codeSnippet); + if (i != m_scriptWrappedFunctionCache.constEnd()) { wrappedFunction = i.value(); } else { QStringList wrapperArgList; @@ -1104,8 +1102,8 @@ void ControllerEngine::timerEvent(QTimerEvent *event) { return; } - QHash<int, TimerInfo>::const_iterator it = m_timers.find(timerId); - if (it == m_timers.end()) { + auto it = m_timers.constFind(timerId); + if (it == m_timers.constEnd()) { qWarning() << "Timer" << timerId << "fired but there's no function mapped to it!"; return; } diff --git a/src/controllers/controlpickermenu.cpp b/src/controllers/controlpickermenu.cpp index 17f3f49ba7..8b82f05b68 100644 --- a/src/controllers/controlpickermenu.cpp +++ b/src/controllers/controlpickermenu.cpp @@ -432,7 +432,7 @@ ControlPickerMenu::ControlPickerMenu(QWidget* pParent) tr("Replace Auto DJ Queue with selected tracks"), m_libraryStr, libraryMenu); - + // Load track (these can be loaded into any channel) addDeckAndSamplerControl("LoadSelectedTrack", tr("Load Track"), @@ -1072,10 +1072,6 @@ void ControlPickerMenu::addAvailableControl(ConfigKey key, } bool ControlPickerMenu::controlExists(ConfigKey key) const { - qDebug() << "LOOKING FOR KEY " << key; - foreach(const ConfigKey& key, m_titlesByKey.keys()) { - qDebug() << "key: " << key; - } return m_titlesByKey.contains(key); } diff --git a/src/controllers/keyboard/keyboardeventfilter.cpp b/src/controllers/keyboard/keyboardeventfilter.cpp index b62fc2dda6..28305f59ff 100644 --- a/src/controllers/keyboard/keyboardeventfilter.cpp +++ b/src/controllers/keyboard/keyboardeventfilter.cpp @@ -51,9 +51,8 @@ bool KeyboardEventFilter::eventFilter(QObject*, QEvent* e) { // Check if a shortcut is defined bool result = false; // using const_iterator here is faster than QMultiHash::values() - for (QMultiHash<ConfigValueKbd, ConfigKey>::const_iterator it = - m_keySequenceToControlHash.find(ksv); - it != m_keySequenceToControlHash.end() && it.key() == ksv; ++it) { + for (auto it = m_keySequenceToControlHash.constFind(ksv); + it != m_keySequenceToControlHash.constEnd() && it.key() == ksv; ++it) { const ConfigKey& configKey = it.value(); if (configKey.group != "[KeyboardShortcuts]") { ControlObject* control = ControlObject::getControl(configKey); diff --git a/src/controllers/learningutils.cpp b/src/controllers/learningutils.cpp index dfd28caf5b..4df4710df3 100644 --- a/src/controllers/learningutils.cpp +++ b/src/controllers/learningutils.cpp @@ -73,19 +73,17 @@ MidiInputMappings LearningUtils::guessMidiInputMappings( qDebug() << "Control:" << control; } - for (QMap<unsigned char, int>::const_iterator it = stats.value_histogram.begin(); - it != stats.value_histogram.end(); ++it) { + for (auto it = stats.value_histogram.constBegin(); + it != stats.value_histogram.constEnd(); ++it) { qDebug() << "Overall Value:" << it.key() << "count" << it.value(); } - for (QMap<unsigned char, MessageStats>::const_iterator control_it = - stats_by_control.begin(); - control_it != stats_by_control.end(); ++control_it) { + for (auto control_it = stats_by_control.constBegin(); + control_it != stats_by_control.constEnd(); ++control_it) { QString controlName = QString("Control %1").arg(control_it.key()); - for (QMap<unsigned char, int>::const_iterator it = - control_it->value_histogram.begin(); - it != control_it->value_histogram.end(); ++it) { + for (auto it = control_it->value_histogram.constBegin(); + it != control_it->value_histogram.constEnd(); ++it) { qDebug() << controlName << "Value:" << it.key() << "count" << it.value(); } @@ -103,8 +101,8 @@ MidiInputMappings LearningUtils::guessMidiInputMappings( bool has_cc = stats.opcodes.contains(MIDI_CC); bool only_cc = stats.opcodes.size() == 1 && has_cc; int num_cc_controls = 0; - for (QMap<unsigned char, MessageStats>::const_iterator it = stats_by_control.begin(); - it != stats_by_control.end(); ++it) { + for (auto it = stats_by_control.constBegin(); + it != stats_by_control.constEnd(); ++it) { if (it->opcodes.contains(MIDI_CC)) { num_cc_controls++; } @@ -225,8 +223,8 @@ MidiInputMappings LearningUtils::guessMidiInputMappings( // Find the CC control (based on the predicate one must exist) and add a // binding for it. - for (QMap<unsigned char, MessageStats>::const_iterator it = stats_by_control.begin(); - it != stats_by_control.end(); ++it) { + for (auto it = stats_by_control.constBegin(); + it != stats_by_control.constEnd(); ++it) { if (it->opcodes.contains(MIDI_CC)) { MidiKey knob; knob.status = MIDI_CC | *stats.channels.begin(); diff --git a/src/controllers/midi/midicontroller.cpp b/src/controllers/midi/midicontroller.cpp index 8dec542e7a..0176aa653e 100644 --- a/src/controllers/midi/midicontroller.cpp +++ b/src/controllers/midi/midicontroller.cpp @@ -211,7 +211,7 @@ void MidiController::receive(unsigned char status, unsigned char control, emit(messageReceived(status, control, value)); auto it = m_temporaryInputMappings.constFind(mappingKey.key); - if (it != m_temporaryInputMappings.end()) { + if (it != m_temporaryInputMappings.constEnd()) { for (; it != m_temporaryInputMappings.end() && it.key() == mappingKey.key; ++it) { processInputMapping(it.value(), status, control, value, timestamp); } @@ -220,7 +220,7 @@ void MidiController::receive(unsigned char status, unsigned char control, } auto it = m_preset.inputMappings.constFind(mappingKey.key); - for (; it != m_preset.inputMappings.end() && it.key() == mappingKey.key; ++it) { + for (; it != m_preset.inputMappings.constEnd() && it.key() == mappingKey.key; ++it) { processInputMapping(it.value(), status, control, value, timestamp); } } @@ -271,8 +271,7 @@ void MidiController::processInputMapping(const MidiInputMapping& mapping, if (mapping_is_14bit) { bool found = false; - for (QList<QPair<MidiInputMapping, unsigned char> >::iterator it = - m_fourteen_bit_queued_mappings.begin(); + for (auto it = m_fourteen_bit_queued_mappings.begin(); it != m_fourteen_bit_queued_mappings.end(); ++it) { if (it->first.control == mapping.control) { if ((it->first.options.fourteen_bit_lsb && mapping.options.fourteen_bit_lsb) || @@ -463,8 +462,8 @@ void MidiController::receive(QByteArray data, mixxx::Duration timestamp) { emit(messageReceived(mappingKey.status, mappingKey.control, 0x7F)); auto it = m_temporaryInputMappings.constFind(mappingKey.key); - if (it != m_temporaryInputMappings.end()) { - for (; it != m_temporaryInputMappings.end() && it.key() == mappingKey.key; ++it) { + if (it != m_temporaryInputMappings.constEnd()) { + for (; it != m_temporaryInputMappings.constEnd() && it.key() == mappingKey.key; ++it) { processInputMapping(it.value(), data, timestamp); } return; @@ -472,7 +471,7 @@ void MidiController::receive(QByteArray data, mixxx::Duration timestamp) { } auto it = m_preset.inputMappings.constFind(mappingKey.key); - for (; it != m_preset.inputMappings.end() && it.key() == mappingKey.key; ++it) { + for (; it != m_preset.inputMappings.constEnd() && it.key() == mappingKey.key; ++it) { processInputMapping(it.value(), data, timestamp); } } diff --git a/src/controllers/midi/midicontrollerpresetfilehandler.cpp b/src/controllers/midi/midicontrollerpresetfilehandler.cpp index 682e091441..32e0124476 100644 --- a/src/controllers/midi/midicontrollerpresetfilehandler.cpp +++ b/src/controllers/midi/midicontrollerpresetfilehandler.cpp @@ -211,8 +211,8 @@ void MidiControllerPresetFileHandler::addControlsToDocument(const MidiController // to remove duplicate keys or else we'll duplicate those values. auto sortedInputKeys = preset.inputMappings.uniqueKeys(); std::sort(sortedInputKeys.begin(), sortedInputKeys.end()); - for (auto key : sortedInputKeys) { - for (auto it = preset.inputMappings.constFind(key); + for (const auto& key : sortedInputKeys) { + for (auto it = preset.inputMappings.constFind(key); it != preset.inputMappings.constEnd() && it.key() == key; ++it) { QDomElement controlNode = inputMappingToXML(doc, it.value()); controls.appendChild(controlNode); @@ -225,8 +225,8 @@ void MidiControllerPresetFileHandler::addControlsToDocument(const MidiController QDomElement outputs = doc->createElement("outputs"); auto sortedOutputKeys = preset.outputMappings.uniqueKeys(); std::sort(sortedOutputKeys.begin(), sortedOutputKeys.end()); - for (auto key : sortedOutputKeys) { - for (auto it = preset.outputMappings.constFind(key); + for (const auto& key : sortedOutputKeys) { + for (auto it = preset.outputMappings.constFind(key); it != preset.outputMappings.constEnd() && it.key() == key; ++it) { QDomElement outputNode = outputMappingToXML(doc, it.value()); outputs.appendChild(outputNode); |