Logo Search packages:      
Sourcecode: webissues version File versions  Download package

SetValueDialog::SetValueDialog ( int  issueId,
int  attributeId,
QWidget *  parent 
)

Constructor.

Parameters:
issueId Identifier of the issue to modify.
attributeId Identifier of the attribute to modify.
parent The parent widget.

Definition at line 143 of file issuedialogs.cpp.

References WebIssues::DataManager::attributes(), WebIssues::ValueEditorFactory::createValueEditor(), WebIssues::dataManager, WebIssues::AttributeRow::definition(), RDB::CrossTable< ROW >::find(), RDB::ChildTable< ROW >::find(), WebIssues::IssueRow::folderId(), WebIssues::DataManager::folders(), WebIssues::DataManager::issues(), WebIssues::AttributeRow::name(), WebIssues::IssueRow::name(), WebIssues::DefinitionParser::parse(), WebIssues::IconLoader::pixmap(), WebIssues::FolderRow::projectId(), WebIssues::DefinitionInfo::required(), WebIssues::CommandDialog::setContentLayout(), WebIssues::CommandDialog::setPrompt(), WebIssues::CommandDialog::setPromptPixmap(), WebIssues::AbstractValueEditor::setValue(), WebIssues::ValueRow::value(), WebIssues::DataManager::values(), and WebIssues::AbstractValueEditor::widget().

                                                                              : IssueDialog( parent ),
    m_issueId( issueId ),
    m_attributeId( attributeId )
{
    const IssueRow* issue = dataManager->issues()->find( issueId );
    QString issueName = issue ? issue->name() : QString();
    int folderId = issue ? issue->folderId() : 0;

    const AttributeRow* attribute = dataManager->attributes()->find( attributeId );
    QString attrName = attribute ? attribute->name() : QString();
    QString definition = attribute ? attribute->definition() : QString();

    const ValueRow* value = dataManager->values()->find( attributeId, issueId );
    m_oldValue = value ? value->value() : QString();

    const FolderRow* folder = dataManager->folders()->find( folderId );
    int projectId = folder ? folder->projectId() : 0;

    setWindowTitle( tr( "Set Value" ) );
    setPrompt( tr( "Set a new value of attribute <b>%1</b> for issue <b>%2</b>:" ).arg( attrName, issueName ) );
    setPromptPixmap( IconLoader::pixmap( "edit-modify", 22 ) );

    DefinitionParser parser;
    DefinitionInfo info = parser.parse( definition );

    QVBoxLayout* layout = new QVBoxLayout();

    QRadioButton* button1 = new QRadioButton( tr( "&No Value" ), this );
    layout->addWidget( button1 );

    QHBoxLayout* editorLayout = new QHBoxLayout();
    layout->addLayout( editorLayout );

    QRadioButton* button2 = new QRadioButton( tr( "&Value:" ), this );
    editorLayout->addWidget( button2, 0 );

    m_group = new QButtonGroup( this );
    m_group->addButton( button1, 0 );
    m_group->addButton( button2, 1 );

    m_editor = ValueEditorFactory::createValueEditor( info, projectId, this, this );
    editorLayout->addWidget( m_editor->widget(), 1 );

    if ( m_oldValue.isEmpty() ) {
        m_group->button( 0 )->setChecked( true );
        m_editor->widget()->setEnabled( false );
    } else {
        m_group->button( 1 )->setChecked( true );
        m_editor->setValue( m_oldValue );
    }

    if ( info.required() )
        button1->setEnabled( false );

    connect( button2, SIGNAL( toggled( bool ) ), m_editor->widget(), SLOT( setEnabled( bool ) ) );
    connect( button2, SIGNAL( clicked() ), m_editor->widget(), SLOT( setFocus() ) );

    setContentLayout( layout, true );

    m_editor->widget()->setFocus();
}


Generated by  Doxygen 1.6.0   Back to index