Esempio n. 1
0
void FilterSortingArea::moveWidget(const FilterInfo &info, int beforeId)
{
    // find both widgets
    FilterWidget *filter = 0;
    // first, find the filter
    for (int i = 0; i < ui->layout->count(); i++) {
        FilterWidget *current =
            qobject_cast<FilterWidget *>(ui->layout->itemAt(i)->widget());
        if (!current)
            continue;
        if (current->filterId() == info.id) {
            filter = current;
            break;
        }
    }
    if (!filter) // filter was not found
        return;
    ui->layout->removeWidget(filter);
    update();
    // now, find the position
    int pos = ui->layout->indexOf(ui->outputs);
    for (int i = 0; i < ui->layout->count(); i++) {
        FilterWidget *current =
            qobject_cast<FilterWidget *>(ui->layout->itemAt(i)->widget());
        if (!current)
            continue;
        if (current->filterId() == beforeId) {
            pos = i;
            break;
        }
    }
    ui->layout->insertWidget(pos, filter);
    emit delayedUpdateReq();
}
Esempio n. 2
0
int FilterSortingArea::dragAnimation(QDropEvent *event)
{
    int spacerIndex = ui->layout->indexOf(mEmptyWidget);
    for (int i = 0; i < ui->layout->count(); i++) {
        FilterWidget *filter =
            qobject_cast<FilterWidget *>(ui->layout->itemAt(i)->widget());
        if (filter) {
            if (filter->pos().y() > event->pos().y()) {
                if (spacerIndex != i - 1) {
                    ui->layout->insertWidget(i, mEmptyWidget);
                    if (!mEmptyWidget->isVisible())
                        mEmptyWidget->setVisible(true);
                    update();
                }
                return filter->filterId();
            }
        }
    }
    int index = ui->layout->indexOf(ui->outputs);
    if (spacerIndex != index - 1) {
        ui->layout->insertWidget(index, mEmptyWidget);
        if (!mEmptyWidget->isVisible())
            mEmptyWidget->setVisible(true);
        update();
    }
    return 0;
}
Esempio n. 3
0
void FilterSortingArea::dragEnterEvent(QDragEnterEvent *event)
{
    FilterWidget *filter = qobject_cast<FilterWidget *>(event->source());
    if (!filter)
        return;
    int moveId = filter->filterId();
    int beforeId = dragAnimation(event);
    if (moveId != 0 && !mInterface.canMove(moveId, beforeId))
        return;
    event->acceptProposedAction();
}
Esempio n. 4
0
void FilterSortingArea::dropEvent(QDropEvent *event)
{
    FilterWidget *filter = qobject_cast<FilterWidget *>(event->source());
    if (!filter)
        return;
    int moveId = filter->filterId();
    int beforeId = dragAnimation(event);
    if (moveId != 0 && !mInterface.canMove(moveId, beforeId))
        return;
    event->acceptProposedAction();
    // need to clear the animation widget here, in case of new filter
    mEmptyWidget->hide();
    update();
    if (moveId > 0){
        emit moveFilterRequested(moveId, beforeId);
    } else {
        emit addFilterRequested(mProcessorId, filter->filterType(), beforeId);
    }
}