MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / editUserEntry

Method editUserEntry

Gui/KnobGuiTable.cpp:696–747  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

694}
695
696bool
697KnobGuiLayers::editUserEntry(QStringList& row)
698{
699 std::vector<std::string> channels;
700 QStringList splits = row[1].split( QLatin1Char(' ') );
701
702 for (int i = 0; i < splits.size(); ++i) {
703 channels.push_back( splits[i].toStdString() );
704 }
705 ImagePlaneDesc original(row[0].toStdString(), row[0].toStdString(), std::string(), channels);;
706 NewLayerDialog dialog( original, getGui() );
707 if ( dialog.exec() ) {
708 ImagePlaneDesc comps = dialog.getComponents();
709 if ( comps == ImagePlaneDesc::getNoneComponents() ) {
710 Dialogs::errorDialog( tr("Layer").toStdString(), tr("A layer must contain at least 1 channel and channel names must be "
711 "Python compliant.").toStdString() );
712
713 return false;
714 }
715
716 std::string oldLayerName = row[0].toStdString();
717 row[0] = ( QString::fromUtf8( comps.getPlaneLabel().c_str() ) );
718
719 KnobLayersPtr knob = _knob.lock();
720 if (!knob) {
721 return false;
722 }
723 std::list<std::vector<std::string> > table;
724 knob->getTable(&table);
725 for (std::list<std::vector<std::string> >::iterator it = table.begin(); it != table.end(); ++it) {
726 if ( ( (*it)[0] == comps.getPlaneLabel() ) && ( (*it)[0] != oldLayerName ) ) {
727 Dialogs::errorDialog( tr("Layer").toStdString(), tr("A Layer with the same name already exists").toStdString() );
728
729 return false;
730 }
731 }
732
733 std::string channelsStr;
734 const std::vector<std::string>& channels = comps.getChannels();
735 for (std::size_t i = 0; i < channels.size(); ++i) {
736 channelsStr += channels[i];
737 if ( i < (channels.size() - 1) ) {
738 channelsStr += ' ';
739 }
740 }
741 row[1] = ( QString::fromUtf8( channelsStr.c_str() ) );
742
743 return true;
744 }
745
746 return false;
747}
748
749void
750KnobGuiLayers::tableChanged(int row,

Callers

nothing calls this directly

Calls 11

getGuiFunction · 0.85
toStdStringMethod · 0.80
getComponentsMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45
execMethod · 0.45
lockMethod · 0.45
getTableMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
getChannelsMethod · 0.45

Tested by

no test coverage detected