Exemplo n.º 1
0
void CGUIEditControl::OnClick()
{  
  // we received a click - it's not from the keyboard, so pop up the virtual keyboard, unless
  // that is where we reside!
  if (GetParentID() == WINDOW_DIALOG_KEYBOARD)
    return;

  CStdString utf8;
  g_charsetConverter.wToUTF8(m_text2, utf8);
  bool textChanged = false;
  CStdString heading = g_localizeStrings.Get(m_inputHeading ? m_inputHeading : 16028);
  switch (m_inputType)
  {
    case INPUT_TYPE_NUMBER:
      textChanged = CGUIDialogNumeric::ShowAndGetNumber(utf8, heading);
      break;
    case INPUT_TYPE_SECONDS:
      textChanged = CGUIDialogNumeric::ShowAndGetSeconds(utf8, g_localizeStrings.Get(21420));
      break;
    case INPUT_TYPE_DATE:
    {
      CDateTime dateTime;
      dateTime.SetFromDBDate(utf8);
      if (dateTime < CDateTime(2000,1, 1, 0, 0, 0))
        dateTime = CDateTime(2000, 1, 1, 0, 0, 0);
      SYSTEMTIME date;
      dateTime.GetAsSystemTime(date);
      if (CGUIDialogNumeric::ShowAndGetDate(date, g_localizeStrings.Get(21420)))
      {
        dateTime = CDateTime(date);
        utf8 = dateTime.GetAsDBDate();
        textChanged = true;
      }
      break;
    }
    case INPUT_TYPE_IPADDRESS:
      textChanged = CGUIDialogNumeric::ShowAndGetIPAddress(utf8, heading);
      break;
    case INPUT_TYPE_SEARCH:
      textChanged = CGUIDialogKeyboard::ShowAndGetFilter(utf8, true);
      break;
    case INPUT_TYPE_FILTER:
      textChanged = CGUIDialogKeyboard::ShowAndGetFilter(utf8, false);
      break;
    case INPUT_TYPE_TEXT:
    default:
      textChanged = CGUIDialogKeyboard::ShowAndGetInput(utf8, heading, true, m_inputType == INPUT_TYPE_PASSWORD);
      break;
  }
  if (textChanged)
  {
    g_charsetConverter.utf8ToW(utf8, m_text2, false);
    m_cursorPos = m_text2.size();
    UpdateText();
    m_cursorPos = m_text2.size();
  }
}
Exemplo n.º 2
0
void CGUIEditControl::OnClick()
{
    // we received a click - it's not from the keyboard, so pop up the virtual keyboard, unless
    // that is where we reside!
    if (GetParentID() == WINDOW_DIALOG_KEYBOARD)
        return;

    std::string utf8;
    g_charsetConverter.wToUTF8(m_text2, utf8);
    bool textChanged = false;
    std::string heading = g_localizeStrings.Get(m_inputHeading ? m_inputHeading : 16028);
    switch (m_inputType)
    {
    case INPUT_TYPE_READONLY:
        textChanged = false;
        break;
    case INPUT_TYPE_NUMBER:
        textChanged = CGUIDialogNumeric::ShowAndGetNumber(utf8, heading);
        break;
    case INPUT_TYPE_SECONDS:
        textChanged = CGUIDialogNumeric::ShowAndGetSeconds(utf8, g_localizeStrings.Get(21420));
        break;
    case INPUT_TYPE_TIME:
    {
        CDateTime dateTime;
        dateTime.SetFromDBTime(utf8);
        SYSTEMTIME time;
        dateTime.GetAsSystemTime(time);
        if (CGUIDialogNumeric::ShowAndGetTime(time, !heading.empty() ? heading : g_localizeStrings.Get(21420)))
        {
            dateTime = CDateTime(time);
            utf8 = dateTime.GetAsLocalizedTime("", false);
            textChanged = true;
        }
        break;
    }
    case INPUT_TYPE_DATE:
    {
        CDateTime dateTime;
        dateTime.SetFromDBDate(utf8);
        if (dateTime < CDateTime(2000,1, 1, 0, 0, 0))
            dateTime = CDateTime(2000, 1, 1, 0, 0, 0);
        SYSTEMTIME date;
        dateTime.GetAsSystemTime(date);
        if (CGUIDialogNumeric::ShowAndGetDate(date, !heading.empty() ? heading : g_localizeStrings.Get(21420)))
        {
            dateTime = CDateTime(date);
            utf8 = dateTime.GetAsDBDate();
            textChanged = true;
        }
        break;
    }
    case INPUT_TYPE_IPADDRESS:
        textChanged = CGUIDialogNumeric::ShowAndGetIPAddress(utf8, heading);
        break;
    case INPUT_TYPE_SEARCH:
        textChanged = CGUIKeyboardFactory::ShowAndGetFilter(utf8, true);
        break;
    case INPUT_TYPE_FILTER:
        textChanged = CGUIKeyboardFactory::ShowAndGetFilter(utf8, false);
        break;
    case INPUT_TYPE_PASSWORD_NUMBER_VERIFY_NEW:
        textChanged = CGUIDialogNumeric::ShowAndVerifyNewPassword(utf8);
        break;
    case INPUT_TYPE_PASSWORD_MD5:
        utf8 = ""; // TODO: Ideally we'd send this to the keyboard and tell the keyboard we have this type of input
    // fallthrough
    case INPUT_TYPE_TEXT:
    default:
        textChanged = CGUIKeyboardFactory::ShowAndGetInput(utf8, heading, true, m_inputType == INPUT_TYPE_PASSWORD || m_inputType == INPUT_TYPE_PASSWORD_MD5);
        break;
    }
    if (textChanged)
    {
        ClearMD5();
        m_edit.clear();
        g_charsetConverter.utf8ToW(utf8, m_text2);
        m_cursorPos = m_text2.size();
        UpdateText();
        m_cursorPos = m_text2.size();
    }
}
Exemplo n.º 3
0
void XMLUtils::SetDate(TiXmlNode* pRootNode, const char *strTag, const CDateTime& date)
{
  SetString(pRootNode, strTag, date.IsValid() ? date.GetAsDBDate() : "");
}
Exemplo n.º 4
0
void CGUIDialogPVRGuideSearch::Update()
{
  CGUISpinControlEx      *pSpin;
  CGUIEditControl        *pEdit;
  CGUIRadioButtonControl *pRadioButton;

  if (!m_searchfilter)
    return;

  pEdit = (CGUIEditControl *)GetControl(CONTROL_EDIT_SEARCH);
  if (pEdit)
  {
    pEdit->SetLabel2(m_searchfilter->m_strSearchTerm);
    pEdit->SetInputType(CGUIEditControl::INPUT_TYPE_TEXT, 16017);
  }

  pRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_BTN_CASE_SENS);
  if (pRadioButton) pRadioButton->SetSelected(m_searchfilter->m_bIsCaseSensitive);

  pRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_BTN_INC_DESC);
  if (pRadioButton) pRadioButton->SetSelected(m_searchfilter->m_bSearchInDescription);

  pRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_BTN_FTA_ONLY);
  if (pRadioButton) pRadioButton->SetSelected(m_searchfilter->m_bFTAOnly);

  pRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_BTN_UNK_GENRE);
  if (pRadioButton) pRadioButton->SetSelected(m_searchfilter->m_bIncludeUnknownGenres);

  pRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_BTN_IGNORE_REC);
  if (pRadioButton) pRadioButton->SetSelected(m_searchfilter->m_bIgnorePresentRecordings);

  pRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_BTN_IGNORE_TMR);
  if (pRadioButton) pRadioButton->SetSelected(m_searchfilter->m_bIgnorePresentTimers);

  pRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_SPIN_NO_REPEATS);
  if (pRadioButton) pRadioButton->SetSelected(m_searchfilter->m_bPreventRepeats);

  /* Set duration list spin */
  pSpin = (CGUISpinControlEx *)GetControl(CONTROL_SPIN_MIN_DURATION);
  if (pSpin)
  {
    pSpin->Clear();
    pSpin->AddLabel("-", -1);
    for (int i = 1; i < 12*60/5; i++)
    {
      CStdString string;
      string.Format(g_localizeStrings.Get(14044),i*5);
      pSpin->AddLabel(string, i*5);
    }
    pSpin->SetValue(m_searchfilter->m_iMinimumDuration);
  }

  pSpin = (CGUISpinControlEx *)GetControl(CONTROL_SPIN_MAX_DURATION);
  if (pSpin)
  {
    pSpin->Clear();
    pSpin->AddLabel("-", -1);
    for (int i = 1; i < 12*60/5; i++)
    {
      CStdString string;
      string.Format(g_localizeStrings.Get(14044),i*5);
      pSpin->AddLabel(string, i*5);
    }
    pSpin->SetValue(m_searchfilter->m_iMaximumDuration);
  }

  /* Set time fields */
  pEdit = (CGUIEditControl *)GetControl(CONTROL_EDIT_START_TIME);
  if (pEdit)
  {
    CDateTime time = m_searchfilter->m_startTime;
    pEdit->SetLabel2(time.GetAsLocalizedTime("", false));
    pEdit->SetInputType(CGUIEditControl::INPUT_TYPE_TIME, 14066);
  }
  pEdit = (CGUIEditControl *)GetControl(CONTROL_EDIT_STOP_TIME);
  if (pEdit)
  {
    CDateTime time = m_searchfilter->m_endTime;
    pEdit->SetLabel2(time.GetAsLocalizedTime("", false));
    pEdit->SetInputType(CGUIEditControl::INPUT_TYPE_TIME, 14066);
  }
  pEdit = (CGUIEditControl *)GetControl(CONTROL_EDIT_START_DATE);
  if (pEdit)
  {
    CDateTime date = m_searchfilter->m_startDate;
    pEdit->SetLabel2(date.GetAsDBDate());
    pEdit->SetInputType(CGUIEditControl::INPUT_TYPE_DATE, 14067);
  }
  pEdit = (CGUIEditControl *)GetControl(CONTROL_EDIT_STOP_DATE);
  if (pEdit)
  {
    CDateTime date = m_searchfilter->m_endDate;
    pEdit->SetLabel2(date.GetAsDBDate());
    pEdit->SetInputType(CGUIEditControl::INPUT_TYPE_DATE, 14067);
  }

  /* Set Channel list spin */
  pSpin = (CGUISpinControlEx *)GetControl(CONTROL_SPIN_CHANNELS);
  if (pSpin)
  {
    CFileItemList channelslist_tv;
    const CPVRChannelGroup *group = CPVRManager::GetChannelGroups()->GetById(false, m_searchfilter->m_iChannelGroup);
    if (group)
      group->GetMembers(&channelslist_tv);

    pSpin->Clear();
    pSpin->AddLabel(g_localizeStrings.Get(19217), -1);
    pSpin->AddLabel(g_localizeStrings.Get(19023), -2);
    pSpin->AddLabel(g_localizeStrings.Get(19024), -3);

    for (int i = 0; i < channelslist_tv.Size(); i++)
    {
      int chanNumber = channelslist_tv[i]->GetPVRChannelInfoTag()->ChannelNumber();
      CStdString string;
      string.Format("%i %s", chanNumber, channelslist_tv[i]->GetPVRChannelInfoTag()->ChannelName().c_str());
      pSpin->AddLabel(string, chanNumber);
    }
    pSpin->SetValue(m_searchfilter->m_iChannelNumber);
  }

  /* Set Group list spin */
  pSpin = (CGUISpinControlEx *)GetControl(CONTROL_SPIN_GROUPS);
  if (pSpin)
  {
    CFileItemList grouplist;
    CPVRManager::GetChannelGroups()->GetTV()->GetGroupList(&grouplist);

    pSpin->Clear();
    pSpin->AddLabel(g_localizeStrings.Get(593), -1);

    for (int i = 0; i < grouplist.Size(); i++)
      pSpin->AddLabel(grouplist[i]->GetLabel(), atoi(grouplist[i]->m_strPath));

    pSpin->SetValue(m_searchfilter->m_iChannelGroup);
  }

  /* Set Genre list spin */
  pSpin = (CGUISpinControlEx *)GetControl(CONTROL_SPIN_GENRE);
  if (pSpin)
  {
    pSpin->Clear();
    pSpin->AddLabel(g_localizeStrings.Get(593), -1);
    pSpin->AddLabel(g_localizeStrings.Get(19500), EVCONTENTMASK_MOVIEDRAMA);
    pSpin->AddLabel(g_localizeStrings.Get(19516), EVCONTENTMASK_NEWSCURRENTAFFAIRS);
    pSpin->AddLabel(g_localizeStrings.Get(19532), EVCONTENTMASK_SHOW);
    pSpin->AddLabel(g_localizeStrings.Get(19548), EVCONTENTMASK_SPORTS);
    pSpin->AddLabel(g_localizeStrings.Get(19564), EVCONTENTMASK_CHILDRENYOUTH);
    pSpin->AddLabel(g_localizeStrings.Get(19580), EVCONTENTMASK_MUSICBALLETDANCE);
    pSpin->AddLabel(g_localizeStrings.Get(19596), EVCONTENTMASK_ARTSCULTURE);
    pSpin->AddLabel(g_localizeStrings.Get(19612), EVCONTENTMASK_SOCIALPOLITICALECONOMICS);
    pSpin->AddLabel(g_localizeStrings.Get(19628), EVCONTENTMASK_EDUCATIONALSCIENCE);
    pSpin->AddLabel(g_localizeStrings.Get(19644), EVCONTENTMASK_LEISUREHOBBIES);
    pSpin->AddLabel(g_localizeStrings.Get(19660), EVCONTENTMASK_SPECIAL);
    pSpin->AddLabel(g_localizeStrings.Get(19499), EVCONTENTMASK_USERDEFINED);
    pSpin->SetValue(m_searchfilter->m_iGenreType);
  }
}
Exemplo n.º 5
0
bool CGUIDialogAddonSettings::ShowVirtualKeyboard(int iControl)
{
  int controlId = CONTROL_START_SETTING;
  bool bCloseDialog = false;

  const TiXmlElement *setting = GetFirstSetting();
  while (setting)
  {
    if (controlId == iControl)
    {
      const CGUIControl* control = GetControl(controlId);
      const std::string id = XMLUtils::GetAttribute(setting, "id");
      const std::string type = XMLUtils::GetAttribute(setting, "type");

      //Special handling for actions: does not require id attribute. TODO: refactor me.
      if (control && control->GetControlType() == CGUIControl::GUICONTROL_BUTTON && type == "action")
      {
        const char *option = setting->Attribute("option");
        std::string action = XMLUtils::GetAttribute(setting, "action");
        if (!action.empty())
        {
          // replace $CWD with the url of plugin/script
          StringUtils::Replace(action, "$CWD", m_addon->Path());
          StringUtils::Replace(action, "$ID", m_addon->ID());
          if (option)
            bCloseDialog = (strcmpi(option, "close") == 0);
          CApplicationMessenger::Get().ExecBuiltIn(action);
        }
        break;
      }

      if (control && control->GetControlType() == CGUIControl::GUICONTROL_BUTTON &&
          !id.empty() && !type.empty())
      {
        const char *option = setting->Attribute("option");
        const char *source = setting->Attribute("source");
        std::string value = m_buttonValues[id];
        std::string label = GetString(setting->Attribute("label"));

        if (type == "text")
        {
          // get any options
          bool bHidden  = false;
          bool bEncoded = false;
          if (option)
          {
            bHidden = (strstr(option, "hidden") != NULL);
            bEncoded = (strstr(option, "urlencoded") != NULL);
          }
          if (bEncoded)
            value = CURL::Decode(value);

          if (CGUIKeyboardFactory::ShowAndGetInput(value, label, true, bHidden))
          {
            // if hidden hide input
            if (bHidden)
            {
              std::string hiddenText;
              hiddenText.append(value.size(), L'*');
              ((CGUIButtonControl *)control)->SetLabel2(hiddenText);
            }
            else
              ((CGUIButtonControl*) control)->SetLabel2(value);
            if (bEncoded)
              value = CURL::Encode(value);
          }
        }
        else if (type == "number" && CGUIDialogNumeric::ShowAndGetNumber(value, label))
        {
          ((CGUIButtonControl*) control)->SetLabel2(value);
        }
        else if (type == "ipaddress" && CGUIDialogNumeric::ShowAndGetIPAddress(value, label))
        {
          ((CGUIButtonControl*) control)->SetLabel2(value);
        }
        else if (type == "select")
        {
          CGUIDialogSelect *pDlg = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
          if (pDlg)
          {
            pDlg->SetHeading(label.c_str());
            pDlg->Reset();

            int selected = -1;
            vector<std::string> valuesVec;
            if (setting->Attribute("values"))
              StringUtils::Tokenize(setting->Attribute("values"), valuesVec, "|");
            else if (setting->Attribute("lvalues"))
            { // localize
              StringUtils::Tokenize(setting->Attribute("lvalues"), valuesVec, "|");
              for (unsigned int i = 0; i < valuesVec.size(); i++)
              {
                if (i == (unsigned int)atoi(value.c_str()))
                  selected = i;
                std::string localized = m_addon->GetString(atoi(valuesVec[i].c_str()));
                if (localized.empty())
                  localized = g_localizeStrings.Get(atoi(valuesVec[i].c_str()));
                valuesVec[i] = localized;
              }
            }
            else if (source)
            {
              valuesVec = GetFileEnumValues(source, XMLUtils::GetAttribute(setting, "mask"), XMLUtils::GetAttribute(setting, "option"));
            }

            for (unsigned int i = 0; i < valuesVec.size(); i++)
            {
              pDlg->Add(valuesVec[i]);
              if (selected == (int)i || (selected < 0 && StringUtils::EqualsNoCase(valuesVec[i], value)))
                pDlg->SetSelected(i); // FIXME: the SetSelected() does not select "i", it always defaults to the first position
            }
            pDlg->DoModal();
            int iSelected = pDlg->GetSelectedLabel();
            if (iSelected >= 0)
            {
              if (setting->Attribute("lvalues"))
                value = StringUtils::Format("%i", iSelected);
              else
                value = valuesVec[iSelected];
              ((CGUIButtonControl*) control)->SetLabel2(valuesVec[iSelected]);
            }
          }
        }
        else if (type == "audio" || type == "video"
              || type == "image" || type == "executable"
              || type == "file"  || type == "folder")
        {
          // setup the shares
          VECSOURCES *shares = NULL;
          if (source && strcmpi(source, "") != 0)
            shares = CMediaSourceSettings::Get().GetSources(source);

          VECSOURCES localShares;
          if (!shares)
          {
            g_mediaManager.GetLocalDrives(localShares);
            if (!source || strcmpi(source, "local") != 0)
              g_mediaManager.GetNetworkLocations(localShares);
          }
          else // always append local drives
          {
            localShares = *shares;
            g_mediaManager.GetLocalDrives(localShares);
          }

          if (type == "folder")
          {
            // get any options
            bool bWriteOnly = false;
            if (option)
              bWriteOnly = (strcmpi(option, "writeable") == 0);

            if (CGUIDialogFileBrowser::ShowAndGetDirectory(localShares, label, value, bWriteOnly))
              ((CGUIButtonControl*) control)->SetLabel2(value);
          }
          else if (type == "image")
          {
            if (CGUIDialogFileBrowser::ShowAndGetImage(localShares, label, value))
              ((CGUIButtonControl*) control)->SetLabel2(value);
          }
          else
          {
            // set the proper mask
            std::string strMask;
            if (setting->Attribute("mask"))
            {
              strMask = setting->Attribute("mask");
              // convert mask qualifiers
              StringUtils::Replace(strMask, "$AUDIO", g_advancedSettings.GetMusicExtensions());
              StringUtils::Replace(strMask, "$VIDEO", g_advancedSettings.m_videoExtensions);
              StringUtils::Replace(strMask, "$IMAGE", g_advancedSettings.m_pictureExtensions);
#if defined(_WIN32_WINNT)
              StringUtils::Replace(strMask, "$EXECUTABLE", ".exe|.bat|.cmd|.py");
#else
              StringUtils::Replace(strMask, "$EXECUTABLE", "");
#endif
            }
            else
            {
              if (type == "video")
                strMask = g_advancedSettings.m_videoExtensions;
              else if (type == "audio")
                strMask = g_advancedSettings.GetMusicExtensions();
              else if (type == "executable")
#if defined(_WIN32_WINNT)
                strMask = ".exe|.bat|.cmd|.py";
#else
                strMask = "";
#endif
            }

            // get any options
            bool bUseThumbs = false;
            bool bUseFileDirectories = false;
            if (option)
            {
              vector<string> options = StringUtils::Split(option, '|');
              bUseThumbs = find(options.begin(), options.end(), "usethumbs") != options.end();
              bUseFileDirectories = find(options.begin(), options.end(), "treatasfolder") != options.end();
            }

            if (CGUIDialogFileBrowser::ShowAndGetFile(localShares, strMask, label, value, bUseThumbs, bUseFileDirectories))
              ((CGUIButtonControl*) control)->SetLabel2(value);
          }
        }
        else if (type == "date")
        {
          CDateTime date;
          if (!value.empty())
            date.SetFromDBDate(value);
          SYSTEMTIME timedate;
          date.GetAsSystemTime(timedate);
          if(CGUIDialogNumeric::ShowAndGetDate(timedate, label))
          {
            date = timedate;
            value = date.GetAsDBDate();
            ((CGUIButtonControl*) control)->SetLabel2(value);
          }
        }
        else if (type == "time")
        {
          SYSTEMTIME timedate;
          if (value.size() >= 5)
          {
            // assumes HH:MM
            timedate.wHour = atoi(value.substr(0, 2).c_str());
            timedate.wMinute = atoi(value.substr(3, 2).c_str());
          }
          if (CGUIDialogNumeric::ShowAndGetTime(timedate, label))
          {
            value = StringUtils::Format("%02d:%02d", timedate.wHour, timedate.wMinute);
            ((CGUIButtonControl*) control)->SetLabel2(value);
          }
        }
        else if (type == "addon")
        {
          const char *strType = setting->Attribute("addontype");
          if (strType)
          {
            vector<string> addonTypes = StringUtils::Split(strType, ',');
            vector<ADDON::TYPE> types;
            for (vector<string>::iterator i = addonTypes.begin(); i != addonTypes.end(); ++i)
            {
              StringUtils::Trim(*i);
              ADDON::TYPE type = TranslateType(*i);
              if (type != ADDON_UNKNOWN)
                types.push_back(type);
            }
            if (types.size() > 0)
            {
              const char *strMultiselect = setting->Attribute("multiselect");
              bool multiSelect = strMultiselect && strcmpi(strMultiselect, "true") == 0;
              if (multiSelect)
              {
                // construct vector of addon IDs (IDs are comma seperated in single string)
                vector<string> addonIDs = StringUtils::Split(value, ',');
                if (CGUIWindowAddonBrowser::SelectAddonID(types, addonIDs, false) == 1)
                {
                  value = StringUtils::Join(addonIDs, ",");
                  ((CGUIButtonControl*) control)->SetLabel2(GetAddonNames(value));
                }
              }
              else // no need of string splitting/joining if we select only 1 addon
                if (CGUIWindowAddonBrowser::SelectAddonID(types, value, false) == 1)
                  ((CGUIButtonControl*) control)->SetLabel2(GetAddonNames(value));
            }
          }
        }
        m_buttonValues[id] = value;
        break;
      }
    }
    setting = setting->NextSiblingElement("setting");
    controlId++;
  }
  EnableControls();
  return bCloseDialog;
}
Exemplo n.º 6
0
void CGUIDialogMediaFilter::OnSettingChanged(SettingInfo &setting)
{
  map<uint32_t, Filter>::iterator it = m_filters.find(setting.id);
  if (it == m_filters.end())
    return;

  bool changed = true;
  bool remove = false;
  Filter& filter = it->second;

  switch (filter.type)
  {
    case SettingInfo::STRING:
    case SettingInfo::EDIT:
    {
      CStdString *str = static_cast<CStdString*>(filter.data);
      if (!str->empty())
      {
        if (filter.rule == NULL)
          filter.rule = AddRule(filter.field, filter.ruleOperator);
        filter.rule->m_parameter.clear();
        filter.rule->m_parameter.push_back(*str);
      }
      else
        remove = true;
        
      break;
    }
    
    case SettingInfo::CHECK:
    {
      int choice = *(int *)setting.data;
      if (choice > CHECK_ALL)
      {
        CSmartPlaylistRule::SEARCH_OPERATOR ruleOperator = choice == CHECK_YES ? CSmartPlaylistRule::OPERATOR_TRUE : CSmartPlaylistRule::OPERATOR_FALSE;
        if (filter.rule == NULL)
          filter.rule = AddRule(filter.field, ruleOperator);
        else
          filter.rule->m_operator = ruleOperator;
      }
      else
        remove = true;

      break;
    }

    case SettingInfo::BUTTON:
    {
      CFileItemList items;
      OnBrowse(filter, items);
      
      if (items.Size() > 0)
      {
        if (filter.rule == NULL)
          filter.rule = AddRule(filter.field, filter.ruleOperator);

        filter.rule->m_parameter.clear();
        for (int index = 0; index < items.Size(); index++)
          filter.rule->m_parameter.push_back(items[index]->GetLabel());

        *(CStdString *)filter.data = filter.rule->GetLocalizedParameter(m_mediaType);
      }
      else
      {
        remove = true;
        *(CStdString *)filter.data = "";
      }

      SET_CONTROL_LABEL2(filter.controlIndex, *(CStdString *)filter.data);
      break;
    }

    case SettingInfo::RANGE:
    {
      SettingInfo &setting = m_settings[filter.controlIndex - CONTROL_START];
      float *valueLower = ((float **)filter.data)[0];
      float *valueUpper = ((float **)filter.data)[1];

      if (*valueLower > setting.min || *valueUpper < setting.max)
      {
        if (filter.rule == NULL)
          filter.rule = AddRule(filter.field, filter.ruleOperator);

        filter.rule->m_parameter.clear();
        if (filter.field == FieldAirDate)
        {
          CDateTime lower = (time_t)*valueLower;
          CDateTime upper = (time_t)*valueUpper;
          filter.rule->m_parameter.push_back(lower.GetAsDBDate());
          filter.rule->m_parameter.push_back(upper.GetAsDBDate());
        }
        else
        {
          CStdString tmp;
          tmp.Format("%.1f", *valueLower);
          filter.rule->m_parameter.push_back(tmp);
          tmp.clear();
          tmp.Format("%.1f", *valueUpper);
          filter.rule->m_parameter.push_back(tmp);
        }
      }
      else
      {
        remove = true;
        *((float **)filter.data)[0] = setting.min;
        *((float **)filter.data)[1] = setting.max;
      }
      break;
    }

    default:
      changed = false;
      break;
  }

  // we need to remove the existing rule for the title
  if (remove && filter.rule != NULL)
  {
    DeleteRule(filter.field);
    filter.rule = NULL;
  }

  if (changed)
  {
    CGUIMessage message(GUI_MSG_NOTIFY_ALL, GetID(), 0, GUI_MSG_FILTER_ITEMS, 10); // 10 for advanced
    g_windowManager.SendMessage(message);

    UpdateControls();
  }
}