Skip to content

Commit

Permalink
More tweaks to the import dialog #4364
Browse files Browse the repository at this point in the history
  • Loading branch information
derwin12 authored and dkulp committed Feb 26, 2024
1 parent f2037e5 commit a2a4cbd
Showing 1 changed file with 31 additions and 10 deletions.
41 changes: 31 additions & 10 deletions xLights/xLightsImportChannelMapDialog.cpp
Expand Up @@ -69,6 +69,24 @@ int wxCALLBACK MyCompareFunctionDescEffects(wxIntPtr item1, wxIntPtr item2, wxIn
return it1 == it2 ? 0 : ((it1 < it2) ? 1 : -1);
}

int wxCALLBACK MyCompareFunctionAscName(wxIntPtr item1, wxIntPtr item2, wxIntPtr sortData)
{
wxListCtrl* list = (wxListCtrl*)sortData;
auto i1 = list->GetItemText(item1, 0);
auto i2 = list->GetItemText(item2, 0);

return i1.Cmp(i2);
}

int wxCALLBACK MyCompareFunctionDescName(wxIntPtr item1, wxIntPtr item2, wxIntPtr sortData)
{
wxListCtrl* list = (wxListCtrl*)sortData;
auto i1 = list->GetItemText(item1, 0);
auto i2 = list->GetItemText(item2, 0);

return i2.Cmp(i1);
}

class MDDropSource : public wxDropSource
{
xLightsImportChannelMapDialog* _window;
Expand Down Expand Up @@ -197,13 +215,8 @@ int xLightsImportTreeModel::Compare(const wxDataViewItem& item1, const wxDataVie
else {
return NumberAwareStringCompareRev(node1->_node.ToStdString(), node2->_node.ToStdString());
}
} else if (node1->_strand != "" && node2->_strand != "") {
if (ascending) {
return NumberAwareStringCompare(node1->_strand.ToStdString(), node2->_strand.ToStdString());
}
else {
return NumberAwareStringCompareRev(node1->_strand.ToStdString(), node2->_strand.ToStdString());
}
} else if (node1->_strand != "" && node2->_strand != "") { // dont sort the submodels
return 1;
}
else
{
Expand Down Expand Up @@ -808,6 +821,7 @@ bool xLightsImportChannelMapDialog::InitImport(std::string checkboxText) {
TreeListCtrl_Mapping->Freeze();
TreeListCtrl_Mapping->AssociateModel(_dataModel);
TreeListCtrl_Mapping->AppendColumn(new wxDataViewColumn("Model", new wxDataViewTextRenderer("string", wxDATAVIEW_CELL_INERT, wxALIGN_LEFT), 0, 150, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE));
TreeListCtrl_Mapping->GetColumn(0)->SetSortOrder(true);
TreeListCtrl_Mapping->AppendColumn(new wxDataViewColumn("Map To", new wxDataViewTextRenderer("string", wxDATAVIEW_CELL_ACTIVATABLE, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL), 1, 150, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE));
if (_allowColorChoice) {
TreeListCtrl_Mapping->AppendColumn(new wxDataViewColumn("Color", new ColorRenderer(), 2, 150, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE));
Expand Down Expand Up @@ -929,6 +943,7 @@ void xLightsImportChannelMapDialog::PopulateAvailable(bool ccr)

_sortOrder = 1;
ListCtrl_Available->SortItems(MyCompareFunctionAsc, (wxIntPtr)ListCtrl_Available);
ListCtrl_Available->ShowSortIndicator(0, true);

// Set Autosize Width after it is populated or it doesn't work
ListCtrl_Available->SetColumnWidth(0, wxLIST_AUTOSIZE);
Expand Down Expand Up @@ -1831,10 +1846,14 @@ void xLightsImportChannelMapDialog::OnListCtrl_AvailableColumnClick(wxListEvent&
if (event.m_col == 0) {
if (_sortOrder == 0) {
_sortOrder = 1;
ListCtrl_Available->SortItems(MyCompareFunctionAsc, (wxIntPtr)ListCtrl_Available);
} else {
ListCtrl_Available->SortItems(MyCompareFunctionAsc, (wxIntPtr)ListCtrl_Available); // put it back in start order as otherwise this does not work
ListCtrl_Available->SortItems(MyCompareFunctionAscName, (wxIntPtr)ListCtrl_Available);
ListCtrl_Available->ShowSortIndicator(0, true);
} else {
_sortOrder = 0;
ListCtrl_Available->SortItems(MyCompareFunctionDesc, (wxIntPtr)ListCtrl_Available);
ListCtrl_Available->SortItems(MyCompareFunctionAsc, (wxIntPtr)ListCtrl_Available); // put it back in start order as otherwise this does not work
ListCtrl_Available->SortItems(MyCompareFunctionDescName, (wxIntPtr)ListCtrl_Available);
ListCtrl_Available->ShowSortIndicator(0, false);
}
}
else if (event.m_col == 1)
Expand All @@ -1843,10 +1862,12 @@ void xLightsImportChannelMapDialog::OnListCtrl_AvailableColumnClick(wxListEvent&
_sortOrder = 4;
ListCtrl_Available->SortItems(MyCompareFunctionAsc, (wxIntPtr)ListCtrl_Available); // put it back in start order as otherwise this does not work
ListCtrl_Available->SortItems(MyCompareFunctionAscEffects, (wxIntPtr)ListCtrl_Available);
ListCtrl_Available->ShowSortIndicator(1, true);
} else {
_sortOrder = 3;
ListCtrl_Available->SortItems(MyCompareFunctionAsc, (wxIntPtr)ListCtrl_Available); // put it back in start order as otherwise this does not work
ListCtrl_Available->SortItems(MyCompareFunctionDescEffects, (wxIntPtr)ListCtrl_Available);
ListCtrl_Available->ShowSortIndicator(1, false);
}
}
}
Expand Down

0 comments on commit a2a4cbd

Please sign in to comment.