Exemple #1
0
void MRuleDialog::onMandatoryFieldsChanged()
{
	bool valid=ui->variableBox->count() > 0;

	if (valid && actionName()!=QString())
	{
		ProgramVariable var=_prog.getVariableByName(ui->variableBox->currentText(), actionName());
		switch(var.type())
		{
		case Type::RegExp:
		case Type::String:
			valid=var.validate(ui->valueLineEdit->text());
			break;

		case Type::StringList:
			valid=var.validate(ui->valueComboBox->currentText());
			break;

		case Type::Int:
			valid=var.validate(ui->valueSpinBox->value());
			break;

		case Type::Boolean:
			valid=true;
			break;

		default:
			valid=false;
		}
	}

	ui->propAddButton->setEnabled(valid);
}
Exemple #2
0
bool KKeyChooser::isKeyPresent()
{
	// Search the global key codes to find if this keyCode is already used
	//  elsewhere
	
	QDictIterator<int> gIt( *globalDict );
	
	gIt.toFirst();
	while ( gIt.current() ) {
		debug("current %s:%d code %d", gIt.currentKey(), *gIt.current(), pEntry->aConfigKeyCode);
		if ( *gIt.current() == pEntry->aConfigKeyCode && *gIt.current() != 0 ) {
			QString actionName( gIt.currentKey() );
			actionName.stripWhiteSpace();

			QString keyName = keyToString( *gIt.current() );
			
			QString str;
			str.sprintf(
				"The %s key combination has already been allocated\nto the global %s action.\n\nPlease choose a unique key combination.",
				keyName.data(),
				actionName.data() );
				
			QMessageBox::warning( this, "Global key conflict", str.data() );
			
			return TRUE;
		}
		++gIt;
	}
	
	// Search the aConfigKeyCodes to find if this keyCode is already used
	// elsewhere
	aIt->toFirst();
	while ( aIt->current() ) {
		if ( aIt->current() != pEntry
				&& aIt->current()->aConfigKeyCode == pEntry->aConfigKeyCode ) {
			QString actionName( aIt->currentKey() );
			actionName.stripWhiteSpace();

			QString keyName = keyToString( aIt->current()->aConfigKeyCode );
			
			QString str;
			str.sprintf(
				"The %s key combination has already been allocated\nto the %s action.\n\nPlease choose a unique key combination.",
				keyName.data(),
				actionName.data() );
				
			QMessageBox::warning( this, "Key conflict", str.data() );
			
			return TRUE;
		}
		++(*aIt);
	}
	
	emit keyChange();
	
	return FALSE;
}   
Exemple #3
0
void MRuleDialog::onCondAddButtonClicked()
{
	//Data of the future new row
	QStringList itemStrList;
	itemStrList.append(ui->variableBox->currentText());
	QStringList data;

	//Delegate used to edit the row
	TypedDelegate *delegate=0;

	if(actionName()==QString())
		delegate=new TypedDelegate(Type::String, 1, this);
	else
	{
		//Variable that we have to add
		ProgramVariable var=_prog.getVariableByName(ui->variableBox->currentText(), actionName());
		switch (var.type())
		{
		case Type::Int:
			itemStrList.append(QString("%1").arg(ui->valueSpinBox->value()));
			delegate=new TypedDelegate(Type::Int, 1, this, ui->valueSpinBox->minimum(), ui->valueSpinBox->maximum());
			break;

		case Type::String:
			itemStrList.append(ui->valueLineEdit->text());
			delegate=new TypedDelegate(Type::String, 1, this, ui->valueLineEdit->validationExpression());
			break;

		case Type::RegExp:
			itemStrList.append(ui->valueLineEdit->text());
			qDebug("%s", qPrintable(ui->valueLineEdit->text()));
			delegate=new TypedDelegate(Type::String, 1, this, ui->valueLineEdit->validationExpression());
			break;

		case Type::StringList:
			itemStrList.append(ui->valueComboBox->currentText());
			for(int i=0; i<ui->valueComboBox->count(); ++i)
				data.append(ui->valueComboBox->itemText(i));
			delegate=new TypedDelegate(Type::StringList, 1, this, data);
			break;

		case Type::Boolean:
			itemStrList.append(ui->valueCheckBox->isChecked()? "True":"False");
			delegate=new TypedDelegate(Type::Boolean, 1, this);
		}
	}

	QTreeWidgetItem *item=new QTreeWidgetItem(ui->propList, itemStrList);
	item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsEnabled);
	ui->propList->setItemDelegateForRow(ui->propList->indexOfTopLevelItem(item), delegate);

	ui->variableBox->removeItem(ui->variableBox->currentIndex());
	ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(conditionCount() > 0);
}
QString sJarvisNodeComponent::slotName(jarvisActions a)
{
    QString result = "1";
    result.append(actionName(a));
    result.append("()");
    return result;
}
Exemple #5
0
void
outputSWF_ACTION (int n, SWF_ACTION *act)
{
  struct SWF_ACTIONRECORD *action = (struct SWF_ACTIONRECORD *)act;
  int i;

  for (i = 0; i < numActions; i++)
    {
      if (actions[i].type == action->ActionCode)
      {
	INDENT;
	if( verbose )
  	    printf ("  Action: %d ", n );
  	printf ("  %lu:%s\n", action->Offset, actionName (action->ActionCode));
	if( verbose ) {
	    INDENT;
  	    printf ("  Offset: %lx\n", action->Offset );
	}
  	if (actions[i].func != NULL )
  	{
	  	actions[i].func(act);
  	} else {
  		if (action->ActionCode >= 0x80)
  		{
			if( verbose ) {
				INDENT;
				printf ("  Length: %d\n", action->Length);
			}
  		}
  	}
      }
    }
}
void MatLabUdmState::setupState( void ) {

	State udmState = getUdmState();
	udmState.name() = getUniqueName().c_str();
	udmState.RefId() = getRefId();
	udmState.Description() = MatLabEngine::globalEngine().getMxStringValue( getMatLabObject() + ".Description" );

	// GET LABEL STRING, PERFORM SUBSTITUTIONS FOR READABILITY
	std::string labelString = RegexCommon::eliminateContinuations(  MatLabEngine::globalEngine().getMxStringValue( getMatLabObject() + ".LabelString" )  );
	labelString = boost::regex_replace( labelString, MatLabEngine::matLabComment(), "" );


	std::string stateType = MatLabEngine::globalEngine().getMxStringValue(  std::string( "class( " + getMatLabObject() + " )" )  );

	if ( stateType == "Stateflow.Box" ) {
		udmState.Decomposition() = "GROUP_STATE";
		return;
	}

	// REGISTER THIS STATE SO TRANSITIONS CAN LOCATE IT AND USE IT AS AN ENDPOINT
	registerForTransitions();

	std::string stateOrder = boost::lexical_cast< std::string >(
	 MatLabEngine::globalEngine().getMxIntValue( getMatLabObject() + ".ExecutionOrder" )
	);
	udmState.Order() = stateOrder.empty() ? "0" : stateOrder;

	static boost::regex nameRegex(  std::string( "\\A\\s*(\\w*)\\s*/?\\s*" ), boost::regex_constants::perl  );
	static boost::regex actionRegex(  std::string( "((\\w+)\\s*:\\s*(.*?\\S?)\\s*)(?:\\w+\\s*:|\\z)" ), boost::regex_constants::perl  );
	static boost::regex defaultActionRegex(  std::string( "\\A\\s*(.*\\S?)\\s*\\Z" ), boost::regex_constants::perl  );
	boost::match_results< std::string::const_iterator > results;

	if (  regex_search( labelString, results, nameRegex )  ) {
		udmState.Name() = std::string( results[1].first, results[1].second ).c_str();
		labelString = std::string(  results[0].second, static_cast< std::string::const_iterator >( labelString.end() )  );
	}

	while (  regex_search( labelString, results, actionRegex )  ) {
		std::string actionName( results[2].first, results[2].second );
		std::transform( actionName.begin(), actionName.end(), actionName.begin(), ToLower() );
		std::string actionValue( results[3].first, results[3].second );
		if      ( actionName.substr(0, 2) == "en" ) udmState.EnterAction()  = actionValue.c_str();
		else if ( actionName.substr(0, 1) == "d" )  udmState.DuringAction() = actionValue.c_str();
		else if ( actionName.substr(0, 2) == "ex" ) udmState.ExitAction()   = actionValue.c_str();

		labelString.replace(
		 results[1].first - labelString.begin(),
		 results[1].second - results[1].first,
		 ""
		);
	}

	regex_search( labelString, results, defaultActionRegex );
	std::string defaultEnterAction( results[1].first, results[1].second );
	if (  defaultEnterAction != ""  &&  std::string( udmState.EnterAction() ) == ""  ) {
		udmState.EnterAction() = defaultEnterAction;
	}

	udmState.Decomposition() = MatLabEngine::globalEngine().getMxStringValue( getMatLabObject() + ".Type" ) + "_STATE";
}
FilterAction::FilterAction(QObject *parent, FilterAction::Action action) :
    QAction(parent),
    action_(action),
    type_(ActionTypePlain),
    direction_(ActionDirectionAToAny)
{
    setText(actionName(action));
}
GtkAction* WebPopupMenuProxyGtk::createGtkActionForMenuItem(const WebPopupItem& item, int itemIndex)
{
    GUniquePtr<char> actionName(g_strdup_printf("popup-menu-action-%d", itemIndex));
    GtkAction* action = gtk_action_new(actionName.get(), item.m_text.utf8().data(), item.m_toolTip.utf8().data(), 0);
    g_object_set_data(G_OBJECT(action), "popup-menu-action-index", GINT_TO_POINTER(itemIndex));
    g_signal_connect(action, "activate", G_CALLBACK(menuItemActivated), this);
    gtk_action_set_sensitive(action, item.m_isEnabled);

    return action;
}
Exemple #9
0
ActionData NewActionDialog::actionData() const
{
    ActionData rc;
    rc.text = actionText();
    rc.name = actionName();
    rc.toolTip = m_ui->tooltipEditor->text();
    rc.icon = m_ui->iconSelector->icon();
    rc.checkable = m_ui->checkableCheckBox->checkState() == Qt::Checked;
    rc.keysequence = PropertySheetKeySequenceValue(m_ui->keySequenceEdit->keySequence());
    return rc;
}
Exemple #10
0
GtkAction* PopupMenuGtk::createGtkActionForMenuItem(int itemIndex)
{
    GOwnPtr<char> actionName(g_strdup_printf("popup-menu-action-%d", itemIndex));
    GtkAction* action = gtk_action_new(actionName.get(), client()->itemText(itemIndex).utf8().data(), client()->itemToolTip(itemIndex).utf8().data(), 0);
    g_object_set_data(G_OBJECT(action), "popup-menu-action-index", GINT_TO_POINTER(itemIndex));
    g_signal_connect(action, "activate", G_CALLBACK(menuItemActivated), this);
    // FIXME: Apply the PopupMenuStyle from client()->itemStyle(i)
    gtk_action_set_visible(action, !client()->itemStyle(itemIndex).isDisplayNone());
    gtk_action_set_sensitive(action, client()->itemIsEnabled(itemIndex));

    return action;
}
ACTIONS act_predict::produce_action_ranked(const QVector<float>& update)
{
    float highest=0;
    int index=0;
    for(int i=0;i<update.count();i++)
    {
        if (update[i]>highest)
        {
            highest=update[i];
            index=i;
        }
    }

    if(highest<MINIMUM_PROB)
        return START;

    qDebug() <<"ranked_selected action "<<actionName(ACTIONS(index))<<"with probability"<<update[index];
    return ACTIONS(index);
}
Exemple #12
0
void MenuButton::setAction(const QString & name)
{
  if (actionName() == name)
    return;

  if (_guiClientInterface)
  {
    QAction *action = _guiClientInterface->findAction(name);
    if (!action)
    {
      // Create one so property can be saved.  Maybe gui client
      // action name provided will be valid in another instance.
      action = new QAction(this);
      action->setObjectName(name);
      action->setEnabled(false);
    }
    setAction(action);
  }
}
ACTIONS act_predict::produce_action_rng(const QVector<float>& update)
{

    int val=qrand()*(100.0/RAND_MAX);
    qDebug()<<"Random variable "<<val;
    int current=0;
    int index=0;
    for(int i=0;i<update.count();i++)
    {
       current+=update[i]*100;
       if(current>=val)
       {
           index=i;
           break;
       }
    }
    //produce_action_ranked(update);
    //This way of drawing and instance is not correct, needs to be fixed!!
    //+ Later studies made me change my mind, This is actually a correct way of drawing
    //  instances of PD.
    qDebug() <<"rng_selected action "<<actionName(ACTIONS(index))<<"with probability"<<update[index];
    return ACTIONS(index);
}
Exemple #14
0
//***************************************************************************
void Kwave::FilterPlugin::run(QStringList params)
{
    Kwave::UndoTransactionGuard *undo_guard = 0;
    m_pause = false;

    if (!interpreteParameters(params)) m_params = params;

    sample_index_t first, last;
    QList<unsigned int> tracks;
    selection(&tracks, &first, &last, true);

    // switch to interactive mode in pre-listen mode
    Kwave::StreamObject::setInteractive(m_listen);

    // create all objects
    Kwave::MultiTrackReader source(
	(m_listen) ? Kwave::FullSnapshot : Kwave::SinglePassForward,
	signalManager(), tracks, first, last);

    Kwave::SampleSource *filter = createFilter(tracks.count());
    Q_ASSERT(filter);

    if (m_listen) {
	// pre-listen mode
	Q_ASSERT(m_sink);
    } else {
	// normal mode, with undo
	undo_guard = new(std::nothrow)
	    Kwave::UndoTransactionGuard(*this, actionName());
	Q_ASSERT(undo_guard);
	if (!undo_guard) {
	    if (filter) delete filter;
	    Kwave::StreamObject::setInteractive(false);
	    return;
	}
	m_sink = new(std::nothrow) MultiTrackWriter(signalManager(), tracks,
	    Kwave::Overwrite, first, last);
	Q_ASSERT(m_sink);
    }
    if (!filter || !m_sink || m_sink->done()) {
	if (filter)     delete filter;
	if (undo_guard) delete undo_guard;
	if (m_sink)     delete m_sink;
	m_sink = 0;
	Kwave::StreamObject::setInteractive(false);
	return;
    }

    // set up the progress dialog when in processing (not pre-listen) mode
    if (!m_listen) {
	connect(&source, SIGNAL(progress(qreal)),
		this,    SLOT(updateProgress(qreal)),
		Qt::BlockingQueuedConnection);
    }

    // force initial update of the filter settings
    updateFilter(filter, true);

    // connect them
    Kwave::connect(source,  SIGNAL(output(Kwave::SampleArray)),
                   *filter, SLOT(input(Kwave::SampleArray)));
    Kwave::connect(*filter, SIGNAL(output(Kwave::SampleArray)),
                   *m_sink, SLOT(input(Kwave::SampleArray)));

    // transport the samples
    while (!shouldStop() && (!source.done() || m_listen)) {
	// process one step
	source.goOn();
	filter->goOn();

	// watch out for changed parameters when in
	// pre-listen mode
	if (m_listen && paramsChanged()) {
	    updateFilter(filter);
        }

	if (m_listen && source.done()) {
	    // start the next loop
	    source.reset();
	    continue;
	}

	// this lets the process wait if the user pressed cancel
	// and the confirm_cancel dialog is active
	while (m_pause && !shouldStop())
	    sleep(1);
    }

    // cleanup
    if (filter)     delete filter;
    if (m_sink)     delete m_sink;
    m_sink = 0;
    if (undo_guard) delete undo_guard;

    m_pause  = false;
    m_listen = false;

    Kwave::StreamObject::setInteractive(false);
}
Exemple #15
0
void MRuleDialog::onVariableChanged(QString var_name)
{
	//Hide all the edit widgets, and show below the one to be used
	ui->valueInvalidType->hide();
	ui->valueCheckBox->hide();
	ui->valueComboBox->hide();
	ui->valueLineEdit->hide();
	ui->valueSpinBox->hide();

	//Check that there is an action setup. If there is one, fetch current variable and put the good widget for its type
	if(actionName()!=QString())
	{
		ProgramVariable var=_prog.getVariableByName(var_name, actionName());
		ui->valueDescLabel->setText("<i>"+var.description()+"</i>");
		ui->valueDescLabel->show();

		//Setup the options for the editor widget we'll use
		switch(var.type())
		{
		case Type::RegExp:
		case Type::String:
			ui->valueLineEdit->setIsRegexpSyntax(var.type()==Type::RegExp);
			ui->valueLineEdit->setValidationExpression(var.stringValidation());
			ui->valueLineEdit->setAutocompletionList(ProgramVariable::assignedValues(var_name, var.type()));
			ui->valueLineEdit->clear();

			if(var.stringValidation()!=QString() && var.stringValidation()!=".*")
				ui->valueDescLabel->setText(ui->valueDescLabel->text()+"<i> The value must match the expression '"+ var.stringValidation()+"'.</i>");

			ui->valueLineEdit->show();
			break;

		case Type::StringList:
			ui->valueComboBox->clear();
			ui->valueComboBox->addItems(var.stringList());
			ui->valueComboBox->show();
			break;

		case Type::Int:
			ui->valueSpinBox->setRange(var.intMinimum(), var.intMaximum());
			ui->valueSpinBox->setValue(0 > var.intMinimum() ? 0:var.intMinimum());
			ui->valueSpinBox->show();
				break;

		case Type::Boolean:
			ui->valueCheckBox->setChecked(false);
			ui->valueCheckBox->show();
			break;

		default:
			ui->valueDescLabel->hide();
			ui->valueInvalidType->show();
		}
	}
	//Else just put a line edit for a string
	else
	{
		ui->valueLineEdit->setIsRegexpSyntax(false);
		ui->valueLineEdit->setValidationExpression(".*");
		ui->valueLineEdit->clear();
		ui->valueDescLabel->hide();
		ui->valueLineEdit->show();
	}
}
Exemple #16
0
MRuleDialog::MRuleDialog(Program prog, QString action, QMap<QString,QString> conds, QString name, QWidget *parent) :
		QDialog(parent),
		ui(new Ui::MRuleDialog),
		_prog(prog),
		_current_variable_type(Type::Invalid)
{
	initDialog();
	setWindowTitle("Edit Matching Rule");

	//Set the current action
	ui->actionBox->setCurrentIndex(ui->actionBox->findData(action));
	if(ui->actionBox->currentIndex()==-1)
		ui->actionBox->setCurrentIndex(ui->actionBox->findText(UndefinedAction));

	//If the current action is valid, take care of the variables
	if(ui->actionBox->currentIndex()!=-1)
	{
		//Add the existing conditions to the list, and remove their variables from the variable combobox
		for(QMap<QString,QString>::const_iterator it=conds.begin(); it!=conds.end(); ++it)
		{
			QStringList itemStrList;
			ui->variableBox->removeItem(ui->variableBox->findText(it.key()));
			itemStrList.append(it.key());
			itemStrList.append(it.value());
			QTreeWidgetItem *item=new QTreeWidgetItem(ui->propList, itemStrList);
			item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsEnabled);

			//Setup the delegate for editing the condition's value directly in the tree widget
			TypedDelegate *delegate=0;

			if(actionName()==QString())
				delegate=new TypedDelegate(Type::String, 1, this);
			else
			{
				ProgramVariable var=_prog.getVariableByName(it.key(), action);

				switch (var.type())
				{
				case Type::Int:
					delegate=new TypedDelegate(Type::Int, 1, this, var.intMinimum(), var.intMaximum());
					break;

				case Type::String:
				case Type::RegExp:
					delegate=new TypedDelegate(Type::String, 1, this, var.stringValidation());
					break;

				case Type::StringList:
					delegate=new TypedDelegate(Type::StringList, 1, this, var.stringList());
					break;

				case Type::Boolean:
					delegate=new TypedDelegate(Type::Boolean, 1, this);
				}
				ui->propList->setItemDelegateForRow(ui->propList->indexOfTopLevelItem(item), delegate);
			}
		}
	}

	//Initialise the display name line edit
	ui->displayNameLineEdit->setText(name);

	//Make sure the Ok button is enabled if there are enough properties
	ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(conditionCount() > 0);
}
void NewActionDialog::updateButtons()
{
    QPushButton *okButton = m_ui->buttonBox->button(QDialogButtonBox::Ok);
    okButton->setEnabled(!actionText().isEmpty() && !actionName().isEmpty());
}
IJingle::Action JingleStanza::action() const
{
    return action4name(actionName());
}
Exemple #19
0
//***************************************************************************
QString Kwave::FilterPlugin::progressText()
{
    return i18n("Applying '%1'...", actionName());
}
Exemple #20
0
 StrBuffer& RedirExtAction::write(StrBuffer& sb) const
 {
     return sb << actionName() << ":" << indent << nl << url_ << outdent;
 }