diff --git a/API b/API index 4c77d96bac..eb69b83485 160000 --- a/API +++ b/API @@ -1 +1 @@ -Subproject commit 4c77d96bac2ecf5e7447886fb15b937ff05aa498 +Subproject commit eb69b83485605f6d3e6a11db58a4e6d6cabc893c diff --git a/base/plugins/iscore-plugin-deviceexplorer/DeviceExplorer/Protocol/DeviceInterface.hpp b/base/plugins/iscore-plugin-deviceexplorer/DeviceExplorer/Protocol/DeviceInterface.hpp index 8f7109a6ec..bb6bb39931 100644 --- a/base/plugins/iscore-plugin-deviceexplorer/DeviceExplorer/Protocol/DeviceInterface.hpp +++ b/base/plugins/iscore-plugin-deviceexplorer/DeviceExplorer/Protocol/DeviceInterface.hpp @@ -15,6 +15,8 @@ class DeviceInterface : public QObject explicit DeviceInterface(const iscore::DeviceSettings& s); const iscore::DeviceSettings& settings() const; + virtual void updateSettings(const iscore::DeviceSettings&) = 0; + // Asks, and returns all the new addresses if the device can refresh itself Minuit-like. // The addresses are not applied to the device, they have to be via a command! virtual bool canRefresh() const { return false; } @@ -38,6 +40,6 @@ class DeviceInterface : public QObject // In case the whole namespace changed? void namespaceUpdated(); - private: + protected: iscore::DeviceSettings m_settings; }; diff --git a/base/plugins/iscore-plugin-deviceexplorer/Plugin/Commands/Update/UpdateDeviceSettings.cpp b/base/plugins/iscore-plugin-deviceexplorer/Plugin/Commands/Update/UpdateDeviceSettings.cpp index 12ce353d82..c6ca679d75 100644 --- a/base/plugins/iscore-plugin-deviceexplorer/Plugin/Commands/Update/UpdateDeviceSettings.cpp +++ b/base/plugins/iscore-plugin-deviceexplorer/Plugin/Commands/Update/UpdateDeviceSettings.cpp @@ -18,7 +18,7 @@ UpdateDeviceSettings::UpdateDeviceSettings( auto it = std::find_if(devplug.rootNode().begin(), devplug.rootNode().end(), [&] (const iscore::Node& n) - { return n.get().name == name; }); + { return n.get().name == name; }); ISCORE_ASSERT(it != devplug.rootNode().end()); diff --git a/base/plugins/iscore-plugin-deviceexplorer/Plugin/DocumentPlugin/NodeUpdateProxy.cpp b/base/plugins/iscore-plugin-deviceexplorer/Plugin/DocumentPlugin/NodeUpdateProxy.cpp index f5cece1ea0..2cfd2b3a69 100644 --- a/base/plugins/iscore-plugin-deviceexplorer/Plugin/DocumentPlugin/NodeUpdateProxy.cpp +++ b/base/plugins/iscore-plugin-deviceexplorer/Plugin/DocumentPlugin/NodeUpdateProxy.cpp @@ -45,9 +45,22 @@ void NodeUpdateProxy::loadDevice(const iscore::Node& node) void NodeUpdateProxy::updateDevice( const QString &name, - const iscore::DeviceSettings &dev) + const iscore::DeviceSettings& dev) { - ISCORE_TODO; + m_devModel.list().device(name).updateSettings(dev); + + if(m_deviceExplorer) + { + m_deviceExplorer->updateDevice(name, dev); + } + else + { + auto it = std::find_if(m_devModel.rootNode().begin(), m_devModel.rootNode().end(), + [&] (const iscore::Node& n) { return n.get().name == name; }); + + ISCORE_ASSERT(it != m_devModel.rootNode().end()); + it->set(dev); + } } void NodeUpdateProxy::removeDevice(const iscore::DeviceSettings& dev) diff --git a/base/plugins/iscore-plugin-deviceexplorer/Plugin/Panel/DeviceExplorerModel.cpp b/base/plugins/iscore-plugin-deviceexplorer/Plugin/Panel/DeviceExplorerModel.cpp index a1d210f5fc..bd12815749 100644 --- a/base/plugins/iscore-plugin-deviceexplorer/Plugin/Panel/DeviceExplorerModel.cpp +++ b/base/plugins/iscore-plugin-deviceexplorer/Plugin/Panel/DeviceExplorerModel.cpp @@ -108,7 +108,8 @@ DeviceExplorerModel::getColumns() const return HEADERS.values(); } -int DeviceExplorerModel::addDevice(Node* deviceNode) +int DeviceExplorerModel::addDevice( + Node* deviceNode) { int row = m_rootNode.childCount(); QModelIndex parent; //invalid @@ -120,6 +121,28 @@ int DeviceExplorerModel::addDevice(Node* deviceNode) return row; } +void DeviceExplorerModel::updateDevice( + const QString& name, + const DeviceSettings& dev) +{ + for(int i = 0; i < m_rootNode.childCount(); i++) + { + auto n = &m_rootNode.childAt(i); + if(n->get().name == name) + { + QModelIndex index = createIndex(i, 0, n->parent()); + + QModelIndex changedTopLeft = index; + QModelIndex changedBottomRight = index; + + n->set(dev); + + emit dataChanged(changedTopLeft, changedBottomRight); + return; + } + } +} + Node* DeviceExplorerModel::addAddress( Node* parentNode, const iscore::AddressSettings &addressSettings) @@ -144,7 +167,10 @@ Node* DeviceExplorerModel::addAddress( return node; } -void DeviceExplorerModel::addAddress(Node *parentNode, Node *node, int row) +void DeviceExplorerModel::addAddress( + Node *parentNode, + Node *node, + int row) { ISCORE_ASSERT(parentNode); ISCORE_ASSERT(parentNode != &m_rootNode); @@ -166,7 +192,9 @@ void DeviceExplorerModel::addAddress(Node *parentNode, Node *node, int row) endInsertRows(); } -void DeviceExplorerModel::updateAddress(Node *node, const AddressSettings &addressSettings) +void DeviceExplorerModel::updateAddress( + Node *node, + const AddressSettings &addressSettings) { ISCORE_ASSERT(node); ISCORE_ASSERT(node != &m_rootNode); @@ -181,7 +209,8 @@ void DeviceExplorerModel::updateAddress(Node *node, const AddressSettings &addre createIndex(nodeIndex.row(), HEADERS.count(), node->parent())); } -void DeviceExplorerModel::removeNode(Node* node) +void DeviceExplorerModel::removeNode( + Node* node) { ISCORE_ASSERT(node); ISCORE_ASSERT(node != &m_rootNode); @@ -202,7 +231,8 @@ void DeviceExplorerModel::removeNode(Node* node) delete node; } -bool DeviceExplorerModel::checkDeviceInstantiatable(iscore::DeviceSettings& n) +bool DeviceExplorerModel::checkDeviceInstantiatable( + iscore::DeviceSettings& n) { // Request from the protocol factory the protocol to see // if it is compatible. diff --git a/base/plugins/iscore-plugin-deviceexplorer/Plugin/Panel/DeviceExplorerModel.hpp b/base/plugins/iscore-plugin-deviceexplorer/Plugin/Panel/DeviceExplorerModel.hpp index d28b366d6c..882844f91b 100644 --- a/base/plugins/iscore-plugin-deviceexplorer/Plugin/Panel/DeviceExplorerModel.hpp +++ b/base/plugins/iscore-plugin-deviceexplorer/Plugin/Panel/DeviceExplorerModel.hpp @@ -75,6 +75,10 @@ class DeviceExplorerModel : public QAbstractItemModel // Returns the row (useful for undo) int addDevice(iscore::Node* deviceNode); + void updateDevice( + const QString &name, + const iscore::DeviceSettings& dev); + iscore::Node* addAddress( iscore::Node * parentNode, const iscore::AddressSettings& addressSettings); diff --git a/base/plugins/iscore-plugin-deviceexplorer/Plugin/Panel/DeviceExplorerWidget.cpp b/base/plugins/iscore-plugin-deviceexplorer/Plugin/Panel/DeviceExplorerWidget.cpp index f937545a21..ab81671624 100644 --- a/base/plugins/iscore-plugin-deviceexplorer/Plugin/Panel/DeviceExplorerWidget.cpp +++ b/base/plugins/iscore-plugin-deviceexplorer/Plugin/Panel/DeviceExplorerWidget.cpp @@ -421,9 +421,6 @@ void DeviceExplorerWidget::edit() iscore::Node* select = model()->nodeFromModelIndex(m_ntView->selectedIndex()); if (select->is()) { - ISCORE_TODO; - return; - /* if(! m_deviceDialog) { m_deviceDialog = new DeviceEditDialog(this); @@ -435,12 +432,15 @@ void DeviceExplorerWidget::edit() if(code == QDialog::Accepted) { - auto deviceSettings = m_deviceDialog->getSettings(); - select->setDeviceSettings(deviceSettings); + auto cmd = new DeviceExplorer::Command::UpdateDeviceSettings{ + iscore::IDocument::path(model()->deviceModel()), + set.name, + m_deviceDialog->getSettings()}; + + m_cmdDispatcher->submitCommand(cmd); } updateActions(); - */ } else { diff --git a/base/plugins/iscore-plugin-deviceexplorer/Plugin/Panel/Widgets/AddressEditDialog.cpp b/base/plugins/iscore-plugin-deviceexplorer/Plugin/Panel/Widgets/AddressEditDialog.cpp index c5bbcea6f1..f459632ce7 100644 --- a/base/plugins/iscore-plugin-deviceexplorer/Plugin/Panel/Widgets/AddressEditDialog.cpp +++ b/base/plugins/iscore-plugin-deviceexplorer/Plugin/Panel/Widgets/AddressEditDialog.cpp @@ -12,7 +12,6 @@ AddressEditDialog::AddressEditDialog( QWidget* parent): AddressEditDialog{makeDefaultSettings(), parent} { - m_nameEdit->setEnabled(true); } AddressEditDialog::AddressEditDialog( @@ -26,7 +25,6 @@ AddressEditDialog::AddressEditDialog( // Name m_nameEdit = new QLineEdit(this); - m_nameEdit->setEnabled(false); // TODO update when we can do it in the API m_layout->addRow(tr("Name"), m_nameEdit); setNodeSettings(); diff --git a/base/plugins/iscore-plugin-ossia/Protocols/MIDI/MIDIDevice.cpp b/base/plugins/iscore-plugin-ossia/Protocols/MIDI/MIDIDevice.cpp index 2322a32fdd..e6776f0195 100644 --- a/base/plugins/iscore-plugin-ossia/Protocols/MIDI/MIDIDevice.cpp +++ b/base/plugins/iscore-plugin-ossia/Protocols/MIDI/MIDIDevice.cpp @@ -10,3 +10,9 @@ MIDIDevice::MIDIDevice(const iscore::DeviceSettings &settings): m_dev = Device::create(parameters, settings.name.toStdString()); } + + +void MIDIDevice::updateSettings(const iscore::DeviceSettings&) +{ + ISCORE_TODO; +} diff --git a/base/plugins/iscore-plugin-ossia/Protocols/MIDI/MIDIDevice.hpp b/base/plugins/iscore-plugin-ossia/Protocols/MIDI/MIDIDevice.hpp index 0abd145665..65f8e3071f 100644 --- a/base/plugins/iscore-plugin-ossia/Protocols/MIDI/MIDIDevice.hpp +++ b/base/plugins/iscore-plugin-ossia/Protocols/MIDI/MIDIDevice.hpp @@ -6,5 +6,5 @@ class MIDIDevice : public OSSIADevice public: MIDIDevice(const iscore::DeviceSettings& settings); - + void updateSettings(const iscore::DeviceSettings&) override; }; diff --git a/base/plugins/iscore-plugin-ossia/Protocols/Minuit/MinuitDevice.cpp b/base/plugins/iscore-plugin-ossia/Protocols/Minuit/MinuitDevice.cpp index 45c01e38bd..8f0f891edc 100644 --- a/base/plugins/iscore-plugin-ossia/Protocols/Minuit/MinuitDevice.cpp +++ b/base/plugins/iscore-plugin-ossia/Protocols/Minuit/MinuitDevice.cpp @@ -23,6 +23,19 @@ MinuitDevice::MinuitDevice(const iscore::DeviceSettings &settings): m_dev = Device::create(m_minuitSettings, settings.name.toStdString()); } +void MinuitDevice::updateSettings(const iscore::DeviceSettings& settings) +{ + m_settings = settings; + auto stgs = settings.deviceSpecificSettings.value(); + + // TODO m_dev->setName(m_settings.name.toStdString()); + + auto prot = dynamic_cast(m_dev->getProtocol().get()); + prot->setInPort(stgs.inPort); + prot->setOutPort(stgs.outPort); + prot->setIp(stgs.host.toStdString()); +} + bool MinuitDevice::canRefresh() const { return true; @@ -38,7 +51,6 @@ iscore::Node MinuitDevice::refresh() // First make the node corresponding to the root node. device_node.set(settings()); - //device_node.setAddressSettings(ToAddressSettings(*m_dev.get())); // Recurse on the children for(const auto& node : m_dev->children()) diff --git a/base/plugins/iscore-plugin-ossia/Protocols/Minuit/MinuitDevice.hpp b/base/plugins/iscore-plugin-ossia/Protocols/Minuit/MinuitDevice.hpp index 837c8c497a..b758c2be84 100644 --- a/base/plugins/iscore-plugin-ossia/Protocols/Minuit/MinuitDevice.hpp +++ b/base/plugins/iscore-plugin-ossia/Protocols/Minuit/MinuitDevice.hpp @@ -11,6 +11,9 @@ class MinuitDevice : public OSSIADevice { public: MinuitDevice(const iscore::DeviceSettings& settings); + + void updateSettings(const iscore::DeviceSettings&) override; + bool canRefresh() const override; iscore::Node refresh() override; // throws std::runtime_error iscore::Value refresh(const iscore::Address&) override; diff --git a/base/plugins/iscore-plugin-ossia/Protocols/OSC/OSCDevice.cpp b/base/plugins/iscore-plugin-ossia/Protocols/OSC/OSCDevice.cpp index 694326952b..7fb3c8d7d8 100644 --- a/base/plugins/iscore-plugin-ossia/Protocols/OSC/OSCDevice.cpp +++ b/base/plugins/iscore-plugin-ossia/Protocols/OSC/OSCDevice.cpp @@ -1,12 +1,29 @@ #include "OSCDevice.hpp" #include #include + OSCDevice::OSCDevice(const iscore::DeviceSettings &stngs): OSSIADevice{stngs} { using namespace OSSIA; auto settings = stngs.deviceSpecificSettings.value(); - auto oscDeviceParameter = OSSIA::OSC::create(settings.host.toStdString(), settings.inputPort, settings.outputPort); + auto oscDeviceParameter = OSSIA::OSC::create( + settings.host.toStdString(), + settings.inputPort, + settings.outputPort); m_dev = OSSIA::Device::create(oscDeviceParameter, stngs.name.toStdString()); } + +void OSCDevice::updateSettings(const iscore::DeviceSettings& settings) +{ + m_settings = settings; + auto stgs = settings.deviceSpecificSettings.value(); + + m_dev->setName(m_settings.name.toStdString()); + + auto prot = dynamic_cast(m_dev->getProtocol().get()); + prot->setInPort(stgs.inputPort); + prot->setOutPort(stgs.outputPort); + prot->setIp(stgs.host.toStdString()); +} diff --git a/base/plugins/iscore-plugin-ossia/Protocols/OSC/OSCDevice.hpp b/base/plugins/iscore-plugin-ossia/Protocols/OSC/OSCDevice.hpp index dae0ed41b0..9f3e6b203e 100644 --- a/base/plugins/iscore-plugin-ossia/Protocols/OSC/OSCDevice.hpp +++ b/base/plugins/iscore-plugin-ossia/Protocols/OSC/OSCDevice.hpp @@ -6,4 +6,5 @@ class OSCDevice : public OSSIADevice { public: OSCDevice(const iscore::DeviceSettings& stngs); + void updateSettings(const iscore::DeviceSettings& settings) override; }; diff --git a/base/plugins/iscore-plugin-ossia/Protocols/OSSIADevice.cpp b/base/plugins/iscore-plugin-ossia/Protocols/OSSIADevice.cpp index f04cdeb1b7..acf08dac6f 100644 --- a/base/plugins/iscore-plugin-ossia/Protocols/OSSIADevice.cpp +++ b/base/plugins/iscore-plugin-ossia/Protocols/OSSIADevice.cpp @@ -1,12 +1,14 @@ #include "OSSIADevice.hpp" #include #include +#include #include "iscore2OSSIA.hpp" #include "OSSIA2iscore.hpp" using namespace iscore::convert; using namespace OSSIA::convert; + void OSSIADevice::addAddress(const iscore::FullAddressSettings &settings) { using namespace OSSIA; @@ -24,6 +26,7 @@ void OSSIADevice::updateAddress(const iscore::FullAddressSettings &settings) using namespace OSSIA; OSSIA::Node* node = getNodeFromPath(settings.address.path, m_dev.get()); + node->setName(settings.address.path.last().toStdString()); if(settings.ioType == iscore::IOType::Invalid) removeOSSIAAddress(node);