Ejemplo n.º 1
0
void MainWindowController::select(int x, int y, Square* defSq, bool lower, int xS, int yS) {
    currentSquare = 0;
    selected.setX(x);
    selected.setY(y);
    selectedLower = lower;
    vector<StandardSquare*> selectedStandardSquares;
    if(lower)
        selectedStandardSquares = (dynamic_cast<DefinitionSquare *>(defSq)) -> lowerWordSquares;
    else
        selectedStandardSquares = (dynamic_cast<DefinitionSquare *>(defSq)) -> upperWordSquares;

    for (vector<StandardSquare*>::iterator it = selectedStandardSquares.begin(); it!=selectedStandardSquares.end(); ++it) {
        if((*it)->getModifiable()) {
            x = (*it)->getX();
            y = (*it)->getY();

            getView(x,y)->setBackgroundBrush(QBrush(QColor(228, 211, 170)));
            selectedSquares.push_back(QPoint(x,y));
        }

    }
    if(selectedSquares.size() != 0) {
        if(xS != -1 && yS != -1) {
            for(unsigned int i = 0; i < selectedSquares.size(); i++) {
                if(selectedSquares[i].x() == xS && selectedSquares[i].y() == yS)
                    currentSquare = i;
            }
        }

        QPoint selPoint = selectedSquares[currentSquare];
        QGraphicsView* v =  getView(selPoint.x(), selPoint.y());
        v->setBackgroundBrush(QBrush(QColor(150, 250, 150 )));
        v->setFocus();
    }
    else {
        QGraphicsView* v = getView(selected.x(), selected.y());
        v->setFocus();
        selected.setX(-1);
        selected.setY(-1);
    }


}
Ejemplo n.º 2
0
void MainWindowController::nextSquare(int dir) {
    QPoint selPoint = selectedSquares[currentSquare];
    getView(selPoint.x(), selPoint.y())->setBackgroundBrush(QBrush(QColor(228, 211, 170 )));
    if( (currentSquare == selectedSquares.size()-1 && dir == 1))
        currentSquare = 0;
    else if  ( (currentSquare == 0 && dir == -1))
        currentSquare = selectedSquares.size()-1;
    else
        currentSquare+= dir;
    selPoint = selectedSquares[currentSquare];
    QGraphicsView* v =  getView(selPoint.x(), selPoint.y());
    v->setBackgroundBrush(QBrush(QColor(150, 250, 150 )));
    v->setFocus();

}