Exemplo n.º 1
0
void PoeditListCtrl::ReadCatalog()
{
    wxWindowUpdateLocker no_updates(this);

    // clear the list and its sort order too:
    SetItemCount(0);
    m_mapListToCatalog.clear();
    m_mapCatalogToList.clear();

    if (m_catalog == NULL)
    {
        Refresh();
        return;
    }

    auto lang = m_catalog->GetLanguage();
    auto isRTL = lang.IsRTL();
#ifdef __WXMSW__
    // a quirk of wx API: if the current locale is RTL, the meaning of L and R is reversed
    if (m_appIsRTL)
        isRTL = !isRTL;
#endif
    m_isRTL = isRTL;

    wxString langname = lang.IsValid() ? lang.DisplayName() : _("unknown language");
    wxListItem colInfo;
    colInfo.SetMask(wxLIST_MASK_TEXT);
    colInfo.SetText(wxString::Format(_(L"Translation — %s"), langname));
    colInfo.SetAlign(isRTL ? wxLIST_FORMAT_RIGHT : wxLIST_FORMAT_LEFT);
    SetColumn(1, colInfo);

    // sort catalog items, create indexes mapping
    CreateSortMap();

    // now that everything is prepared, we may set the item count
    SetItemCount(m_catalog->GetCount());

    // scroll to the top and refresh everything:
    if ( m_catalog->GetCount() )
    {
        SelectOnly(0);
        RefreshItems(0, m_catalog->GetCount()-1);
    }
    else
    {
        Refresh();
    }
}
NS_IMETHODIMP
sbLocalDatabaseMediaListViewSelection::TimedSelectOnly(PRInt32 aIndex, PRInt32 aDelay)
{
  PRBool suppressed = mSelectionNotificationsSuppressed;
  if (aDelay != -1)
    mSelectionNotificationsSuppressed = PR_TRUE;
  nsresult rv = SelectOnly(aIndex);
  mSelectionNotificationsSuppressed = suppressed;
  NS_ENSURE_SUCCESS(rv, rv);

  if (aDelay != -1 && !mSelectionNotificationsSuppressed) {
    if (mSelectTimer)
      mSelectTimer->Cancel();

    mSelectTimer = do_CreateInstance("@mozilla.org/timer;1");
    mSelectTimer->InitWithFuncCallback(DelayedSelectNotification, this, aDelay,
                                       nsITimer::TYPE_ONE_SHOT);
  }

  return NS_OK;
}