Ejemplo n.º 1
0
//--------------------------------------------------------------------------------------
//
//--------------------------------------------------------------------------------------
void tDataSourcesDialog::OnItemSelectionChanged( const QModelIndex& modelIndex )
{
    m_SelectedSource = m_pDataModel->DataId( modelIndex );
    m_SelectedData = m_pDataModel->DataType( modelIndex );
    m_SelectedInstance = m_pDataModel->Instance( modelIndex );
    m_SelectedCategory = m_pDataModel->Category( modelIndex );

    RefreshValue();

    int count = SetScopeList( m_pScopeAct,
        m_pSourceSelection->GetSourceSettings()->SettingCanBeLocalScope( m_SelectedData ),
        tNDP2kSimnetSelectedData::SourceSelectionAllowed( m_SelectedData ),
        m_pSourceSelection->GetSourceSettings()->SettingCanBeGlobalScope( m_SelectedData ) );

    int scope = tDataSourceTreeModel::eGlobalScope;
    if (m_pSourceSelection->GetSourceSettings()->SettingHasGlobalScope( m_SelectedData ) == false)
    {
        tDataId source = m_pSourceSelection->LocalSetting(m_SelectedData);
        if(source.DataEngine() == DATA_ENGINE_SIMNET_SELECTION)
        {
            scope = tDataSourceTreeModel::eSimradScope;
        }
        else
        {
            scope = tDataSourceTreeModel::eLocalScope;
        }
    }
    m_pScopeAct->SetValue( scope );
    m_pScopeAct->setEnabled( count > 1 && m_SelectedSource.IsValid() && m_pSourceSelection->GetSourceSettings()->SettingCanBeLocalScope( m_SelectedData ) );

    bool selectEnabled = (m_SelectedSource.IsValid() &&                                  // eliminates the categories && instances
                          m_SelectedSource.DataEngine() != DATA_ENGINE_PROXY_ACTIVE &&   // eliminate the DataType captions
                          (scope != tDataSourceTreeModel::eSimradScope || tNDP2kSimnetSelectedData::IsSimnetSelectable( m_SelectedSource )));
    m_pSelectAct->setEnabled( selectEnabled );
    m_pConfigureAct->setEnabled( CanConfigureSource( m_SelectedSource ) );

    bool canEditInstances = m_pSourceSelection->GetSourceSettings()->CanEditInstance( m_SelectedCategory );
    m_pRenameAct->setEnabled( canEditInstances && m_SelectedInstance >= 0 ); // eliminates the category column
    m_pNewInstanceAct->setEnabled( canEditInstances );
    m_pRemoveAct->setEnabled( canEditInstances && m_SelectedInstance >= 0 && // eliminates the category column
        tDigitalData::NumInstances( m_SelectedCategory ) > 1 );

    if( canEditInstances )
    {
        m_pRenameAct->setText(tr("Rename") + QString(" (%1)").arg(tDigitalData::CategoryName(m_SelectedCategory)));
        m_pNewInstanceAct->setText(tr("New") + QString(" (%1)").arg(tDigitalData::CategoryName(m_SelectedCategory)));
        m_pRemoveAct->setText(tr("Remove") + QString(" (%1)").arg(tDigitalData::CategoryName(m_SelectedCategory)));
    }
    else
    {
        m_pRenameAct->setText( tr( "Rename" ) );
        m_pNewInstanceAct->setText( tr( "New" ) );
        m_pRemoveAct->setText( tr( "Remove" ) );
    }
}
Ejemplo n.º 2
0
RegisterColumn::RegisterColumn(RegisterType type, std::function<u64()> get,
                               std::function<void(u64)> set)
    : m_type(type), m_get_register(std::move(get)), m_set_register(std::move(set))
{
  RefreshValue();
  Update();

  setFlags(m_set_register == nullptr ? flags() ^ Qt::ItemIsEditable :
                                       Qt::ItemIsEditable | Qt::ItemIsEnabled);
  setData(DATA_TYPE, static_cast<quint32>(type));
}
Ejemplo n.º 3
0
void RegisterColumn::SetValue()
{
  u64 value = 0;

  bool valid = false;

  switch (m_display)
  {
  case RegisterDisplay::Hex:
    value = text().toULongLong(&valid, 16);
    break;
  case RegisterDisplay::SInt32:
    value = text().toInt(&valid);
    break;
  case RegisterDisplay::UInt32:
    value = text().toUInt(&valid);
    break;
  case RegisterDisplay::Float:
  {
    float f = text().toFloat(&valid);
    std::memcpy(&value, &f, sizeof(u32));
    break;
  }
  case RegisterDisplay::Double:
  {
    double f = text().toDouble(&valid);
    std::memcpy(&value, &f, sizeof(u64));
    break;
  }
  }

  if (!valid)
    QMessageBox::critical(nullptr, QObject::tr("Error"), QObject::tr("Invalid input provided"));
  else
    m_set_register(value);

  RefreshValue();
}
// This method is called when GTBehaviour object is updated.
int32 UIBSLabelSmoothValueChange::OnUpdate(void)
{
	GTBehaviour::OnUpdate();

	if(m_nWorkingValue != m_nTargetValue)
	{
		// Check if it's time to update working value
		float fTimeNow = TimeManager::GetInstance()->GetTime();
		float fTimeDelta = fTimeNow - m_fPrevTimer;
		if(fTimeDelta > m_fTimerInterval)
		{
			if(m_nWorkingValue < m_nTargetValue)
			{
				m_nWorkingValue++;
				if(m_nWorkingValue > m_nTargetValue)
				{
					m_nWorkingValue = m_nTargetValue;
				}
			}
			else if(m_nWorkingValue > m_nTargetValue)
			{
				m_nWorkingValue--;
				if(m_nWorkingValue < 0)
				{
					m_nWorkingValue = 0;
				}
			}

			// Refresh the value dispalyed
			RefreshValue();
			// Save current time for next update
			m_fPrevTimer = fTimeNow;
		}
	}
	
	return 1;
}
Ejemplo n.º 5
0
//--------------------------------------------------------------------------------------
// 
//--------------------------------------------------------------------------------------
void tDataSourcesDialog::timerEvent( QTimerEvent* )
{
    RefreshValue();
}
Ejemplo n.º 6
0
//--------------------------------------------------------------------------------------
//
//--------------------------------------------------------------------------------------
void tDataSourcesDialog::OnNumTrimTabsChanged( int numTrimTabsIndex )
{
    int numTrimTabs = numTrimTabsIndex + 1;
    m_pSourceSelection->SetInstances(DATA_CATEGORY_TRIM_TAB, numTrimTabs);
    RefreshValue();
}
Ejemplo n.º 7
0
//--------------------------------------------------------------------------------------
//
//--------------------------------------------------------------------------------------
void tDataSourcesDialog::OnUINumTanksChanged( int numTanksSelectedIndex )
{
    int numTanks = numTanksSelectedIndex + 1;
    m_pSourceSelection->SetInstancesWithPreservedNames(DATA_CATEGORY_FUEL_TANK, numTanks);
    RefreshValue();
}
Ejemplo n.º 8
0
//--------------------------------------------------------------------------------------
//
//--------------------------------------------------------------------------------------
void tDataSourcesDialog::OnUINumTransChanged( int numTransSelectedIndex )
{
    int numTrans = numTransSelectedIndex + 1;
    m_pSourceSelection->SetInstances(DATA_CATEGORY_TRANSMISSION, numTrans);
    RefreshValue();
}
Ejemplo n.º 9
0
//--------------------------------------------------------------------------------------
//
//--------------------------------------------------------------------------------------
void tDataSourcesDialog::OnUINumEnginesChanged( int numEnginesSelectedIndex )
{
    int numEngines = numEnginesSelectedIndex + 1;
    m_pSourceSelection->SetInstances(DATA_CATEGORY_ENGINE, numEngines);
    RefreshValue();
}