コード例 #1
0
ファイル: countdialog.cpp プロジェクト: geaney91/E-CountApp
//Finds the vote by id chosen form the list
void CountDialog::on_search_by_vote_id_btn_clicked()
{
    bool vote_found = false;
    QString id_string = ui->search_by_vote_id_spinbox->text();
    if (id_string != "" && id_string != "0")
    {
        int id = id_string.toInt();
        int size = count->get_candidates().size();
        QList<Vote *> votes;
        int votes_size = 0;
        for (int y = 0; y < size; y++)
        {
            votes = count->get_candidates().at(y)->get_total_votes();
            votes_size = votes.size();
            Vote *v;
            VoteListItem *item;
            for (int j = votes_size-1; j >= 0; j--)
            {
                v = votes[j];
                if (v->get_id() == id)
                {
                    vote_found = true;
                    ui->votes_list->clear();
                    item = new VoteListItem(v);
                    item->setText(QString::number(v->get_id()));
                    ui->votes_list->addItem(item);
                }
            }
        }

        QList<Vote *> nonTs = count->get_nonTransferable_votes_not_effective();
        int nonTs_size = nonTs.size();
        for (int i = 0; i < nonTs_size; i++)
        {
            Vote *v = nonTs[i];
            if (v->get_id() == id)
            {
                vote_found = true;
                ui->votes_list->clear();
                VoteListItem *item = new VoteListItem(v);
                item->setText(QString::number(v->get_id()));
                ui->votes_list->addItem(item);
            }
        }
        if (ui->votes_list->count() == 0)
        {
            vote_found = false;
        }
    }
    //If vote doesn't exist, display message box telling the user.
    if (!vote_found)
    {
        QMessageBox box;
        box.setText("Invalid vote id");
        box.exec();
    }

}
コード例 #2
0
ファイル: voting.cpp プロジェクト: jevolk/SPQF
id_t Voting::duplicated(const Vote &vote)
const
{
	const auto pit(chanidx.equal_range(vote.get_chan_name()));
	for(auto it(pit.first); it != pit.second; ++it)
	{
		const auto id(it->second);
		const auto vit(votes.find(id));
		if(vit == votes.end())
			continue;

		const auto &existing(*vit->second);
		if(vote.get_id() == existing.get_id())
			continue;

		if(vote.get_type() != existing.get_type())
			continue;

		if(!boost::iequals(vote.get_issue(),existing.get_issue()))
			continue;

		return existing.get_id();
	};

	return 0;
}
コード例 #3
0
ファイル: countdialog.cpp プロジェクト: geaney91/E-CountApp
//Displays the votes of the candidate selected from the combo box
void CountDialog::on_search_by_cand_combo_currentIndexChanged(int index)
{
    ui->votes_list->clear();
    int size = count->get_candidates().size();
    QList<Vote *> votes;
    int votes_size = 0;
    QCoreApplication::processEvents();
    //It's a candidate
    if (index > 0 && index <= size)
    {
        votes = count->get_candidates().at(index-1)->get_total_votes();
        votes_size = votes.size();
        Vote *v;
        VoteListItem *item;
        for (int j = votes_size-1; j >= 0; j--)
        {
            v = votes[j];
            item = new VoteListItem(v);
            item->setText(QString::number(v->get_id()));
            ui->votes_list->addItem(item);
        }
    }
    //It's the non-transferable not effectives
    else if (index == size+1)
        display_non_transferable_votes();
    //It should be blank
    else
    {
        ui->votes_list->clear();
    }

}
コード例 #4
0
ファイル: countdialog.cpp プロジェクト: geaney91/E-CountApp
void CountDialog::display_non_transferable_votes()
{
    QList<Vote *> nonTs = count->get_nonTransferable_votes_not_effective();
    int nonTs_size = nonTs.size();
    Vote *v;
    VoteListItem *item;
    for (int i = 0; i < nonTs_size; i++)
    {
        v = nonTs[i];
        item = new VoteListItem(v);
        item->setText(QString::number(v->get_id()));
        ui->votes_list->addItem(item);
    }
}
コード例 #5
0
ファイル: voting.cpp プロジェクト: jevolk/SPQF
void Voting::cancel(Vote &vote,
                    const Chan &chan,
                    const User &user)
{
	if(user.get_acct() != vote.get_user_acct())
		throw Exception() << "You can't cancel a vote by " << vote.get_user_acct() << ".";

	if(vote.total() > 1)
		throw Exception("You can't cancel after someone else has voted.");

	const auto &cfg(vote.get_cfg());
	if(!cfg.get("cancel",true))
		throw Exception("You can't cancel votes of this type.");

	vote.cancel();
	del(vote.get_id());
}