Ejemplo n.º 1
0
void SchedulePoint::adjust(int tempAdjust, qreal xPos)
{
    if(tempAdjust>0)
        increaseTemp();
    if(tempAdjust<0)
        decreaseTemp();
    if(xPos<0)
        shiftLeft();
    if(xPos>0)
        shiftRight();
}
Ejemplo n.º 2
0
void SchedulePoint::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
{
    if(disabled())
        return;
    int oldTemp = temp;
    qreal oldX = pos().x();
    // provide event handler for mouse move
    emit clicked(this);
    if(m_pressed == true)
    {
        if(m_yClickPos - m_weekHeight/4 > e->pos().y())
        {
            m_yClickPos = e->pos().y();
            increaseTemp();
        }
        else if(m_yClickPos + m_weekHeight/4 < e->pos().y())
        {
            m_yClickPos = e->pos().y();
            decreaseTemp();
        }

        if(m_xClickPos - m_timeBlockWidth > e->pos().x())
        {
            //m_xClickPos = e->pos().x();
            shiftLeft();
        }
        else if(m_xClickPos + m_timeBlockWidth < e->pos().x())
        {
            //m_xClickPos = e->pos().x();
            shiftRight();
        }
    }

    emit(shareAdjustment(temp-oldTemp, pos().x()-oldX));

    e->accept();
}
Ejemplo n.º 3
0
void schedulescreen::showButtons(schedulepoint *point)
{
    // show left, right, up, and down buttons in correct position for any input conditions
    int i;
    // track which is the point that has been clicked on
    currentPoint = point;
    // show time indicated by position of current point
    currentTime->setText(currentPoint->time());

    // first hide all 4 buttons, then we will make them reappear in the correct position
    hideButtons();

    // create left arrow
    QPushButton *leftArrowButton = new QPushButton();
    leftArrowButton->setFocusPolicy(Qt::NoFocus);
    leftArrowButton->setStyleSheet("background: rgba(0,0,0,0);"
                                   "border-image: url(:/Images/simple-black-square-icon-arrowleft.png) 1;");
    leftArrowButton->setFixedSize(25,25);
    connect(leftArrowButton, SIGNAL(clicked()), this, SLOT(shiftLeft()));

    // create right arrow
    QPushButton *rightArrowButton = new QPushButton();
    rightArrowButton->setFocusPolicy(Qt::NoFocus);
    rightArrowButton->setStyleSheet("background: rgba(0,0,0,0);"
                                   "border-image: url(:/Images/simple-black-square-icon-arrowright.png) 1;");
    rightArrowButton->setFixedSize(25,25);
    connect(rightArrowButton, SIGNAL(clicked()),this,SLOT(shiftRight()));

    // create up arrow
    QPushButton *upArrowButton = new QPushButton();
    upArrowButton->setFocusPolicy(Qt::NoFocus);
    upArrowButton->setStyleSheet("background: rgba(0,0,0,0);"
                                 "border-image: url(:/Images/simple-black-square-icon-arrowup.png) 1;");
    upArrowButton->setFixedSize(25,25);
    connect(upArrowButton, SIGNAL(clicked()), this, SLOT(increaseTemp()));

    // create down arrow
    QPushButton *downArrowButton = new QPushButton();
    downArrowButton->setFocusPolicy(Qt::NoFocus);
    downArrowButton->setStyleSheet("background: rgba(0,0,0,0);"
                                 "border-image: url(:/Images/simple-black-square-icon-arrowdown.png) 1;");
    downArrowButton->setFixedSize(25,25);
    connect(downArrowButton, SIGNAL(clicked()), this, SLOT(decreaseTemp()));

    // create proxy widgets so that buttons can be added to graphics view
    proxyLeftButton = new QGraphicsProxyWidget();
    proxyLeftButton->setWidget(leftArrowButton);
    proxyRightButton = new QGraphicsProxyWidget();
    proxyRightButton->setWidget(rightArrowButton);
    proxyUpButton = new QGraphicsProxyWidget();
    proxyUpButton->setWidget(upArrowButton);
    proxyDownButton = new QGraphicsProxyWidget();
    proxyDownButton->setWidget(downArrowButton);

    // set position of left and right buttons on either side of currently selected point
    proxyLeftButton->setPos(QPoint(0.075 + (85 * (point->getID() % 4)),
                                        25 + (22 * ((point->getID() / 4) % 7))));
    scene->addItem(proxyLeftButton);
    proxyRightButton->setPos(QPoint(45.075 + (85 * (point->getID() % 4)),
                                    25 + (22 * ((point->getID() / 4) % 7))));
    scene->addItem(proxyRightButton);

    // set up and down buttons at the top and bottom of currently visible column
    for(i=0; i<7; i++) {
        if(pointList.at((point->getID()%4 + 4*i))->isVisible()) {
            proxyUpButton->setPos(QPoint(-13 + pointList.at(point->getID()%4 + 4*i)->pos().x(),
                                         -31 + pointList.at(point->getID()%4 +4*i)->pos().y()));
            break;
        }
    }
    scene->addItem(proxyUpButton);

    for(i=0; i<7; i++) {
        if(pointList.at((24+(point->getID()%4) - 4*i))->isVisible()) { // only works if last row is visible
            proxyDownButton->setPos(QPoint(-13 + pointList.at((24+(point->getID()%4) - 4*i))->pos().x(),
                                           6 + pointList.at((24+(point->getID()%4) - 4*i))->pos().y()));
            break;
        }
    }

    scene->addItem(proxyDownButton);

    // if the point has already been moved, make sure buttons are created at the right spot
    if(point->getLocation()<0) {
        for(i=0; i>point->getLocation(); i--) {
            shiftHorizontalButtonsLeft();
        }
    } else {
        for(i=0; i<point->getLocation(); i++) {
            shiftHorizontalButtonsRight();
        }
    }

    // blur all columns except the currently selected column
    blur();

}