RKPluginBrowser::RKPluginBrowser (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) { RK_TRACE (PLUGIN); // get xml-helper XMLHelper *xml = XMLHelper::getStaticHelper (); // create and add property addChild ("selection", selection = new RKComponentPropertyBase (this, true)); connect (selection, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (textChanged (RKComponentPropertyBase *))); setRequired (xml->getBoolAttribute (element, "required", true, DL_INFO)); connect (requirednessProperty (), SIGNAL (valueChanged(RKComponentPropertyBase*)), this, SLOT (requirednessChanged(RKComponentPropertyBase*))); QVBoxLayout *vbox = new QVBoxLayout (this, RKGlobals::spacingHint ()); int intmode = xml->getMultiChoiceAttribute (element, "type", "file;dir;savefile", 0, DL_INFO); GetFileNameWidget::FileType mode; if (intmode == 0) { mode = GetFileNameWidget::ExistingFile; } else if (intmode == 0) { mode = GetFileNameWidget::ExistingDirectory; } else { mode = GetFileNameWidget::SaveFile; } selector = new GetFileNameWidget (this, mode, xml->getStringAttribute (element, "label", i18n ("Enter filename"), DL_INFO), i18n ("Select"), xml->getStringAttribute (element, "initial", QString::null, DL_INFO)); selector->setFilter (xml->getStringAttribute (element, "filter", QString::null, DL_INFO)); connect (selector, SIGNAL (locationChanged ()), SLOT (textChanged ())); vbox->addWidget (selector); // initialize updating = false; textChanged (); }
RKInput::RKInput (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) { RK_TRACE (PLUGIN); textedit = 0; lineedit = 0; // get xml-helper XMLHelper *xml = parent_component->xmlHelper (); // create and add property addChild ("text", text = new RKComponentPropertyBase (this, false)); connect (text, SIGNAL (valueChanged(RKComponentPropertyBase*)), this, SLOT (textChanged(RKComponentPropertyBase*))); setRequired (xml->getBoolAttribute (element, "required", false, DL_INFO)); connect (requirednessProperty (), SIGNAL (valueChanged(RKComponentPropertyBase*)), this, SLOT (requirednessChanged(RKComponentPropertyBase*))); // do all the layouting QVBoxLayout *vbox = new QVBoxLayout (this); vbox->setContentsMargins (0, 0, 0, 0); label_string = xml->i18nStringAttribute (element, "label", i18n ("Enter text"), DL_INFO); if (!label_string.isEmpty ()) { QLabel *label = new QLabel (label_string, this); vbox->addWidget (label); } int size = xml->getMultiChoiceAttribute (element, "size", "small;medium;large", 1, DL_INFO); if (size == 2) { textedit = new QTextEdit (this); QFontMetrics fm = QFontMetrics (textedit->currentFont ()); int lheight = fm.lineSpacing (); int margin = fm.descent () + 2; textedit->setMinimumSize (250, lheight * 4 + margin); vbox->addWidget (textedit); connect (textedit, SIGNAL (textChanged()), SLOT (textChanged())); } else { lineedit = new QLineEdit (this); vbox->addWidget (lineedit); connect (lineedit, SIGNAL (textChanged(QString)), SLOT (textChanged(QString))); } vbox->addStretch (1); // to keep the label attached // initialize updating = false; // DO NOT replace "" with QString (), here! it is important, that this is actually an empty string, not a null string. text->setValue (xml->getStringAttribute (element, "initial", "", DL_INFO)); }
void RKComponent::setRequired (bool required) { RK_TRACE (PLUGIN); requirednessProperty ()->setBoolValue (required); }