void RKComponent::changed () { RK_TRACE (PLUGIN); if (parentComponent ()) { parentComponent ()->changed (); } }
void RKComponent::changed () { RK_TRACE (PLUGIN); if (parentComponent ()) { parentComponent ()->changed (); } emit (componentChanged (this)); }
void RKComponent::removeFromParent () { RK_TRACE (PLUGIN); if (!parentComponent ()) return; // unfortunately, several items might hvae the same key, and there seems to be no way to selectively remove the current item only. // however, this function should only ever be called in cases of emergency and to prevent crashes. So we make extra sure to remove the child, // even if we remove a little more than necessary along the way. QString key = getIdInParent (); while (parentComponent ()->child_map.remove (key)) {;} _parent = 0; }
RKPreviewBox::RKPreviewBox (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) { RK_TRACE (PLUGIN); preview_active = false; last_plot_done = true; new_plot_pending = false; dev_num = 0; // get xml-helper XMLHelper *xml = XMLHelper::getStaticHelper (); // create and add property addChild ("state", state = new RKComponentPropertyBool (this, true, preview_active, "active", "inactive")); state->setInternal (true); // restoring this does not make sense. connect (state, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (changedState (RKComponentPropertyBase *))); // create checkbox QVBoxLayout *vbox = new QVBoxLayout (this); vbox->setContentsMargins (0, 0, 0, 0); toggle_preview_box = new QCheckBox (xml->getStringAttribute (element, "label", i18n ("Preview"), DL_INFO), this); vbox->addWidget (toggle_preview_box); toggle_preview_box->setChecked (preview_active); connect (toggle_preview_box, SIGNAL (stateChanged (int)), this, SLOT (changedState (int))); // status lable status_label = new QLabel (QString::null, this); vbox->addWidget (status_label); // find and connect to code property of the parent QString dummy; RKComponentBase *cp = parentComponent ()->lookupComponent ("code", &dummy); if (cp && dummy.isNull () && (cp->type () == PropertyCode)) { code_property = static_cast<RKComponentPropertyCode *> (cp); connect (code_property, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (changedCode (RKComponentPropertyBase *))); } else {
void RKComponent::removeFromParent () { RK_TRACE (PLUGIN); if (!parentComponent ()) return; for (QDictIterator<RKComponentBase> it (parentComponent ()->child_map); it.current (); ++it) { if (it.current () == this) { QString key = it.currentKey (); // unfortunately, several items might hvae the same key, and there seems to be no way to selectively remove the current item only. // however, this function should only ever be called in cases of emergency and to prevent crashes. So we make extra sure to remove the child, // even if we remove a little more than necessary along the way. while (parentComponent ()->child_map.remove (key)); return; } } RK_ASSERT (false); }
void RKComponent::updateEnablednessRecursive () { RK_TRACE (PLUGIN); bool enabled; if (enabledness_property->boolValue ()) { enabled = ((!parentComponent ()) || (parentComponent ()->isEnabled ())); } else { enabled = false; } if (enabled != isEnabled ()) { setEnabled (enabled); for (QDictIterator<RKComponentBase> it (child_map); it.current (); ++it) { if (it.current ()->isComponent()) { static_cast<RKComponent*> (it.current ())->updateEnablednessRecursive (); } } } }
void RKComponent::updateEnablednessRecursive () { RK_TRACE (PLUGIN); bool enabled; if (enabledness_property->boolValue ()) { enabled = ((!parentComponent ()) || (parentComponent ()->isEnabled ())); } else { enabled = false; } setEnabled (enabled); /* We do this, even if the state *seems* to be unchanged. This is needed, as isEnabled () also returns false, if the parent QWidget is not enabled. However, the parent QWidget may not always be the parent component. */ if (enabled != isEnabled ()) { for (QHash<QString, RKComponentBase*>::const_iterator it = child_map.constBegin (); it != child_map.constEnd (); ++it) { if (it.value ()->isComponent()) { static_cast<RKComponent*> (it.value ())->updateEnablednessRecursive (); } } } }
QString RKComponent::getIdInParent () const { RK_TRACE (PLUGIN); if (!parentComponent ()) return QString (); return (parentComponent ()->child_map.key (const_cast<RKComponent*> (this))); }
RKPreviewBox::RKPreviewBox (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) { RK_TRACE (PLUGIN); prior_preview_done = true; new_preview_pending = false; // get xml-helper XMLHelper *xml = parent_component->xmlHelper (); preview_mode = (PreviewMode) xml->getMultiChoiceAttribute (element, "mode", "plot;data;output;custom", 0, DL_INFO); placement = (PreviewPlacement) xml->getMultiChoiceAttribute (element, "placement", "default;attached;detached;docked", 0, DL_INFO); if (placement == DefaultPreview) placement = DockedPreview; preview_active = xml->getBoolAttribute (element, "active", false, DL_INFO); idprop = RObject::rQuote (QString ().sprintf ("%p", this)); // create and add property addChild ("state", state = new RKComponentPropertyBool (this, true, preview_active, "active", "inactive")); state->setInternal (true); // restoring this does not make sense. connect (state, SIGNAL (valueChanged(RKComponentPropertyBase*)), this, SLOT (changedState(RKComponentPropertyBase*))); // create checkbox QVBoxLayout *vbox = new QVBoxLayout (this); vbox->setContentsMargins (0, 0, 0, 0); toggle_preview_box = new QCheckBox (xml->i18nStringAttribute (element, "label", i18n ("Preview"), DL_INFO), this); vbox->addWidget (toggle_preview_box); toggle_preview_box->setChecked (preview_active); connect (toggle_preview_box, SIGNAL (stateChanged(int)), this, SLOT (changedState(int))); // status label status_label = new QLabel (QString (), this); status_label->setWordWrap (true); vbox->addWidget (status_label); // prepare placement placement_command = ".rk.with.window.hints ({"; placement_end = "\n}, "; if (placement == AttachedPreview) placement_end.append ("\"attached\""); else if (placement == DetachedPreview) placement_end.append ("\"detached\""); else placement_end.append ("\"\""); placement_end.append (", " + RObject::rQuote (idprop) + ", style=\"preview\")"); if (placement == DockedPreview) { RKStandardComponent *uicomp = topmostStandardComponent (); if (uicomp) { uicomp->addDockedPreview (state, toggle_preview_box->text (), idprop); if (preview_mode == OutputPreview) { RKGlobals::rInterface ()->issueCommand ("local ({\n" "outfile <- tempfile (fileext='html')\n" "rk.assign.preview.data(" + idprop + ", list (filename=outfile, on.delete=function (id) {\n" " rk.flush.output (outfile, ask=FALSE)\n" " unlink (outfile)\n" "}))\n" "oldfile <- rk.set.output.html.file (outfile, style='preview') # for initialization\n" "rk.set.output.html.file (oldfile)\n" "})\n" + placement_command + "rk.show.html(rk.get.preview.data (" + idprop + ")$filename)" + placement_end, RCommand::Plugin | RCommand::Sync); } else { // For all others, create an empty data.frame as dummy. Even for custom docked previews it has the effect of initializing the preview area with _something_. RKGlobals::rInterface ()->issueCommand ("local ({\nrk.assign.preview.data(" + idprop + ", data.frame ())\n})\n" + placement_command + "rk.edit(rkward::.rk.variables$.rk.preview.data[[" + idprop + "]])" + placement_end, RCommand::Plugin | RCommand::Sync); } // A bit of a hack: For now, in wizards, docked previews are always active, and control boxes are meaningless. if (uicomp->isWizardish ()) { hide (); toggle_preview_box->setChecked (true); } } } // find and connect to code property of the parent QString dummy; RKComponentBase *cp = parentComponent ()->lookupComponent ("code", &dummy); if (cp && dummy.isNull () && (cp->type () == PropertyCode)) { code_property = static_cast<RKComponentPropertyCode *> (cp); connect (code_property, SIGNAL (valueChanged(RKComponentPropertyBase*)), this, SLOT (changedCode(RKComponentPropertyBase*))); } else {