示例#1
0
void plugin::requestProperties() {
	changeProperty(SceneDocument::createModelReset("leds", "channel").getData(), m_lastsessionid);
    QMap<QString, plugin::iochannel>::iterator i = m_ios.begin();
    for (;i!=m_ios.end();++i) {
        const plugin::iochannel& io = i.value();
        SceneDocument sc = SceneDocument::createModelChangeItem("leds");
        sc.setData("channel", io.channel);
        sc.setData("value", io.value);
        sc.setData("name", io.name);
        sc.setData("moodlight", io.moodlight);
		changeProperty(sc.getData(), m_lastsessionid);
    }
}
示例#2
0
void plugin::requestProperties(int sessionid) {
    Q_UNUSED(sessionid);


    changeProperty(ServiceData::createModelReset("udpio.sensor", "sensorid").getData());
    if (m_read) {
        ServiceData sc = ServiceData::createModelChangeItem("udpio.sensor");
        for (int id=0;id<m_sensors.size();++id) {
            sc.setData("sensorid", id);
            sc.setData("value", m_sensors[id]);
            changeProperty(sc.getData());
        }
    }
    return l;
}
示例#3
0
void plugin::subpluginChange(const QVariantMap& target, const QString& channel, int value, const QString& name) {
    // Assign data to structure
    bool before = m_ios.contains(channel);
    iochannel& io = m_ios[channel];
	SceneDocument targetD(target);
	io.componentID = targetD.componentID().toUtf8();
	io.instanceID = targetD.instanceID().toUtf8();
    //p.moodlight = false;
    //p.fadeType = 1;
    io.channel = channel;
    io.value = value;
    if (!before)
        io.name = name.size()?name : m_namecache.value(io.channel);
    if (io.name.isEmpty()) {
        io.name = QLatin1String("Channel ") + QString::number(m_ios.size());
    }

    SceneDocument sc = SceneDocument::createModelChangeItem("leds");
    sc.setData("channel", io.channel);
    if (io.name.size()) sc.setData("name", io.name);
    if (io.value != -1) sc.setData("value", io.value);
    sc.setData("moodlight", io.moodlight);

    changeProperty(sc.getData());
}
示例#4
0
void plugin::setLedName ( const QString& channel, const QString& name, bool updateDatabase )
{
    if ( !m_ios.contains(channel) ) return;
    if (name.isNull()) return;

    plugin::iochannel& io = m_ios[channel];

    io.name = name;

    // change name property
    SceneDocument sc = SceneDocument::createModelChangeItem("leds");
    sc.setData("channel", channel);
    sc.setData("name", name);
    sc.setData("value", io.value);
    sc.setData("moodlight", io.moodlight);
    changeProperty(sc.getData());

    if (updateDatabase) {
        // save name to database
        QVariantMap settings;
        settings[QLatin1String("channel")] = channel;
        settings[QLatin1String("name")] = name;
        settings[QLatin1String("isname")] = true;
        changeConfig("channelname_" + channel.toUtf8(),settings);
    }
}
示例#5
0
void
KexiReportFactory::editText()
{
	QCString classname = m_widget->className();
	QString text;

	if(classname == "Label")
		text = ((QLabel*)m_widget)->text();

	if(editRichText(m_widget, text)) {
		changeProperty("textFormat", "RichText", m_container->form());
		changeProperty("text", text, m_container->form());
	}

	if(classname == "Label")
		m_widget->resize(m_widget->sizeHint());
}
示例#6
0
void btEditorNodeType::disconnectChangeProperty()
{
    disconnect(m_sender, SIGNAL(propertyChanged(QString, QVariant)), this, SLOT(changeProperty(QString, QVariant)));
    disconnect(m_sender, SIGNAL(propertyDescriptionChanged(QString, QString, QString)), this, SLOT(changePropertyDescription(QString,QString, QString)));
    disconnect(m_sender, SIGNAL(nameChanged(QString)), this, SLOT(changeName(QString)));
    disconnect(m_sender, SIGNAL(descriptionChanged(QString)), this, SLOT(changeDescription(QString)));
    disconnect(m_sender, SIGNAL(classNameChanged(QString)), this, SLOT(changeClassName(QString)));
}
示例#7
0
void plugin::requestProperties() {
    SceneDocument s = SceneDocument::createNotification("nextalarm");
    if (mEvents.size())
        s.setData("seconds", QDateTime::currentDateTime().secsTo(mEvents.begin().key()));
    changeProperty(s.getData(), m_lastsessionid);

    changeProperty(SceneDocument::createModelReset("time.alarms", "uid").getData(), m_lastsessionid);

    QMapIterator<QDateTime, EventTimeStructure>  i(mEvents);
    while(i.hasNext()) {
        i.next();
        SceneDocument sc = SceneDocument::createModelChangeItem("time.alarms");
        sc.setData("uid", i.value().eventid);
        sc.setData("seconds", QDateTime::currentDateTime().secsTo(i.key()));
        changeProperty(sc.getData(), m_lastsessionid);
    }
}
示例#8
0
void plugin::addToEvents(const QDateTime& nextTimeout, const plugin::EventTimeStructure& ts) {
    mEvents.insert(nextTimeout, ts);
    // property update
    SceneDocument sc = SceneDocument::createModelChangeItem("time.alarms");
    sc.setData("uid", ts.eventid);
    sc.setData("seconds", QDateTime::currentDateTime().secsTo(nextTimeout));
    changeProperty(sc.getData());
    setupTimer();
}
示例#9
0
void
StdWidgetFactory::editText()
{
	QCString classname = widget()->className();
	QString text;
	if(classname == "KTextEdit")
		text = ((KTextEdit*)widget())->text();
	else if(classname == "QLabel")
		text = ((QLabel*)widget())->text();

	if(editRichText(widget(), text))
	{
		changeProperty("textFormat", "RichText", m_container->form());
		changeProperty("text", text, m_container->form());
	}

	if(classname == "QLabel")
		widget()->resize(widget()->sizeHint());
}
示例#10
0
void plugin::requestProperties(int sessionid) {
    Q_UNUSED(sessionid);

    {
        ServiceData sc = ServiceData::createNotification(PLUGIN_ID,  "pulse.version" );
        sc.setData("protocol", getProtocolVersion());
        sc.setData("server", getServerVersion());
		changeProperty(sc.getData());
    }
    {
        ServiceData sc = ServiceData::createModelReset( "pulse.channels", "sinkid" );
        changeProperty(sc.getData());
    }
    QList<PulseChannel> channels = getAllChannels();
    foreach(PulseChannel channel, channels) {
        ServiceData sc = ServiceData::createModelChangeItem( "pulse.channels" );
        sc.setData("sinkid", channel.sinkid);
        sc.setData("mute", channel.mute);
        sc.setData("volume", channel.volume);
        changeProperty(sc.getData());
    }
示例#11
0
OrdinalPropertyAnimator::OrdinalPropertyAnimator()
    : Processor()
    , type_("property", "Property")
    , delay_("delay", "Delay (ms)", 50, 1, 10000, 1)
    , pbc_("pbc", "Periodic", true)
    , active_("active", "Active", false) 
    , timer_(delay_, [this](){timerEvent();})
{
    delay_.onChange(this, &OrdinalPropertyAnimator::updateTimerInterval);

    properties_.push_back(new PrimProp<float>("org.inviwo.FloatProperty", "org.inviwo.FloatProperty"));
    properties_.push_back(new VecProp<vec2>("org.inviwo.FloatVec2Property", "org.inviwo.FloatVec2Property"));
    properties_.push_back(new VecProp<vec3>("org.inviwo.FloatVec3Property", "org.inviwo.FloatVec3Property"));
    properties_.push_back(new VecProp<vec4>("org.inviwo.FloatVec4Property", "org.inviwo.FloatVec4Property"));
    properties_.push_back(new PrimProp<double>("org.inviwo.DoubleProperty","org.inviwo.DoubleProperty"));
    properties_.push_back(new VecProp<dvec2>("org.inviwo.DoubleVec2Property", "org.inviwo.DoubleVec2Property"));
    properties_.push_back(new VecProp<dvec3>("org.inviwo.DoubleVec3Property", "org.inviwo.DoubleVec3Property"));
    properties_.push_back(new VecProp<dvec4>("org.inviwo.DoubleVec4Property", "org.inviwo.DoubleVec4Property"));
    properties_.push_back(new PrimProp<int>("org.inviwo.IntProperty", "org.inviwo.IntProperty"));
    properties_.push_back(new VecProp<ivec2>("org.inviwo.IntVec2Property", "org.inviwo.IntVec2Property"));
    properties_.push_back(new VecProp<ivec3>("org.inviwo.IntVec3Property", "org.inviwo.IntVec3Property"));
    properties_.push_back(new VecProp<ivec4>("org.inviwo.IntVec4Property", "org.inviwo.IntVec4Property"));

    addProperty(type_);
    addProperty(active_);
    addProperty(delay_);
    addProperty(pbc_);

    int count = 0;
    for (auto p : properties_) {
        type_.addOption(p->classname_, p->displayName_, count);
        Property* prop = p->getProp();
        Property* delta = p->getDelta();

        addProperty(prop);
        addProperty(delta);
        prop->setVisible(false);
        delta->setVisible(false);
        count++;
    }
    type_.setSelectedIndex(0);
    type_.setCurrentStateAsDefault();
    
    type_.onChange(this, &OrdinalPropertyAnimator::changeProperty);
    active_.onChange(this, &OrdinalPropertyAnimator::changeActive);

    changeProperty();

    setAllPropertiesCurrentStateAsDefault();
}
示例#12
0
void plugin::removeEvent ( const QString& eventid) {
    SceneDocument s = SceneDocument::createModelRemoveItem("time.alarms");
    QMutableMapIterator<QDateTime, EventTimeStructure>  i(mEvents);
    while(i.hasNext()) {
        i.next();
        if (i.value().eventid == eventid) {
            // property update
            s.setData("uid", eventid);
            changeProperty(s.getData());
            i.remove();
        }
    }
    setupTimer();
}
示例#13
0
void plugin::watchpinChanged(const unsigned char port, const unsigned char pinmask) {
    qDebug() << "WATCH PIN CHANGED" << port << pinmask;
    ServiceData sc = ServiceData::createModelChangeItem("udpio.sensor");
    for (int i=0;i<8;++i) {
        bool newvalue = (1 << i) & pinmask;
        if (!m_read || m_sensors[i] != newvalue) {
            m_sensors[i] = newvalue;
            sc.setData("sensorid", i);
            sc.setData("value", m_sensors[i]);
            changeProperty(sc.getData());
            m_events.triggerEvent(i, m_serverCollectionController);
        }
    }
    m_read = true;
}
示例#14
0
void plugin::clear(const QVariantMap& target) {
	SceneDocument targetD(target);
	QByteArray componentid_ = targetD.componentID().toUtf8();
	QByteArray instanceid_ = targetD.instanceID().toUtf8();
	
    // Remove all leds referenced by "plugin_id"
    QMutableMapIterator<QString, iochannel> i(m_ios);
    while (i.hasNext()) {
        i.next();
		if (i.value().componentID == componentid_ && i.value().instanceID == instanceid_) {
            SceneDocument sc = SceneDocument::createModelRemoveItem("leds");
            sc.setData("channel", i.value().channel);
            changeProperty(sc.getData());
            i.remove();
        }
    }
}
示例#15
0
void plugin::setupTimer() {
    m_timer.stop();
    QMutableMapIterator<QDateTime, EventTimeStructure>  i(mEvents);
    while(i.hasNext()) {
        i.next();
        int sec = QDateTime::currentDateTime().secsTo(i.key());
        if (sec>0) {
            SceneDocument s = SceneDocument::createNotification("nextalarm");
            s.setData("seconds", sec);
            changeProperty(s.getData());
            qDebug()<<"Next alarm in"<<sec<<"s";
            m_timer.start ( sec * 1000 );
            break;
        }
        i.remove();
    };
}
示例#16
0
bool
StdWidgetFactory::changeText(const QString &text)
{
	QCString n = WidgetFactory::widget()->className();
	QWidget *w = WidgetFactory::widget();
	if(n == "KIntSpinBox")
		((KIntSpinBox*)w)->setValue(text.toInt());
	else
		changeProperty("text", text, m_container->form());

	/* By-hand method not needed as sizeHint() can do that for us
	QFontMetrics fm = w->fontMetrics();
	QSize s(fm.width( text ), fm.height());
	int width;
	if(n == "QLabel") // labels are resized to fit the text
	{
		w->resize(w->sizeHint());
		WidgetFactory::m_editor->resize(w->size());
		return;
	}
	// and other widgets are just enlarged if needed
	else if(n == "KPushButton")
		width = w->style().sizeFromContents( QStyle::CT_PushButton, w, s).width();
	else if(n == "QCheckBox")
		width = w->style().sizeFromContents( QStyle::CT_CheckBox, w, s).width();
	else if(n == "QRadioButton")
		width = w->style().sizeFromContents( QStyle::CT_RadioButton, w, s).width();
	else
		return;
	int width = w->sizeHint().width();*/

#if 0 //not needed here, size hint is used on creation in InsertWidgetCommand::execute()
	if(w->width() < width)
	{
		w->resize(width, w->height() );
		//WidgetFactory::m_editor->resize(w->size());
	}
#endif
	return true;
}
示例#17
0
void KateStyleTreeWidget::contextMenuEvent( QContextMenuEvent * event )
{
  KateStyleTreeWidgetItem *i = dynamic_cast<KateStyleTreeWidgetItem*>(itemAt(event->pos()));
  if (!i) return;

  KMenu m( this );
  KTextEditor::Attribute::Ptr currentStyle = i->style();
  // the title is used, because the menu obscures the context name when
  // displayed on behalf of spacePressed().
  QPainter p;
  p.setPen(Qt::black);

  QIcon cl = brushIcon( i->style()->foreground().color() );
  QIcon scl = brushIcon( i->style()->selectedForeground().color() );
  QIcon bgcl = brushIcon( i->style()->hasProperty(QTextFormat::BackgroundBrush) ? i->style()->background().color() : viewport()->palette().base().color() );
  QIcon sbgcl = brushIcon( i->style()->hasProperty(KTextEditor::Attribute::SelectedBackground) ? i->style()->selectedBackground().color() : viewport()->palette().base().color() );

  m.addTitle( i->contextName() );

  QAction* a = m.addAction( i18n("&Bold"), this, SLOT(changeProperty()) );
  a->setCheckable(true);
  a->setChecked( currentStyle->fontBold() );
  a->setData(KateStyleTreeWidgetItem::Bold);

  a = m.addAction( i18n("&Italic"), this, SLOT(changeProperty()) );
  a->setCheckable(true);
  a->setChecked( currentStyle->fontItalic() );
  a->setData(KateStyleTreeWidgetItem::Italic);

  a = m.addAction( i18n("&Underline"), this, SLOT(changeProperty()) );
  a->setCheckable(true);
  a->setChecked( currentStyle->fontUnderline() );
  a->setData(KateStyleTreeWidgetItem::Underline);

  a = m.addAction( i18n("S&trikeout"), this, SLOT(changeProperty()) );
  a->setCheckable(true);
  a->setChecked( currentStyle->fontStrikeOut() );
  a->setData(KateStyleTreeWidgetItem::StrikeOut);

  m.addSeparator();

  a = m.addAction( cl, i18n("Normal &Color..."), this, SLOT(changeProperty()) );
  a->setData(KateStyleTreeWidgetItem::Foreground);

  a = m.addAction( scl, i18n("&Selected Color..."), this, SLOT(changeProperty()) );
  a->setData(KateStyleTreeWidgetItem::SelectedForeground);

  a = m.addAction( bgcl, i18n("&Background Color..."), this, SLOT(changeProperty()) );
  a->setData(KateStyleTreeWidgetItem::Background);

  a = m.addAction( sbgcl, i18n("S&elected Background Color..."), this, SLOT(changeProperty()) );
  a->setData(KateStyleTreeWidgetItem::SelectedBackground);

  // Unset [some] colors. I could show one only if that button was clicked, but that
  // would disable setting this with the keyboard (how many aren't doing just
  // that every day? ;)
  // ANY ideas for doing this in a nicer way will be warmly wellcomed.
  KTextEditor::Attribute::Ptr style = i->style();
  if ( style->hasProperty( QTextFormat::BackgroundBrush) || style->hasProperty( KTextEditor::Attribute::SelectedBackground ) )
  {
    m.addSeparator();
    if ( style->hasProperty( QTextFormat::BackgroundBrush) ) {
      a = m.addAction( i18n("Unset Background Color"), this, SLOT(unsetColor()) );
      a->setData(100);
    }
    if ( style->hasProperty( KTextEditor::Attribute::SelectedBackground ) ) {
      a = m.addAction( i18n("Unset Selected Background Color"), this, SLOT(unsetColor()) );
      a->setData(101);
    }
  }

  if ( ! i->isDefault() && ! i->defStyle() ) {
    m.addSeparator();
    a = m.addAction( i18n("Use &Default Style"), this, SLOT(changeProperty()) );
    a->setCheckable(true);
    a->setChecked( i->defStyle() );
    a->setData(KateStyleTreeWidgetItem::UseDefaultStyle);
  }
  m.exec( event->globalPos() );
}
示例#18
0
void OrdinalPropertyAnimator::initializeResources() {
    changeProperty();
    updateTimerInterval();
}