MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / doSort

Method doSort

src/modinfodialogconflictsmodels.cpp:260–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258}
259
260void ConflictListModel::doSort()
261{
262 if (m_items.empty()) {
263 return;
264 }
265
266 if (m_sortColumn < 0) {
267 return;
268 }
269
270 const auto c = static_cast<std::size_t>(m_sortColumn);
271 if (c >= m_columns.size()) {
272 return;
273 }
274
275 const auto& col = m_columns[c];
276
277 // avoids branching on sort order while sorting
278 auto sortAsc = [&](const auto& a, const auto& b) {
279 return (naturalCompare((a.*col.getText)(), (b.*col.getText)()) < 0);
280 };
281
282 auto sortDesc = [&](const auto& a, const auto& b) {
283 return (naturalCompare((a.*col.getText)(), (b.*col.getText)()) > 0);
284 };
285
286 if (m_sortOrder == Qt::AscendingOrder) {
287 std::sort(m_items.begin(), m_items.end(), sortAsc);
288 } else {
289 std::sort(m_items.begin(), m_items.end(), sortDesc);
290 }
291}
292
293OverwriteConflictListModel::OverwriteConflictListModel(QTreeView* tree)
294 : ConflictListModel(tree, {{tr("File"), &ConflictItem::relativeName},

Callers

nothing calls this directly

Calls 4

emptyMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected