diff options
author | Jan Holthuis <jan.holthuis@ruhr-uni-bochum.de> | 2020-12-15 01:05:33 +0100 |
---|---|---|
committer | Jan Holthuis <jan.holthuis@ruhr-uni-bochum.de> | 2020-12-15 01:57:06 +0100 |
commit | 0471998e13aada9a76e92b13ab3885c2d1c2fb84 (patch) | |
tree | 776d15ab92ef044956940bc2228b61256ca4feb9 /src/controllers | |
parent | 63b858b5d827797eec959d009ad0b970de167dc5 (diff) |
Add missing braces around single-line statements
Diffstat (limited to 'src/controllers')
-rw-r--r-- | src/controllers/bulk/bulkcontroller.cpp | 8 | ||||
-rw-r--r-- | src/controllers/controller.cpp | 8 | ||||
-rw-r--r-- | src/controllers/controllerpresetfilehandler.cpp | 3 | ||||
-rw-r--r-- | src/controllers/controllerpresetinfo.cpp | 16 | ||||
-rw-r--r-- | src/controllers/dlgprefcontroller.cpp | 15 | ||||
-rw-r--r-- | src/controllers/hid/hidcontroller.cpp | 23 | ||||
-rw-r--r-- | src/controllers/hid/hidenumerator.cpp | 18 | ||||
-rw-r--r-- | src/controllers/keyboard/keyboardeventfilter.cpp | 12 | ||||
-rw-r--r-- | src/controllers/midi/midicontroller.cpp | 16 | ||||
-rw-r--r-- | src/controllers/midi/midicontrollerpresetfilehandler.cpp | 90 | ||||
-rw-r--r-- | src/controllers/midi/portmidicontroller.cpp | 3 |
11 files changed, 152 insertions, 60 deletions
diff --git a/src/controllers/bulk/bulkcontroller.cpp b/src/controllers/bulk/bulkcontroller.cpp index 76b0afdd34..f8b91e4494 100644 --- a/src/controllers/bulk/bulkcontroller.cpp +++ b/src/controllers/bulk/bulkcontroller.cpp @@ -126,9 +126,13 @@ bool BulkController::matchProductInfo(const ProductInfo& product) { bool ok; // Product and vendor match is always required value = product.vendor_id.toInt(&ok, 16); - if (!ok || vendor_id!=value) return false; + if (!ok || vendor_id != value) { + return false; + } value = product.product_id.toInt(&ok, 16); - if (!ok || product_id!=value) return false; + if (!ok || product_id != value) { + return false; + } // Match found return true; diff --git a/src/controllers/controller.cpp b/src/controllers/controller.cpp index 8149dd88b0..876fcc673d 100644 --- a/src/controllers/controller.cpp +++ b/src/controllers/controller.cpp @@ -120,8 +120,12 @@ void Controller::receive(const QByteArray& data, mixxx::Duration timestamp) { QString::number(length)); for(int i=0; i<length; i++) { QString spacer=" "; - if ((i+1) % 4 == 0) spacer=" "; - if ((i+1) % 16 == 0) spacer="\n"; + if ((i + 1) % 4 == 0) { + spacer = " "; + } + if ((i + 1) % 16 == 0) { + spacer = "\n"; + } message += QString("%1%2") .arg((unsigned char)(data.at(i)), 2, 16, QChar('0')).toUpper() .arg(spacer); diff --git a/src/controllers/controllerpresetfilehandler.cpp b/src/controllers/controllerpresetfilehandler.cpp index cfec632695..55151d1858 100644 --- a/src/controllers/controllerpresetfilehandler.cpp +++ b/src/controllers/controllerpresetfilehandler.cpp @@ -116,8 +116,9 @@ void ControllerPresetFileHandler::addScriptFilesToPreset( const QDomElement& controller, ControllerPreset* preset, const QDir& systemPresetsPath) const { - if (controller.isNull()) + if (controller.isNull()) { return; + } QString deviceId = controller.attribute("id", ""); preset->setDeviceId(deviceId); diff --git a/src/controllers/controllerpresetinfo.cpp b/src/controllers/controllerpresetinfo.cpp index 34f075de5b..b519330acb 100644 --- a/src/controllers/controllerpresetinfo.cpp +++ b/src/controllers/controllerpresetinfo.cpp @@ -47,16 +47,24 @@ PresetInfo::PresetInfo(const QString& preset_path) } QDomElement dom_author = info.firstChildElement("author"); - if (!dom_author.isNull()) m_author = dom_author.text(); + if (!dom_author.isNull()) { + m_author = dom_author.text(); + } QDomElement dom_description = info.firstChildElement("description"); - if (!dom_description.isNull()) m_description = dom_description.text(); + if (!dom_description.isNull()) { + m_description = dom_description.text(); + } QDomElement dom_forums = info.firstChildElement("forums"); - if (!dom_forums.isNull()) m_forumlink = dom_forums.text(); + if (!dom_forums.isNull()) { + m_forumlink = dom_forums.text(); + } QDomElement dom_wiki = info.firstChildElement("wiki"); - if (!dom_wiki.isNull()) m_wikilink = dom_wiki.text(); + if (!dom_wiki.isNull()) { + m_wikilink = dom_wiki.text(); + } QDomElement devices = info.firstChildElement("devices"); if (!devices.isNull()) { diff --git a/src/controllers/dlgprefcontroller.cpp b/src/controllers/dlgprefcontroller.cpp index bdbd148287..64ba02bd85 100644 --- a/src/controllers/dlgprefcontroller.cpp +++ b/src/controllers/dlgprefcontroller.cpp @@ -205,8 +205,9 @@ QString DlgPrefController::presetName( const ControllerPresetPointer pPreset) const { if (pPreset) { QString name = pPreset->name(); - if (name.length() > 0) + if (name.length() > 0) { return name; + } } return tr("No Name"); } @@ -215,8 +216,9 @@ QString DlgPrefController::presetDescription( const ControllerPresetPointer pPreset) const { if (pPreset) { QString description = pPreset->description(); - if (description.length() > 0) + if (description.length() > 0) { return description; + } } return tr("No Description"); } @@ -225,8 +227,9 @@ QString DlgPrefController::presetAuthor( const ControllerPresetPointer pPreset) const { if (pPreset) { QString author = pPreset->author(); - if (author.length() > 0) + if (author.length() > 0) { return author; + } } return tr("No Author"); } @@ -236,8 +239,9 @@ QString DlgPrefController::presetForumLink( QString url; if (pPreset) { QString link = pPreset->forumlink(); - if (link.length() > 0) + if (link.length() > 0) { url = "<a href=\"" + link + "\">Mixxx Forums</a>"; + } } return url; } @@ -247,8 +251,9 @@ QString DlgPrefController::presetWikiLink( QString url; if (pPreset) { QString link = pPreset->wikilink(); - if (link.length() > 0) + if (link.length() > 0) { url = "<a href=\"" + link + "\">Mixxx Wiki</a>"; + } } return url; } diff --git a/src/controllers/hid/hidcontroller.cpp b/src/controllers/hid/hidcontroller.cpp index 4ca0d444a8..b94eecc8cc 100644 --- a/src/controllers/hid/hidcontroller.cpp +++ b/src/controllers/hid/hidcontroller.cpp @@ -103,8 +103,9 @@ void HidController::visit(const HidControllerPreset* preset) { bool HidController::matchPreset(const PresetInfo& preset) { const QList<ProductInfo>& products = preset.getProducts(); for (const auto& product : products) { - if (matchProductInfo(product)) + if (matchProductInfo(product)) { return true; + } } return false; } @@ -114,20 +115,30 @@ bool HidController::matchProductInfo(const ProductInfo& product) { bool ok; // Product and vendor match is always required value = product.vendor_id.toInt(&ok,16); - if (!ok || hid_vendor_id!=value) return false; + if (!ok || hid_vendor_id != value) { + return false; + } value = product.product_id.toInt(&ok,16); - if (!ok || hid_product_id!=value) return false; + if (!ok || hid_product_id != value) { + return false; + } // Optionally check against interface_number / usage_page && usage if (hid_interface_number!=-1) { value = product.interface_number.toInt(&ok,16); - if (!ok || hid_interface_number!=value) return false; + if (!ok || hid_interface_number != value) { + return false; + } } else { value = product.usage_page.toInt(&ok,16); - if (!ok || hid_usage_page!=value) return false; + if (!ok || hid_usage_page != value) { + return false; + } value = product.usage.toInt(&ok,16); - if (!ok || hid_usage!=value) return false; + if (!ok || hid_usage != value) { + return false; + } } // Match found return true; diff --git a/src/controllers/hid/hidenumerator.cpp b/src/controllers/hid/hidenumerator.cpp index 330425f4d9..d88b4baebb 100644 --- a/src/controllers/hid/hidenumerator.cpp +++ b/src/controllers/hid/hidenumerator.cpp @@ -13,16 +13,19 @@ bool recognizeDevice(const hid_device_info& device_info) { for (int bl_index = 0; bl_index < denylist_len; bl_index++) { hid_denylist_t denylisted = hid_denylisted[bl_index]; // If vendor ids do not match, skip. - if (device_info.vendor_id != denylisted.vendor_id) + if (device_info.vendor_id != denylisted.vendor_id) { continue; + } // If product IDs do not match, skip. - if (device_info.product_id != denylisted.product_id) + if (device_info.product_id != denylisted.product_id) { continue; + } // Denylist entry based on interface number if (denylisted.interface_number != -1) { // Skip matching for devices without usage info. - if (!interface_number_valid) + if (!interface_number_valid) { continue; + } // If interface number is present and the interface numbers do not // match, skip. if (device_info.interface_number != denylisted.interface_number) { @@ -32,14 +35,17 @@ bool recognizeDevice(const hid_device_info& device_info) { // Denylist entry based on usage_page and usage (both required) if (denylisted.usage_page != 0 && denylisted.usage != 0) { // Skip matching for devices with no usage_page/usage info. - if (device_info.usage_page == 0 && device_info.usage == 0) + if (device_info.usage_page == 0 && device_info.usage == 0) { continue; + } // If usage_page is different, skip. - if (device_info.usage_page != denylisted.usage_page) + if (device_info.usage_page != denylisted.usage_page) { continue; + } // If usage is different, skip. - if (device_info.usage != denylisted.usage) + if (device_info.usage != denylisted.usage) { continue; + } } return false; } diff --git a/src/controllers/keyboard/keyboardeventfilter.cpp b/src/controllers/keyboard/keyboardeventfilter.cpp index 8722ab770e..254e4700f1 100644 --- a/src/controllers/keyboard/keyboardeventfilter.cpp +++ b/src/controllers/keyboard/keyboardeventfilter.cpp @@ -131,17 +131,21 @@ QKeySequence KeyboardEventFilter::getKeySeq(QKeyEvent* e) { // TODO(XXX) check if we may simply return QKeySequence(e->modifiers()+e->key()) - if (e->modifiers() & Qt::ShiftModifier) + if (e->modifiers() & Qt::ShiftModifier) { modseq += "Shift+"; + } - if (e->modifiers() & Qt::ControlModifier) + if (e->modifiers() & Qt::ControlModifier) { modseq += "Ctrl+"; + } - if (e->modifiers() & Qt::AltModifier) + if (e->modifiers() & Qt::AltModifier) { modseq += "Alt+"; + } - if (e->modifiers() & Qt::MetaModifier) + if (e->modifiers() & Qt::MetaModifier) { modseq += "Meta+"; + } if (e->key() >= 0x01000020 && e->key() <= 0x01000023) { // Do not act on Modifier only diff --git a/src/controllers/midi/midicontroller.cpp b/src/controllers/midi/midicontroller.cpp index d767dd002a..1aa4c75b97 100644 --- a/src/controllers/midi/midicontroller.cpp +++ b/src/controllers/midi/midicontroller.cpp @@ -371,14 +371,16 @@ double MidiController::computeValue( if (options.rot64 || options.rot64_inv) { tempval = prevmidivalue; diff = newmidivalue - 64.; - if (diff == -1 || diff == 1) + if (diff == -1 || diff == 1) { diff /= 16; - else + } else { diff += (diff > 0 ? -1 : +1); - if (options.rot64) + } + if (options.rot64) { tempval += diff; - else + } else { tempval -= diff; + } return (tempval < 0. ? 0. : (tempval > 127. ? 127.0 : tempval)); } @@ -392,8 +394,9 @@ double MidiController::computeValue( if (options.diff) { //Interpret 7-bit signed value using two's compliment. - if (newmidivalue >= 64.) + if (newmidivalue >= 64.) { newmidivalue = newmidivalue - 128.; + } //Apply sensitivity to signed value. FIXME // if(sensitivity > 0) // _newmidivalue = _newmidivalue * ((double)sensitivity / 50.); @@ -403,8 +406,9 @@ double MidiController::computeValue( if (options.selectknob) { //Interpret 7-bit signed value using two's compliment. - if (newmidivalue >= 64.) + if (newmidivalue >= 64.) { newmidivalue = newmidivalue - 128.; + } //Apply sensitivity to signed value. FIXME //if(sensitivity > 0) // _newmidivalue = _newmidivalue * ((double)sensitivity / 50.); diff --git a/src/controllers/midi/midicontrollerpresetfilehandler.cpp b/src/controllers/midi/midicontrollerpresetfilehandler.cpp index 838b915482..a87fb0ae23 100644 --- a/src/controllers/midi/midicontrollerpresetfilehandler.cpp +++ b/src/controllers/midi/midicontrollerpresetfilehandler.cpp @@ -38,11 +38,15 @@ ControllerPresetPointer MidiControllerPresetFileHandler::load(const QDomElement& // Allow specifying hex, octal, or decimal. unsigned char midiStatusByte = strMidiStatus.toInt(&ok, 0); - if (!ok) midiStatusByte = 0x00; + if (!ok) { + midiStatusByte = 0x00; + } // Allow specifying hex, octal, or decimal. unsigned char midiControl = midiNo.toInt(&ok, 0); - if (!ok) midiControl = 0x00; + if (!ok) { + midiControl = 0x00; + } QDomElement groupNode = control.firstChildElement("group"); QDomElement keyNode = control.firstChildElement("key"); @@ -62,21 +66,51 @@ ControllerPresetPointer MidiControllerPresetFileHandler::load(const QDomElement& strMidiOption = optionsNode.nodeName().toLower(); // "normal" is no options - if (strMidiOption == "invert") options.invert = true; - if (strMidiOption == "rot64") options.rot64 = true; - if (strMidiOption == "rot64inv") options.rot64_inv = true; - if (strMidiOption == "rot64fast")options.rot64_fast = true; - if (strMidiOption == "diff") options.diff = true; - if (strMidiOption == "button") options.button = true; - if (strMidiOption == "switch") options.sw = true; - if (strMidiOption == "hercjog") options.herc_jog = true; - if (strMidiOption == "hercjogfast") options.herc_jog_fast = true; - if (strMidiOption == "spread64") options.spread64 = true; - if (strMidiOption == "selectknob")options.selectknob = true; - if (strMidiOption == "soft-takeover") options.soft_takeover = true; - if (strMidiOption == "script-binding") options.script = true; - if (strMidiOption == "fourteen-bit-msb") options.fourteen_bit_msb = true; - if (strMidiOption == "fourteen-bit-lsb") options.fourteen_bit_lsb = true; + if (strMidiOption == "invert") { + options.invert = true; + } + if (strMidiOption == "rot64") { + options.rot64 = true; + } + if (strMidiOption == "rot64inv") { + options.rot64_inv = true; + } + if (strMidiOption == "rot64fast") { + options.rot64_fast = true; + } + if (strMidiOption == "diff") { + options.diff = true; + } + if (strMidiOption == "button") { + options.button = true; + } + if (strMidiOption == "switch") { + options.sw = true; + } + if (strMidiOption == "hercjog") { + options.herc_jog = true; + } + if (strMidiOption == "hercjogfast") { + options.herc_jog_fast = true; + } + if (strMidiOption == "spread64") { + options.spread64 = true; + } + if (strMidiOption == "selectknob") { + options.selectknob = true; + } + if (strMidiOption == "soft-takeover") { + options.soft_takeover = true; + } + if (strMidiOption == "script-binding") { + options.script = true; + } + if (strMidiOption == "fourteen-bit-msb") { + options.fourteen_bit_msb = true; + } + if (strMidiOption == "fourteen-bit-lsb") { + options.fourteen_bit_lsb = true; + } optionsNode = optionsNode.nextSiblingElement(); } @@ -130,16 +164,24 @@ ControllerPresetPointer MidiControllerPresetFileHandler::load(const QDomElement& //Use QString with toInt base of 0 to auto convert hex values mapping.output.status = midiStatus.toInt(&ok, 0); - if (!ok) mapping.output.status = 0x00; + if (!ok) { + mapping.output.status = 0x00; + } mapping.output.control = midiNo.toInt(&ok, 0); - if (!ok) mapping.output.control = 0x00; + if (!ok) { + mapping.output.control = 0x00; + } mapping.output.on = midiOn.toInt(&ok, 0); - if (!ok) mapping.output.on = DEFAULT_OUTPUT_ON; + if (!ok) { + mapping.output.on = DEFAULT_OUTPUT_ON; + } mapping.output.off = midiOff.toInt(&ok, 0); - if (!ok) mapping.output.off = DEFAULT_OUTPUT_OFF; + if (!ok) { + mapping.output.off = DEFAULT_OUTPUT_OFF; + } QDomElement minNode = output.firstChildElement("minimum"); QDomElement maxNode = output.firstChildElement("maximum"); @@ -151,8 +193,9 @@ ControllerPresetPointer MidiControllerPresetFileHandler::load(const QDomElement& ok = false; } - if (!ok) //If not a double, or node wasn't defined + if (!ok) { //If not a double, or node wasn't defined mapping.output.min = DEFAULT_OUTPUT_MIN; + } if (!maxNode.isNull()) { mapping.output.max = maxNode.text().toDouble(&ok); @@ -160,8 +203,9 @@ ControllerPresetPointer MidiControllerPresetFileHandler::load(const QDomElement& ok = false; } - if (!ok) //If not a double, or node wasn't defined + if (!ok) { //If not a double, or node wasn't defined mapping.output.max = DEFAULT_OUTPUT_MAX; + } // END unserialize output diff --git a/src/controllers/midi/portmidicontroller.cpp b/src/controllers/midi/portmidicontroller.cpp index d6a19f7436..87488f4e76 100644 --- a/src/controllers/midi/portmidicontroller.cpp +++ b/src/controllers/midi/portmidicontroller.cpp @@ -47,8 +47,9 @@ int PortMidiController::open() { return -1; } - if (getName() == MIXXX_PORTMIDI_NO_DEVICE_STRING) + if (getName() == MIXXX_PORTMIDI_NO_DEVICE_STRING) { return -1; + } m_bInSysex = false; m_cReceiveMsg_index = 0; |