<commit_before>/******************************************************************************\
* File:          listview.cpp
* Purpose:       Implementation of wxExListView and related classes
* Author:        <NAME>
* RCS-ID:        $Id$
*
* Copyright (c) 1998-2009 <NAME>
* All rights are reserved. Reproduction in whole or part is prohibited
* without the written consent of the copyright owner.
\******************************************************************************/

#include <wx/config.h>
#include <wx/numdlg.h> // for wxGetNumberFromUser
#include <wx/generic/dirctrlg.h> // for wxTheFileIconsTable
#include <wx/textfile.h> // for wxTextFile::GetEOL()
#include <wx/tokenzr.h>
#include <wx/extension/listview.h>
#include <wx/extension/frame.h>
#include <wx/extension/frd.h>
#include <wx/extension/printing.h>
#include <wx/extension/util.h>

#if wxUSE_GUI

wxExColumn::wxExColumn(
  const wxString& name,
  wxExColumn::wxExColumnType type,
  int width)
  : wxListItem()
  , m_Type(type)
  , m_IsSortedAscending(false)
{
  wxListColumnFormat align = wxLIST_FORMAT_RIGHT;

  switch (m_Type)
  {
  case wxExColumn::COL_FLOAT: align = wxLIST_FORMAT_RIGHT; if (width == 0) width = 80; break;
  case wxExColumn::COL_INT: align = wxLIST_FORMAT_RIGHT; if (width == 0) width = 80; break;
  case wxExColumn::COL_STRING: align = wxLIST_FORMAT_LEFT;  if (width == 0) width = 100; break;
  case wxExColumn::COL_DATE: align = wxLIST_FORMAT_LEFT;  if (width == 0) width = 150; break;
  default: wxFAIL;
  }

  SetColumn(-1); // set a default value, should be overriden when inserting the col
  SetText(name);
  SetAlign(align);
  SetWidth(width);
}

void wxExColumn::SetIsSortedAscending(wxExSortType type)
{
  switch (type)
  {
  case SORT_ASCENDING: m_IsSortedAscending = true; break;
  case SORT_DESCENDING: m_IsSortedAscending = false; break;
  case SORT_KEEP: break;
  case SORT_TOGGLE: m_IsSortedAscending = !m_IsSortedAscending; break;
  default: wxFAIL; break;
  }
}

wxExListItem::wxExListItem(wxExListView* lv, const wxString& text)
  : m_ListView(lv)
{
  SetId(m_ListView->GetItemCount());
  SetMask(wxLIST_MASK_TEXT);
  SetText(text);
}

wxExListItem::wxExListItem(wxExListView* lv, int itemnumber)
  : m_ListView(lv)
{
  SetId(itemnumber);
}

const wxString wxExListItem::GetColumnText(int col_no) const
{
  if (col_no < 0) 
  {
    // We cannot wxFAIL here, as e.g. "Line No" column is used
    // to get line number, in several lists, als in lists without that column.
    return wxEmptyString;
  }

  wxListItem item;

  item.SetColumn(col_no);
  item.SetMask(wxLIST_MASK_TEXT);

  if (!m_ListView->GetItem(item))
  {
    wxFAIL;
    return wxEmptyString;
  }

  return item.GetText();
}

void wxExListItem::SetColumnText(int col_no, const wxString& text)
{
  if (col_no >= m_ListView->GetColumnCount())
  {<commit_msg>the item id is needed as well<commit_after>/******************************************************************************\
* File:          listview.cpp
* Purpose:       Implementation of wxExListView and related classes
* Author:        <NAME>
* RCS-ID:        $Id$
*
* Copyright (c) 1998-2009 <NAME>
* All rights are reserved. Reproduction in whole or part is prohibited
* without the written consent of the copyright owner.
\******************************************************************************/

#include <wx/config.h>
#include <wx/numdlg.h> // for wxGetNumberFromUser
#include <wx/generic/dirctrlg.h> // for wxTheFileIconsTable
#include <wx/textfile.h> // for wxTextFile::GetEOL()
#include <wx/tokenzr.h>
#include <wx/extension/listview.h>
#include <wx/extension/frame.h>
#include <wx/extension/frd.h>
#include <wx/extension/printing.h>
#include <wx/extension/util.h>

#if wxUSE_GUI

wxExColumn::wxExColumn(
  const wxString& name,
  wxExColumn::wxExColumnType type,
  int width)
  : wxListItem()
  , m_Type(type)
  , m_IsSortedAscending(false)
{
  wxListColumnFormat align = wxLIST_FORMAT_RIGHT;

  switch (m_Type)
  {
  case wxExColumn::COL_FLOAT: align = wxLIST_FORMAT_RIGHT; if (width == 0) width = 80; break;
  case wxExColumn::COL_INT: align = wxLIST_FORMAT_RIGHT; if (width == 0) width = 80; break;
  case wxExColumn::COL_STRING: align = wxLIST_FORMAT_LEFT;  if (width == 0) width = 100; break;
  case wxExColumn::COL_DATE: align = wxLIST_FORMAT_LEFT;  if (width == 0) width = 150; break;
  default: wxFAIL;
  }

  SetColumn(-1); // set a default value, should be overriden when inserting the col
  SetText(name);
  SetAlign(align);
  SetWidth(width);
}

void wxExColumn::SetIsSortedAscending(wxExSortType type)
{
  switch (type)
  {
  case SORT_ASCENDING: m_IsSortedAscending = true; break;
  case SORT_DESCENDING: m_IsSortedAscending = false; break;
  case SORT_KEEP: break;
  case SORT_TOGGLE: m_IsSortedAscending = !m_IsSortedAscending; break;
  default: wxFAIL; break;
  }
}

wxExListItem::wxExListItem(wxExListView* lv, const wxString& text)
  : m_ListView(lv)
{
  SetId(m_ListView->GetItemCount());
  SetMask(wxLIST_MASK_TEXT);
  SetText(text);
}

wxExListItem::wxExListItem(wxExListView* lv, int itemnumber)
  : m_ListView(lv)
{
  SetId(itemnumber);
}

const wxString wxExListItem::GetColumnText(int col_no) const
{
  if (col_no < 0) 
  {
    // We cannot wxFAIL here, as e.g. "Line No" column is used
    // to get line number, in several lists, als in lists without that column.
    return wxEmptyString;
  }

  wxListItem item;

  item.SetId(GetId());
  item.SetColumn(col_no);
  item.SetMask(wxLIST_MASK_TEXT);

  if (!m_ListView->GetItem(item))
  {
    wxFAIL;
    return wxEmptyString;
  }

  return item.GetText();
}

void wxExListItem::SetColumnText(int col_no, const wxString& text)
{
  if (col_no >= m_ListView->GetColumnCount())
  {
{'fraction_non_alphanumeric': 0.16856492027334852, 'fraction_numerical': 0.00841072367268267, 'mean_word_length': 4.612586037364799, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1535323', 'n_tokens_mistral': 2065, 'n_tokens_neox': 1966, 'n_words': 475}