示例#1
0
void SchedScene::swapItems(size_t i, size_t j)
{
    std::swap((*perm_)[i], (*perm_)[j]);

    items_[i]->updateData(getItemWidth(i));
    items_[j]->updateData(getItemWidth(j));

    updateItems();

    qDebug() << "Cost: " << get_cost(*task_, *sched_);
}
示例#2
0
SchedScene::SchedScene(task_t *task, perm_t *perm, sched_t *sched, QObject *parent)
    : QGraphicsScene(parent)
    , task_(task)
    , perm_(perm)
    , sched_(sched)
    , items_(task->size())
    , marker(new Marker)
    , tRect_(NULL)

{
    for (size_t i = 0; i < task->size(); ++i)
    {
        items_[i] = new SchedItem(this, i);
        items_[i]->setPos(sched->operator[](i), 0);

        addItem(items_[i]);
        items_[i]->updateData(getItemWidth(i));
    }

    marker->setPos(0, 0);
    addItem(marker);

    tRect_ = addRect(0, 0, 0, 0);
    tRect_->setPen(QPen(Qt::red, 1));
    tRect_->setBrush(QBrush(Qt::red, Qt::Dense5Pattern));


    updateItems();
}
示例#3
0
void TreeViewItem::updatePositions (int newY)
{
    y = newY;
    itemHeight = getItemHeight();
    totalHeight = itemHeight;
    itemWidth = getItemWidth();
    totalWidth = jmax (itemWidth, 0) + getIndentX();

    if (isOpen())
    {
        newY += totalHeight;

        for (int i = 0; i < subItems.size(); ++i)
        {
            TreeViewItem* const ti = subItems.getUnchecked(i);

            ti->updatePositions (newY);
            newY += ti->totalHeight;
            totalHeight += ti->totalHeight;
            totalWidth = jmax (totalWidth, ti->totalWidth);
        }
    }
}
示例#4
0
/*!
 * This is a convenience function that updates things so our items will be
 * drawn correctly. This should be called, e.g., after our widget is resized,
 * or some size property is changed.
 */
void CSIconListWidget::resizeItems()
{
	setGridSize(QSize(getItemWidth(), getItemHeight()));
}