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