Exemple #1
0
void MoveBox::removeMove()
{
	QList<QTreeWidgetItem *> selectedItems = m_treeWidget->selectedItems();
	if (selectedItems.empty())
		return;
	
	Quackle::MoveList selectedMoves;

	for (QList<QTreeWidgetItem *>::iterator it = selectedItems.begin(); it != selectedItems.end(); ++it)
	{
		for (QMap<Quackle::Move, QTreeWidgetItem *>::iterator mapIt = m_moveMap.begin(); mapIt != m_moveMap.end(); ++mapIt)
		{
			if (mapIt.value() == *it)
			{
				selectedMoves.push_back(mapIt.key());
				break;
			}
		}
	}

	emit removeCandidateMoves(selectedMoves);

	// TODO make this code work to select the next item
	QTreeWidgetItem *prevLastSelection = m_moveMap.value(selectedMoves.back());
	QTreeWidgetItem *nextSelection = 0;
	const int numItems = m_treeWidget->topLevelItemCount();
	for (int i = 0; i < numItems; ++i)
	{
		if (m_treeWidget->topLevelItem(i) == prevLastSelection)
		{
			if (i != numItems - 1)
			{
				nextSelection = m_treeWidget->topLevelItem(i + 1);
				break;
			}
		}
	}

	if (nextSelection)
	{
		for (QMap<Quackle::Move, QTreeWidgetItem *>::iterator mapIt = m_moveMap.begin(); mapIt != m_moveMap.end(); ++mapIt)
		{
			if (mapIt.value() == nextSelection)
			{
				emit setCandidateMove(mapIt.key());
				break;
			}
		}
	}
}
Exemple #2
0
int View::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = BaseView::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: setCandidateMove((*reinterpret_cast< const Quackle::Move(*)>(_a[1]))); break;
        case 1: removeCandidateMoves((*reinterpret_cast< const Quackle::MoveList(*)>(_a[1]))); break;
        case 2: commit(); break;
        case 3: setRack((*reinterpret_cast< const Quackle::Rack(*)>(_a[1]))); break;
        case 4: setNote((*reinterpret_cast< const UVString(*)>(_a[1]))); break;
        case 5: positionChanged((*reinterpret_cast< const Quackle::GamePosition(*)>(_a[1]))); break;
        case 6: movesChanged((*reinterpret_cast< const Quackle::MoveList(*)>(_a[1]))); break;
        case 7: grabFocus(); break;
        }
        _id -= 8;
    }
    return _id;
}