Пример #1
0
void ViewConfigController::setTargetModel( AbstractModel* model )
{
    if( mByteArrayView ) mByteArrayView->disconnect( this );

    mByteArrayView = model ? model->findBaseModel<ByteArrayView*>() : 0;

    const bool hasView = ( mByteArrayView != 0 );
    if( hasView )
    {
        onOffsetColumnVisibleChanged( mByteArrayView->offsetColumnVisible() );
        onOffsetCodingChanged( mByteArrayView->offsetCoding() );
        onShowsNonprintingChanged( mByteArrayView->showsNonprinting() );
        onValueCodingChanged( mByteArrayView->valueCoding() );
        onCharCodecChanged( mByteArrayView->charCodingName() );
        onLayoutStyleChanged( mByteArrayView->layoutStyle() );
        onVisibleByteArrayCodingsChanged( mByteArrayView->visibleByteArrayCodings() );

        connect( mByteArrayView, &ByteArrayView::offsetColumnVisibleChanged,
                 this, &ViewConfigController::onOffsetColumnVisibleChanged );
        connect( mByteArrayView, &ByteArrayView::offsetCodingChanged, this, &ViewConfigController::onOffsetCodingChanged );
        connect( mByteArrayView, &ByteArrayView::showsNonprintingChanged,
                 this, &ViewConfigController::onShowsNonprintingChanged );
        connect( mByteArrayView, &ByteArrayView::valueCodingChanged, this, &ViewConfigController::onValueCodingChanged );
        connect( mByteArrayView, &ByteArrayView::charCodecChanged,
            this, &ViewConfigController::onCharCodecChanged );
        connect( mByteArrayView, &ByteArrayView::layoutStyleChanged, this, &ViewConfigController::onLayoutStyleChanged );
        connect( mByteArrayView, &ByteArrayView::visibleByteArrayCodingsChanged,
                 this, &ViewConfigController::onVisibleByteArrayCodingsChanged );
    }

    mOffsetCodingAction->setEnabled( hasView );
    mCodingAction->setEnabled( hasView );
    mEncodingAction->setEnabled( hasView );
    mShowsNonprintingAction->setEnabled( hasView );
    mSetBytesPerLineAction->setEnabled( hasView );
    mSetBytesPerGroupAction->setEnabled( hasView );
    mResizeStyleAction->setEnabled( hasView );
    mShowOffsetColumnAction->setEnabled( hasView );
    mToggleColumnsAction->setEnabled( hasView );
}
void
ByteArrayViewProfileSynchronizer::setView( ByteArrayView* view )
{
    if( mView && ! mViewProfileId.isEmpty() ) mView->disconnect( this );

    mView = view;

    // TODO: drop all changes and set view to profile if set
    mDirtyFlags = 0;

    if( mView && ! mViewProfileId.isEmpty() )
    {
        const ByteArrayViewProfile viewProfile = mViewProfileManager->viewProfile( mViewProfileId );
        updateView( viewProfile );

        connect( mView, SIGNAL(showsNonprintingChanged(bool)),
                 SLOT(onShowsNonprintingChanged()) );
        connect( mView, SIGNAL(valueCodingChanged(int)),
                 SLOT(onValueCodingChanged()) );
        connect( mView, SIGNAL(charCodecChanged(QString)),
                 SLOT(onCharCodecChanged()) );
        connect( mView, SIGNAL(substituteCharChanged(QChar)),
                 SLOT(onSubstituteCharChanged()) );
        connect( mView, SIGNAL(undefinedCharChanged(QChar)),
                 SLOT(onUndefinedCharChanged()) );
        connect( mView, SIGNAL(visibleByteArrayCodingsChanged(int)),
                 SLOT(onVisibleByteArrayCodingsChanged()) );
        connect( mView, SIGNAL(offsetColumnVisibleChanged(bool)),
                 SLOT(onOffsetColumnVisibleChanged()) );
        connect( mView, SIGNAL(noOfBytesPerLineChanged(int)),
                 SLOT(onNoOfBytesPerLineChanged()) );
        connect( mView, SIGNAL(noOfGroupedBytesChanged(int)),
                 SLOT(onNoOfGroupedBytesChanged()) );
        connect( mView, SIGNAL(layoutStyleChanged(int)),
                 SLOT(onLayoutStyleChanged()) );
        connect( mView, SIGNAL(viewModusChanged(int)),
                 SLOT(onViewModusChanged()) );
    }
}
Пример #3
0
FilterView::FilterView( FilterTool *tool, QWidget* parent )
  : AbstractToolWidget( parent ),
    mTool( tool )
{
    QVBoxLayout *baseLayout = new QVBoxLayout( this );
    baseLayout->setMargin( 0 );

    // filter
    QHBoxLayout *operationLayout = new QHBoxLayout();
    QLabel *label = new QLabel( i18nc("@label:listbox operation to use by the filter","Operation:"), this );
    mOperationComboBox = new KComboBox( this );
    connect( mOperationComboBox, SIGNAL(activated(int)),
             SLOT(onOperationChange(int)) );

    label->setBuddy( mOperationComboBox );
    const QString operationToolTip =
        i18nc("@info:tooltip","The operation to use for the filter.");
    label->setToolTip( operationToolTip );
    mOperationComboBox->setToolTip( operationToolTip );
    const QString operationWhatsThis =
        i18nc("@info:whatsthis","Select the operation to use for the filter.");
    label->setWhatsThis( operationWhatsThis );
    mOperationComboBox->setWhatsThis( operationWhatsThis );

    operationLayout->addWidget( label );
    operationLayout->addWidget( mOperationComboBox, 10 );
    baseLayout->addLayout( operationLayout );

    QGroupBox *parameterSetBox = new QGroupBox( i18nc("@title:group","Parameters"), this );
    baseLayout->addWidget( parameterSetBox );

    QVBoxLayout *parameterSetLayout = new QVBoxLayout;

    parameterSetBox->setLayout( parameterSetLayout );

    mParameterSetEditStack = new QStackedWidget( parameterSetBox );

    parameterSetLayout->addWidget( mParameterSetEditStack );

    // filter button
    QHBoxLayout *buttonLayout = new QHBoxLayout();
    buttonLayout->addStretch( 10 );
    mFilterButton = new KPushButton( KGuiItem(i18nc("@action:button","&Filter"),
                      QLatin1String("run-build"),
                      i18nc("@info:tooltip","Executes the filter for the bytes in the selected range."),
                      i18nc("@info:whatsthis",
                            "If you press the <interface>Filter</interface> button, the operation you selected "
                            "above is executed for the bytes in the selected range with the given options.")), this );
    mFilterButton->setEnabled( mTool->hasWriteable() );
    connect( mTool, SIGNAL(hasWriteableChanged(bool)), SLOT(onHasWriteableChanged(bool)) );
    connect( mTool, SIGNAL(charCodecChanged(QString)), SLOT(onCharCodecChanged(QString)) );
    connect( mFilterButton, SIGNAL(clicked(bool)), SLOT(onFilterClicked()) );
    addButton( mFilterButton, AbstractToolWidget::Default );
    buttonLayout->addWidget( mFilterButton );
    baseLayout->addLayout( buttonLayout );
    baseLayout->addStretch( 10 );

    // automatically set focus to the parameters if a operation has been selected
    QAbstractItemView* operationComboBoxListView = mOperationComboBox->view();
    QObject::connect( operationComboBoxListView, SIGNAL(activated(QModelIndex)),
             mParameterSetEditStack, SLOT(setFocus()) );
    // TODO: is a workaround for Qt 4.5.1 which doesn't emit activated() for mouse clicks
    QObject::connect( operationComboBoxListView, SIGNAL(pressed(QModelIndex)),
             mParameterSetEditStack, SLOT(setFocus()) );
    // TODO: goto filter button if there are no parameters

    addFilters();
}