diff --git a/PowerEditor/src/WinControls/AnsiCharPanel/ListView.cpp b/PowerEditor/src/WinControls/AnsiCharPanel/ListView.cpp index 4230cc26..0941c224 100644 --- a/PowerEditor/src/WinControls/AnsiCharPanel/ListView.cpp +++ b/PowerEditor/src/WinControls/AnsiCharPanel/ListView.cpp @@ -120,6 +120,37 @@ void ListView::addLine(const vector & values2Add, LPARAM lParam, } } +size_t ListView::findAlphabeticalOrderPos(const generic_string& string2Cmp, SortDirection sortDir) +{ + size_t nbItem = ListView_GetItemCount(_hSelf); + if (!nbItem) + return 0; + + for (size_t i = 0; i < nbItem; ++i) + { + TCHAR str[MAX_PATH]; + ListView_GetItemText(_hSelf, i, 0, str, sizeof(str)); + + int res = lstrcmp(string2Cmp.c_str(), str); + + if (res < 0) // string2Cmp < str + { + if (sortDir == sortEncrease) + { + return i; + } + } + else // str2Cmp >= str + { + if (sortDir == sortDecrease) + { + return i; + } + } + } + return nbItem; +} + LPARAM ListView::getLParamFromIndex(int itemIndex) const { diff --git a/PowerEditor/src/WinControls/AnsiCharPanel/ListView.h b/PowerEditor/src/WinControls/AnsiCharPanel/ListView.h index 1cc8a353..3ef91292 100644 --- a/PowerEditor/src/WinControls/AnsiCharPanel/ListView.h +++ b/PowerEditor/src/WinControls/AnsiCharPanel/ListView.h @@ -46,6 +46,10 @@ public: ListView() : Window() {}; virtual ~ListView() {}; + enum SortDirection { + sortEncrease = 0, + sortDecrease = 1 + }; // addColumn() should be called before init() void addColumn(const columnInfo & column2Add) { _columnInfos.push_back(column2Add); @@ -63,6 +67,8 @@ public: _extraStyle = extraStyle; }; + size_t findAlphabeticalOrderPos(const generic_string& string2search, SortDirection sortDir); + void addLine(const std::vector & values2Add, LPARAM lParam = 0, int pos2insert = -1); size_t nbItem() const { diff --git a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp index 7669aa08..d1159f7d 100644 --- a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp +++ b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp @@ -607,7 +607,10 @@ void PluginViewList::pushBack(PluginUpdateInfo* pi) Version v = pi->_version; values2Add.push_back(v.toString()); //values2Add.push_back(TEXT("Yes")); - _ui.addLine(values2Add, reinterpret_cast(pi)); + + // add in order + size_t i = _ui.findAlphabeticalOrderPos(pi->_displayName, _sortType == DISPLAY_NAME_ALPHABET_ENCREASE ? _ui.sortEncrease : _ui.sortDecrease); + _ui.addLine(values2Add, reinterpret_cast(pi), i); } bool loadFromJson(PluginViewList & pl, const json& j) diff --git a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.h b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.h index 594f4cdc..a3f50d6a 100644 --- a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.h +++ b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.h @@ -112,6 +112,16 @@ struct NppCurrentStatus }; enum COLUMN_TYPE { COLUMN_PLUGIN, COLUMN_VERSION }; +enum SORT_TYPE { DISPLAY_NAME_ALPHABET_ENCREASE, DISPLAY_NAME_ALPHABET_DECREASE }; + + +struct SortDisplayNameDecrease final +{ + bool operator() (PluginUpdateInfo* l, PluginUpdateInfo* r) + { + return (l->_displayName.compare(r->_displayName) <= 0); + } +}; class PluginViewList { @@ -151,6 +161,8 @@ public: private: std::vector _list; ListView _ui; + + SORT_TYPE _sortType = DISPLAY_NAME_ALPHABET_ENCREASE; }; enum LIST_TYPE { AVAILABLE_LIST, UPDATES_LIST, INSTALLED_LIST }; diff --git a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp index d8876e42..fcfb045f 100644 --- a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp +++ b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp @@ -30,7 +30,6 @@ #include "VerticalFileSwitcher.h" #include "menuCmdID.h" #include "Parameters.h" -//#include "localization.h" int CALLBACK ListViewCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) {