Debian Codegraph @

src/logic/folderarrangement/FolderSort.vala

raw
1 /*
2 * Copyright (c) 2017-2019 José Amuedo (https://github.com/spheras)
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 /**
19 * @class
20 * Folder Arragement Interface
21 */
22 public interface DesktopFolder.FolderSort : Object {
23 public static int SORT_BY_NAME = 0;
24 public static int SORT_BY_SIZE = 1;
25 public static int SORT_BY_TYPE = 2;
26
27 /**
28 * @name sort
29 * @description sort the list of items by the criteria of the concrete sort
30 * @param List<ItemManager> items the reference to the list of items
31 * @param bool asc if the order is ascendent or not
32 */
33 public abstract void sort (ref List <ItemManager> items, bool asc);
34
35 /**
36 * Factory method to obtain an sort type
37 * @see SORT_BY_NAME, SORT_BY_SIZE, SORT_BY_TYPE constants
38 * @param int type the factory type
39 * @return FolderSort the concrete folder sort for that type, null if none valid
40 */
41 public static FolderSort ? factory (int type) {
42 if (type == FolderSort.SORT_BY_NAME) {
43 return new FolderSortByName ();
44 } else if (type == FolderSort.SORT_BY_SIZE) {
45 return new FolderSortBySize ();
46 } else if (type == FolderSort.SORT_BY_TYPE) {
47 return new FolderSortByType ();
48 }
49 return null;
50 }
51
52 }