| 823 | } |
| 824 | |
| 825 | void |
| 826 | ReadNodePrivate::refreshPluginSelectorKnob() |
| 827 | { |
| 828 | KnobFilePtr fileKnob = inputFileKnob.lock(); |
| 829 | |
| 830 | assert(fileKnob); |
| 831 | std::string filePattern = fileKnob->getValue(); |
| 832 | std::vector<ChoiceOption> entries, help; |
| 833 | entries.push_back(ChoiceOption(kPluginSelectorParamEntryDefault, "", ReadNode::tr("Use the default plug-in chosen from the Preferences to read this file format").toStdString())); |
| 834 | |
| 835 | QString qpattern = QString::fromUtf8( filePattern.c_str() ); |
| 836 | std::string ext = QtCompat::removeFileExtension(qpattern).toLower().toStdString(); |
| 837 | std::string pluginID; |
| 838 | if ( !ext.empty() ) { |
| 839 | pluginID = appPTR->getReaderPluginIDForFileType(ext); |
| 840 | IOPluginSetForFormat readersForFormat; |
| 841 | appPTR->getReadersForFormat(ext, &readersForFormat); |
| 842 | |
| 843 | // Reverse it so that we sort them by decreasing score order |
| 844 | for (IOPluginSetForFormat::reverse_iterator it = readersForFormat.rbegin(); it != readersForFormat.rend(); ++it) { |
| 845 | Plugin* plugin = appPTR->getPluginBinary(QString::fromUtf8( it->pluginID.c_str() ), -1, -1, false); |
| 846 | std::stringstream ss; |
| 847 | ss << "Use " << plugin->getPluginLabel().toStdString() << " version "; |
| 848 | ss << plugin->getMajorVersion() << "." << plugin->getMinorVersion(); |
| 849 | ss << " to read this file format"; |
| 850 | entries.push_back( ChoiceOption(plugin->getPluginID().toStdString(), "", ss.str())); |
| 851 | } |
| 852 | } |
| 853 | |
| 854 | KnobChoicePtr pluginChoice = pluginSelectorKnob.lock(); |
| 855 | |
| 856 | pluginChoice->populateChoices(entries); |
| 857 | pluginChoice->blockValueChanges(); |
| 858 | pluginChoice->resetToDefaultValue(0); |
| 859 | pluginChoice->unblockValueChanges(); |
| 860 | if (entries.size() <= 2) { |
| 861 | pluginChoice->setSecret(true); |
| 862 | } else { |
| 863 | pluginChoice->setSecret(false); |
| 864 | } |
| 865 | |
| 866 | KnobStringPtr pluginIDKnob = pluginIDStringKnob.lock(); |
| 867 | pluginIDKnob->blockValueChanges(); |
| 868 | pluginIDKnob->setValue(pluginID); |
| 869 | pluginIDKnob->unblockValueChanges(); |
| 870 | |
| 871 | refreshFileInfoVisibility(pluginID); |
| 872 | |
| 873 | } // ReadNodePrivate::refreshPluginSelectorKnob |
| 874 | |
| 875 | bool |
| 876 | ReadNode::isReader() const |
no test coverage detected