示例#1
0
void StartLiveDataDialog::initListenerPropLayout(const QString& inst)
{
  // remove previous listener's properties
  auto props = m_algorithm->getPropertiesInGroup("ListenerProperties");
  for(auto prop = props.begin(); prop != props.end(); ++prop)
  {
    QString propName = QString::fromStdString((**prop).name());
    if ( m_algProperties.contains( propName ) )
    {
      m_algProperties.remove( propName );
    }
  }

  // update algorithm's properties
  m_algorithm->setPropertyValue("Instrument", inst.toStdString());
  // create or clear the layout
  QLayout *layout = ui.listenerProps->layout();
  if ( !layout )
  {
    QGridLayout *listenerPropLayout = new QGridLayout(ui.listenerProps);
    layout = listenerPropLayout;
  }
  else
  {
    QLayoutItem *child;
    while ((child = layout->takeAt(0)) != NULL)  
    {
      child->widget()->close();
      delete child;
    }
  }

  // find the listener's properties
  props = m_algorithm->getPropertiesInGroup("ListenerProperties");

  // no properties - don't show the box
  if ( props.empty() )
  {
    ui.listenerProps->setVisible(false);
    return;
  }
  
  auto gridLayout = static_cast<QGridLayout*>( layout );
  // add widgets for the listener's properties
  for(auto prop = props.begin(); prop != props.end(); ++prop)
  {
    int row = static_cast<int>(std::distance( props.begin(), prop ));
    QString propName = QString::fromStdString((**prop).name());
    gridLayout->addWidget( new QLabel(propName), row, 0 );
    QLineEdit *propWidget = new QLineEdit();
    gridLayout->addWidget( propWidget, row, 1 );
    if ( !m_algProperties.contains( propName ) )
    {
      m_algProperties.append( propName );
    }
    tie(propWidget, propName, gridLayout);
  }
  ui.listenerProps->setVisible(true);

}
示例#2
0
void StartMenu::SortScrollArea(QScrollArea *area){
  //qDebug() << "Sorting Scroll Area:";
  //Sort all the items in the scroll area alphabetically
  QLayout *lay = area->widget()->layout();
  QStringList items;
  for(int i=0; i<lay->count(); i++){
    items << lay->itemAt(i)->widget()->whatsThis();
  }
  
  items.sort();
  //qDebug() << " - Sorted Items:" << items;
  for(int i=0; i<items.length(); i++){
    if(items[i].isEmpty()){ continue; }
    //QLayouts are weird in that they can only add items to the end - need to re-insert almost every item
    for(int j=0; j<lay->count(); j++){
      //Find this item
      if(lay->itemAt(j)->widget()->whatsThis()==items[i]){
	//Found it - now move it if necessary
	//qDebug() << "Found Item:" << items[i] << i << j;
	lay->addItem( lay->takeAt(j) );
	break;
      }
    }
  }
}
示例#3
0
void MainWindow::addSpinBoxes(bool checked, int count, Range range)
{
    if (checked) {
        QWidget *w = new QWidget(ui->quantifierValuesGroupBox);
        if (ui->quantifierValuesGroupBox->layout() == 0) {
            QHBoxLayout *hbl = new QHBoxLayout(ui->quantifierValuesGroupBox);
            ui->quantifierValuesGroupBox->setLayout(hbl);
        }
        ui->quantifierValuesGroupBox->layout()->addWidget(w);
        QFormLayout *fl = new QFormLayout(w);
        for (int i = 0; i < count; i++) {
            QAbstractSpinBox *asb;
            if (range == Absolute) {
                QSpinBox *sb = new QSpinBox(w);
                sb->setMinimum(0);
                sb->setMaximum(10000);
                asb = sb;
            } else {
                QDoubleSpinBox *sb = new QDoubleSpinBox(w);
                sb->setMinimum(0);
                sb->setMaximum(1);
                sb->setSingleStep(0.05);
                asb = sb;
            }
            fl->addRow(QString(QChar('A' + i)), asb);
        }
    } else {
        QLayout *fl = ui->quantifierValuesGroupBox->layout();
        if (fl != nullptr && fl->count() > 0) {
            QWidget *w = fl->takeAt(0)->widget();
            delete w;
            // there is no mem-leak here, qt handles qobject's children by itself
        }
    }
}
示例#4
0
void CollapsiblePairWidget::setPrimaryWidget(QWidget* widget)
{
  QLayout* primaryLayout = _primaryContainer->layout();

  QLayoutItem *child;
  while ((child = primaryLayout->takeAt(0)) != 0)
     delete child;

  primaryLayout->addWidget(widget);
}
示例#5
0
void CollapsiblePairWidget::setSecondaryWidget(QWidget* widget)
{
  QLayout* secondaryLayout = _secondaryContainer->layout();

  QLayoutItem *child;
  while ((child = secondaryLayout->takeAt(0)) != 0)
     delete child;

  secondaryLayout->addWidget(widget);
}
示例#6
0
void MainWindow::removeLayoutWidgets() {

    if (otherContainer->layout()) {
        QLayoutItem *item;
        QLayout *layout = otherContainer->layout();
        while ((item = layout->takeAt(0))) {
            item->widget()->setUserData(Qt::UserRole + 1, nullptr);
            delete item->widget();
            delete item;
        };
    }
}
示例#7
0
void USNavigation::ResetRangeMeters()
{
  m_RangeMeters.clear();

  QLayout* layout = m_Controls.m_RangeBox->layout();
  QLayoutItem *item;
  while((item = layout->takeAt(0))) {
    if (item->widget()) {
      delete item->widget();
    }
    delete item;
  }
}
示例#8
0
	void MsgFormatterWidget::handleEmoPackChanged ()
	{
		const QString& emoPack = XmlSettingsManager::Instance ()
				.property ("SmileIcons").toString ();
		AddEmoticon_->setEnabled (!emoPack.isEmpty ());

		IEmoticonResourceSource *src = Core::Instance ().GetCurrentEmoSource ();
		if (!src)
			return;

		const QHash<QImage, QString>& images = src->GetReprImages (emoPack);

		QLayout *lay = SmilesTooltip_->layout ();
		if (lay)
		{
			while (lay->count ())
				delete lay->takeAt (0);
			delete lay;
		}

		QGridLayout *layout = new QGridLayout (SmilesTooltip_);
		layout->setSpacing (0);
		layout->setContentsMargins (1, 1, 1, 1);
		const int numRows = std::sqrt (static_cast<double> (images.size ())) + 1;
		int pos = 0;
		for (QHash<QImage, QString>::const_iterator i = images.begin (),
				end = images.end (); i != end; ++i)
		{
			const QIcon icon (QPixmap::fromImage (i.key ()));
			QAction *action = new QAction (icon, *i, this);
			action->setToolTip (*i);
			action->setProperty ("Text", *i);

			connect (action,
					SIGNAL (triggered ()),
					this,
					SLOT (insertEmoticon ()));

			QToolButton *button = new QToolButton ();
			button->setDefaultAction (action);

			layout->addWidget (button, pos / numRows, pos % numRows);
			++pos;
		}

		SmilesTooltip_->setLayout (layout);
		SmilesTooltip_->adjustSize ();
		SmilesTooltip_->setMaximumSize (SmilesTooltip_->sizeHint ());
	}
示例#9
0
void QVideoWidgetPrivate::clearService()
{
    if (service) {
        QObject::disconnect(service, SIGNAL(destroyed()), q_func(), SLOT(_q_serviceDestroyed()));

        if (widgetBackend) {
            QLayout *layout = q_func()->layout();

            for (QLayoutItem *item = layout->takeAt(0); item; item = layout->takeAt(0)) {
                item->widget()->setParent(0);
                delete item;
            }
            delete layout;

            widgetBackend->releaseControl();

            delete widgetBackend;
            widgetBackend = 0;
        } else if (rendererBackend) {
            rendererBackend->clearSurface();
            rendererBackend->releaseControl();

            delete rendererBackend;
            rendererBackend = 0;
        } else {
            windowBackend->releaseControl();

            delete windowBackend;
            windowBackend = 0;
        }

        currentBackend = 0;
        currentControl = 0;
        service = 0;
    }
}
示例#10
0
文件: UiUtil.cpp 项目: xtuer/Qt
// 删除 widget 中的所有子 widgets
void UiUtil::emptyWidget(QWidget *widget) {
    QLayout *layout = widget->layout();
    QLayoutItem *item = nullptr;

    if (nullptr == layout) {
        return;
    }

    while ((item = layout->takeAt(0)) != nullptr) {
        if (item->widget()) {
            delete item->widget();
        } else {
            delete item;
        }
    }
}
示例#11
0
void ActionManagerDialog::switchPropertiesEditorWidget(QWidget* widget)
{
    QLayout *layout = mPropertiesEditorParentWidget->layout();
    if (! layout)
        return;

    QLayoutItem* item = layout->takeAt(0);
    if (item && item->widget())
        item->widget()->hide();

    if (widget) {
        layout->addWidget(widget);
        if (widget->isHidden())
            widget->show();
    }
}
示例#12
0
	void MatchConfigDialog::on_FieldName__activated (int idx)
	{
		const auto& data = Ui_.FieldName_->itemData (idx).value<ANFieldData> ();
		Ui_.DescriptionLabel_->setText (data.Description_);

		QLayout *lay = Ui_.ConfigWidget_->layout ();
		QLayoutItem *oldItem = 0;
		while ((oldItem = lay->takeAt (0)) != 0)
		{
			delete oldItem->widget ();
			delete oldItem;
		}

		CurrentMatcher_ = TypedMatcherBase::Create (data.Type_, data);
		if (CurrentMatcher_)
			lay->addWidget (CurrentMatcher_->GetConfigWidget ());
		else
			lay->addWidget (new QLabel (tr ("Invalid matcher type %1.")
						.arg (QVariant::typeToName (data.Type_))));
	}
示例#13
0
void
RadioWidget::refresh( const unicorn::Session& session )
{
    if ( session.isValid() )
    {
        m_movie->stop();

        if ( session.youRadio() )
        {
            unicorn::UserSettings us( session.user().name() );
            QString stationUrl = us.value( "lastStationUrl", "" ).toString();
            QString stationTitle = us.value( "lastStationTitle", tr( "A Radio Station" ) ).toString();

            ui->nowPlayingFrame->setVisible( !stationUrl.isEmpty() );

            RadioStation lastStation( stationUrl );
            lastStation.setTitle( stationTitle );

            ui->lastStation->setStation( lastStation, stationTitle );
            ui->lastStation->setObjectName( "station" );
            style()->polish( ui->lastStation );

            ui->library->setStation( RadioStation::library( session.user() ), tr( "My Library Radio" ), tr( "Music you know and love" ) );
            ui->mix->setStation( RadioStation::mix( session.user() ), tr( "My Mix Radio" ), tr( "Your library plus new music" ) );
            ui->rec->setStation( RadioStation::recommendations( session.user() ), tr( "My Recommended Radio" ), tr( "New music from Last.fm" ) );

            ui->friends->setStation( RadioStation::friends( session.user() ), tr( "My Friends' Radio" ), tr( "Music your friends like" ) );
            ui->neighbours->setStation( RadioStation::neighbourhood( session.user() ), tr( "My Neighbourhood Radio" ), tr ( "Music from listeners like you" ) );

            if ( m_currentUsername != session.user().name() )
            {
                m_currentUsername = session.user().name();

                // clear the recent stations
                QLayout* recentStationsLayout = ui->recentStations->layout();
                while ( recentStationsLayout->count() )
                {
                    QLayoutItem* item = recentStationsLayout->takeAt( 0 );
                    delete item->widget();
                    delete item;
                }

                // fetch recent stations
                connect( session.user().getRecentStations( MAX_RECENT_STATIONS ), SIGNAL(finished()), SLOT(onGotRecentStations()));
            }

            ui->stackedWidget->setCurrentWidget( ui->mainPage );
        }
        else
        {
            ui->listen->setVisible( session.registeredWebRadio() );

            ui->stackedWidget->setCurrentWidget( ui->nonSubPage );

            ui->title->setText( tr( "Subscribe to listen to radio, only %1 a month" ).arg( session.subscriptionPriceString() ) );
            ui->subscribe->setVisible( session.subscriberRadio() );
        }
    }
    else
    {
        ui->stackedWidget->setCurrentWidget( ui->spinnerPage );
        m_movie->start();
    }
}
示例#14
0
//----------------------------------------------------------------------------
void DynamicEditor::setupTabs(QDomDocument *elmerDefs, const QString &Section, int ID)
{
  // Clear:
  //-------
  this->ID = ID;

  hash.clear();

  QLayout *layout = this->layout();
  if(layout != NULL) {
    QLayoutItem *item;
    while((item = layout->takeAt(0)) != 0)
      delete item;
    if(tabWidget != NULL) {
      tabWidget->clear();
      delete tabWidget;
    }
    delete layout;
  }

  // Get root element of elmerDefs:
  //-------------------------------
  root = elmerDefs->documentElement();

  tabWidget = new QTabWidget;
  //tabWidget->setTabShape(QTabWidget::Triangular);
  tabWidget->setUsesScrollButtons(true);
  tabWidget->setElideMode(Qt::ElideNone);
  all_stuff = root.firstChildElement("ALL");
  element = root.firstChildElement("PDE");

  tabs = 0;

  while(!element.isNull()) {

    name = element.firstChildElement("Name");

    QGridLayout *grid = new QGridLayout;

    int params = 0;

    for( int iter=0; iter<2; iter++ )
    {
      if ( iter==0 ) {
        if ( name.text().trimmed() == "General" ) continue;
        section = all_stuff.firstChildElement(Section);
      } else  {
        section = element.firstChildElement(Section);
      }

      param = section.firstChildElement("Parameter");
      
      // ML: Added argument "Parameter" for nextSiblingElement(), 5. August 2010:
      for( ; !param.isNull(); param=param.nextSiblingElement("Parameter"), params++ ) {

        // label
        QString widget_type = param.attribute("Widget","Edit");
        QString widget_enabled = param.attribute("Enabled","True");
        QString widget_visible = param.attribute("Visible","True");
        QString paramType = param.firstChildElement("Type").text().trimmed();
        QString labelName = param.firstChildElement("Name").text().trimmed();
        QString sifName   = param.firstChildElement("SifName").text().trimmed();
        if ( sifName == "" ) sifName = labelName;
        QString paramDefault = param.firstChildElement("DefaultValue").text().trimmed();
        QString whatis    = param.firstChildElement("Whatis").text().trimmed();
        QString statusTip = param.firstChildElement("StatusTip").text().trimmed();
        QString fullName  = "/"+name.text().trimmed()+"/"+Section+"/"+labelName+"/"+QString::number(ID);
        h.widget = NULL;

        if ( widget_type == "Edit" ) {
          DynLineEdit *edit = new DynLineEdit;
          h.widget = edit->lineEdit;
          edit->lineEdit->setText(paramDefault);
          edit->name = fullName;
          connect(edit->lineEdit, SIGNAL(returnPressed()),
		  edit, SLOT(editSlot()));
          connect(edit->lineEdit, SIGNAL(textChanged(QString)),
		  this, SLOT(textChangedSlot(QString)));

        } else if (widget_type == "TextEdit") {
	  QTextEdit *textEdit = new QTextEdit;
	  // set height to 5..8 lines of current font:
	  QFont currentFont = textEdit->currentFont();
	  QFontMetrics fontMetrics(currentFont);
	  int fontHeight = fontMetrics.height();
	  textEdit->setMinimumHeight(5*fontHeight);
	  textEdit->setMaximumHeight(8*fontHeight);
	  h.widget = textEdit;

	} else if ( widget_type == "Combo" ) {
          QComboBox *combo = new QComboBox;
          h.widget = combo;

          // combo->setObjectName(labelName);  // removed 30. sept. 2008, ML
          int count = 0, active=0;

          QDomElement item = param.firstChildElement("Item");
          for( ; !item.isNull(); item=item.nextSiblingElement("Item") ) {
            QString itemType = item.attribute( "Type", "" );
            if ( itemType == "Active" ) active=count;
            QDomElement itemName = item.firstChildElement("Name");
            combo->insertItem(count++,itemName.text().trimmed() );
          } 
          combo->setCurrentIndex(active);
          // connect(combo, SIGNAL(activated(QString)), this, SLOT(comboSlot(QString)));
	  connect(combo, SIGNAL(currentIndexChanged(QString)), this, SLOT(comboSlot(QString)));

        } else if ( widget_type == "CheckBox" ) {
          QCheckBox *l = new QCheckBox;
          h.widget = l;

          l->setText("");
          l->setChecked(false);
          if ( paramDefault == "True" ) l->setChecked(true);
          connect(l, SIGNAL(stateChanged(int)), this, SLOT(lSlot(int)));

        } else if ( widget_type == "Label" ) {
          QLabel *label = new QLabel;
          QFont font;
          font.setBold(true);
          font.setUnderline(true);
          label->setFont(font);
          label->setText(labelName);
          h.widget = label;
        }

        if ( h.widget ) {
          h.widget->setWhatsThis(whatis);
          h.widget->setStatusTip(statusTip);
          h.widget->setProperty( "dom address",fullName);
          h.elem = param;

          if ( widget_enabled == "False" ) h.widget->setEnabled(false);

	  if(widget_type != "TextEdit") h.widget->setFixedHeight(18);

	  if(widget_type == "TextEdit") {
            QLabel *textEditLabel = new QLabel;
            textEditLabel->setText(labelName);
            h.label = textEditLabel;
	    grid->addWidget(h.widget, params, 0, 1, 2);

            if ( widget_visible == "False" ) {
              h.label->hide();
              h.widget->hide();
            }

	  } else if ( widget_type != "Label" ) {
            QLabel *label = new QLabel;
            label->setText(labelName);
            h.label = label;
            grid->addWidget(h.label,  params, 0);
            grid->addWidget(h.widget, params, 1);

            if ( widget_visible == "False" ) {
              h.label->hide();
              h.widget->hide();
            }
          } else {
            h.label = NULL;
            grid->addWidget(h.widget, params, 0);
          }
          hash[fullName] = h;
        }
      }
    }
示例#15
0
//-----------------------------------------------------------------------------
//! Rebuilt the trip history list layout, which updates the trip history list
//-----------------------------------------------------------------------------
void tTripHistoryList::RebuildList(tFocusAction focusAction)
{
    m_WidgetToDataMap.clear();

    QWidget* pFocusWidget = 0;
    pFocusWidget = focusWidget();
    QLayout* pLayout = layout();

    // Rebuilding the layout. may need to record focus index of current widget, and record current QScrollArea vertical position.
    int focusIndex = -1;
    int verticalScrollPos = -1;
    tScrollArea* pScrollArea = GetScrollAreaLayout(pLayout);
    if (pScrollArea != 0)
    {
        QScrollBar* pVerticalBar = pScrollArea->verticalScrollBar();
        verticalScrollPos = pVerticalBar->value();

        QVBoxLayout* pVBoxLayout = GetTripWidgetLayout(pScrollArea);
        if (pVBoxLayout != 0)
        {
            focusIndex = pVBoxLayout->indexOf(pFocusWidget);
        }
    }

    // NB: Deleting layouts doesn't delete the widgets that are added to it
    // because the QWidgets are parented to the QWidget that owns the QLayout.
    // Because of this, explicitly delete the child widgets first before they're
    // recreated in tMfdUiHeroicFactory::CreateTripHistoryListLayout
    // SM: Only delete widgets in the layout
    if (pLayout != 0)
    {
        QLayoutItem* item;
        while ( ( item = pLayout->takeAt( 0 ) ) != 0 )
        {
            delete item->widget();
            delete item;
        }
        delete pLayout;
    }

    //Build a new layout
    QLayout* pNewLayout = m_MfdUiHeroicFactory.CreateTripHistoryListLayout(this);
    setLayout(pNewLayout);

    // Restore focus of current widget if necessary, restore QScrollArea position.
    pScrollArea = GetScrollAreaLayout(pNewLayout);
    if (pScrollArea != 0 && focusIndex != -1)
    {
        if (focusAction == KEEP_FOCUS)
        {
            QVBoxLayout* pVBoxLayout = GetTripWidgetLayout(pScrollArea);
            if (pVBoxLayout != 0)
            {
                QLayoutItem* pNewLayoutItem = pVBoxLayout->itemAt(focusIndex);
                if (dynamic_cast<QWidgetItem *>(pNewLayoutItem))
                {
                    QWidget* pNewFocusWidget = pNewLayoutItem->widget();
                    pNewFocusWidget->setFocus();
                }
            }
        }
        if (verticalScrollPos != -1)
        {
            pScrollArea->verticalScrollBar()->setValue(verticalScrollPos);
        }
    }
}
示例#16
0
void GNURadioGui::displaySettings()
{
	int oldIndex = 0;

	oldIndex = ui->cboDevices->currentIndex();
	ui->cboDevices->clear();

	QString oldArgs = ui->txtDeviceArgs->text();

	osmosdr::devices_t devices = osmosdr::device::find();

	for ( uint i = 0; i < devices.size(); i++ )
	{
		osmosdr::device_t dev = devices[i];

		QString label;

		if ( dev.count( "label" ) )
		{
			label = QString(dev[ "label" ].c_str());
			dev.erase("label");
		}

		QPair< QString, QString > pair(label, dev.to_string().c_str());
		m_devs.append(pair);

		ui->cboDevices->addItem(label);
	}

	if ( ui->cboDevices->count() && oldIndex >= 0 )
	{
		if ( oldIndex > ui->cboDevices->count() - 1 )
			oldIndex = 0;

		ui->cboDevices->setCurrentIndex(oldIndex);

		if ( oldArgs.length() == 0 )
			ui->txtDeviceArgs->setText( m_devs[oldIndex].second );
	}

	if ( oldArgs.length() )
		ui->txtDeviceArgs->setText( oldArgs );

	ui->centerFrequency->setValueRange(7,
					   unsigned(m_freqMin / 1000.0),
					   unsigned(m_freqMax / 1000.0));

	ui->centerFrequency->setValue(m_generalSettings.m_centerFrequency / 1000);

	ui->sldFreqCorr->setRange(-100, +100);
	ui->sldFreqCorr->setValue( m_freqCorr );
	ui->lblFreqCorr->setText(tr("%1").arg(ui->sldFreqCorr->value()));

	m_gainControls.clear();
	QVBoxLayout *layoutGains = ui->verticalLayoutGains;
	QLayoutItem *layoutItem;

	while ( ( layoutItem = layoutGains->takeAt( 0 ) ) != NULL )
	{
		QLayout *layout = layoutItem->layout();

		if ( !layout )
			continue;

		while ( ( layoutItem = layout->takeAt( 0 ) ) != NULL )
		{
			delete layoutItem->widget();
			delete layoutItem;
		}

		delete layout;
	}

	for ( uint i = 0; i < m_namedGains.size(); i++ )
	{
		std::pair< QString, std::vector<double> > pair = m_namedGains[i];

		QHBoxLayout *layout = new QHBoxLayout();
		QLabel *gainName = new QLabel( pair.first + " Gain" );
		QSlider *gainSlider = new QSlider(Qt::Horizontal);
		QLabel *gainLabel = new QLabel("0");
		gainLabel->setMinimumWidth(30);
		gainLabel->setAlignment(Qt::AlignHCenter | Qt::AlignHCenter);

		QPair< QSlider*, QLabel* > pair2( gainSlider, gainLabel );
		m_gainControls.push_back( pair2 );

		connect(gainSlider, SIGNAL(valueChanged(int)),
			this, SLOT(on_sldGain_valueChanged(int)));

		layout->addWidget(gainName);
		layout->addWidget(gainSlider);
		layout->addWidget(gainLabel);

		layoutGains->addLayout(layout);

		std::vector<double> gain_values = pair.second;

		if ( gain_values.size() ) {
			gainSlider->setRange(0, gain_values.size() - 1);
			gainSlider->setValue(gain_values.size() / 4);
			gainSlider->setEnabled(true);
		} else {
			gainSlider->setEnabled(false);
		}
	}

	oldIndex = ui->cboSampleRate->currentIndex();
	ui->cboSampleRate->clear();

	for ( uint i = 0; i < m_sampRates.size(); i++ )
		ui->cboSampleRate->addItem( QString::number(m_sampRates[i] / 1e6) );

	if ( oldIndex > ui->cboSampleRate->count() - 1 )
		oldIndex = 0;

	if ( ui->cboSampleRate->count() && oldIndex >= 0 )
		ui->cboSampleRate->setCurrentIndex(oldIndex);

	if ( ui->cboSampleRate->count() ) {
		ui->cboSampleRate->setEnabled(true);
	} else {
		ui->cboSampleRate->setEnabled(false);
	}

	oldIndex = ui->cboAntennas->currentIndex();
	ui->cboAntennas->clear();

	if ( m_antennas.size() ) {
		for ( uint i = 0; i < m_antennas.size(); i++ )
			ui->cboAntennas->addItem( m_antennas[i] );

		if ( oldIndex > ui->cboAntennas->count() - 1 )
			oldIndex = 0;

		if ( ui->cboAntennas->count() && oldIndex >= 0 )
			ui->cboAntennas->setCurrentIndex(oldIndex);

		ui->cboAntennas->setEnabled(true);
	} else {
		ui->cboAntennas->setEnabled(false);
	}

	oldIndex = ui->cboDCOffset->currentIndex();
	ui->cboDCOffset->clear();

	if ( m_dcoffs.size() ) {
		for ( uint i = 0; i < m_dcoffs.size(); i++ )
			ui->cboDCOffset->addItem( m_dcoffs[i] );

		if ( ui->cboDCOffset->count() && oldIndex >= 0 )
			ui->cboDCOffset->setCurrentIndex(oldIndex);

		ui->cboDCOffset->setEnabled(true);
	} else {
		ui->cboDCOffset->setEnabled(false);
	}

	oldIndex = ui->cboIQBalance->currentIndex();
	ui->cboIQBalance->clear();

	if ( m_iqbals.size() ) {
		for ( uint i = 0; i < m_iqbals.size(); i++ )
			ui->cboIQBalance->addItem( m_iqbals[i] );

		if ( ui->cboIQBalance->count() && oldIndex >= 0 )
			ui->cboIQBalance->setCurrentIndex(oldIndex);

		ui->cboIQBalance->setEnabled(true);
	} else {
		ui->cboIQBalance->setEnabled(false);
	}

	oldIndex = ui->cboBandwidth->currentIndex();
	ui->cboBandwidth->clear();

	for ( uint i = 0; i < m_bandwidths.size(); i++ )
		if ( 0.0 == m_bandwidths[i] )
			ui->cboBandwidth->addItem( "Auto" );
		else
			ui->cboBandwidth->addItem( QString::number(m_bandwidths[i] / 1e6) );

	if ( oldIndex > ui->cboBandwidth->count() - 1 )
		oldIndex = 0;

	if ( ui->cboBandwidth->count() && oldIndex >= 0 )
		ui->cboBandwidth->setCurrentIndex(oldIndex);

	if ( ui->cboBandwidth->count() ) {
		ui->cboBandwidth->setEnabled(true);
	} else {
		ui->cboBandwidth->setEnabled(false);
	}
}
示例#17
0
void QtUnit::mousePressEvent(QMouseEvent *event)
{
    if (event->button() != Qt::LeftButton)
        return;
    if (!this->IsClickable())
        return;
    QVBoxLayout *objGroupLayout = new QVBoxLayout();
    QScrollArea *objScroll = new QScrollArea(objDetail);
    objScroll->setStyleSheet("background-color: rgb(25, 25, 25);");
    objScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    objScroll->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);

    QWidget *scrollChild = new QWidget();
    QGridLayout *objGrid = new QGridLayout(scrollChild);
    objGrid->setSizeConstraint(QLayout::SetMinAndMaxSize);

    QLayout *currentLayout = NULL;
    QLayoutItem *child = NULL;
    if (objDetail) {
        if ((currentLayout = objDetail->layout())) {
            while ((child = currentLayout->takeAt(0)) != 0)
                delete child->widget();
            delete currentLayout;
        }
        
    }

    objGroupLayout->addWidget(objScroll);

    QLabel *overlapLab = new QLabel("overlap: ");
    QLabel *overlapVal = new QLabel(QString::number(((Column *)node)->GetOverlap()));
    objGrid->addWidget(overlapLab, 0, 0);
    objGrid->addWidget(overlapVal, 0, 1);

    QLabel *synapsesLab = new QLabel("synaptic details");
    objGrid->addWidget(synapsesLab, 1, 0, 1, 3);
    QLabel *idx = new QLabel("Idx");
    QLabel *coord = new QLabel("Coord");
    QLabel *firing = new QLabel("Firing");
    QLabel *perm = new QLabel("Perm");
    objGrid->addWidget(idx, 2, 0);
    objGrid->addWidget(coord, 2, 1);
    objGrid->addWidget(firing, 2, 2);
    objGrid->addWidget(perm, 2, 3);

    Column *col = (Column *)node;
    DendriteSegment *segment = col->GetProximalDendriteSegment();
    std::vector<Synapse *> syns  = segment->GetSynapses();
    for (int i=0; i<col->GetRecFieldSz(); i++) {
        char synCoordStr[32];
        memset(synCoordStr, 0, sizeof(synCoordStr));
        unsigned int x = syns[i]->GetX(), y = syns[i]->GetY();
        snprintf(synCoordStr, sizeof(synCoordStr), "(%d, %d)", x, y);
        float p = syns[i]->GetPerm();

        QLabel *synIdx = new QLabel(QString("%1: ").arg(i));
        QLabel *synCoordLab = new QLabel(synCoordStr);
        QLabel *synFiring = new QLabel(QString("%1").arg(syns[i]->IsFiring()? 1 : 0));
        QLabel *synPerm = new QLabel(QString("%1: ").arg(p));
        objGrid->addWidget(synIdx, 3+i, 0, 1, 1);
        objGrid->addWidget(synCoordLab, 3+i, 1, 1, 1);
        objGrid->addWidget(synFiring, 3+i, 2, 1, 1);
        objGrid->addWidget(synPerm, 3+i, 3, 1, 1);
    }

    // Note: must add the layout of widget before calling setWidget() or won't
    // be visible.
    objScroll->setWidget(scrollChild);
    objDetail->setLayout(objGroupLayout);
}