コード例 #1
0
ファイル: ServerConfEditor.cpp プロジェクト: Ppito/PuppetFTP
void ServerConfEditor::initCustomField() {
    getForm()->removeWidget("internet_protocol");
    getForm()->removeWidget("virtual_user_auth");

    InputChoice* selectProtocol = new InputChoice("internet_protocol", InputChoice::SELECT);
    {
        selectProtocol->addOption("IPv4", "IPv4");
        selectProtocol->addOption("IPv6", "IPv6");
    }
    getForm()->addWidget("editor", selectProtocol);

    InputChoice* selectVirtual = new InputChoice("virtual_user_auth", InputChoice::SELECT);
    {
        selectVirtual->addOption("0", "Anonymous");
    }
    getForm()->addWidget("editor", selectVirtual);

    Input* hidden = new Input("type", Input::HIDDEN);
    {
        hidden->setValue("general");
        hidden->setLabel("");
    }
    getForm()->addWidget("editor", hidden);

    // Set attribute
    getContent()->removeAttribute("class");
}
コード例 #2
0
UserModelEditor::UserModelEditor() : ModelEntityEditor< ::Model::User >() {
    // Remove unsed widget
    getForm()->removeWidget("id");
    getForm()->removeWidget("created_at");
    getForm()->removeWidget("last_access");
    getForm()->removeWidget("puppetftp_role");
    getForm()->removeWidget("passwd");

    // Set label
    getForm()->getWidget("firstname")->setLabel("First Name");
    getForm()->getWidget("lastname")->setLabel("Last Name");
    getForm()->getWidget("email")->setLabel("Email");

    // Add custom attribute
    getForm()->getWidget("email")->setAttribute("autocomplete", "off");

    // Get role
    ITable*         table = DatabaseManager::instance()->getTable("puppetftp_role");
    if (table == NULL) {
        // rediriger ou gérer le cas d'erreur

    }
    QList<QObject*> roles = table->getAll();

    // Create custom widget
    InputChoice* selectRole = new InputChoice("puppetftp_role", InputChoice::SELECT);
    selectRole->setLabel("Role");

    for (QList<QObject*>::const_iterator it = roles.begin(); it != roles.end(); it++) {
        Model::Role* role = dynamic_cast<Model::Role*>(*it);
        selectRole->addOption(QString::number(role->getId()), role->getName());
    }
    getForm()->addWidget("editor", selectRole);

    Input* password = new Input("passwd", Input::PASSWORD);
    password->setLabel("Password");
    password->setAttribute("autocomplete", "off");

    getForm()->addWidget("editor", password);

    roles.clear();
    delete table;
}