mitk::PropertyPersistence::InfoResultType mitk::PropertyPersistence::GetInfo(const std::string &propertyName,
                                                                             const MimeTypeNameType &mime,
                                                                             bool allowMimeWildCard,
                                                                             bool allowNameRegEx) const
{
  SelectFunctionType select = [propertyName, mime](const InfoMap::value_type &x) {
    return infoPredicate(x, propertyName, mime);
  };

  InfoMap selection = SelectInfo(m_InfoMap, select);

  if (allowNameRegEx)
  {
    select = [propertyName, mime](const InfoMap::value_type &x) { return infoPredicateRegEx(x, propertyName, mime); };

    InfoMap regExSelection = SelectInfo(m_InfoMap, select);

    selection.insert(regExSelection.begin(), regExSelection.end());
  }

  if (selection.empty() && allowMimeWildCard)
  { // no perfect match => second run through with "any mime type"
    select = [propertyName](const InfoMap::value_type &x) {
      return infoPredicate(x, propertyName, PropertyPersistenceInfo::ANY_MIMETYPE_NAME());
    };

    selection = SelectInfo(m_InfoMap, select);

    if (allowNameRegEx)
    {
      select = [propertyName](const InfoMap::value_type &x) {
        return infoPredicateRegEx(x, propertyName, PropertyPersistenceInfo::ANY_MIMETYPE_NAME());
      };

      InfoMap regExSelection = SelectInfo(m_InfoMap, select);

      selection.insert(regExSelection.begin(), regExSelection.end());
    }
  }

  InfoResultType result;
  for (const auto &pos : selection)
  {
    result.push_back(pos.second->UnRegExByName(propertyName).GetPointer());
  }

  return result;
}
mitk::PropertyPersistence::InfoResultType mitk::PropertyPersistence::GetInfo(const std::string &propertyName,
                                                                             bool allowNameRegEx) const
{
  SelectFunctionType select = [propertyName](const InfoMap::value_type &x) {
    return x.second.IsNotNull() && !x.second->IsRegEx() && x.second->GetName() == propertyName;
  };

  InfoMap selection = SelectInfo(m_InfoMap, select);

  InfoResultType result;
  for (const auto &pos : selection)
  {
    result.push_back(pos.second->UnRegExByName(propertyName).GetPointer());
  }

  if (allowNameRegEx)
  {
    select = [propertyName](const InfoMap::value_type &x) {
      if (x.second.IsNotNull() && x.second->IsRegEx())
      {
        std::regex ex(x.second->GetName());
        return std::regex_match(propertyName, ex);
      }
      return false;
    };

    selection = SelectInfo(m_InfoMap, select);

    for (const auto &pos : selection)
    {
      result.push_back(pos.second->UnRegExByName(propertyName).GetPointer());
    }
  }

  return result;
}
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tSuzukiRepowerEnginePanel::keyPressEvent( QKeyEvent* pEvent )
{
    bool editMode = m_pPageWidget->InEditMode();
    pEvent->ignore();

    switch( pEvent->key() )
    {
    case Key::Enter:
    case Key::Rotary:
        if( pEvent->isAutoRepeat() ) break;
      
        if( editMode )
        {
            SelectInfo();
        }
        else
        {
            EnterEditMode();
        }            
        pEvent->accept();
        break;    

    case Key::Exit:
        if( pEvent->isAutoRepeat() ) break;

        if( editMode )
        {
            EditCancel();
            pEvent->accept();
        }
        break;

    default:
        if( pEvent->isAutoRepeat() ) break;

        if( editMode )
        {
            EditSave();
        }

        tPanel::keyPressEvent( pEvent );
        break;
    }
}
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tSuzukiRepowerEnginePanel::CreateActions()
{
    m_pSpacerAct = new tAction( this );

    m_pEditAct = new tAction( tr( "Edit" ) + "...", this );
    m_pEditAct->SetAbbreviation( tr( "Edit", "[abbrev] for Edit" ) );
    Connect( m_pEditAct, SIGNAL( triggered() ), this, SLOT( EnterEditMode() ) );

    m_pSaveAct = new tAction( tr( "Save", "[button]" ), this );
    m_pSaveAct->SetAbbreviation( tr( "Save", "[abbrev] for Save" ) );
    Connect( m_pSaveAct, SIGNAL( triggered() ), this, SLOT( EditSave() ) );

    m_pCancelAct = new tAction( tr( "Cancel", "[button]" ), this );
    m_pCancelAct->SetAbbreviation( tr( "Cancel", "[abbrev] for Cancel" ) );
    m_pCancelAct->SetAppearance( Action::DestructiveAppearance );
    Connect( m_pCancelAct, SIGNAL( triggered() ), this, SLOT( EditCancel() ), Qt::QueuedConnection );

    m_pChangeGaugeRangeAct = new tAction( tr( "Configure limits", "[button]" ) + "..." );
    m_pChangeGaugeRangeAct->SetAbbreviation( tr( "Config. limits", "[abbrev] for Configure limits" ) );
    Connect( m_pChangeGaugeRangeAct, SIGNAL( triggered() ), this, SLOT( ConfigureGaugeLimits() ) );

    m_pSelectDataAct = new tAction( tr( "Select info" ) + "..." );
    m_pSelectDataAct->SetAbbreviation( tr( "Select info", "[abbrev] for Select information" ) );
    Connect( m_pSelectDataAct, SIGNAL( triggered() ), this, SLOT( SelectInfo() ) );

    m_pAddSourceAct = new tAction( tr( "Add" ) );
    m_pAddSourceAct->SetAbbreviation( tr( "Add", "[abbrev] for Add" ) );
    m_pRemoveSourceAct = new tAction( tr( "Remove" ) );
    m_pRemoveSourceAct->SetAbbreviation( tr( "Remove", "[abbrev] for Remove" ) );
    m_pAutoAct = new tAction( tr( "Auto" ), this );
    m_pAutoAct->SetAbbreviation( tr( "Auto", "[abbrev] for Auto" ) );
    m_pAutoAct->setCheckable( true );

    m_pSourceMenuAct = new tAction( tr("Sources"), tr( "Sources", "[abbrev] for Sources" ), this );
    m_pSourceMenuAct->AppendSubAction( m_pAddSourceAct );
    m_pSourceMenuAct->AppendSubAction( m_pRemoveSourceAct );
    m_pSourceMenuAct->AppendSubAction( m_pAutoAct );
    Connect( m_pAddSourceAct, SIGNAL( triggered() ), m_pPageWidget, SLOT( AddSource() ) );
    Connect( m_pRemoveSourceAct, SIGNAL( triggered() ), m_pPageWidget, SLOT( RemoveSource() ), Qt::QueuedConnection );
    Connect( m_pAutoAct, SIGNAL( toggled( bool ) ), m_pPageWidget, SLOT( SetAutoConfigureSources( bool ) ) );
}