Ejemplo n.º 1
0
void MiniProgrammerUI::setVertical(bool vertical)
{
    if(m_isVertical == vertical)
        return;

    m_isVertical = vertical;

    QBoxLayout *from = ui->horLayout;
    QBoxLayout *to = ui->vertLayout;

    if(!vertical)
        std::swap(from, to);

    while(from->count() != 0)
    {
        QLayoutItem *i = from->takeAt(0);
        if(i->layout())
        {
            i->layout()->setParent(0);
            to->addLayout(i->layout());
        }
        else
            to->addItem(i);
    }

    delete to->takeAt(to->count()-1);
    to->addStretch(1);
}
Ejemplo n.º 2
0
AskColorDialog::AskColorDialog(QColor initial, QWidget *parent) :
	QColorDialog(initial, parent)
{
	hexcode = new QLineEdit( this);
	hexcode->setMaxLength(9);
	QLayout *layout = this->layout();

	// find a nice spot in the layout...
	for (int k=0; k<2; k++) if (layout) {
		for (int i=2; i>=0; i--) {
			QLayoutItem *test = layout->itemAt(i);
			if (test) if (test->layout()) {
				layout = test->layout();
				//qDebug("ok %d (%d)",i,k);
				break;
			}
		}
	}

	if (layout) layout->addWidget(hexcode);

	connect(hexcode,SIGNAL(textEdited(QString)),this,SLOT(setHex()));
	connect(this,SIGNAL(currentColorChanged(QColor)),this,SLOT(updateHex()));


	setOption(ShowAlphaChannel, true);
	updateHex();
	setHex();
}
Ejemplo n.º 3
0
void MainWindow::stopButtonClicked()
{
    player->stop();
    playPauseButton->setText("Play");
    progressSlider->setValue(0);
    subtitleTimer->stop();

    //Reload subtitles
    mysubs = getsubtitles(subtitleName.toStdString());

    if ( subtitleLayout != NULL )
    {
        QLayoutItem* layoutItem;
        while((layoutItem = subtitleLayout->takeAt(0)) != NULL)
        {
            QLayoutItem* widgetItem;
            while((widgetItem = layoutItem->layout()->takeAt(0)) != NULL)
            {
                delete widgetItem->widget();
            }
            delete widgetItem;
            delete layoutItem->layout();
        }
        delete layoutItem;
    }
}
Ejemplo n.º 4
0
static void showLayout(QLayout *layout)
{
  for(GLint i=0; i<layout->count(); ++i) {
    QLayoutItem *item = layout->itemAt(i);
    if(item->widget()) { item->widget()->show(); }
    if(item->layout()) { showLayout(item->layout()); }
  }
}
void WizardPageEnvOptions::recursiveEnable( QLayout *layout, bool enable )
{
	int numChildren = layout->count();
	for( int c = 0; c < numChildren; ++c ) {
		QLayoutItem *item = layout->itemAt( c );
		if( item->layout() )
			recursiveEnable( item->layout(), enable );
		else if( item->widget() )
			item->widget()->setEnabled( enable );
	}
}
Ejemplo n.º 6
0
void EditorWindow::clearLayout(QLayout *layout)
{
    QLayoutItem *child;
    while ((child = layout->takeAt(0)) != 0) {
        if(child->layout() != 0)
            clearLayout( child->layout() );
        else if(child->widget() != 0)
            delete child->widget();

        delete child;
    }
}
Ejemplo n.º 7
0
void editSimulators::recursiveDeleteLater(QLayout * parentLayout) {

    QLayoutItem * item;
    while ((item = parentLayout->takeAt(0))) {
        if (item->widget() && item->widget() != ui->addEnv)
            item->widget()->deleteLater();
        if (item->layout())
            recursiveDeleteLaterloop(item->layout());
        delete item;
    }

}
Ejemplo n.º 8
0
void recursiveDeleteLater2(QLayout * parentLayout) {

    QLayoutItem * item;
    while ((item = parentLayout->takeAt(0))) {
        if (item->widget())
            item->widget()->deleteLater();
        if (item->layout())
            recursiveDeleteLater2(item->layout());
    }
    parentLayout->deleteLater();

}
Ejemplo n.º 9
0
void clearLayout(QLayout *layout){
    QLayoutItem *item;
    while((item = layout->takeAt(0))) {
        if (item->layout()) {
            clearLayout(item->layout());
            delete item->layout();
        }
        if (item->widget()) {
            delete item->widget();
        }
        delete item;
    }
}
Ejemplo n.º 10
0
void BaseTrackView::setLayoutWidgetsVisibility(QLayout *layout, bool visible)
{
    for (int i = 0; i < layout->count(); ++i) {
        QLayoutItem *item = layout->itemAt(i);
        if (item->layout()) {
            setLayoutWidgetsVisibility(item->layout(), visible);
        } else {
            QWidget *widget = item->widget();
            if (widget)
                widget->setVisible(visible);
        }
    }
}
Ejemplo n.º 11
0
void clear_layout(QLayout* layout)
{
    for (int i = layout->count(); i > 0; --i)
    {
        QLayoutItem* item = layout->takeAt(0);

        if (item->layout())
            clear_layout(item->layout());
        else item->widget()->deleteLater();

        delete item;
    }
}
Ejemplo n.º 12
0
void ParameterWidget::storeFilterValue(QDate date)
{
  QObject *filter = (QObject *)sender();
  QLayoutItem *test;
  QLayoutItem *test2;
  QLayoutItem *child;
  QLayoutItem *child2;
  QGridLayout *layout;
  QHBoxLayout *layout2;
  QWidget *found;
  XComboBox *mybox;
  int foundRow = 0;

  for (int i = 1; i < _filtersLayout->rowCount(); i++)
  {
    test = _filtersLayout->itemAtPosition(i, 1);
    if (test)
    {
      layout = (QGridLayout *)test->layout();
      child =layout->itemAtPosition(0, 0);
      layout2 = (QHBoxLayout *)child->layout()->itemAt(0);
      child2 = layout2->itemAt(0);
      found = child2->widget();

      if (found == filter )
        foundRow = i;
    }
  }

  test2 = _filtersLayout->itemAtPosition(foundRow, 0)->layout()->itemAt(0);
  mybox = (XComboBox*)test2->widget();
  QString currText = mybox->currentText();
  QPair<QString, ParameterWidgetTypes> tempPair = _types[currText];

  _filterValues[foundRow] = qMakePair(tempPair.first, QVariant(date));
  //if (!mybox->currentText().isEmpty())
  //{
  //_usedTypes->removeAll(mybox->currentText());
  
  if (!_usedTypes.isEmpty())
    _usedTypes.remove(foundRow);

  _usedTypes[foundRow] = mybox->currentText();
  _addFilterRow->setDisabled(false);
  repopulateComboboxes();

  emit updated();
}
Ejemplo n.º 13
0
/*Dato un layout, elimina il suo contenuto, "distruggendo" gli oggetti che contiene*/
void FormPerson::emptyLayout(QLayout * layout)
{
    QLayoutItem * item;
    QLayout * sublayout;
    QWidget * widget;

    // Per ciascun oggetto conenuto nel layout
    while ((item = layout->takeAt(0)))
    {
        // Se l'oggetto è un layout, ricorsivamente richiamo questa funzione
        if ((sublayout = item->layout()) != 0)
        {           
            emptyLayout(sublayout);
        }
        else if ((widget = item->widget()) != 0) // ...se invece l'oggetto è un widget ..
        {
            widget->hide(); // nascondo il widget
            layout->removeWidget(widget); // rimuovo il widget dal layout
            delete widget; // distruggo il widget
        }
        else //...in qualsiasi altro caso ...
        {
            // NOTA: in realtà non so quando avviene questo evento

            // rimuovo l'oggetto dal layout
            layout->removeItem(item);
            // distruggo l'oggetto
            delete item;

            qDebug() << "Perchè sono qui? Dovremo capirlo prima o poi!!!";
        }
    }
}
Ejemplo n.º 14
0
void StatusBar::clearSpacing(QLayout *lp)
{
    // Traverse the structure of the given layout ensuring that each object takes
    // no extra space. Start with the layout itself.
    lp->setMargin(0);
    lp->setSpacing(0);

    // Now examine its children, if any.
    int numItems = lp->count();
    for (int i = 0; i < numItems; ++i) {
	QLayoutItem *child = lp->itemAt(i);

	// Recursively examine any nested layouts.
	QLayout *l = child->layout();
	if (l) {
	    clearSpacing(l);
	    continue;
	}

	// Remove any spacer items.
	// Careful!! The list will shrink!
	QSpacerItem *s = child->spacerItem();
	if (s) {
	    lp->removeItem(s);
	    delete s;
	    --numItems;
	    --i;
	}
    }
}
Ejemplo n.º 15
0
void layoutDeleteChildren(QLayout *layout) {
    while(layout->count() > 0) {
        QLayoutItem* child;
        if ((child = layout->takeAt(0)) != nullptr) {
            if (child->layout()) {
                layoutDeleteChildren(child->layout());
            }
            if (dynamic_cast<QToolButton*>(child->widget())) {
                delete child;
                break;
            }
            delete child->widget();
            delete child;
        }
    }
}
Ejemplo n.º 16
0
void PropertyToolBox::addPage( QWidget* page )
{
    QBoxLayout* pageLayout = qobject_cast<QBoxLayout*>( page->layout() );
    if ( pageLayout && pageLayout->direction() == QBoxLayout::TopToBottom ) {
        pageLayout->setContentsMargins( 5, 5, 5, 5 );
        pageLayout->setSpacing( 3 );
        for ( int i = 0; i < pageLayout->count(); i++ ) {
            QLayoutItem* item = pageLayout->itemAt( i );
            if ( item->spacerItem() )
                continue;
            QLabel* label = qobject_cast<QLabel*>( item->widget() );
            if ( label ) {
                QString style = "border: none; border-bottom: 1px solid palette(dark);";
                if ( i > 0 )
                    style += "margin-top: 2px;";
                label->setStyleSheet( style );
                continue;
            }
            QBoxLayout* itemLayout = qobject_cast<QBoxLayout*>( item->layout() );
            if ( itemLayout && itemLayout->direction() == QBoxLayout::LeftToRight ) {
                itemLayout->insertSpacing( 0, 10 );
            } else {
                pageLayout->removeItem( item );
                QHBoxLayout* wrapperLayout = new QHBoxLayout();
                wrapperLayout->addSpacing( 10 );
                wrapperLayout->addItem( item );
                pageLayout->insertLayout( i, wrapperLayout );
            }
        }
    }

    page->setBackgroundRole( QPalette::Base );

    addItem( page, page->windowTitle() );
}
Ejemplo n.º 17
0
 /**
 * Clear the old widgets for a new Loader type
 * @param layout :: The layout containing the child layouts/widgets
 */
 void LoadDialog::removeOldInputWidgets(QVBoxLayout *layout)
 {
   // Remove the old widgets if necessary
   if( layout->count() > 2 )
   {
     int count = layout->count();
     while( count > 2 )
     {
       QLayoutItem *child = layout->takeAt(count - 1);
       if( QWidget *w = child->widget() )
       {
         w->deleteLater();
       }
       else if( QLayout *l = child->layout() )
       {
         QLayoutItem *subChild(NULL);
         while( (subChild = l->takeAt(0)) != NULL )
         {
           subChild->widget()->deleteLater();
         }
       }
       count = layout->count();
     }
   }
 }
Ejemplo n.º 18
0
void MainFen::ViderLayout(QLayout *layout)
{
    QLayoutItem *item;
    while((item=layout->itemAt(0)) != 0)
    {
        if(item->layout())
        {
            ViderLayout(item->layout());
        }
        for(int i=0; i < layout->count(); ++i)
        {
            layout->takeAt(i)->widget()->hide();
        }
    }

}
Ejemplo n.º 19
0
void PropertiesManager::clearLayoutItems(QLayout *layout)
{
    QLayoutItem *l = NULL;
    while ((l=layout->itemAt(0)) != NULL)
    {
        layout->removeItem(l);
        if (l->widget() != NULL){
            l->widget()->deleteLater();
            delete l;
            l = NULL;
        }else if (l->layout())
        {
            PropertiesManager::clearLayoutItems(l->layout());
        }
    }
}
Ejemplo n.º 20
0
QLayout *QLayoutItemProto::layout()
{
  QLayoutItem *item = qscriptvalue_cast<QLayoutItem*>(thisObject());
  if (item)
    return item->layout();
  return 0;
}
void Calibration::clearLayout(QLayout *layout)
{
	QLayoutItem *item;
	while((item = layout->takeAt(0)))
	{
		if (item->layout())
		{
			clearLayout(item->layout());
			layout->removeItem(item);
		}
		if (item->widget())
		{
			layout->removeItem(item);
		}
		delete item->layout();
		delete item->widget();
	}
}
Ejemplo n.º 22
0
/**
 * Clears all child widgets from a given QLayout
 * @param layout QLayout to remove children from
 */
void CFortEdit::ClearLayout(QLayout* layout)
{
    QLayoutItem* Child;
    while ((Child = layout->takeAt(0)) != 0)
    {
        if (Child->layout())
        {
            ClearLayout(Child->layout());
        }

        if (Child->widget())
        {
            layout->removeWidget(Child->widget());
        }

        layout->removeItem(Child);
    }
}
Ejemplo n.º 23
0
/**
 * 	-	clearLayout: clear Layout
 *      remove all child of layout
 *
*/
void Popup::clearLayout(QLayout *layout)
{
    QLayoutItem* child;
    while(layout->count()!=0)
    {
        child = layout->takeAt(0);
        if(child->layout() != 0)
        {
            clearLayout(child->layout());
        }
        else if(child->widget() != 0)
        {
            delete child->widget();
        }

        delete child;
    }
}
Ejemplo n.º 24
0
void GuiTabularDataCreate::removeLayout(QLayout* layout)
{
    QLayoutItem* child;
    while(layout->count()!=0)
    {
        child = layout->takeAt(0);
        if(child->layout() != 0)
        {
            removeLayout(child->layout());
        }
        else if(child->widget() != 0)
        {
            delete child->widget();
        }

        delete child;
    }
}
Ejemplo n.º 25
0
void tst_QFormLayout::taskQTBUG_27420_takeAtShouldUnparentLayout()
{
    QSharedPointer<QFormLayout> outer(new QFormLayout);
    QPointer<QFormLayout> inner = new QFormLayout;

    outer->addRow(inner);
    QCOMPARE(outer->count(), 1);
    QCOMPARE(inner->parent(), outer.data());

    QLayoutItem *item = outer->takeAt(0);
    QCOMPARE(item->layout(), inner.data());
    QVERIFY(!item->layout()->parent());

    outer.reset();

    if (inner)
        delete item; // success: a taken item/layout should not be deleted when the old parent is deleted
    else
        QVERIFY(!inner.isNull());
}
void QualitativeParameter::remove_cycle()
{
	QLayoutItem *item;
	//if (item->layout()) {
	int tmp=counter;
		for (int i = tmp; i > tmp-3; --i){
			item=static_cast<QGridLayout*>(extension->layout())->takeAt(i);
			if (item->layout())
			{
				//clearLayout(item->layout());
				delete item->layout();
			}
			delete item->widget();
			delete item;
			counter--;

		}
		counter_row--;
	//}
	/*
	if(counter>=0){
		while ((item = static_cast<QGridLayout*>(extension->layout())->takeAt(counter)))
		{
			if (item->layout())
			{
				//clearLayout(item->layout());
				delete item->layout();
			}
			delete item->widget();
			delete item;
		}
		counter--;
	}
	*/
	//else{
		//QMessageBox()
		//std::cerr << "error no value to remove" << std::endl;
	//}
	extension->resize(static_cast<QGridLayout*>(extension->layout())->minimumSize());

}
Ejemplo n.º 27
0
// Find the layout the item is contained in, recursing over
// child layouts
static const QLayout *findLayoutOfItem(const QLayout *haystack, const QLayoutItem *needle)
{
    const int count = haystack->count();
    for (int i = 0; i < count; i++) {
        QLayoutItem *item = haystack->itemAt(i);
        if (item == needle)
            return haystack;
        if (QLayout *childLayout =  item->layout())
            if (const QLayout *containing = findLayoutOfItem(childLayout, needle))
                return containing;
    }
    return 0;
}
Ejemplo n.º 28
0
void ProfileMatchView::drawDemandProfileButton(int ids, QList<QPair<QString, DemandDataList > >  &dp)
{
	QString temp2 = "";
	dPButtonList.clear();
//	for (int j =0; j < formLayout1->count(); j++)
//		formLayout1->takeAt(j);

    QLayoutItem *item;
    while((item = formLayout1->takeAt(0))) 
	{
        if (item->layout()) 
		{
            clearLayout(item->layout());
            delete item->layout();
        }
        if (item->widget()) 
		{
            delete item->widget();
        }
        delete item;
    }

	for (int i =0; i < dp[ids].second.count(); i++)
	{
		temp2 = dp[ids].second[i].demandName();

		testButton = new MyButton;
		testButton->setText(temp2);
		testButton->setCheckable(true);
		dPButtonList.append(testButton);
		connect(dPButtonList[i], SIGNAL(clicked()), this, SLOT(setDrawProfileMatch()));
		connect(dPButtonList[i], SIGNAL(toggled(bool)), this, SLOT(resetProfileDraw(bool)));
	}

	demandButtonVector.resize(dPButtonList.count());
	for (int j = 0; j < dPButtonList.count(); j++)
		formLayout1->addRow(dPButtonList[j]);
}
Ejemplo n.º 29
0
QLayout *rw_recurseFindLayout(QLayout *lo, QWidget *w)
{
	//printf("scanning layout: %p\n", lo);
	QLayoutIterator it = lo->iterator();
	for(QLayoutItem *i; (i = it.current()); ++it) {
		//printf("found: %p,%p\n", i->layout(), i->widget());
		QLayout *slo = i->layout();
		if(slo) {
			QLayout *tlo = rw_recurseFindLayout(slo, w);
			if(tlo)
				return tlo;
		}
		else if(i->widget() == w)
			return lo;
	}
	return 0;
}
Ejemplo n.º 30
0
void LayoutStream::ClearLayout(QLayout *layout)
{
	QLayoutItem *item;
	while((item = layout->takeAt(0))) {
		// Making sure not to delete things multiple times
		QLayout* layout = item->layout();
		QWidget* widget = item->widget();
		if (layout) {
			ClearLayout(layout);
			delete layout;
		}
		if (widget && (QLayoutItem*)widget != (QLayoutItem*)layout)
			delete widget;

		if (item != (QLayoutItem*)widget && item != (QLayoutItem*)layout)
			delete item;
	}
}