Changeset View
Changeset View
Standalone View
Standalone View
treeview.cpp
Show First 20 Lines • Show All 1365 Lines • ▼ Show 20 Line(s) | |||||
1366 | */ | 1366 | */ | ||
1367 | void TreeView::sort(const int sortCmd) | 1367 | void TreeView::sort(const int sortCmd) | ||
1368 | { | 1368 | { | ||
1369 | // determine the chosen sort type and the selected item | 1369 | // determine the chosen sort type and the selected item | ||
1370 | SortType sortType = static_cast<SortType>(sortCmd); | 1370 | SortType sortType = static_cast<SortType>(sortCmd); | ||
1371 | TreeItem *itemToSort; | 1371 | TreeItem *itemToSort; | ||
1372 | if (sortType == SortByName || sortType == SortByDescription) { | 1372 | if (sortType == SortByName || sortType == SortByDescription) { | ||
1373 | itemToSort = static_cast<TreeItem *>(selectedItem()); | 1373 | itemToSort = static_cast<TreeItem *>(selectedItem()); | ||
1374 | sortItem(itemToSort, sortType); | ||||
1374 | } else if (sortType == SortAllByDescription) { | 1375 | } else if (sortType == SortAllByDescription) { | ||
1375 | sortType = SortByDescription; | 1376 | sortType = SortByDescription; | ||
1376 | itemToSort = static_cast<TreeItem *>(invisibleRootItem()); | 1377 | for (int i = 0; i < topLevelItemCount(); ++i) { | ||
1378 | itemToSort = static_cast<TreeItem *>(topLevelItem(i)); | ||||
1379 | sortItem(itemToSort, sortType); | ||||
1380 | } | ||||
1377 | } else { /* if (sortType == SortAllByName) */ | 1381 | } else { /* if (sortType == SortAllByName) */ | ||
1378 | sortType = SortByName; | 1382 | sortType = SortByName; | ||
1379 | itemToSort = static_cast<TreeItem *>(invisibleRootItem()); | 1383 | for (int i = 0; i < topLevelItemCount(); ++i) { | ||
1380 | } | 1384 | itemToSort = static_cast<TreeItem *>(topLevelItem(i)); | ||
1381 | | ||||
1382 | // proceed to the sorting | | |||
1383 | sortItem(itemToSort, sortType); | 1385 | sortItem(itemToSort, sortType); | ||
1384 | } | 1386 | } | ||
1387 | } | ||||
1388 | } | ||||
1385 | 1389 | | |||
1386 | /** | 1390 | /** | ||
1387 | * Sort children of the given item, according to the sort type. | 1391 | * Sort children of the given item, according to the sort type. | ||
1388 | * The sorting is done on children groups, splited by separator items. | 1392 | * The sorting is done on children groups, splited by separator items. | ||
1389 | * | 1393 | * | ||
1390 | * @brief Sort item children. | 1394 | * @brief Sort item children. | ||
1391 | * @param item Item to sort. | 1395 | * @param item Item to sort. | ||
1392 | * @param sortType Sort type. | 1396 | * @param sortType Sort type. | ||
▲ Show 20 Lines • Show All 496 Lines • Show Last 20 Lines |