예제 #1
0
void CStudentManage::slotDelStudentClicked()
{
    //开始事务
    m_Model->database().transaction();
    //获取被选中的model
    QItemSelectionModel *selectModel = m_View->selectionModel();

    //通过被选中的model, 获取被选中的格子
    QModelIndexList selectList = selectModel->selectedIndexes();

    QList<int> delRow;

    //遍历格子,获得行
    for (int i = 0; i < selectList.size(); ++i)
    {
        delRow << selectList.at(i).row();
    }

    //去除重复的行
    while (delRow.size() > 0)
    {
        int row = delRow.at(0);
        //去重
        delRow.removeAll(row);

        //删除行
        m_Model->removeRow(row);
    }
    //提交
    QString msg = "删除成功!";
    SubmitData(msg);
}
예제 #2
0
void ShuffleRound::BroadcastPublicKeys()
{
    _state = KeySharing;
    int idx = _group.GetIndex(_local_id);
    int kidx = _group.GetSize() - 1 - idx;
    _public_inner_keys[kidx] = _inner_key->GetPublicKey();
    _public_outer_keys[kidx] = _outer_key->GetPublicKey();
    QByteArray inner_key = _public_inner_keys[kidx]->GetByteArray();
    QByteArray outer_key = _public_outer_keys[kidx]->GetByteArray();

    QByteArray msg;
    QDataStream stream(&msg, QIODevice::WriteOnly);
    stream << PublicKeys << GetId().GetByteArray() << inner_key << outer_key;

    Broadcast(msg);
    if(++_keys_received == _group.GetSize()) {
        SubmitData();
    }
}
예제 #3
0
void ShuffleRound::HandlePublicKeys(QDataStream &stream, const Id &id)
{
    qDebug() << _group.GetIndex(_local_id) << _local_id.ToString() <<
             ": received public keys from " << _group.GetIndex(id) << id.ToString();

    if(_state != Offline && _state != KeySharing) {
        qWarning() << "Received a key message while in state " <<
                   StateToString(_state) << " from " << id.ToString();
        return;
    }

    int idx = _group.GetIndex(id);
    int kidx = _group.GetSize() - 1 - idx;
    if(_public_inner_keys[kidx] != 0 || _public_outer_keys[kidx] != 0) {
        qWarning() << _group.GetIndex(_local_id) << _local_id.ToString() <<
                   ": received duplicate public keys from " << _group.GetIndex(id)
                   << id.ToString();
        return;
    }

    QByteArray inner_key, outer_key;
    stream >> inner_key >> outer_key;
    _public_inner_keys[kidx] = new CppPublicKey(inner_key);
    _public_outer_keys[kidx] = new CppPublicKey(outer_key);

    if(!_public_inner_keys[kidx]->IsValid()) {
        qWarning() << _group.GetIndex(_local_id) << _local_id.ToString() <<
                   ": invalid inner key from " << idx << id.ToString();
    } else if(!_public_outer_keys[kidx]->IsValid()) {
        qWarning() << _group.GetIndex(_local_id) << _local_id.ToString() <<
                   ": invalid outer key from " << idx << id.ToString();
    }

    if(++_keys_received == _group.GetSize()) {
        SubmitData();
    }
}
예제 #4
0
void CStudentManage::slotChgStudentClicked()
{
    QString msg = "修改保存成功!";
    SubmitData(msg);
}