summaryrefslogtreecommitdiffstats
path: root/src/controllers/controllerpresetinfo.cpp
diff options
context:
space:
mode:
authorRJ Ryan <rryan@mixxx.org>2014-04-21 16:48:21 -0400
committerRJ Ryan <rryan@mixxx.org>2014-04-21 16:48:21 -0400
commit8a0a4aa47ef3c9f8b8d4ade332992ebab5af3f26 (patch)
tree4ae3b3d62e36d8c1c25cde6e1de8f1b6c931abb8 /src/controllers/controllerpresetinfo.cpp
parent2dd7033c816feab48b9465f29bd6f4d1ec925aad (diff)
Move preset loading into a static method in ControllerPresetFileHandler.
PresetInfoEnumerator does a lot of filesystem access in its constructor so putting this code in there added a huge speed penalty for code that just wanted to parse a preset.
Diffstat (limited to 'src/controllers/controllerpresetinfo.cpp')
-rw-r--r--src/controllers/controllerpresetinfo.cpp61
1 files changed, 0 insertions, 61 deletions
diff --git a/src/controllers/controllerpresetinfo.cpp b/src/controllers/controllerpresetinfo.cpp
index 632f792f8b..30142b96f0 100644
--- a/src/controllers/controllerpresetinfo.cpp
+++ b/src/controllers/controllerpresetinfo.cpp
@@ -12,8 +12,6 @@
#include <QDirIterator>
#include "controllers/controllerpresetinfo.h"
-#include "controllers/midi/midicontrollerpresetfilehandler.h"
-#include "controllers/hid/hidcontrollerpresetfilehandler.h"
#include "controllers/defs_controllers.h"
#include "xmlparse.h"
@@ -146,13 +144,6 @@ PresetInfoEnumerator::PresetInfoEnumerator(ConfigObject<ConfigValue>* pConfig)
fileExtensions.append(QString(HID_PRESET_EXTENSION));
fileExtensions.append(QString(BULK_PRESET_EXTENSION));
- m_presetFileHandlersByExtension[QString(MIDI_PRESET_EXTENSION)] =
- new MidiControllerPresetFileHandler();
- m_presetFileHandlersByExtension[QString(HID_PRESET_EXTENSION)] =
- new HidControllerPresetFileHandler();
- m_presetFileHandlersByExtension[QString(BULK_PRESET_EXTENSION)] =
- new HidControllerPresetFileHandler();
-
loadSupportedPresets();
}
@@ -165,58 +156,6 @@ PresetInfoEnumerator::~PresetInfoEnumerator() {
}
}
-ControllerPresetPointer PresetInfoEnumerator::loadPreset(const QString& pathOrFilename,
- const QStringList& presetPaths) {
- QString scriptPath = pathOrFilename;
- QFileInfo scriptPathInfo(pathOrFilename);
-
- // If the path is not absolute, search for it in presetPaths.
- if (scriptPathInfo.isAbsolute()) {
- qDebug() << "Loading controller preset directly:" << scriptPath;
- } else {
- qDebug() << "Searching for controller preset" << scriptPath
- << "in paths:" << presetPaths.join(",");
- bool found = false;
- foreach (const QString& presetPath, presetPaths) {
- QDir presetDir(presetPath);
-
- if (presetDir.exists(pathOrFilename)) {
- scriptPath = presetDir.absoluteFilePath(pathOrFilename);
- scriptPathInfo = QFileInfo(scriptPath);
- found = true;
- break;
- }
- }
- if (!found) {
- qDebug() << "Could not find" << pathOrFilename
- << "in any preset path.";
- return ControllerPresetPointer();
- }
- }
-
- if (!scriptPathInfo.exists() || !scriptPathInfo.isReadable()) {
- qDebug() << "Preset" << scriptPath << "does not exist or is unreadable.";
- return ControllerPresetPointer();
- }
-
- // TODO(XXX): This means filenames can't have .foo.midi.xml filenames. We
- // should regex match against the end.
- // NOTE(rryan): We prepend a dot because all the XXX_PRESET_EXTENSION
- // defines include the dot.
- QString extension = "." + scriptPathInfo.completeSuffix();
-
- ControllerPresetFileHandler* pHandler =
- m_presetFileHandlersByExtension.value(extension, NULL);
- if (pHandler == NULL) {
- qDebug() << "Preset" << scriptPath << "has an unrecognized extension.";
- return ControllerPresetPointer();
- }
-
- // NOTE(rryan): We don't provide a device name. It's unused currently.
- return pHandler->load(scriptPath, QString());
-}
-
-
bool PresetInfoEnumerator::isValidExtension(const QString extension) {
if (presetsByExtension.contains(extension))
return true;