Exemple #1
0
int WBorderLayout::count() const
{
  int j = 0;
  for (int i = 0; i < 5; ++i)
    if (itemAtPosition((LayoutPosition)i).item_)
      ++j;

  return j;
}
Exemple #2
0
LayoutPosition WBorderLayout::position(WLayoutItem *item) const
{
  for (int i = 0; i < 5; ++i) {
    if (itemAtPosition((LayoutPosition)i).item_.get() == item) {
      return (LayoutPosition)i;
    }
  }

  LOG_ERROR("position(): item not found");
  return LayoutPosition::Center;
}
Exemple #3
0
void WBorderLayout::add(std::unique_ptr<WLayoutItem> item,
			LayoutPosition position)
{
  auto& it = itemAtPosition(position);
  if (it.item_) {
    LOG_ERROR("supports only one widget per position");
    return;
  }

  it.item_ = std::move(item);
  itemAdded(it.item_.get());
}
void HeatmapView::mouseDoubleClickEvent(QMouseEvent *e)
{
    if (m_data && e->button() == Qt::LeftButton) {
        qint64 index = itemAtPosition(e->pos());

        if (index >= 0) {
            m_data->itemDoubleClicked(index);
            return;
        }
    }

    GraphView::mouseDoubleClickEvent(e);
}
void CameraLayout::updateLayout(){
    calculateCellsSize();
    for (int r = 0; r < rowCount(); ++r ){
        for (int c = 0; c < columnCount(); ++c ){
                QLayoutItem *item = itemAtPosition( r, c );
                if ( item ){
                        if ( item->widget() ){
                            item->widget()->setFixedSize( d->cellsSize );
                            setColumnStretch( c, d->cellsSize.width() );
                            setRowStretch( c, d->cellsSize.height() );
                        }
                }
            }
        }
}
Exemple #6
0
WLayoutItem *WBorderLayout::itemAt(int index) const
{
  int j = 0;
  for (int i = 0; i < 5; ++i) {
    WLayoutItem *it = itemAtPosition((LayoutPosition)i).item_.get();
    if (it) {
      if (j == index)
	return it;
      else
	++j;
    }
  }

  return nullptr;
}
Exemple #7
0
std::unique_ptr<WLayoutItem> WBorderLayout::removeItem(WLayoutItem *item)
{
  std::unique_ptr<WLayoutItem> result;

  for (int i = 0; i < 5; ++i) {
    Impl::Grid::Item& gridItem = itemAtPosition((LayoutPosition)i);
    if (gridItem.item_.get() == item) {
      result = std::move(gridItem.item_);
      itemRemoved(item);

      break;
    }
  }

  return result;
}
void CameraLayout::clear(){
    for (int r = 0; r < rowCount(); ++r ){
        for (int c = 0; c < columnCount(); ++c ){
                QLayoutItem *item = itemAtPosition( r, c );
                if ( item ){
                        removeItem( item );
                        if ( item->widget() ){
                            BlackWidget *bw = qobject_cast < BlackWidget *> ( item->widget() );
                            if ( bw ) delete bw;
                            //else is camera o similar
                            else item->widget()->setVisible( false );
                        }
                }
                delete item;
            }
        }
}
void HeatmapView::mouseMoveEvent(QMouseEvent *e)
{
    GraphView::mouseMoveEvent(e);

    if (e->buttons() || !m_data) {
        QToolTip::hideText();
        return;
    }

    qint64 index = itemAtPosition(e->pos());

    if (index >= 0) {
        QToolTip::showText(e->globalPos(), m_data->itemTooltip(index));
    } else {
        QToolTip::hideText();
    }
}
void writeToPropertySheet(
        const cu::UserParameterContainer & cont
        , QWidget & sheet
        )
{
    const auto layout =
        dynamic_cast<QGridLayout*>( sheet.layout() );
    assert( layout );
    const auto nParams = cont.getNParameters();
    for ( size_t row = 0; row != nParams; ++row )
    {
        const auto item = layout->itemAtPosition( row, 1 );
        assert( item );
        const auto control = item->widget();
        assert( control );
        const auto param = cont.getParameter( row );
        assert( param );
        writeToControl( *param, *control );
    }
}
void CameraLayout::addWidget ( QWidget * widget ){
    if ( !checkLayoutDimensions ( ) ){
         qDebug("CameraLayout::addWidget: Not Enough Space" );
         return;
    }
    QLayoutItem *item = itemAtPosition( d->rowCount, d->columnCount );
    if ( !item )
        return;

    QSize size = item->widget()->size();
    removeItem( item );
    delete item->widget();
    widget->setFixedSize( size );
    QGridLayout::addWidget ( widget, d->rowCount , d->columnCount );
    d->columnCount++;
    //setColumnStretch( d->columnCount , size.width() );
    if ( d->columnCount >= d->columns ) {
            d->rowCount++;
            d->columnCount = 0;
    }
}
Exemple #12
0
void Plots::changeOrder(QList<std::tuple<int, int> > orderedFilterInfo)
{
    if(orderedFilterInfo.empty())
    {
        qDebug() << "orderedFilterInfo is empty, do not reorder..";
        return;
    }

    qDebug() << "changeOrder: items = " << orderedFilterInfo.count();

    auto gridLayout = static_cast<QGridLayout*> (layout());
    auto rowsCount = gridLayout->rowCount();

    Q_ASSERT(m_plotsCount <= rowsCount);

    qDebug() << "plotsCount: " << m_plotsCount;

    QList <std::tuple<size_t, size_t, size_t>> currentOrderedPlotsInfo;
    QList <std::tuple<size_t, size_t, size_t>> expectedOrderedPlotsInfo;

    for(auto row = 0; row < m_plotsCount; ++row)
    {
        auto plotItem = gridLayout->itemAtPosition(row, 0);
        auto legendItem = gridLayout->itemAtPosition(row, 1);

        Q_ASSERT(plotItem);
        Q_ASSERT(legendItem);

        auto plot = qobject_cast<Plot*> (plotItem->widget());
        Q_ASSERT(plot);

        currentOrderedPlotsInfo.push_back(std::make_tuple(plot->group(), plot->type(), plot->streamPos()));
    }

    for(auto filterInfo : orderedFilterInfo)
    {
        for(auto plotInfo : currentOrderedPlotsInfo)
        {
            if(std::get<0>(plotInfo) == std::get<0>(filterInfo) && std::get<1>(plotInfo) == std::get<1>(filterInfo))
            {
                expectedOrderedPlotsInfo.push_back(plotInfo);
            }
        }
    }

    Q_ASSERT(currentOrderedPlotsInfo.length() == expectedOrderedPlotsInfo.length());
    if(currentOrderedPlotsInfo.length() != expectedOrderedPlotsInfo.length())
        return;

    for(auto i = 0; i < expectedOrderedPlotsInfo.length(); ++i)
    {
        qDebug() << "cg: " << std::get<0>(currentOrderedPlotsInfo[i])
                 << ", "
                 << "ct: " << std::get<1>(currentOrderedPlotsInfo[i])
                 << ", "
                 << "cp: " << std::get<2>(currentOrderedPlotsInfo[i])
                 << ", "
                 << "eg: " << std::get<0>(expectedOrderedPlotsInfo[i])
                 << ", "
                 << "et: " << std::get<1>(expectedOrderedPlotsInfo[i])
                 << ", "
                 << "ep: " << std::get<2>(expectedOrderedPlotsInfo[i]);
    }

    for(auto i = 0; i < expectedOrderedPlotsInfo.length(); ++i)
    {
        if(expectedOrderedPlotsInfo[i] != currentOrderedPlotsInfo[i])
        {
            // search current item which we should put at expected position
            for(auto j = 0; j < expectedOrderedPlotsInfo.length(); ++j)
            {
                if(expectedOrderedPlotsInfo[i] == currentOrderedPlotsInfo[j])
                {
                    qDebug() << "i: " << i << ", j: " << j;

                    auto plotWidget = gridLayout->itemAtPosition(j, 0)->widget();
                    auto legendWidget = gridLayout->itemAtPosition(j, 1)->widget();

                    {
                        auto plot = qobject_cast<Plot*> (plotWidget);
                        qDebug() << "jg: " << plot->group() << ", t: " << plot->type() << ", p: " << plot->streamPos() << ", ptr = " << plot;
                    }

                    auto swapPlotWidget = gridLayout->itemAtPosition(i, 0)->widget();
                    auto swapLegendWidget = gridLayout->itemAtPosition(i, 1)->widget();

                    {
                        auto plot = qobject_cast<Plot*> (swapPlotWidget);
                        qDebug() << "ig: " << plot->group() << ", t: " << plot->type() << ", p: " << plot->streamPos() << ", ptr = " << plot;
                    }

                    gridLayout->removeWidget(plotWidget);
                    gridLayout->removeWidget(legendWidget);

                    gridLayout->removeWidget(swapPlotWidget);
                    gridLayout->removeWidget(swapLegendWidget);

                    gridLayout->addWidget(plotWidget, i, 0);
                    gridLayout->addWidget(legendWidget, i, 1);

                    gridLayout->addWidget(swapPlotWidget, j, 0);
                    gridLayout->addWidget(swapLegendWidget, j, 1);

                    currentOrderedPlotsInfo[j] = currentOrderedPlotsInfo[i];
                    currentOrderedPlotsInfo[i] = expectedOrderedPlotsInfo[i];

                    break;
                }
            }
        }
    }

    Q_ASSERT(rowsCount == gridLayout->rowCount());

    for(auto row = 0; row < m_plotsCount; ++row)
    {
        auto plotItem = gridLayout->itemAtPosition(row, 0);
        auto legendItem = gridLayout->itemAtPosition(row, 1);

        Q_ASSERT(plotItem);
        Q_ASSERT(legendItem);

        auto plot = qobject_cast<Plot*> (plotItem->widget());
        Q_ASSERT(plot);

        Q_ASSERT(plot->group() == std::get<0>(expectedOrderedPlotsInfo[row]) &&
                 plot->type() == std::get<1>(expectedOrderedPlotsInfo[row]));
    }
}
Exemple #13
0
WLayoutItem *WBorderLayout::itemAt(LayoutPosition position) const
{
  auto& gridItem = itemAtPosition(position);
  return gridItem.item_.get();
}