Exemplo n.º 1
0
void CGUIDialogKeyboardGeneric::OnIPAddress()
{
  // find any IP address in the current string if there is any
  // We match to #.#.#.#
  CStdString utf8String;
  g_charsetConverter.wToUTF8(m_strEdit, utf8String);
  CStdString ip;
  CRegExp reg;
  reg.RegComp("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+");
  int start = reg.RegFind(utf8String.c_str());
  int length = 0;
  if (start > -1)
  {
    length = reg.GetSubLength(0);
    ip = utf8String.Mid(start, length);
  }
  else
    start = utf8String.size();
  if (CGUIDialogNumeric::ShowAndGetIPAddress(ip, g_localizeStrings.Get(14068)))
  {
    utf8String = utf8String.Left(start) + ip + utf8String.Mid(start + length);
    g_charsetConverter.utf8ToW(utf8String, m_strEdit);
    UpdateLabel();
    CGUILabelControl* pEdit = ((CGUILabelControl*)GetControl(CTL_LABEL_EDIT));
    if (pEdit)
      pEdit->SetCursorPos(m_strEdit.size());
  }
}
void CGUIDialogKeyboardGeneric::OnIPAddress()
{
    // find any IP address in the current string if there is any
    // We match to #.#.#.#
    std::string text = GetText();
    std::string ip;
    CRegExp reg;
    reg.RegComp("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+");
    int start = reg.RegFind(text.c_str());
    int length = 0;
    if (start > -1)
    {
        length = reg.GetSubLength(0);
        ip = text.substr(start, length);
    }
    else
        start = text.size();
    if (CGUIDialogNumeric::ShowAndGetIPAddress(ip, g_localizeStrings.Get(14068)))
        SetEditText(text.substr(0, start) + ip.c_str() + text.substr(start + length));
}