Exemple #1
0
void ByteTableTool::setTargetModel( AbstractModel* model )
{
    if( mByteArrayView )
    {
        mByteArrayView->disconnect( mByteTableModel );
        mByteArrayView->disconnect( this );
    }

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

    ByteArrayDocument* document =
        mByteArrayView ? qobject_cast<ByteArrayDocument*>( mByteArrayView->baseModel() ) : 0;
    mByteArrayModel = document ? document->content() : 0;

    const bool hasView = ( mByteArrayView && mByteArrayModel );
    if( hasView )
    {
        mByteTableModel->setCharCodec( mByteArrayView->charCodingName() );
        mByteTableModel->setUndefinedChar( mByteArrayView->undefinedChar() );
        connect( mByteArrayView,  &ByteArrayView::charCodecChanged,
                 mByteTableModel, &ByteTableModel::setCharCodec );
        connect( mByteArrayView, &ByteArrayView::undefinedCharChanged,
                 mByteTableModel, &ByteTableModel::setUndefinedChar );

        connect( mByteArrayView, &ByteArrayView::readOnlyChanged,
                 this, &ByteTableTool::onReadOnlyChanged );
    }

    const bool isWriteable = ( hasView && !mByteArrayView->isReadOnly() );

    emit hasWriteableChanged( isWriteable );
}
void CharsetConversionTool::setTargetModel( AbstractModel* model )
{
    if( mByteArrayView ) mByteArrayView->disconnect( this );

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

    ByteArrayDocument* document =
        mByteArrayView ? qobject_cast<ByteArrayDocument*>( mByteArrayView->baseModel() ) : 0;
    mByteArrayModel = document ? document->content() : 0;

    if( mByteArrayView && mByteArrayModel )
    {
        connect( mByteArrayView,  SIGNAL(charCodecChanged(QString)),
                 SLOT(onViewChanged()) );
        connect( mByteArrayView,  SIGNAL(selectedDataChanged(const Kasten2::AbstractModelSelection*)),
                 SLOT(onViewChanged()) );
    }

    onViewChanged();
}
Exemple #3
0
void ChecksumTool::setTargetModel( AbstractModel* model )
{
    if( mByteArrayView ) mByteArrayView->disconnect( this );

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

    ByteArrayDocument* document =
        mByteArrayView ? qobject_cast<ByteArrayDocument*>( mByteArrayView->baseModel() ) : 0;
    mByteArrayModel = document ? document->content() : 0;

    if( mByteArrayView && mByteArrayModel )
    {
        connect( mByteArrayView,  SIGNAL(selectedDataChanged(const Kasten2::AbstractModelSelection*)),
                 SLOT(onSelectionChanged()) );
    }

    // TODO: if there is no view, there is nothing calculate a checksum from
    // or this could be the view where we did the checksum from and it did not change
    checkUptoDate();
    emit uptodateChanged( mChecksumUptodate );
    emit isApplyableChanged( isApplyable() );
}