コード例 #1
1
void CloseColorDots::cycleThroughColors()
{
	colorIndex = updateValue(colorIndex, up, 0, maxColorIndex, cycles);
	
	for (int n=0;n<countFoos();n++)
	{
		int tmpIndex = updateValueBy(colorIndex, up, n, 0, maxColorIndex, cycles);
		
		foos.entry(n)->me->fLEDs.entry(0)->me->color.calculateRGB(maxColorIndex, tmpIndex);
	}
}
コード例 #2
0
/*! Returns `true` if the value of the ModuleParameter has been updated since the last time
this function was called. This should be called right after updateValue() or with `checkForUpdates = true`.
Updates to the value resulting from assignment of a new value with `operator=()` count as updates
to the value.

If you don't care whether the value has been updated before using it, don't call this function.
Instead, just use updateValue() and getValue().

\param checkForUpdates Check for updates before determining whether the value has been updated.
\return `true` if the value has been updated since the last check.
*/
bool ModuleParameter::valueUpdated(bool checkForUpdates) {
	if (checkForUpdates) {
		updateValue();
	}

	if (_updated) {
		_updated = false;
		return true;
	}
	return false;
}
コード例 #3
0
ファイル: jan15_QSET.cpp プロジェクト: 2012ankitkmr/My-works
/*long int next_int()
{
        long int n = 0;
        char c = getchar();
        while (!('0' <= c && c <= '9'))
        {
                c = getchar();
        }
        while ('0' <= c && c <= '9')
        {
                n = (n<<3)+(n<<1) + c - '0';
                c = getchar();
        }
        return n;
}

*/
int main()
{
 ios_base::sync_with_stdio(false);
	char c[100005];
    int arr[100005],count,i,s,j;
	long int n,q;
cin>>n>>q;
	//n=next_int();
    //q=next_int();
	cin>>c;


for(i=0;i<n;i++)
{
	arr[i]=(c[i]-'0');
}
	
	 int *st = constructST(arr, n);

	while(q--)

	{

		long int a,b,d;

	//	a=next_int();
      //  b=next_int();
      //  d=next_int();
	cin>>a>>b>>d;
		if(a==1)

		{
			    updateValue(arr, st, n, b-1, d);

	}
		else
		{
		count=0;	
		for(i=b-1;i<d;i++)
		{
		for(j=i;j<d;j++)	
		{
		s=getSum(st, n, i, j);

if(s%3==0)
count++;
         }
	
	}
		cout<<count<<"\n";
		}
	}
	return 0;
}
コード例 #4
0
ファイル: AccountWindow.cpp プロジェクト: jonyamo/centerim5
AccountWindow::IntegerOption::IntegerOption(PurpleAccount *account_,
    PurpleAccountOption *option_)
: Button(FLAG_VALUE), account(account_), option(option_)
{
  g_assert(account);
  g_assert(option);

  setText(purple_account_option_get_text(option));
  updateValue();
  signal_activate.connect(sigc::mem_fun(this, &IntegerOption::onActivate));
}
コード例 #5
0
ファイル: animation.cpp プロジェクト: mardy/trg2
void
Animation::restart()
{
    forward = true;
    updateValue(0.);
    started = currentTimeMillis();

    if (timer == NULL) {
        timer = new Timer(10, Animation_TimerCallback, (void*)this);
    }
}
コード例 #6
0
 void update(float t) {
   
     
     hasStarted = (t >= startTime);
     hasEnded = (t >= endTime);
     
     if(isAlive) updateValue(t);
     
     if(hasEnded) isAlive = false;
     
 };
コード例 #7
0
ファイル: MovingFoo.cpp プロジェクト: ryantuck/lit-halo
void MovingFoo::move(bool direction)
{
	if (hasLEDs())
	{
		for (int n=0;n<countLEDs();n++)
		{
			byte addr = fLEDs.entry(n)->me->address;
			addr = updateValue(addr, direction, 0, 31, cycles);
			fLEDs.entry(n)->me->address = addr;
		}
	}
}
コード例 #8
0
ファイル: AccountWindow.cpp プロジェクト: jonyamo/centerim5
void AccountWindow::StringOption::initialize()
{
  if (type == TYPE_PASSWORD)
    setText(_("Password"));
  else if (type == TYPE_ALIAS)
    setText(_("Alias"));
  else
    setText(purple_account_option_get_text(option));

  updateValue();
  signal_activate.connect(sigc::mem_fun(this, &StringOption::onActivate));
}
コード例 #9
0
ファイル: Slider.cpp プロジェクト: 03050903/GamePlay
bool Slider::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
{
    State state = getState();

    switch (evt)
    {
    case Touch::TOUCH_PRESS:
        updateValue(x, y);
        return true;

    case Touch::TOUCH_MOVE:
        if (state == ACTIVE)
        {
            updateValue(x, y);
            return true;
        }
        break;
    }

    return Control::touchEvent(evt, x, y, contactIndex);
}
コード例 #10
0
// Textual value change notification.
void qtractorTimeSpinBox::valueChangedSlot ( const QString& sText )
{
#ifdef CONFIG_DEBUG_0
	qDebug("qtractorTimeSpinBox[%p]::valueChangedSlot(\"%s\")",
		this, sText.toUtf8().constData());
#endif

	// Kind of interim fixup.
	if (updateValue(valueFromText(sText), false)) {
		// Just forward this one...
		emit valueChanged(sText);
	}
}
コード例 #11
0
//BEGIN Class PropertyEditorItem
PropertyEditorItem::PropertyEditorItem( PropertyEditorItem * par, Property * property )
	: KListViewItem( par, property->editorCaption(), property->displayString() )
{
	setExpandable( false );
	m_property=property;
	connect( m_property, SIGNAL(valueChanged( QVariant, QVariant )), this, SLOT(propertyValueChanged()) );

	updateValue();

	//3 rows per item is enough?
	setMultiLinesEnabled( true );
	setHeight(static_cast<PropertyEditor*>(listView())->baseRowHeight()*3);
}
コード例 #12
0
ファイル: BatteryFoo.cpp プロジェクト: ryantuck/lit-halo
void BatteryFoo::grow()
{
	// set the color of each subsequent LED as some range from red to green
	// this is a bit of a hack, but it works and looks cool.
	// calculateRGB is the same function used to create a rainbow line of
	//	arbitrary length.
	Color tmpColor = Color(LITColor.black);
	tmpColor.calculateRGB(96, valueCounter);
	
	addLEDs(tmpColor, maxBrightness, valueCounter, valueCounter);
	
	valueCounter = updateValue(valueCounter, up, 0, value, !cycles);
}
コード例 #13
0
ファイル: llui.cpp プロジェクト: ArxNet/SingularityViewer
	ParamValue<const LLFontGL*>::ParamValue(const LLFontGL* fontp)
	:	super_t(fontp),
		name("name"),
		size("size"),
		style("style")
	{
		if (!fontp)
		{
			updateValue(LLFontGL::getFontDefault());
		}
		addSynonym(name, "");
		updateBlockFromValue(false);
	}
コード例 #14
0
ファイル: floatentry.cpp プロジェクト: 87maxi/oom
	void FloatEntry::setValue(double val)
	{
		if (_log)
		{
			if (val == 0.0f)
				_value = _minValue;
			else
				_value = fast_log10(val) * 20.0f;
		}
		else
			_value = val;
		updateValue();
	}
コード例 #15
0
ファイル: llui.cpp プロジェクト: ArxNet/SingularityViewer
	void ParamValue<const LLFontGL*>::updateValueFromBlock()
	{
		const LLFontGL* res_fontp = LLFontGL::getFontByName(name);
		if (res_fontp)
		{
			updateValue(res_fontp);
			return;
		}

		U8 fontstyle = 0;
		fontstyle = LLFontGL::getStyleFromString(style());
		LLFontDescriptor desc(name(), size(), fontstyle);
		const LLFontGL* fontp = LLFontGL::getFont(desc);
		if (fontp)
		{
			updateValue(fontp);
		}
		else
		{
			updateValue(LLFontGL::getFontDefault());
		}
	}
コード例 #16
0
// Pseudo-fixup slot.
void qtractorTimeSpinBox::editingFinishedSlot (void)
{
#ifdef CONFIG_DEBUG_0
	qDebug("qtractorTimeSpinBox[%p]::editingFinishedSlot()", this);
#endif

	if (m_iValueChanged > 0) {
		// Kind of final fixup.
		if (updateValue(valueFromText(), true)) {
			// Rephrase text display...
			updateText();
		}
	}
}
コード例 #17
0
void GConfItemQmlProxy::setKey(const QString &newKey)
{
#ifndef QT_SIMULATOR
   if (_gconfItem) {
       delete _gconfItem;
   }
   _gconfItem = new GConfItem(newKey);
#endif
   _key = newKey;

#ifndef QT_SIMULATOR
   connect(_gconfItem, SIGNAL(valueChanged()), this, SLOT(updateValue()));
#endif
}
コード例 #18
0
ファイル: options.cpp プロジェクト: GilDev/IntelliCasier
static void print(void)
{
	stopLcdScroll(0);
	clearLcdLine(0);

	strcpy_P(buffer, (char *) pgm_read_word(&(strings[OPTION_1 + selectedOption])));

	if (stringsSizes[OPTION_1 + selectedOption] > 16)
		newLcdScroll(buffer, 0, 200);
	else
		printLcd(8 - stringsSizes[OPTION_1 + selectedOption], 0, buffer);

	updateValue();
}
コード例 #19
0
void TCPJwL::listen()
{
	if (audio.beats.detected())
	{
		baseCycler = updateValue(baseCycler, up, 0, 2, cycles);
		
		TwoColorParticleJam* x = (TwoColorParticleJam*)foos.entry(0)->me;
		
		int a1 = baseCycler;
		int a2 = baseCycler+3;
		
		x->changeColors(*LITColor.colorList[a1],*LITColor.colorList[a2]);
	}
}
コード例 #20
0
MemoryTablePrivate::Error MemoryTablePrivate::insert(const key_type &key, const value_type &value, TableMetadata *table)
{
    const quint32 valueSize = dataSize(value);

    IndexElement *tableEnd = end(table);
    IndexElement *position = std::lower_bound(begin(table), tableEnd, key);
    if (position != tableEnd && position->key == key) {
        // This is a replacement - the item has an allocation already
        Allocation *allocation = allocationAt(position->offset, table);
        if (allocation->size < requiredSpace(valueSize)) {
            // Replace the existing allocation with a bigger one
            quint32 newOffset = allocate(valueSize, table, false);
            if (!newOffset)
                return MemoryTable::InsufficientSpace;

            deallocate(position->offset, table);
            position->offset = newOffset;
        } else {
            // Reuse this allocation
            // TODO: swap with a better fit from the free list?
        }
    } else {
        // This item needs to be added to the index
        if (table->count == std::numeric_limits<quint32>::max())
            return MemoryTable::InsufficientSpace;

        quint32 offset = allocate(valueSize, table, true);
        if (!offset)
            return MemoryTable::InsufficientSpace;

        // For index insertion, move the displaced elements of the index
        if (position != tableEnd)
            std::memmove(position + 1, position, (tableEnd - position) * sizeof(IndexElement));

        ++(table->count);
        position->key = key;
        position->offset = offset;
    }

    Q_ASSERT(contains(key, table));

    // Ensure that the data allocation does not overlap the index space
    Q_ASSERT((reinterpret_cast<char *>(table) + table->freeOffset) >= reinterpret_cast<char *>(end(table)));

    // Update the value stored at the position
    updateValue(value, valueSize, position->offset, table);

    return MemoryTable::NoError;
}
コード例 #21
0
CertificateDialog::CertificateDialog(QList<QSslCertificate> certificates, QWidget *parent) : Dialog(parent),
	m_certificates(certificates),
	m_ui(new Ui::CertificateDialog)
{
	m_ui->setupUi(this);
	m_ui->buttonBox->button(QDialogButtonBox::Save)->setText(tr("Export…"));

	if (certificates.isEmpty())
	{
		setWindowTitle(tr("Invalid Certificate"));

		return;
	}

	setWindowTitle(tr("View Certificate for %1").arg(certificates.first().subjectInfo(QSslCertificate::CommonName).join(QLatin1String(", "))));

	QStandardItemModel *chainModel(new QStandardItemModel(this));
	QStandardItem *certificateItem(nullptr);

	for (int i = (certificates.count() - 1); i >= 0; --i)
	{
		QStandardItem *parentCertificateItem(certificateItem);

		certificateItem = new QStandardItem(certificates.at(i).subjectInfo(QSslCertificate::Organization).value(0, tr("Unknown")));
		certificateItem->setData(i, Qt::UserRole);

		if (parentCertificateItem)
		{
			parentCertificateItem->appendRow(certificateItem);
		}
		else
		{
			chainModel->appendRow(certificateItem);
		}
	}

	m_ui->chainItemView->setViewMode(ItemViewWidget::TreeViewMode);
	m_ui->chainItemView->setModel(chainModel);
	m_ui->chainItemView->expandAll();
	m_ui->chainItemView->setCurrentIndex(chainModel->index(0, 0));
	m_ui->detailsItemView->setViewMode(ItemViewWidget::TreeViewMode);
	m_ui->detailsItemView->setModel(new QStandardItemModel(this));

	updateCertificate();

	connect(m_ui->chainItemView, SIGNAL(needsActionsUpdate()), this, SLOT(updateCertificate()));
	connect(m_ui->detailsItemView, SIGNAL(needsActionsUpdate()), this, SLOT(updateValue()));
	connect(m_ui->buttonBox->button(QDialogButtonBox::Save), SIGNAL(clicked(bool)), this, SLOT(exportCertificate()));
}
コード例 #22
0
ファイル: Scroll.cpp プロジェクト: Nand-e/STM32-Watering
void ScrollBar::update(uint16_t x1, uint16_t y1, uint16_t z) {
	bool press = false;
	if (z > MINPRESSURE && z < MAXPRESSURE) press = true;



	if (press) {
		if (x < x1 && x1 < (x + size) && y < y1 && y1 < (y + size)) {
			pressedL = true;
			lastpressed = millis();
			updateValue();
		}
		uint16_t v = width + pageW + size + x;
		if (( v ) < x1 && x1 < (v+size)  && y < y1 && y1 < (y + size)) 
		{
			pressedR = true;
			lastpressed = millis();
			updateValue();
		}
	}

	if (millis() - lastpressed > 200) {
		pressedR = false;
		pressedL = false;
	}

	if (pressedR != opressedR || pressedL != opressedL ) { 	// some buttons state changed										
		reDrawButtons();
		opressedR = pressedR;
		opressedL = pressedL;
	
		//if (handler != 0) handler->callBack1(pressed, ID);
		return;
	}
	//if (pressed && handler != 0)  handler->callBack2(pressed, ID);     // continouse pressing 
}
コード例 #23
0
ファイル: animation.cpp プロジェクト: mardy/trg2
void
Animation::rewind()
{
    forward = false;

    if (timer != NULL) {
        int elapsed = currentTimeMillis() - started;
        int remaining = duration - elapsed;
        started = currentTimeMillis() - remaining;
    } else {
        updateValue(1.);
        started = currentTimeMillis();
        timer = new Timer(10, Animation_TimerCallback, (void*)this);
    }
}
コード例 #24
0
int RoundRectItem::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: activated(); break;
        case 1: updateValue((*reinterpret_cast< qreal(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 2;
    }
    return _id;
}
コード例 #25
0
ファイル: Dial.cpp プロジェクト: eriser/Anthem
void Dial::setupUi()
{
	QDial::setCursor(Qt::PointingHandCursor);

	connect(this, &QDial::valueChanged,
			this, &Dial::updateValue);

	setMinimumSize(100,100);

	setMaximumAngle(-360);

	setStartAngle(270);

	updateValue();
}
コード例 #26
0
ファイル: floatentry.cpp プロジェクト: 87maxi/oom
	void FloatEntry::setSValue(const QString& s)
	{
		bool ok;
		double v = s.toFloat(&ok);
		if (ok && (v != _value))
		{
			if (v < _minValue)
				v = _minValue;
			if (v > _maxValue)
				v = _maxValue;
			_value = v;
			updateValue();
			valueChange();
		}
	}
コード例 #27
0
ファイル: floatentry.cpp プロジェクト: 87maxi/oom
	FloatEntry::FloatEntry(QWidget* parent)
	: QLineEdit(parent)
	{
		_id = 0;
		_minValue = 0.0;
		_maxValue = 1.0;
		_log = false;
		evx = 1.0;
		_precision = 3;
		timer = new QTimer(this);
		connect(timer, SIGNAL(timeout()), SLOT(repeat()));
		_value = 0.0f;
		connect(this, SIGNAL(returnPressed()), SLOT(endEdit()));
		setCursor(QCursor(Qt::ArrowCursor));
		updateValue();
	}
コード例 #28
0
/*!
 * \brief Focus out event handler.
 *
 * This updates the geometry of parameter group, validates
 * the text and also clears the selection.
 */
void PropertyItem::focusOutEvent(QFocusEvent *event)
{
    if(m_edited) {
        updateValue();
    }

    qApp->removeEventFilter(this);

    // Clear the text selection
    QTextCursor c = textCursor();
    c.clearSelection();
    setTextCursor(c);
    disconnect(document(), SIGNAL(contentsChanged()), this,
            SLOT(textChanged()));

    QGraphicsTextItem::focusOutEvent(event);
}
コード例 #29
0
void GuiInspectorDynamicField::setData( const char* data, bool callbacks )
{
   if ( mDynField == NULL )
      return;
   
   const U32 numTargets = mInspector->getNumInspectObjects();
   if( callbacks && numTargets > 1 )
   { mInspector->beginCompoundUndo_callback(); }
      
   // Setting an empty string will kill the field.
   const bool isRemoval = !data[ 0 ];
      
   for( U32 i = 0; i < numTargets; ++ i )
   {
      SimObject* target = mInspector->getInspectObject( i );

      // Callback on the inspector when the field is modified
      // to allow creation of undo/redo actions.
      const char *oldData = target->getDataField( mDynField->slotName, NULL );
      if ( !oldData )
         oldData = "";
      if ( dStrcmp( oldData, data ) != 0 )
      {
         target->inspectPreApply();
         
         if( callbacks )
         {
            if( isRemoval )
            { mInspector->onFieldRemoved_callback( target->getIdString(), mDynField->slotName ); }
            else
            { mInspector->onInspectorFieldModified_callback( target->getIdString(), mDynField->slotName,"(null)", oldData, data ); }
         }

         target->setDataField( mDynField->slotName, NULL, data );

         // give the target a chance to validate
         target->inspectPostApply();
      }
   }
   
   if( callbacks && numTargets > 1 )
   { mInspector->endCompoundUndo_callback(); }

   // Force our edit to update
   updateValue();
}
コード例 #30
0
void ShortIntValueFieldWidget::refreshImpl()
{
    assert(m_ui.m_serValueLineEdit != nullptr);
    updateValue(*m_ui.m_serValueLineEdit, m_wrapper->getSerialisedString());

    auto value = adjustRealToDisplayed(m_wrapper->getValue());
    assert(m_ui.m_valueSpinBox);
    if (m_ui.m_valueSpinBox->value() != value) {
        m_ui.m_valueSpinBox->setValue(value);
    }

    bool valid = m_wrapper->valid();
    setValidityStyleSheet(*m_ui.m_nameLabel, valid);
    setValidityStyleSheet(*m_ui.m_serFrontLabel, valid);
    setValidityStyleSheet(*m_ui.m_serValueLineEdit, valid);
    setValidityStyleSheet(*m_ui.m_serBackLabel, valid);
}