Exemple #1
0
void ChecksumTool::calculateChecksum()
{
    AbstractByteArrayChecksumAlgorithm* algorithm = mAlgorithmList.at( mAlgorithmId );

    if( algorithm )
    {
        // forget old string source
        if( mSourceByteArrayModel ) mSourceByteArrayModel->disconnect( this );

        QApplication::setOverrideCursor( Qt::WaitCursor );

        ChecksumCalculateJob* checksumCalculateJob =
            new ChecksumCalculateJob( &mCheckSum, algorithm, mByteArrayModel, mByteArrayView->selection() );
        checksumCalculateJob->exec();

        QApplication::restoreOverrideCursor();

        // remember checksum source
        mSourceAlgorithmId = mAlgorithmId;
        mSourceByteArrayModel = mByteArrayModel;
        mSourceSelection = mByteArrayView->selection();
        connect( mSourceByteArrayModel,  SIGNAL(contentsChanged(Okteta::ArrayChangeMetricsList)),
                 SLOT(onSourceChanged()) );
        connect( mSourceByteArrayModel,  SIGNAL(destroyed()),
                 SLOT(onSourceDestroyed()) );

        mChecksumUptodate = true;
        mSourceByteArrayModelUptodate = true;
        emit checksumChanged( mCheckSum );
        emit uptodateChanged( true );
    }
}
InterceptWidget::InterceptWidget(IntercepSource * source, QWidget *parent) :
    QWidget(parent),
    source(source)
{
    currentBlockSource = NULL;
    currentGui = NULL;
    ui = new(std::nothrow) Ui::InterceptWidget;
    if (ui == NULL) {
        qFatal("Cannot allocate memory for Ui::InterceptWidget X{");
    }
    ui->setupUi(this);

    packetsTable = new(std::nothrow) QTableView(this);
    if (packetsTable == NULL) {
        qFatal("Cannot allocate memory for QTableView X{");
    }
    QAbstractItemModel *old = packetsTable->model();
    model = source->getModel();
    packetsTable->setModel(model);
    delete old;

    packetsTable->setSelectionMode(QAbstractItemView::ContiguousSelection);
    packetsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
    packetsTable->verticalHeader()->setFont(RegularFont);
    packetsTable->horizontalHeader()->setFont(RegularFont);
    packetsTable->setColumnWidth(PayloadModel::TIMESPTAMP_COLUMN,TIMESTAMP_COLUMN_WIDTH);
    packetsTable->setColumnWidth(PayloadModel::DIRECTION_COLUMN,25);
    packetsTable->verticalHeader()->setDefaultSectionSize(20);
#if QT_VERSION >= 0x050000
    packetsTable->horizontalHeader()->setSectionsMovable( false );
#else
    packetsTable->horizontalHeader()->setMovable(true);
#endif
    connect(packetsTable->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), SLOT(onCurrentSelectedChanged(QModelIndex,QModelIndex)));
    ui->listLayout->addWidget(packetsTable);

    updateColumns();

    sourceChoices << CHOOSE_TEXT << UDP_EXTERNAL_SOURCE_TEXT << TCP_EXTERNAL_SOURCE_TEXT << RAW_TCP_SOURCE_TEXT;
    ui->blockSourceComboBox->addItems(sourceChoices);
    ui->blockSourceComboBox->setCurrentIndex(0);
    QStandardItem * item = qobject_cast<QStandardItemModel *>(ui->blockSourceComboBox->model())->item(0);
    item->setEnabled( false );
    item->setTextAlignment(Qt::AlignCenter);
    item->setBackground(Qt::darkGray);
    item->setForeground(Qt::white);

    connect(ui->blockSourceComboBox, SIGNAL(currentIndexChanged(QString)), SLOT(onSourceChanged(QString)));
}
Exemple #3
0
void ChecksumTool::onSourceDestroyed()
{
    mSourceByteArrayModel = 0;
    onSourceChanged();
}