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

QWidget * DBusMethod::widget ( QWidget *  parent  )  const [virtual]

See also:
DBusItem::widget

FIXME use a better way of making space in the layout

Implements DBusItem.

Definition at line 80 of file dbusmethod.cpp.

References DBusAnnotatable::addAnnotationInfo(), DBusItem::addErrorInfo(), inArgs(), and outArgs().

                                                     {
    d->inputBoxes.clear();
    d->outputBoxes.clear();

    QScrollView * scrollview = new QScrollView( parent );
    QVBox * vbox = new QVBox( scrollview->viewport() );
    scrollview->addChild( vbox );
    scrollview->setMidLineWidth( 0 );
    scrollview->setLineWidth( 0 );
    scrollview->setResizePolicy( QScrollView::AutoOneFit );

    new QLabel(
      i18n( "Method: %1" ).arg( m_signature ),
      vbox
    );

    new QLabel(
      i18n( "Interface: %1" ).arg( m_interface ),
      vbox
    );

    new QLabel(
      i18n( "Object: %1" ).arg( m_object ),
      vbox
    );

    new QLabel(
      i18n( "Service: %1" ).arg( m_service ),
      vbox
    );

    QPtrList< DBusMethodArgument > inArgs = this->inArgs();
    QPtrList< DBusMethodArgument > outArgs = this->outArgs();

    /// FIXME use a better way of making space in the layout
    new QLabel( vbox );

    if ( inArgs.count() > 0 ) {
        new QLabel( i18n( "<b>Input:</b>" ), vbox );
    }

    for ( unsigned int i = 0; i < inArgs.count(); i++ ) {
        QHBox * hbox = new QHBox( vbox );
        new QLabel( hbox );
        (new QLabel(
          inArgs.at(i)->niceType() + " " + inArgs.at(i)->name(),
          hbox 
        ))->setMargin( 5 );
        new QLabel( "   ", hbox );

        KLineEdit * myEdit = new KLineEdit( hbox );
        d->inputBoxes.append( myEdit );
        QObject::connect(
          myEdit,
          SIGNAL(returnPressed()),
          dynamic_cast< DBusTreeWidget * >(
            listView()->parentWidget()->parentWidget()
          )->dispatcher(),
          SLOT(executeMethod())
        );
        new QLabel( "   ", hbox );

        // If we're at the end, and there are no output args, place button
        if ( outArgs.count() == 0 && inArgs.count() == i+1 ) {
            d->placeButton( hbox );
            new QLabel( "   ", hbox );
        } // if ( outArgs.count() == 0 && inArgs.count() == i+1 )

        
    }




    if ( outArgs.count() > 0 ) {
        new QLabel( i18n( "<b>Output:</b>" ), vbox );
    }




    for ( unsigned int i = 0; i < outArgs.count(); i++ ) {
        QHBox * hbox = new QHBox( vbox );
        new QLabel( hbox );
        (new QLabel(
          outArgs.at(i)->niceType() + " " + outArgs.at(i)->name(),
          hbox 
        ))->setMargin( 5 );

        new QLabel( "   ", hbox );

        QTextEdit * myEdit = new QTextEdit( hbox );
        myEdit->setReadOnly( true );
        myEdit->setTextFormat( Qt::PlainText );
        myEdit->setFixedHeight( 24 );
        d->outputBoxes.append( myEdit );

        new QLabel( "   ", hbox );

        // If we're at the end and haven't placed button, then do so now
        if ( outArgs.count() == i+1 ) {
            d->placeButton( hbox );
            new QLabel( "   ", hbox );
        } // if ( outArgs.count() == i+1 )


    }


    // If there are no input or output args, we didn't add button above...
    if ( inArgs.count() == 0 && outArgs.count() == 0 ) {
        QHBox * hbox = new QHBox( vbox );
        d->placeButton( hbox );
        new QLabel( hbox );
        new QLabel( hbox );
        new QLabel( hbox );
        new QLabel( hbox );
        new QLabel( hbox );
        new QLabel( hbox );
        new QLabel( hbox );
    } // if ( inArgs.count() == 0 && outArgs.count() == 0 )


    addAnnotationInfo( vbox );
    addErrorInfo( vbox );

    vbox->adjustSize();
    scrollview->adjustSize();

    return scrollview;
}


Generated by  Doxygen 1.6.0   Back to index